]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-cdrom
calculate hashes while downloading in https
[apt.git] / test / integration / test-apt-cdrom
CommitLineData
c45233ea
DK
1#!/bin/sh
2set -e
3
4TESTDIR=$(readlink -f $(dirname $0))
5. $TESTDIR/framework
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
12841e83 32 sed -e '/gpgv\?: Signature made/ d' -e '/gpgv\?: Good signature/ d' -e '/^Identifying/ d' -e '/Reading / d' rootdir/tmp/apt-cdrom.log
a0975c8d
DK
33 test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!"
34 test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!"
1e071c30
DK
35}
36
a0975c8d 37CDROM_PRE="Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
1166ea79 38Unmounting CD-ROM...
a0975c8d
DK
39Waiting for disc...
40Please insert a Disc in the drive and press enter
41Mounting CD-ROM...
1166ea79 42Scanning disc for index files..."
a0975c8d 43CDROM_POST="This disc is called:
c45233ea
DK
44'Debian APT Testdisk 0.8.15'
45Writing new source list
46Source list entries for this disc are:
47deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
48deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
a0975c8d
DK
49Unmounting CD-ROM...
50Repeat this process for the rest of the CDs in your set."
51
25b86db1 52testsuccessequal "$CDROM_PRE
a0975c8d
DK
53Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
54Found label 'Debian APT Testdisk 0.8.15'
55$CDROM_POST" aptcdromlog add
56
25b86db1 57testsuccessequal "Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
a0975c8d
DK
58Mounting CD-ROM...
59Stored label: Debian APT Testdisk 0.8.15
60Unmounting CD-ROM..." aptcdromlog ident
1e071c30 61
a0975c8d
DK
62# apt-setup uses these commands (expect the tr in the id) to find id and label
63ident="$(LC_ALL=C aptcdrom ident 2>&1 )"
64CD_ID="$(echo "$ident" | grep "^Identifying" | head -n1 | cut -d" " -f2 | tr --delete '[]')"
65CD_LABEL="$(echo "$ident" | grep "^Stored label:" | head -n1 | sed "s/^[^:]*: //")"
25b86db1
DK
66testfileequal rootdir/var/lib/apt/cdroms.list "CD::${CD_ID} \"${CD_LABEL}\";
67CD::${CD_ID}::Label \"${CD_LABEL}\";"
c45233ea 68
5afcfe2a
DK
69testcdromusage() {
70 touch rootdir/var/lib/apt/extended_states
71
25b86db1 72 testsuccessequal 'Reading package lists...
c45233ea 73Building dependency tree...
5afcfe2a 74Reading state information...
c45233ea
DK
75The following NEW packages will be installed:
76 testing
770 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
78Inst testing (0.8.15 stable [amd64])
79Conf testing (0.8.15 stable [amd64])' aptget install testing -s
80
5afcfe2a
DK
81 testdpkgnotinstalled testing
82 testsuccess aptget install testing -y
83 testdpkginstalled testing
84 testsuccess aptget purge testing -y
85 testdpkgnotinstalled testing
86
25b86db1 87 testsuccessequal 'Reading package lists...
c45233ea 88Building dependency tree...
5afcfe2a 89Reading state information...
c45233ea
DK
90The following NEW packages will be installed:
91 testing:i386
920 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
93Inst testing:i386 (0.8.15 stable [i386])
94Conf testing:i386 (0.8.15 stable [i386])' aptget install testing:i386 -s
95
5afcfe2a
DK
96 testdpkgnotinstalled testing:i386
97 testsuccess aptget install testing:i386 -y
98 testdpkginstalled testing:i386
99 testsuccess aptget purge testing:i386 -y
100 testdpkgnotinstalled testing:i386
101
03aa0847 102 cd downloaded
5afcfe2a
DK
103 rm -f testing_0.8.15_amd64.deb
104 testsuccess aptget download testing
105 testsuccess test -s testing_0.8.15_amd64.deb
106 rm -f testing_0.8.15_amd64.deb
107
108 rm -f testing_0.8.15.dsc
109 testsuccess aptget source testing --dsc-only -d
110 testsuccess test -s testing_0.8.15.dsc
111 rm -f testing_0.8.15.dsc
03aa0847 112 cd - >/dev/null
5afcfe2a
DK
113}
114testcdromusage
115
c45233ea 116# check Idempotence of apt-cdrom (and disabling of Translation dropping)
25b86db1 117testsuccessequal "$CDROM_PRE
c45233ea 118Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
a0975c8d 119$CDROM_POST" aptcdromlog add -o APT::CDROM::DropTranslation=0
c45233ea
DK
120
121# take Translations from previous runs as needed
25b86db1 122testsuccessequal "$CDROM_PRE
c45233ea 123Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
a0975c8d 124$CDROM_POST" aptcdromlog add
c45233ea
DK
125msgtest 'Test for the german description translation of' 'testing'
126aptcache show testing -o Acquire::Languages=de | grep -q '^Description-de: ' && msgpass || msgfail
127rm -rf rootdir/var/lib/apt/lists
25b86db1 128testsuccessequal "$CDROM_PRE
c45233ea 129Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
a0975c8d 130$CDROM_POST" aptcdromlog add
c45233ea
DK
131msgtest 'Test for the english description translation of' 'testing'
132aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' && msgpass || msgfail
133
5afcfe2a
DK
134# ensure cdrom method isn't trying to mount the cdrom
135mv rootdir/media/cdrom-unmounted rootdir/media/cdrom-ejected
136# ensure an update doesn't mess with cdrom sources
137testsuccess aptget update
138testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
139mv rootdir/media/cdrom-ejected rootdir/media/cdrom-unmounted
140testcdromusage
141
142# and again to check that it withstands the temptation even if it could mount
143testsuccess aptget update
144testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
145testcdromusage
b0314abb
DK
146
147msgmsg 'Check that nothing touched our' 'CD-ROM'
148for file in $(find rootdir/media/cdrom-unmounted/dists); do
4bb006d1 149 testfilestats "$file" '%U:%G:%a' '=' "${TEST_DEFAULT_USER}:${TEST_DEFAULT_GROUP}:555"
b0314abb 150done