]> git.saurik.com Git - apt.git/blob - test/integration/test-apt-get-install-deb
prepare-release: Use equivs and gdebi-core for travis deps
[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 testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
129 testsuccess aptget install ./incoming/pkg-leading-newline_0_all.deb
130 testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
131
132 testempty apt clean
133 if [ "$(id -u)" = '0' ]; then
134 # see if permission dropping is checked before usage
135 chmod 711 ./incoming
136 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
137 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
138 chmod 710 ./incoming
139 testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
140 testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
141 chmod 700 ./incoming
142 testsuccesswithnotice aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
143 testfailure grep 'is already the newest version' rootdir/tmp/testsuccesswithnotice.output
144 chmod 711 ./incoming
145 else
146 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb --reinstall
147 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
148 fi
149
150 sed -i -e '/^Depends: foo/ d' rootdir/var/lib/dpkg/status
151 testsuccess aptget install -y ./incoming/pkg-as-it-should-be_0_all.deb
152 testfailure grep 'is already the newest version' rootdir/tmp/testsuccess.output
153 testsuccess apt purge -y pkg-as-it-should-be
154
155 echo "Package: pkg-as-it-should-be
156 Architecture: all
157 Version: 0
158 Installed-Size: 2903
159 Filename: incoming/pkg-as-it-should-be_0_all.deb
160 Size: $(stat -c %s incoming/pkg-as-it-should-be_0_all.deb)
161 SHA256: $(sha256sum incoming/pkg-as-it-should-be_0_all.deb | cut -d' ' -f 1)
162 " > Packages
163 testdpkgnotinstalled 'pkg-as-it-should-be'
164 testnopackage pkg-as-it-should-be
165 testsuccess apt install --with-source ./Packages pkg-as-it-should-be -s
166 testsuccess apt install --with-source ./Packages pkg-as-it-should-be --print-uris
167 testsuccess apt show --with-source ./Packages pkg-as-it-should-be
168 testequal 'Package: pkg-as-it-should-be' head -n1 rootdir/tmp/testsuccess.output
169 testsuccess apt install -y --with-source ./Packages pkg-as-it-should-be
170 testdpkginstalled 'pkg-as-it-should-be'