]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-get-install-deb
accept ../ on the cmdline as start for a deb file as well
[apt.git] / test / integration / test-apt-get-install-deb
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6
7 setupenvironment
8 configarchitecture 'amd64' 'i386'
9
10 # regression test for #754904
11 testfailureequal 'E: Unsupported file /dev/null given on commandline' aptget install -qq /dev/null
12
13 # only consider .deb files
14 cat > foo.rpm <<EOF
15 I'm not a deb, I'm a teapot.
16 EOF
17 testfailureequal 'E: Unsupported file ./foo.rpm given on commandline' aptget install -qq ./foo.rpm
18
19 # and ensure we fail for invalid debs
20 mv foo.rpm foo.deb
21 testfailuremsg "E: Sub-process Popen returned an error code (2)
22 E: Encountered a section with no Package: header
23 E: Problem with MergeList ${TMPWORKINGDIRECTORY}/foo.deb
24 E: The package lists or status file could not be parsed or opened." aptget install ./foo.deb
25
26 buildsimplenativepackage 'foo' 'i386,amd64' '1.0'
27
28 testfailureequal "Reading package lists...
29 Building dependency tree...
30 Note, selecting 'foo:i386' instead of './incoming/foo_1.0_i386.deb'
31 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
32 Some packages could not be installed. This may mean that you have
33 requested an impossible situation or if you are using the unstable
34 distribution that some required packages have not yet been created
35 or been moved out of Incoming.
36 The following information may help to resolve the situation:
37
38 The following packages have unmet dependencies:
39 foo:i386 : Conflicts: foo but 1.0 is to be installed
40 foo : Conflicts: foo:i386 but 1.0 is to be installed
41 E: Unable to correct problems, you have held broken packages." aptget install ./incoming/foo_1.0_i386.deb ./incoming/foo_1.0_amd64.deb -s
42
43 testdpkgnotinstalled 'foo' 'foo:i386'
44 testsuccess aptget install ./incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
45 testdpkginstalled 'foo:i386'
46 cd downloaded
47 testsuccess aptget install "$(readlink -f ../incoming/foo_1.0_i386.deb)" -o Debug::pkgCacheGen=1 -y --allow-downgrades
48 testsuccess aptget install ../incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1 -y --allow-downgrades
49 cd ..
50
51 testsuccessequal "Reading package lists...
52 Building dependency tree...
53 Reading state information...
54 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
55 The following packages will be REMOVED:
56 foo:i386
57 The following NEW packages will be installed:
58 foo
59 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
60 Remv foo:i386 [1.0]
61 Inst foo (1.0 local-deb [amd64])
62 Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
63
64 # Check that installing the local deb works if it is not the candidate
65 echo "Package: foo
66 Pin: version 1.0
67 Pin-Priority: -1" > rootdir/etc/apt/preferences
68
69 testsuccessequal "Reading package lists...
70 Building dependency tree...
71 Reading state information...
72 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
73 The following packages will be REMOVED:
74 foo:i386
75 The following NEW packages will be installed:
76 foo
77 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
78 Remv foo:i386 [1.0]
79 Inst foo (1.0 local-deb [amd64])
80 Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
81
82 createpkg() {
83 local PKG="pkg-$1"
84 mkdir -p ./incoming/$PKG/DEBIAN
85 if [ -n "$2" ]; then
86 echo -n "$2" >> ./incoming/$PKG/DEBIAN/control
87 fi
88 echo "Package: $PKG
89 Version: 0
90 Priority: extra
91 Maintainer: No Body <no@example.org>
92 Architecture: all
93 Description: test package" >> ./incoming/$PKG/DEBIAN/control
94 if [ -n "$3" ]; then
95 echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
96 fi
97 testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming
98 #dpkg-deb -I ./incoming/${PKG}_0_all.deb control
99 }
100 createpkg 'as-it-should-be'
101 createpkg 'leading-newline' '
102
103 '
104 createpkg 'trailing-newline' '' '
105 '
106
107 testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
108 testsuccess aptget install ./incoming/pkg-leading-newline_0_all.deb
109 testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
110
111 # see if permission dropping is checked before usage
112 if [ "$(id -u)" = '0' ]; then
113 apt clean
114 chmod 711 ./incoming
115 testsuccess aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
116 chmod 710 ./incoming
117 testsuccesswithnotice aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
118 chmod 700 ./incoming
119 testsuccesswithnotice aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
120 fi