summaryrefslogtreecommitdiff
path: root/tests/tests/quilt-include-binaries
blob: c193e0b462d19e5046949c13c7b294c21c0dd9cd (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
set -e
. tests/lib
t-tstunt-parsechangelog

p=example

mkdir example
cd example
git init

r=1
v0=1.0-$r
t-dgit import-dsc $troot/pkg-srcs/${p}_${v0}.dsc +import

git reset --hard import

cat >debian/source/include-binaries <<END
# comment

enoent/file
bins/file
debian/binfile

../bin-in-parent
$tmp/bin-with-abs
debian/../../bin-tricky-in-parent
bins/bin-via-link
$tmp/
..
debian/../..
END

for f in bin-in-parent bin-with-abs bin-tricky-in-parent bin-via-link; do
	echo SHOULD-NOT-APPEAR-$f >../$f
done

git add debian/source/include-binaries
git commit -m 'specify include binaries'

t-prep () {
	local m=$1
	git checkout -B work master
	t-git-next-date
	r=$(( $r + 1 ))
	v=1.0-$r
	t-dch-commit -v$v -m "$1"
}

t-make-some-bin () {
	local file="$1"
	perl -e '
		use autodie;
		print pack "H*", "d41d8cd98f00b204e9800998ecf8427e";
		print "\n'"$file $r"'\n";
	' >"$file"
}

t-try-build-source () {
	LC_MESSAGES=C LANGUAGE=C \
	t-dgit --quilt=nofix --since-version=$v0 "$@" build-source
}

t-roundtrips-1 () {
 	t-try-build-source "$@" 2>&1 | tee ../build-source-out.$r
	t-dgit import-dsc ../${p}_${v}.dsc +reimport
	set +e
	git --no-pager grep SHOULD-NOT-APPEAR reimport --
	rc=$?
	set -e
	test $rc = 1
	git diff --exit-code work reimport --
}

t-roundtrips () {
	t-roundtrips-1
	t-roundtrips-1 --include-dirty
}

t-prep 'straightforward'

mkdir bins
t-make-some-bin bins/file
git add bins/file
git commit -m 'add bin'

t-roundtrips

for wrongness in 			\
 "forbidden path component '..'" 	\
 "path starts with 'debian'" 		\
; do
	grep "$wrongness" ../build-source-out.$r
done

t-prep 'bin via link'

linktarget="$tmp"
: 'make a new orig, gnagh'
mkdir ../repack
cd ../repack
tar axf $troot/pkg-srcs/${p}_1.0.orig.tar.gz
ln -s "$linktarget" example/bins
tar zcf ../${p}_1.1.orig.tar.gz example
cd ../example
cp ../${p}_1.{0,1}.orig-docs.tar.gz

v=1.1-$r
t-dch-commit -v$v -m 'update upstream'

ln -s "$linktarget" bins
git add bins
git commit -m 'add bins'

t-roundtrips

t-prep 'ignored weird file'

mkdir bins
mkfifo bins/file

t-roundtrips-1 -wdn

grep "'bins/file' not a plain file or directory" ../build-source-out.$r

t-expect-fail E:'dpkg-source: error:  *new version is named pipe' \
t-try-build-source -wdn --ignore-dirty

t-ok