]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-extracttemplates
Merge remote-tracking branch 'mvo/feature/hash-stats' into debian/experimental
[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 'debconf' 'amd64' '1.5'
12 insertinstalledpackage 'pkg-with-template' 'amd64' '1.0'
13
14 # build a simple package that contains a config and a tempalte
15 mkdir -p DEBIAN
16 TEMPLATE_STR="Template: foo/bar
17 Type: string
18 Description: Some bar var
19 "
20 echo "$TEMPLATE_STR" > DEBIAN/templates
21
22 CONFIG_STR="#!/bin/sh
23 random shell stuff
24 "
25 echo "$CONFIG_STR" > DEBIAN/config
26
27 buildsimplenativepackage 'pkg-with-template' 'amd64' '0.8.15' 'stable' '' 'pkg with template' '' '' './DEBIAN'
28
29 # ensure we get the right stuff out of the file
30 mkdir extracttemplates-out
31 OUT="$(aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template*.deb)"
32
33 PKG=$(printf "$OUT" | cut -f1 -d' ')
34 INSTALLED_VER=$(printf "$OUT" | cut -f2 -d' ')
35 TEMPLATE=$(printf "$OUT" | cut -f3 -d' ')
36 CONFIG=$(printf "$OUT" | cut -f4 -d' ')
37
38 testequal "$CONFIG_STR" cat $CONFIG
39 testequal "$TEMPLATE_STR" cat $TEMPLATE
40
41 # ensure that the format of the output string has the right number of dots
42 for s in "$CONFIG" "$TEMPLATE"; do
43 NR_DOTS=$(basename "$s" | tr -c -d .)
44 testequal ".." echo $NR_DOTS
45 done