chiark / gitweb /
Tests suite: import-nonnative: Put a .pc in the craziest .orig too
[dgit.git] / tests / tests / import-nonnative
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-tstunt-parsechangelog
6
7 chk1 () {
8         p=$1
9         v=$2
10
11         t-archive $p $v
12 }
13 chk2() {
14         t-git-none
15         rm -rf $p
16         t-dgit --no-rm-on-error clone $p
17
18         # And now we make an update using the same orig tarball, and
19         # check that the orig import is stable.
20
21         cd $p
22
23         git branch first-import
24
25         m='Commit for import check'
26         echo "$m" >>import-check
27
28         v=${v%-*}-99
29         dch -v $v -D unstable -m "$m"
30
31         git add import-check debian/changelog
32         git commit -m "$m"
33
34         t-dgit -wgf quilt-fixup
35         t-dgit -wgf build-source
36
37         # The resulting .dsc does not have a Dgit line (because dgit push
38         # puts that in).  So we just shove it in the archive now
39
40         ln ../${p}_${v}.* $tmp/mirror/pool/main/
41         t-archive-query
42
43         t-dgit fetch
44
45         git branch first-2nd-import remotes/dgit/dgit/sid
46
47         t-git-next-date
48
49         git update-ref refs/remotes/dgit/dgit/sid first-import
50
51         t-dgit fetch
52
53         t-refs-same-start
54         t-ref-same refs/remotes/dgit/dgit/sid
55         t-ref-same refs/heads/first-2nd-import
56
57         for orig in ../${p}_${v%-*}.orig*.tar.*; do
58                 tar -atf $orig | LC_ALL=C sort >../files.o
59                 pfx=$(perl <../files.o -ne '
60                         while (<>) {
61                                 m#^([^/]+/)# or exit 0;
62                                 $x //= $1;
63                                 $x eq $1 or exit 0;
64                         }
65                         print "$x\n";
66                 ')
67                 perl -i~ -pe '
68                         s#^\Q'"$pfx"'\E##;
69                         $_="" if m/^$/ || m#/$# || m#^\.git/#;
70                 ' ../files.o
71                 orig=${orig#../}
72                 pat="^Import ${orig//./\\.}\$"
73                 t-refs-same-start
74                 for start in first-import first-2nd-import; do
75                         git log --pretty='tformat:%H' --grep "$pat" $start \
76                                 >../t.imp
77                         test $(wc -l <../t.imp) = 1
78                         imp=$(cat ../t.imp)
79                         t-ref-same-val "$orig $start" "$imp"
80                 done
81                 git ls-tree -r --name-only "$t_ref_val:" \
82                         | sort >../files.g
83                 diff ../files.{o,g}
84         done
85         cd ..
86 }
87
88 chk() { chk1 "$@"; chk2; }
89
90 # 1.0 with diff
91 chk pari-extra 3-1
92
93 # 3.0 (quilt), multiple patches, multiple origs
94 chk example 1.0-1
95
96 # 3.0 (quilt), single-debian-patch, one orig
97 chk sunxi-tools 1.2-2.~~dgittest
98
99 mangle1 () {
100         rm -f ${1}_*
101         chk1 "$@"
102         cd $tmp/mirror/pool/main
103         dpkg-source -x ${p}_${v}.dsc td
104         orig=${p}_${v%-*}.orig.tar.gz
105         tar zxf $orig
106         rm $orig ${p}_${v}.*
107         cd $p
108         mkdir urk
109         echo urk >urk/urk
110         export GZIP=-1
111 }
112 mangle2 () {
113         cd ..
114         dpkg-source -b td
115         rm -rf $p td
116         cd $tmp
117         t-archive-none $p
118         t-archive-query
119         chk2
120 }
121
122 # 3.0 (quilt), multiple patches, tarbomb orig
123 mangle1 example 1.0-1
124 tar zvcf ../$orig *
125 mangle2
126
127 # 3.0 (quilt), multiple patches, tarbomb orig with dot
128 mangle1 example 1.0-1
129 tar zvcf ../$orig .
130 mangle2
131
132 # 3.0 (quilt), multiple patches, tarbomb orig with dot and .git and .pc
133 mangle1 example 1.0-1
134 git init
135 mkdir .pc
136 echo SPONG >.pc/SPONG
137 tar zvcf ../$orig .
138 mangle2
139
140 echo done.