summaryrefslogtreecommitdiff
path: root/examples/gbp-configure-unpatched-source
blob: 276e310c0eb6ff8ca25e853b4ec179caea24af80 (plain)
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
#!/bin/bash
#
# 
# Setup dpkg-source and git to unpatch the source after the build and ignore
# the .pc directory.

GIT_EXCLUDE=.git/info/exclude
LOCAL_OPTIONS=debian/source/local-options

help ()
{
	cat << EOF >/dev/stdout

Modifies "$LOCAL_OPTIONS" and "$GIT_EXCLUDE"
to ignore .pc and unpatch the source after the build.

EOF

  exit $1
}


case $1 in
	-h|--help)
		help 0
	;;
esac


if [ ! -d .git ]; then
	echo "Not the top of a git repository - aborting."
	help 1
fi

if ! grep -qs '^3.*\(quilt\)' debian/source/format; then
	echo "Not a source format 3 (quilt) package - aborting."
	help 1
fi

if ! grep -qs '^unapply-patches' $LOCAL_OPTIONS; then
	echo "Setting unapply-patches in $LOCAL_OPTIONS"
	echo "unapply-patches" >> $LOCAL_OPTIONS
	git add $LOCAL_OPTIONS
	git commit -m "Unapply patches from source" $LOCAL_OPTIONS
else
	echo "unapply-patches already configured"
fi

if ! grep -qs "^\.pc/" $GIT_EXCLUDE; then
	echo "Adding .pc/ to $GIT_EXCLUDE"
	echo ".pc/" >> $GIT_EXCLUDE
else
	echo "$GIT_EXCLUDE already configured"
fi