#!/bin/bash polkit_blacklist=" 0.113/README-Note-to-send-security-reports-via-DBus-s-mech.patch 0.114/Add-gettext-support-for-.policy-files.patch 0.114/gettext-switch-to-default-translate-no.patch 0.116/tests-add-tests-for-high-uids.patch 01_pam_polkit.patch 02_gettext.patch 06_systemd-service.patch " openssl_blacklist=" config-hurd.patch engines-path.patch man-dir.patch man-section.patch rehash_pod.patch version-script.patch gnu_source.patch c_rehash-compat.patch dgst_hmac.patch fix-pod-errors.patch ppc64el.patch disable_sslv3_test.patch libdoc-manpgs-pod-spell.patch soname.patch no-symbolic.patch " elfutils_blacklist=" testsuite-ignore-elflint.diff kfreebsd_path.patch hurd_path.patch ignore_strmerge.diff 0001-tests-Add-GCOV-flags-when-necessary.patch " cpufrequtils_blacklist=" 01_add_cpufreq-aperf_manpage.patch 0002-cpufrequtils-Remove-proc-compile-option-and-interfac.patch 0004-i18n-Catalan.patch 0007-po-add-missing-word-in-DE.patch 10_build_static_lib.patch 11_dont_touch_po_files.patch " ppp_blacklist=" 010_scripts_README.diff 011_scripts_redialer.diff chat_man no_crypt_hack pppd-soname-hack.patch secure-card-interpreter-fix " fakeroot_blacklist=" fix-shell-in-fakeroot " set -e set -x start="$(pwd)" src="$(pwd)/$1" deb="$(pwd)/$2" base="$(basename "${src}")" base="${base%_*}" case "${base}" in openssl|elfutils|cpufrequtils|ppp|fakeroot) ;; policykit-1) base=polkit ;; *) echo "Unknown package '${base}'. Aborting!" exit 1 ;; esac blacklistptr="${base}_blacklist" blacklist="${!blacklistptr}" tmp="$(mktemp -d)" cd "$tmp" tar xf "$src" pkg="$(ls -d ${base}-*)" tar xf "$deb" patches=debian/patches for patch in $blacklist; do sed -i "s;\(${patch}\);#\1;" ${patches}/series done if [ "${base}" = "polkit" ]; then for dir in $(find debian/patches/ -mindepth 1 -maxdepth 1 -type d -printf "%P\n"); do sed -i "s;Subject:;Subject: ${dir}:;" "debian/patches/${dir}/"* done fi if [ "${base}" = "ppp" ]; then sed -i 's;^Description: \(.*\)$;Subject: \1\n;' debian/patches/* sed -i -e '/^Subject:/{p;d}' -e '1N;s/\(.*\n\)$/Subject: \1/;' debian/patches/* fi cd "$pkg" git init git add * git commit -m "base" git tag base export FILTER_BRANCH_SQUELCH_WARNING=1 author="$(git config user.name) <$(git config user.email)>" git quiltimport --patches=../$patches/ --author "${author}" git filter-branch --msg-filter "cat | grep -v '^==*$' && echo '\nImported from $(basename $deb)\n\nSigned-off-by: ${author}'" base...master git filter-branch -f --msg-filter "cat | sed -e '/\.diff$/s/-/ /g' -e '1s/.diff$//' " base...master git format-patch --no-signature -N base mkdir "$start/$pkg" mv 0*.patch "$start/$pkg/" cd "$start" rm -rf "$tmp" cd "$start/$pkg/" sed -i 1d 0*.patch ls 0*.patch > series