]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-get-install-deb
deprecate confusing Pkg.CandVersion() method
[apt.git] / test / integration / test-apt-get-install-deb
CommitLineData
9c3e15ab
MV
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
9c3e15ab
MV
6
7setupenvironment
5465192b 8configarchitecture 'amd64' 'i386'
9c3e15ab
MV
9
10# regression test for #754904
14341a7e 11testfailureequal 'E: Unsupported file /dev/null given on commandline' aptget install -qq /dev/null
9c3e15ab 12
5465192b
DK
13# only consider .deb files
14cat > foo.rpm <<EOF
9c3e15ab
MV
15I'm not a deb, I'm a teapot.
16EOF
14341a7e 17testfailureequal 'E: Unsupported file ./foo.rpm given on commandline' aptget install -qq ./foo.rpm
5465192b
DK
18
19# and ensure we fail for invalid debs
20mv foo.rpm foo.deb
14341a7e
DK
21testfailuremsg "E: Sub-process Popen returned an error code (2)
22E: Encountered a section with no Package: header
c9443c01 23E: Problem with MergeList ${TMPWORKINGDIRECTORY}/foo.deb
14341a7e 24E: The package lists or status file could not be parsed or opened." aptget install ./foo.deb
9c3e15ab 25
5465192b
DK
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
87d6947d 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
5465192b 42
3dd64b9c 43testdpkgnotinstalled 'foo' 'foo:i386'
c9443c01 44testsuccess aptget install ./incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
b2640c0a 45testdpkginstalled 'foo:i386'
f359b7e8 46testfailure aptget install incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1
3dd64b9c
DK
47cd downloaded
48testsuccess aptget install "$(readlink -f ../incoming/foo_1.0_i386.deb)" -o Debug::pkgCacheGen=1 -y --allow-downgrades
49testsuccess aptget install ../incoming/foo_1.0_i386.deb -o Debug::pkgCacheGen=1 -y --allow-downgrades
50cd ..
5465192b
DK
51
52testsuccessequal "Reading package lists...
53Building dependency tree...
54Reading state information...
55Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
56The following packages will be REMOVED:
57 foo:i386
58The following NEW packages will be installed:
59 foo
600 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
61Remv foo:i386 [1.0]
c9443c01 62Inst foo (1.0 local-deb [amd64])
87d6947d 63Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
848fd2a6
JAK
64
65# Check that installing the local deb works if it is not the candidate
66echo "Package: foo
67Pin: version 1.0
68Pin-Priority: -1" > rootdir/etc/apt/preferences
69
70testsuccessequal "Reading package lists...
71Building dependency tree...
72Reading state information...
73Note, selecting 'foo' instead of './incoming/foo_1.0_amd64.deb'
74The following packages will be REMOVED:
75 foo:i386
76The following NEW packages will be installed:
77 foo
780 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
79Remv foo:i386 [1.0]
80Inst foo (1.0 local-deb [amd64])
87d6947d 81Conf foo (1.0 local-deb [amd64])" aptget install ./incoming/foo_1.0_amd64.deb -s
2f91076d
DK
82
83createpkg() {
84 local PKG="pkg-$1"
85 mkdir -p ./incoming/$PKG/DEBIAN
86 if [ -n "$2" ]; then
87 echo -n "$2" >> ./incoming/$PKG/DEBIAN/control
88 fi
89 echo "Package: $PKG
90Version: 0
91Priority: extra
92Maintainer: No Body <no@example.org>
93Architecture: all
94Description: test package" >> ./incoming/$PKG/DEBIAN/control
95 if [ -n "$3" ]; then
96 echo -n "$3" >> ./incoming/$PKG/DEBIAN/control
97 fi
98 testsuccess dpkg-deb --build ./incoming/$PKG/ ./incoming
99 #dpkg-deb -I ./incoming/${PKG}_0_all.deb control
100}
101createpkg 'as-it-should-be'
102createpkg 'leading-newline' '
103
104'
105createpkg 'trailing-newline' '' '
106'
107
108testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
109testsuccess aptget install ./incoming/pkg-leading-newline_0_all.deb
110testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
514a25cb
DK
111
112# see if permission dropping is checked before usage
113if [ "$(id -u)" = '0' ]; then
114 apt clean
115 chmod 711 ./incoming
87d6947d 116 testsuccess aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
514a25cb 117 chmod 710 ./incoming
87d6947d 118 testsuccesswithnotice aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
514a25cb 119 chmod 700 ./incoming
87d6947d 120 testsuccesswithnotice aptget install -y --allow-downgrades ./incoming/pkg-as-it-should-be_0_all.deb
514a25cb 121fi