4 TESTDIR
=$(readlink -f $(dirname $0))
7 configarchitecture
"i386"
10 touch aptarchive
/Packages
14 rm -rf rootdir
/var
/lib
/apt rootdir
/var
/cache
/apt
15 aptget update
2>> testaptgetupdate.
diff >> testaptgetupdate.
diff || true
16 sed -i -e '/^Fetched / d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.
diff
19 msgtest
"Test for correctness of" "apt-get update with $*"
20 if [ -z "$GIVEN" ]; then
21 echo -n "" | checkdiff
- testaptgetupdate.
diff && msgpass
|| msgfail
23 echo "$GIVEN" | checkdiff
- testaptgetupdate.
diff && msgpass
|| msgfail
25 rm testaptgetupdate.
diff
28 createemptyarchive
() {
29 find aptarchive
/ \
( -name "Packages*" -o -name "en*" \
) -type f
-delete
30 if [ "en" = "$1" ]; then
31 echo -n "" | $COMPRESSOR > aptarchive
/Packages.
$COMPRESS
33 touch aptarchive
/Packages
34 echo -n "" | $COMPRESSOR > aptarchive
/${1}.
$COMPRESS
35 aptftparchive release aptarchive
/ > aptarchive
/Release
37 rm -f aptarchive
/Packages
41 find aptarchive
/ \
( -name "Packages*" -o -name "en*" \
) -type f
-delete
42 if [ "en" = "$1" ]; then
43 echo -n "" | $COMPRESSOR > aptarchive
/Packages.
$COMPRESS
45 touch aptarchive
/Packages aptarchive
/${1}.
$COMPRESS
46 aptftparchive release aptarchive
/ > aptarchive
/Release
48 rm -f aptarchive
/Packages
55 bzip2) COMPRESS
="bz2";;
56 lzma
) COMPRESS
="lzma";;
58 echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
59 Dir::Bin::gzip \"/does/not/exist\";
60 Dir::Bin::bzip2 \"/does/not/exist\";
61 Dir::Bin::lzma \"/does/not/exist\";" > rootdir
/etc
/apt
/apt.conf.d
/00compressor
62 if [ -e "/bin/${COMPRESSOR}" ]; then
63 echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir
/etc
/apt
/apt.conf.d
/00compressor
64 elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
65 echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> rootdir
/etc
/apt
/apt.conf.d
/00compressor
67 msgtest
"Test for availability of compressor" "${COMPRESSOR}"
77 testaptgetupdate
"Get:1 file: InRelease []
78 Ign file:$(readlink -f aptarchive)/ Translation-en
79 Reading package lists..." "empty file en.$COMPRESS over file"
81 createemptyarchive
'en'
82 testaptgetupdate
"Get:1 file: InRelease []
83 Reading package lists..." "empty archive en.$COMPRESS over file"
85 createemptyarchive
'Packages'
86 # FIXME: Why omits the file transport the Packages Get line?
87 #Get:3 file: Packages []
88 testaptgetupdate
"Ign file:$(readlink -f aptarchive)/ Translation-en
89 Get:1 file: InRelease []
90 Reading package lists..." "empty archive Packages.$COMPRESS over file"
92 createemptyfile
'Packages'
93 testaptgetupdate
"Ign file:$(readlink -f aptarchive)/ Translation-en
94 Get:1 file: InRelease []
97 W: Failed to fetch file:$(readlink -f aptarchive/Packages.$COMPRESS) Undetermined Error
99 E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over file"
106 testaptgetupdate
"Get:1 http://localhost InRelease []
107 Get:2 http://localhost/ Translation-en
108 Get:3 http://localhost Packages []
109 Ign http://localhost/ Translation-en
110 Reading package lists..." "empty file en.$COMPRESS over http"
112 createemptyarchive
'en'
113 testaptgetupdate
"Get:1 http://localhost InRelease []
114 Get:2 http://localhost/ Translation-en []
115 Get:3 http://localhost Packages []
116 Reading package lists..." "empty archive en.$COMPRESS over http"
118 createemptyarchive
'Packages'
119 testaptgetupdate
"Get:1 http://localhost InRelease []
120 Ign http://localhost/ Translation-en
121 Get:2 http://localhost Packages []
122 Reading package lists..." "empty archive Packages.$COMPRESS over http"
124 createemptyfile
'Packages'
125 #FIXME: we should response with a good error message instead
126 testaptgetupdate
"Get:1 http://localhost InRelease []
127 Ign http://localhost/ Translation-en
128 Get:2 http://localhost Packages
129 Err http://localhost Packages
131 W: Failed to fetch http://localhost:8080/Packages.$COMPRESS Undetermined Error
133 E: Some index files failed to download, they have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
136 for COMPRESSOR
in 'gzip' 'bzip2' 'lzma'; do testoverfile
$COMPRESSOR; done
138 # do the same again with http instead of file
141 for COMPRESSOR
in 'gzip' 'bzip2' 'lzma'; do testoverhttp
$COMPRESSOR; done