]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-bug-818628-unreadable-source
add a testcase for support of various build-dependency types
[apt.git] / test / integration / test-bug-818628-unreadable-source
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6setupenvironment
7configarchitecture 'amd64'
8
9if [ "$(id -u)" = '0' ]; then
10 msgskip 'Tests for unreadable files do not work as root'
11 exit 0
12fi
13
14insertinstalledpackage 'foo' 'amd64' '1'
15insertpackage 'unstable' 'foo' 'amd64' '2'
16
17setupaptarchive --no-update
18
19touch rootdir/etc/apt/apt.conf.d/unreadable.conf
20touch rootdir/etc/apt/preferences.d/unreadable.pref
21
22addtrap 'prefix' "chmod -R +r '$(escape_shell "$TMPWORKINGDIRECTORY")/rootdir/etc/apt';"
23chmod -r rootdir/etc/apt/trusted.gpg.d
24testfailure apt update
25chmod +r rootdir/etc/apt/trusted.gpg.d
26testsuccess apt update
27testsuccess apt policy foo
28testsuccess apt search foo
29testsuccessequal "Listing...
30foo/unstable 2 amd64 [upgradable from: 1]
31N: There is 1 additional version. Please use the '-a' switch to see it" apt list --upgradable
32
33runthemall() {
34 local ERR1="$1"
35 local ERR2="$1$2"
36 testfailureequal "$ERR1" aptcache policy
37 testfailureequal "$ERR1" aptcache policy foo
38 testfailureequal "$ERR2" aptcache depends foo
39 testfailureequal "$ERR2" aptcache rdepends foo
40 testfailureequal "$ERR2" aptcache search foo
41 testfailureequal "$ERR1" apt policy
42 testfailureequal "$ERR1" apt policy foo
43 testfailureequal "$ERR2" apt depends foo
44 testfailureequal "$ERR2" apt rdepends foo
45 testfailureequal "$ERR2" apt search foo
46 testfailureequal "$ERR2" apt list --upgradable
47 testfailureequal "$ERR2" apt show foo
48 testfailureequal "$ERR2" aptcache show foo --no-all-versions
49 testfailureequal "$ERR2" aptmark auto foo
50 testfailureequal "$ERR2" aptmark manual foo
51 testfailureequal "$ERR2" aptmark auto foo
52}
53echo 'Apt::Cmd::Disable-Script-Warning "true";' >> aptconfig.conf
54
55msgmsg 'Unreadable sources file'
56chmod -r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
57runthemall "E: Opening $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list - ifstream::ifstream (13: Permission denied)
58E: The list of sources could not be read."
59chmod +r rootdir/etc/apt/sources.list.d/apt-test-unstable-deb-src.list
60
61msgmsg 'Unreadable config file'
62chmod -r rootdir/etc/apt/apt.conf.d/unreadable.conf
63runthemall "E: Opening configuration file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/unreadable.conf - ifstream::ifstream (13: Permission denied)"
64chmod +r rootdir/etc/apt/apt.conf.d/unreadable.conf
65
66msgmsg 'Unreadable preferences file'
67chmod -r rootdir/etc/apt/preferences.d/unreadable.pref
68runthemall "E: Could not open file ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/unreadable.pref - open (13: Permission denied)"
69chmod +r rootdir/etc/apt/preferences.d/unreadable.pref
70
71msgmsg 'Unreadable sources directory'
72chmod -r rootdir/etc/apt/sources.list.d
73runthemall "E: Unable to read $TMPWORKINGDIRECTORY/rootdir/etc/apt/sources.list.d/ - opendir (13: Permission denied)" "
74W: You may want to run apt-get update to correct these problems
75E: The package cache file is corrupted"
76chmod +r rootdir/etc/apt/sources.list.d
77
78msgmsg 'Unreadable config directory'
79chmod -r rootdir/etc/apt/apt.conf.d
80runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/ - opendir (13: Permission denied)"
81chmod +r rootdir/etc/apt/apt.conf.d
82
83msgmsg 'Unreadable preferences directory'
84chmod -r rootdir/etc/apt/preferences.d
85runthemall "E: Unable to read ${TMPWORKINGDIRECTORY}/rootdir/etc/apt/preferences.d/ - opendir (13: Permission denied)"
86chmod +r rootdir/etc/apt/preferences.d