summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-cdrom
blob: 44eccb7bf88a0c5fdea729306685351a1be25fd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
set -e

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
configarchitecture 'amd64' 'i386'

buildsimplenativepackage 'testing' 'amd64,i386' '0.8.15' 'stable'
setupaptarchive --no-update

changetocdrom 'Debian APT Testdisk 0.8.15'

# -de is not in the Release file, but picked up anyway for compatibility
cd rootdir/media/cdrom-unmounted/dists/stable/main/i18n
chmod +w .
sed -e '/^Description-en:/ d' -e '/^ / d' -e '/^$/ d' Translation-en > Translation-de
echo 'Description-de: automatisch generiertes Testpaket testing=0.8.15/stable
 Diese Pakete sind nur für das testen von APT gedacht,
 sie erfüllen keinen Zweck auf einem normalen System…
' >> Translation-de
compressfile Translation-de
rm -f Translation-en Translation-de
chmod -R -w .
cd - > /dev/null

aptcdromlog() {
	rm -f rootdir/tmp/apt-cdrom.log
	test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!"
	test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!"
	aptcdrom "$@" -o quiet=1 >rootdir/tmp/apt-cdrom.log 2>&1 </dev/null
	sed -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' rootdir/tmp/apt-cdrom.log
	test ! -e rootdir/media/cdrom || echo "CD-ROM is mounted, but shouldn't be!"
	test -e rootdir/media/cdrom-unmounted || echo "Unmounted CD-ROM doesn't exist, but it should!"
}

CDROM_PRE="Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
Unmounting CD-ROM...
Waiting for disc...
Please insert a Disc in the drive and press enter 
Mounting CD-ROM...
Scanning disc for index files..."
CDROM_POST="This disc is called: 
'Debian APT Testdisk 0.8.15'
Writing new source list
Source list entries for this disc are:
deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
Unmounting CD-ROM...
Repeat this process for the rest of the CDs in your set."

testequal "$CDROM_PRE
Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
Found label 'Debian APT Testdisk 0.8.15'
$CDROM_POST" aptcdromlog add

testequal "Using CD-ROM mount point $(readlink -f ./rootdir/media)/cdrom/
Mounting CD-ROM...
Stored label: Debian APT Testdisk 0.8.15
Unmounting CD-ROM..." aptcdromlog ident

# apt-setup uses these commands (expect the tr in the id) to find id and label
ident="$(LC_ALL=C aptcdrom ident 2>&1 )"
CD_ID="$(echo "$ident" | grep "^Identifying" | head -n1 | cut -d" " -f2 | tr --delete '[]')"
CD_LABEL="$(echo "$ident" | grep "^Stored label:" | head -n1 | sed "s/^[^:]*: //")"
testequal "CD::${CD_ID} \"${CD_LABEL}\";
CD::${CD_ID}::Label \"${CD_LABEL}\";" cat rootdir/var/lib/apt/cdroms.list

testcdromusage() {
	touch rootdir/var/lib/apt/extended_states

	testequal 'Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  testing
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst testing (0.8.15 stable [amd64])
Conf testing (0.8.15 stable [amd64])' aptget install testing -s

	testdpkgnotinstalled testing
	testsuccess aptget install testing -y
	testdpkginstalled testing
	testsuccess aptget purge testing -y
	testdpkgnotinstalled testing

	testequal 'Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  testing:i386
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst testing:i386 (0.8.15 stable [i386])
Conf testing:i386 (0.8.15 stable [i386])' aptget install testing:i386 -s

	testdpkgnotinstalled testing:i386
	testsuccess aptget install testing:i386 -y
	testdpkginstalled testing:i386
	testsuccess aptget purge testing:i386 -y
	testdpkgnotinstalled testing:i386

	rm -f testing_0.8.15_amd64.deb
	testsuccess aptget download testing
	testsuccess test -s testing_0.8.15_amd64.deb
	rm -f testing_0.8.15_amd64.deb

	rm -f testing_0.8.15.dsc
	testsuccess aptget source testing --dsc-only -d
	testsuccess test -s testing_0.8.15.dsc
	rm -f testing_0.8.15.dsc
}
testcdromusage

# check Idempotence of apt-cdrom (and disabling of Translation dropping)
testequal "$CDROM_PRE
Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
$CDROM_POST" aptcdromlog add -o APT::CDROM::DropTranslation=0

# take Translations from previous runs as needed
testequal "$CDROM_PRE
Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
$CDROM_POST" aptcdromlog add
msgtest 'Test for the german description translation of' 'testing'
aptcache show testing -o Acquire::Languages=de | grep -q '^Description-de: ' && msgpass || msgfail
rm -rf rootdir/var/lib/apt/lists
mkdir -p rootdir/var/lib/apt/lists/partial
testequal "$CDROM_PRE
Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
$CDROM_POST" aptcdromlog add
msgtest 'Test for the english description translation of' 'testing'
aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' && msgpass || msgfail

# ensure cdrom method isn't trying to mount the cdrom
mv rootdir/media/cdrom-unmounted rootdir/media/cdrom-ejected
# ensure an update doesn't mess with cdrom sources
testsuccess aptget update
testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
mv rootdir/media/cdrom-ejected rootdir/media/cdrom-unmounted
testcdromusage

# and again to check that it withstands the temptation even if it could mount
testsuccess aptget update
testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
testcdromusage