~ubuntu-branches/ubuntu/saucy/systemd/saucy-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /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