]>
Commit | Line | Data |
---|---|---|
8d50b63f MV |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
3abb6a6a DK |
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
5 | . "$TESTDIR/framework" | |
8d50b63f MV |
6 | |
7 | setupenvironment | |
8 | configarchitecture 'amd64' | |
9 | ||
10 | # apt-extracttemplates needs this | |
8d50b63f MV |
11 | insertinstalledpackage 'pkg-with-template' 'amd64' '1.0' |
12 | ||
3a8776a3 | 13 | # build a simple package that contains a config and a template |
8d50b63f | 14 | mkdir -p DEBIAN |
8d50b63f MV |
15 | CONFIG_STR="#!/bin/sh |
16 | random shell stuff | |
17 | " | |
18 | echo "$CONFIG_STR" > DEBIAN/config | |
19 | ||
061ee5f0 DK |
20 | testrun() { |
21 | local TEMPLATE_STR='Template: foo/bar | |
22 | Type: string | |
23 | Description: Some bar var | |
24 | ' | |
25 | echo "$TEMPLATE_STR" > DEBIAN/templates | |
26 | buildsimplenativepackage "$1" 'amd64' '0.8.15' 'stable' "$2" 'pkg with template' '' '' './DEBIAN' | |
27 | ||
28 | cp dpkg.status rootdir/var/lib/dpkg/status | |
29 | insertinstalledpackage 'debconf' 'amd64' '3' | |
30 | ||
31 | # ensure we get the right stuff out of the file | |
32 | rm -rf extracttemplates-out rootdir/var/cache/apt | |
33 | mkdir extracttemplates-out | |
34 | testsuccess aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb | |
35 | OUT='rootdir/tmp/testsuccess.output' | |
36 | testequal "$1" cut -f1 -d' ' $OUT | |
37 | if [ -n "$2" ]; then | |
25b86db1 | 38 | testequal '' cut -s -f2 -d' ' $OUT |
061ee5f0 DK |
39 | else |
40 | testequal '1.0' cut -f2 -d' ' $OUT | |
41 | fi | |
42 | TEMPLATE=$(cut -f3 -d' ' $OUT) | |
43 | testfileequal "$TEMPLATE" "$TEMPLATE_STR" | |
44 | CONFIG=$(cut -f4 -d' ' $OUT) | |
45 | testfileequal "$CONFIG" "$CONFIG_STR" | |
8d50b63f | 46 | |
061ee5f0 DK |
47 | # ensure that the format of the output string has the right number of dots |
48 | for s in "$CONFIG" "$TEMPLATE"; do | |
49 | NR_DOTS=$(basename "$s" | tr -c -d '.') | |
50 | testequal '..' echo $NR_DOTS | |
51 | done | |
8d50b63f | 52 | |
061ee5f0 DK |
53 | if [ -n "$2" ]; then |
54 | rm -rf extracttemplates-out rootdir/var/cache/apt | |
55 | mkdir extracttemplates-out | |
56 | cp dpkg.status rootdir/var/lib/dpkg/status | |
57 | insertinstalledpackage 'debconf' 'amd64' '1' | |
58 | testempty aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb | |
59 | fi | |
60 | } | |
8d50b63f | 61 | |
061ee5f0 DK |
62 | cp rootdir/var/lib/dpkg/status dpkg.status |
63 | testrun 'pkg-with-template' '' | |
64 | testrun 'pkg-with-template-depends' 'Depends: debconf (>= 2)' | |
65 | testrun 'pkg-with-template-predepends' 'Pre-Depends: debconf (>= 2)' | |
8d50b63f | 66 | |
061ee5f0 DK |
67 | # test with no debconf installed |
68 | cp dpkg.status rootdir/var/lib/dpkg/status | |
69 | testfailure aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template-depends*.deb | |
70 | testfileequal 'rootdir/tmp/testfailure.output' 'E: Cannot get debconf version. Is debconf installed?' |