]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-get-install-deb
fix testcase expecting incorrect remove log from dpkg
[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 testfailure aptget install incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
47 cd downloaded
48 testsuccess aptget install "$(readlink -f ../incoming/foo_1.0_i386.deb)" -o Debug::pkgCacheGen=1 -y --reinstall
49 testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
50 testsuccess aptget install ../incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1 -y --reinstall
51 testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
52 cd ..
53
54 testsuccessequal "Reading package lists...
55 Building dependency tree...
56 Reading state information...
57 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
58 The following packages will be REMOVED:
59 foo:i386
60 The following NEW packages will be installed:
61 foo
62 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
63 Remv foo:i386 [1.0]
64 Inst foo (1.0 local-deb [amd64])
65 Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
66
67 testsuccessequal 'Reading package lists...
68 Building dependency tree...
69 Reading state information...
70 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget install --with-source ./incoming/foo_1.0_amd64.deb -s
71
72 testsuccessequal 'Reading package lists...
73 Building dependency tree...
74 Reading state information...
75 The following packages will be REMOVED:
76 foo:i386
77 The following NEW packages will be installed:
78 foo
79 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
80 Remv foo:i386 [1.0]
81 Inst foo (1.0 local-deb [amd64])
82 Conf foo (1.0 local-deb [amd64])' aptget install --with-source ./incoming/foo_1.0_amd64.deb foo -s
83
84 # Check that installing the local deb works if it is not the candidate
85 echo "Package: foo
86 Pin: version 1.0
87 Pin-Priority: -1" > rootdir/etc/apt/preferences
88
89 testsuccessequal "Reading package lists...
90 Building dependency tree...
91 Reading state information...
92 Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
93 The following packages will be REMOVED:
94 foo:i386
95 The following NEW packages will be installed:
96 foo
97 0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
98 Remv foo:i386 [1.0]
99 Inst foo (1.0 local-deb [amd64])
100 Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
101
102 createpkg() {
103 local PKG="pkg-$1"
104 mkdir -p ./incoming/$PKG/DEBIAN
105 if [ -n "$2" ]; then
106 echo -n "$2" >> ./incoming/$PKG/DEBIAN/control
107 fi
108 echo "Package: $PKG
109 Version: 0
110 Priority: extra
111 Maintainer: No Body <no@example.org>
112 Architecture: all
113 Depends: foo:i386
114 Description: test package" >> ./incoming/$PKG/DEBIAN/control
115 if [ -n "$3" ]; then
116 echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
117 fi
118 testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming
119 #dpkg-deb -I ./incoming/${PKG}_0_all.deb control
120 }
121 createpkg 'as-it-should-be'
122 createpkg 'leading-newline' '
123
124 '
125 createpkg 'trailing-newline' '' '
126 '
127
128 echo 'Package: /pkg-/
129 Pin: release a=experimental
130 Pin-Priority: 501' > rootdir/etc/apt/preferences.d/pinit
131
132 testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
133 testsuccess aptget install "$(readlink -f ./incoming/pkg-leading-newline_0_all.deb)"
134 testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
135
136 testempty apt clean
137 if [ "$(id -u)" = '0' ]; then
138 # see if permission dropping is checked before usage
139 chmod 711 ./incoming
140 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
141 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
142 chmod 710 ./incoming
143 testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
144 testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
145 chmod 700 ./incoming
146 testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
147 testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
148 chmod 711 ./incoming
149 else
150 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
151 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
152 fi
153
154 sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
155 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
156 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
157 testsuccess apt purge -y pkg-as-it-should-be
158
159 echo "Package: pkg-as-it-should-be
160 Architecture: all
161 Version: 0
162 Installed-Size: 2903
163 Filename: incoming/pkg-as-it-should-be_0_all.deb
164 Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.deb)
165 SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.deb | cut -d' ' -f 1)
166 " > Packages
167 testdpkgnotinstalled 'pkg-as-it-should-be'
168 testnopackage pkg-as-it-should-be
169 testsuccess apt install --with-source ./Packages pkg-as-it-should-be -s
170 testsuccess apt install --with-source ./Packages pkg-as-it-should-be --print-uris
171 testsuccess apt show --with-source ./Packages pkg-as-it-should-be
172 testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
173 testsuccess apt install -y --with-source ./Packages pkg-as-it-should-be
174 testdpkginstalled 'pkg-as-it-should-be'
175 rm -f ./Packages
176
177 echo 'dpkg::install::recursive "true";
178 dpkg::install::recursive::force "true";
179 dpkg::install::recursive::minimum "0";' > rootdir/etc/apt/apt.conf.d/lowerminimum.conf
180 mv ./incoming/pkg-as-it-should-be_0_all.deb ./incoming/pkg-as-it-should-be_0_all.ddeb
181 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.ddeb --reinstall
182 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
183 testsuccess apt purge -y pkg-as-it-should-be
184 testdpkgnotinstalled 'pkg-as-it-should-be'
185
186 mv ./incoming/pkg-as-it-should-be_0_all.ddeb ./incoming/pkg-as-it-should-be_0_all.foobar
187 echo "Package: pkg-as-it-should-be
188 Architecture: all
189 Version: 0
190 Installed-Size: 2903
191 Filename: incoming/pkg-as-it-should-be_0_all.foobar
192 Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.foobar)
193 SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.foobar | cut -d' ' -f 1)
194 " | gzip > Packages.gz
195 testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be -s
196 testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be --print-uris
197 testsuccess apt show --with-source ./Packages.gz pkg-as-it-should-be
198 testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
199 testsuccess apt install -y --with-source ./Packages.gz pkg-as-it-should-be
200 testdpkginstalled 'pkg-as-it-should-be'