]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-apt-get-install-deb
keep Release.gpg on untrusted to trusted IMS-Hit
[apt.git] / test / integration / test-apt-get-install-deb
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6
7setupenvironment
8configarchitecture 'amd64' 'i386'
9
10# regression test for #754904
11testfailureequal 'E: Unsupported file /dev/null given on commandline' aptget install -qq /dev/null
12
13# only consider .deb files
14cat > foo.rpm <<EOF
15I'm not a deb, I'm a teapot.
16EOF
17testfailureequal 'E: Unsupported file ./foo.rpm given on commandline' aptget install -qq ./foo.rpm
18
19# and ensure we fail for invalid debs
20mv foo.rpm foo.deb
21testfailuremsg "E: Sub-process Popen returned an error code (2)
22E: Encountered a section with no Package: header
23E: Problem with MergeList ${TMPWORKINGDIRECTORY}/foo.deb
24E: The package lists or status file could not be parsed or opened." aptget install ./foo.deb
25
26buildsimplenativepackage 'foo' 'i386,amd64' '1.0'
27
28testfailureequal "Reading package lists...
29Building dependency tree...
30Note, selecting 'foo:i386' instead of './incoming/foo_1.0_i386.deb'
31Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
32Some packages could not be installed. This may mean that you have
33requested an impossible situation or if you are using the unstable
34distribution that some required packages have not yet been created
35or been moved out of Incoming.
36The following information may help to resolve the situation:
37
38The 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
41E: 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
43testdpkgnotinstalled 'foo' 'foo:i386'
44testsuccess aptget install ./incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
45testdpkginstalled 'foo:i386'
46testfailure aptget install incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
47cd downloaded
48testsuccess aptget install "$(readlink -f ../incoming/foo_1.0_i386.deb)" -o Debug::pkgCacheGen=1 -y --reinstall
49testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
50testsuccess aptget install ../incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1 -y --reinstall
51testfailure grep 'is already the newest version' ../rootdir/tmp/testsuccess.output
52cd ..
53
54testsuccessequal "Reading package lists...
55Building dependency tree...
56Reading state information...
57Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
58The following packages will be REMOVED:
59 foo:i386
60The following NEW packages will be installed:
61 foo
620 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
63Remv foo:i386 [1.0]
64Inst foo (1.0 local-deb [amd64])
65Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
66
67testsuccessequal 'Reading package lists...
68Building dependency tree...
69Reading state information...
700 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget install --with-source ./incoming/foo_1.0_amd64.deb -s
71
72testsuccessequal 'Reading package lists...
73Building dependency tree...
74Reading state information...
75The following packages will be REMOVED:
76 foo:i386
77The following NEW packages will be installed:
78 foo
790 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
80Remv foo:i386 [1.0]
81Inst foo (1.0 local-deb [amd64])
82Conf 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
85echo "Package: foo
86Pin: version 1.0
87Pin-Priority: -1" > rootdir/etc/apt/preferences
88
89testsuccessequal "Reading package lists...
90Building dependency tree...
91Reading state information...
92Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
93The following packages will be REMOVED:
94 foo:i386
95The following NEW packages will be installed:
96 foo
970 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
98Remv foo:i386 [1.0]
99Inst foo (1.0 local-deb [amd64])
100Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
101
102createpkg() {
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
109Version: 0
110Priority: extra
111Maintainer: No Body <no@example.org>
112Architecture: all
113Depends: foo:i386
114Description: 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}
121createpkg 'as-it-should-be'
122createpkg 'leading-newline' '
123
124'
125createpkg 'trailing-newline' '' '
126'
127
128echo 'Package: /pkg-/
129Pin: release a=experimental
130Pin-Priority: 501' > rootdir/etc/apt/preferences.d/pinit
131
132testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
133testsuccess aptget install "$(readlink -f ./incoming/pkg-leading-newline_0_all.deb)"
134testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
135
136testempty apt clean
137if [ "$(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
149else
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
152fi
153
154sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
155testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
156testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
157testsuccess apt purge -y pkg-as-it-should-be
158
159echo "Package: pkg-as-it-should-be
160Architecture: all
161Version: 0
162Installed-Size: 2903
163Filename: incoming/pkg-as-it-should-be_0_all.deb
164Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.deb)
165SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.deb | cut -d' ' -f 1)
166" > Packages
167testdpkgnotinstalled 'pkg-as-it-should-be'
168testnopackage pkg-as-it-should-be
169testsuccess apt install --with-source ./Packages pkg-as-it-should-be -s
170testsuccess apt install --with-source ./Packages pkg-as-it-should-be --print-uris
171testsuccess apt show --with-source ./Packages pkg-as-it-should-be
172testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
173testsuccess apt install -y --with-source ./Packages pkg-as-it-should-be
174testdpkginstalled 'pkg-as-it-should-be'
175rm -f ./Packages
176
177echo 'dpkg::install::recursive "true";
178dpkg::install::recursive::force "true";
179dpkg::install::recursive::minimum "0";' > rootdir/etc/apt/apt.conf.d/lowerminimum.conf
180mv ./incoming/pkg-as-it-should-be_0_all.deb ./incoming/pkg-as-it-should-be_0_all.ddeb
181testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.ddeb --reinstall
182testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
183testsuccess apt purge -y pkg-as-it-should-be
184testdpkgnotinstalled 'pkg-as-it-should-be'
185
186mv ./incoming/pkg-as-it-should-be_0_all.ddeb ./incoming/pkg-as-it-should-be_0_all.foobar
187echo "Package: pkg-as-it-should-be
188Architecture: all
189Version: 0
190Installed-Size: 2903
191Filename: incoming/pkg-as-it-should-be_0_all.foobar
192Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.foobar)
193SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.foobar | cut -d' ' -f 1)
194" | gzip > Packages.gz
195testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be -s
196testsuccess apt install --with-source ./Packages.gz pkg-as-it-should-be --print-uris
197testsuccess apt show --with-source ./Packages.gz pkg-as-it-should-be
198testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
199testsuccess apt install -y --with-source ./Packages.gz pkg-as-it-should-be
200testdpkginstalled 'pkg-as-it-should-be'