]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-extracttemplates
Make directory paths configurable
[apt.git] / test / integration / test-apt-extracttemplates
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6
7 setupenvironment
8 configarchitecture 'amd64'
9
10 # apt-extracttemplates needs this
11 insertinstalledpackage 'pkg-with-template' 'amd64' '1.0'
12
13 # build a simple package that contains a config and a template
14 mkdir -p DEBIAN
15 CONFIG_STR="#!/bin/sh
16 random shell stuff
17 "
18 echo "$CONFIG_STR" > DEBIAN/config
19
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
38 testequal '' cut -s -f2 -d' ' $OUT
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"
46
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
52
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 }
61
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)'
66
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?'