#!/bin/sh
set -e

rm -rf dist

for pkg in "$@"; do
	arch=$(rpm -qp "$pkg" --qf '%{ARCH}')
	install -d dist/$arch tmp
	rpm2cpio "$pkg" | (cd tmp && cpio --no-absolute-filenames -dimu --quiet)
	mv tmp/usr/lib*/lib*.so* dist/$arch
	rm -rf tmp
done

install -p $0 dist
tar -C dist -cf openssl-compat.tar .
xz -9 openssl-compat.tar
