#! /bin/sh 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 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%-*}" #tar xf ../systemd_$UPSTREAM_VERSION.orig.tar.* --strip-components=1 --keep-newer-files do_patches (){ while read -r line do [ -n "$line" ] || continue case $line in \#*) ;; *) git --git-dir "$REPO_DIR/.git" diff "$line" > "$patch_dir/$line" echo "$line" >> "$patch_dir/series" echo "$line" >> ".pc/applied-patches" if [ ! -s "$patch_dir/$line" ]; then echo "$line generated empty patch, please fix." exit 1 fi ;; esac done } mkdir -p "$patch_dir" || exit 1 mkdir -p ".pc" || 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