]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-cdrom
fix testcase expecting incorrect remove log from dpkg
[apt.git] / test / integration / test-apt-cdrom
CommitLineData
c45233ea
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
c45233ea
DK
6setupenvironment
7configarchitecture 'amd64' 'i386'
8
9buildsimplenativepackage 'testing' 'amd64,i386' '0.8.15' 'stable'
b2ea1a47 10setupaptarchive --no-update
c45233ea
DK
11
12changetocdrom 'Debian APT Testdisk 0.8.15'
13
14# -de is not in the Release file, but picked up anyway for compatibility
a0975c8d
DK
15cd rootdir/media/cdrom-unmounted/dists/stable/main/i18n
16chmod +w .
c45233ea
DK
17sed -e '/^Description-en:/ d' -e '/^ / d' -e '/^$/ d' Translation-en > Translation-de
18echo 'Description-de: automatisch generiertes Testpaket testing=0.8.15/stable
19 Diese Pakete sind nur für das testen von APT gedacht,
20 sie erfüllen keinen Zweck auf einem normalen System…
21' >> Translation-de
276e51dd 22compressfile Translation-de
a0975c8d 23rm -f Translation-en Translation-de
b0314abb 24chmod -R 555 .
c45233ea
DK
25cd - > /dev/null
26
1e071c30
DK
27aptcdromlog() {
28 rm -f rootdir/tmp/apt-cdrom.log
a0975c8d
DK
29 test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!"
30 test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!"
31 aptcdrom "$@" -o quiet=1 >rootdir/tmp/apt-cdrom.log 2>&1 </dev/null
0343b48e
JAK
32 sed -e '/gpgv\?:\s*Signature made/ d' \
33 -e '/gpgv\?:\s*Good signature/ d' \
34 -e '/gpgv\?:\s*using RSA key/ d' \
35 -e '/gpgv\?:\s*issuer/ d' \
36 -e '/^Identifying/ d' \
37 -e '/Reading / d' rootdir/tmp/apt-cdrom.log
a0975c8d
DK
38 test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!"
39 test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!"
1e071c30 40}
d84da499 41aptautotest_aptcdromlog_add() { aptautotest_aptget_update "$@"; }
1e071c30 42
a0975c8d 43CDROM_PRE="Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
1166ea79 44Unmounting CD-ROM...
a0975c8d 45Waiting for disc...
94171725 46Please insert a Disc in the drive and press [Enter]
a0975c8d 47Mounting CD-ROM...
1166ea79 48Scanning disc for index files..."
a0975c8d 49CDROM_POST="This disc is called:
c45233ea
DK
50'Debian APT Testdisk 0.8.15'
51Writing new source list
52Source list entries for this disc are:
53deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
54deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
a0975c8d
DK
55Unmounting CD-ROM...
56Repeat this process for the rest of the CDs in your set."
57
25b86db1 58testsuccessequal "$CDROM_PRE
1dd20368 59Found 3 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
a0975c8d
DK
60Found label 'Debian APT Testdisk 0.8.15'
61$CDROM_POST" aptcdromlog add
62
25b86db1 63testsuccessequal "Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
a0975c8d
DK
64Mounting CD-ROM...
65Stored label: Debian APT Testdisk 0.8.15
66Unmounting CD-ROM..." aptcdromlog ident
1e071c30 67
a0975c8d
DK
68# apt-setup uses these commands (expect the tr in the id) to find id and label
69ident="$(LC_ALL=C aptcdrom ident 2>&1 )"
70CD_ID="$(echo "$ident" | grep "^Identifying" | head -n1 | cut -d" " -f2 | tr --delete '[]')"
71CD_LABEL="$(echo "$ident" | grep "^Stored label:" | head -n1 | sed "s/^[^:]*: //")"
25b86db1
DK
72testfileequal rootdir/var/lib/apt/cdroms.list "CD::${CD_ID} \"${CD_LABEL}\";
73CD::${CD_ID}::Label \"${CD_LABEL}\";"
c45233ea 74
5afcfe2a
DK
75testcdromusage() {
76 touch rootdir/var/lib/apt/extended_states
77
25b86db1 78 testsuccessequal 'Reading package lists...
c45233ea 79Building dependency tree...
5afcfe2a 80Reading state information...
c45233ea
DK
81The following NEW packages will be installed:
82 testing
830 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
84Inst testing (0.8.15 stable [amd64])
85Conf testing (0.8.15 stable [amd64])' aptget install testing -s
86
5afcfe2a
DK
87 testdpkgnotinstalled testing
88 testsuccess aptget install testing -y
89 testdpkginstalled testing
90 testsuccess aptget purge testing -y
91 testdpkgnotinstalled testing
92
25b86db1 93 testsuccessequal 'Reading package lists...
c45233ea 94Building dependency tree...
5afcfe2a 95Reading state information...
c45233ea
DK
96The following NEW packages will be installed:
97 testing:i386
980 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
99Inst testing:i386 (0.8.15 stable [i386])
100Conf testing:i386 (0.8.15 stable [i386])' aptget install testing:i386 -s
101
5afcfe2a
DK
102 testdpkgnotinstalled testing:i386
103 testsuccess aptget install testing:i386 -y
104 testdpkginstalled testing:i386
105 testsuccess aptget purge testing:i386 -y
106 testdpkgnotinstalled testing:i386
107
03aa0847 108 cd downloaded
5afcfe2a
DK
109 rm -f testing_0.8.15_amd64.deb
110 testsuccess aptget download testing
111 testsuccess test -s testing_0.8.15_amd64.deb
112 rm -f testing_0.8.15_amd64.deb
113
114 rm -f testing_0.8.15.dsc
115 testsuccess aptget source testing --dsc-only -d
116 testsuccess test -s testing_0.8.15.dsc
117 rm -f testing_0.8.15.dsc
03aa0847 118 cd - >/dev/null
5afcfe2a
DK
119}
120testcdromusage
121
c45233ea 122# check Idempotence of apt-cdrom (and disabling of Translation dropping)
25b86db1 123testsuccessequal "$CDROM_PRE
1dd20368 124Found 3 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
a0975c8d 125$CDROM_POST" aptcdromlog add -o APT::CDROM::DropTranslation=0
c45233ea
DK
126
127# take Translations from previous runs as needed
25b86db1 128testsuccessequal "$CDROM_PRE
1dd20368 129Found 3 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
a0975c8d 130$CDROM_POST" aptcdromlog add
c45233ea
DK
131msgtest 'Test for the german description translation of' 'testing'
132aptcache show testing -o Acquire::Languages=de | grep -q '^Description-de: ' && msgpass || msgfail
133rm -rf rootdir/var/lib/apt/lists
25b86db1 134testsuccessequal "$CDROM_PRE
1dd20368 135Found 3 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
a0975c8d 136$CDROM_POST" aptcdromlog add
c45233ea
DK
137msgtest 'Test for the english description translation of' 'testing'
138aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' && msgpass || msgfail
139
5afcfe2a
DK
140# ensure cdrom method isn't trying to mount the cdrom
141mv rootdir/media/cdrom-unmounted rootdir/media/cdrom-ejected
d84da499 142msgmsg "ensure an update doesn't mess with cdrom sources"
5afcfe2a 143testsuccess aptget update
1eb1836f 144testfileequal rootdir/tmp/testsuccess.output 'Hit:1 cdrom://Debian APT Testdisk 0.8.15 stable InRelease
ff86d7df 145Reading package lists...'
5afcfe2a
DK
146mv rootdir/media/cdrom-ejected rootdir/media/cdrom-unmounted
147testcdromusage
148
d84da499 149msgmsg 'and again to check that it withstands the temptation even if it could mount'
5afcfe2a 150testsuccess aptget update
1eb1836f 151testfileequal rootdir/tmp/testsuccess.output 'Hit:1 cdrom://Debian APT Testdisk 0.8.15 stable InRelease
ff86d7df 152Reading package lists...'
5afcfe2a 153testcdromusage
b0314abb
DK
154
155msgmsg 'Check that nothing touched our' 'CD-ROM'
156for file in $(find rootdir/media/cdrom-unmounted/dists); do
4bb006d1 157 testfilestats "$file" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:555"
b0314abb 158done