Index: build/make-release ================================================================== --- build/make-release +++ build/make-release @@ -25,10 +25,14 @@ cp "${CACKEY_TARBALL}" ~/rpmbuild/SOURCES/ || exit 1 tar -xOf "${CACKEY_TARBALL}" cackey-${VERSION}/cackey.spec > ~/rpmbuild/SPECS/cackey-${VERSION}.spec || exit 1 rpmbuild -ba ~/rpmbuild/SPECS/cackey-${VERSION}.spec || exit 1 +# Create Debian package from RPM +mkdir -p ~/rpmbuild/DEB +"$(dirname "$0")/rpm2deb" ~/rpmbuild/RPMS/i386/cackey-${VERSION}-1.i386.rpm ~/rpmbuild/DEB/cackey_${VERSION}-1_i386.deb + ## Create Slackware package mkdir -p ~/rpmbuild/TGZ WORKDIR="${TMPDIR:-/tmp}/cackey-build-$$${RANDOM}${RANDOM}${RANDOM}" WORKDIRINSTROOT="${WORKDIR}/root" ADDED build/rpm2deb Index: build/rpm2deb ================================================================== --- /dev/null +++ build/rpm2deb @@ -0,0 +1,75 @@ +#! /bin/bash + +RPMFILE="$(readlink -f "$1")" +DEBFILE="$2" +export RPMFILE DEBGFILE + +if [ -z "${RPMFILE}" ]; then + echo 'Usage: rpm2deb []' >&2 + + exit 1 +fi + +if [ -z "${DEBFILE}" ]; then + DEBFILE="$(echo "${RPMFILE}" | sed 's@\.rpm$@.deb@')" + + if [ "${DEBFILE}" = "${RPMFILE}" ]; then + DEBFILE="${RPMFILE}.deb" + fi +fi + +WORKDIR="${TMPDIR:-/tmp}/rpm2deb-$$${RANDOM}${RANDOM}${RANDOM}" +TMPCPIOFILE="${WORKDIR}/tmp.cpio" +export WORKDIR TMPCPIOFILE + +mkdir -p "${WORKDIR}" "${WORKDIR}/deb" "${WORKDIR}/control" "${WORKDIR}/root" || exit 1 +chmod 700 "${WORKDIR}" + +rpm2cpio < "${RPMFILE}" > "${TMPCPIOFILE}" + +# Extract files +( + cd "${WORKDIR}/root" || exit 1 + + cpio -i --no-absolute-filenames --quiet --make-directories < "${TMPCPIOFILE}" +) || exit 1 + +# Create control files +( + cd "${WORKDIR}/root" || exit 1 + + ## Create MD5 Sums + find . -type f | xargs md5sum > "${WORKDIR}/control/md5sums" + + ## Create Package description + rpm -q --queryformat 'Package: %{Name}\nVersion: %{Version}-%{Release}\nArchitecture: %{Arch}\nInstalled-Size: %{Size}\nMaintainer: %{Packager}\nDescription:' -p "${RPMFILE}" > "${WORKDIR}/control/control" + rpm -q --queryformat '%{Description}' -p "${RPMFILE}" | sed 's@^@ @;s@^ $@ .@' >> "${WORKDIR}/control/control" +echo '' >> "${WORKDIR}/control/control" + + ## Create tarball with all data + cd "${WORKDIR}/control" || exit 1 + tar -zcf "${WORKDIR}/deb/control.tar.gz" * +) || exit 1 + +# Create debian-binary +echo '2.0' > "${WORKDIR}/deb/debian-binary" + +# Create Data archive +( + cd "${WORKDIR}/root" || exit 1 + + cpio -i --list --quiet < "${TMPCPIOFILE}" > "${WORKDIR}/rpm-filelist" + + tar --files-from "${WORKDIR}/rpm-filelist" -cf - | tardy -User root -Group root | gzip -9c > "${WORKDIR}/deb/data.tar.gz" +) || exit 1 + +# Create Debian package +( + cd "${WORKDIR}/deb" || exit 1 + + ar rcu "${WORKDIR}/tmp.deb" debian-binary control.tar.gz data.tar.gz +) + +cp "${WORKDIR}/tmp.deb" "${DEBFILE}" + +rm -rf "${WORKDIR}"