From: Tollef Fog Heen Date: Mon, 27 Feb 2012 21:36:06 +0000 (+0100) Subject: Expand source hook to use git diff over git format-patch X-Git-Tag: 43-1~32 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed3a7e3316a4835d2384e3031fe16e2b6199288f;p=systemd Expand source hook to use git diff over git format-patch --- diff --git a/debian/systemd-hack-up-the-source.hook b/debian/systemd-hack-up-the-source.hook index 1a932124..62eea54e 100755 --- a/debian/systemd-hack-up-the-source.hook +++ b/debian/systemd-hack-up-the-source.hook @@ -4,6 +4,70 @@ set -e set -x +. /usr/share/gitpkg/hooks/repo-config-helper + find -name Makefile -type l -print -delete #rm -r src/Makefile -. /usr/share/gitpkg/hooks/quilt-patches-deb-export-hook +#. /usr/share/gitpkg/hooks/quilt-patches-deb-export-hook + +patch_list=debian/source/git-patches +patch_dir=debian/patches + +if [ ! -r "$patch_list" ]; then + echo "No $patch_list file, I guess you've pushed them all upstream." + echo "Good Work!" + exit 0 +fi + +if [ -e "$patch_dir" ]; then + echo "Uh oh. You already have a $patch_dir here." + echo "You probably don't want us to scribble on that without asking." + exit 1 +fi + +if [ -z "$REPO_DIR" ]; then + # support running as a free-standing script, without gitpkg + DEB_VERSION="$(dpkg-parsechangelog | sed -rne 's/^Version: ([^:]+:)?//p')" + UPSTREAM_VERSION="${DEB_VERSION%-*}" + REPO_DIR=. +fi + +DEB_REF=$(sanitise_git_ref $DEB_VERSION) +UPSTREAM_REF="${DEB_REF%-*}" + +do_patches (){ + while read -r line + do + [ -n "$line" ] || continue + case $line in + \#*) + ;; + *) + count=$(wc -l "$patch_dir/series" | cut -f1 -d' ') + if PATCHES="$(git --git-dir "$REPO_DIR/.git" diff "$line" > "$patch_dir/$line")"; then + if [ -n "$PATCHES" ]; then + echo "$PATCHES" | sed -e "s,$patch_dir/,,g" -e 's, ,\n,g' >> "$patch_dir/series" + else + echo "Warning: no patches from $line" + fi + else + echo "git --git-dir '$REPO_DIR/.git' diff '$line'" + echo "failed." + exit 1 + fi + esac + done +} + +mkdir -p "$patch_dir" || exit 1 +echo "# $patch_list exported from git by export-hook" > "$patch_dir/series" + +(sed -e "s/\$DEB_VERSION/$DEB_VERSION/g" \ + -e "s/\${DEB_VERSION}/$DEB_VERSION/g" \ + -e "s/\$UPSTREAM_VERSION/$UPSTREAM_VERSION/g" \ + -e "s/\${UPSTREAM_VERSION}/$UPSTREAM_VERSION/g" \ + -e "s/\$DEB_REF/$DEB_REF/g" \ + -e "s/\${DEB_REF}/$DEB_REF/g" \ + -e "s/\$UPSTREAM_REF/$UPSTREAM_REF/g" \ + -e "s/\${UPSTREAM_REF}/$UPSTREAM_REF/g" \ + < "$patch_list" ; echo ) | do_patches || exit 1