summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-09-29 08:33:33 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-09-29 08:33:33 +0200
commit48f3f1b24b48066cfc23342a5c6470ddf5e0fa6a (patch)
tree60fdc3dc5d238257bc85ea560cc63a697118ace3
parentffbe056dc554b3f1fdf79b4726415a70f6d59dc1 (diff)
parente359fe101e1a66277b340563c96e868451d9d4b5 (diff)
Merge branch 'debian/sid' into debian/experimental
Conflicts: apt-pkg/acquire-item.cc
-rw-r--r--apt-pkg/acquire-item.cc41
-rw-r--r--apt-pkg/deb/debindexfile.cc60
-rw-r--r--apt-private/private-update.cc9
-rw-r--r--cmdline/apt-get.cc2
-rw-r--r--doc/Doxyfile.in4
-rw-r--r--methods/copy.cc11
-rw-r--r--test/integration/framework30
-rwxr-xr-xtest/integration/test-bug-595691-empty-and-broken-archive-files35
-rwxr-xr-xtest/integration/test-compressed-indexes196
9 files changed, 216 insertions, 172 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index d1c1f8c5a..f46c8a6e4 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1022,6 +1022,7 @@ void pkgAcqIndex::Init(string const &URI, string const &URIDesc, string const &S
else
{
Desc.URI = URI + '.' + comprExt;
+ DestFile = DestFile + '.' + comprExt;
if(Target)
MetaKey = string(Target->MetaKey) + '.' + comprExt;
}
@@ -1080,10 +1081,11 @@ void pkgAcqIndex::InitByHashIfNeeded(const std::string MetaKey)
/* The only header we use is the last-modified header. */
string pkgAcqIndex::Custom600Headers() const
{
+ std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
string Final = _config->FindDir("Dir::State::lists");
Final += URItoFileName(RealURI);
if (_config->FindB("Acquire::GzipIndexes",false))
- Final += ".gz";
+ Final += compExt;
string msg = "\nIndex-File: true";
@@ -1120,8 +1122,8 @@ std::string pkgAcqIndex::GetFinalFilename(std::string const &URI,
{
std::string FinalFile = _config->FindDir("Dir::State::lists");
FinalFile += URItoFileName(URI);
- if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
- FinalFile += ".gz";
+ if (_config->FindB("Acquire::GzipIndexes",false) == true)
+ FinalFile += '.' + compExt;
return FinalFile;
}
/*}}}*/
@@ -1129,8 +1131,8 @@ std::string pkgAcqIndex::GetFinalFilename(std::string const &URI,
void pkgAcqIndex::ReverifyAfterIMS(std::string const &FileName)
{
std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
- if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
- DestFile += ".gz";
+ if (_config->FindB("Acquire::GzipIndexes",false) == true)
+ DestFile += compExt;
string FinalFile = GetFinalFilename(RealURI, compExt);
Rename(FinalFile, FileName);
@@ -1168,7 +1170,7 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
/* Always verify the index file for correctness (all indexes must
* have a Package field) (LP: #346386) (Closes: #627642)
*/
- FileFd fd(DestFile, FileFd::ReadOnlyGzip);
+ FileFd fd(DestFile, FileFd::ReadOnly, FileFd::Extension);
// Only test for correctness if the file is not empty (empty is ok)
if (fd.Size() > 0)
{
@@ -1192,8 +1194,8 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
will work OK */
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(RealURI);
- if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz")
- DestFile += ".gz";
+ if (_config->FindB("Acquire::GzipIndexes",false))
+ DestFile += '.' + compExt;
// Remove the compressed version.
if (Erase == true)
@@ -1249,16 +1251,23 @@ void pkgAcqIndex::Done(string Message,unsigned long long Size,HashStringList con
// matching the Release file
if (!Local && StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
{
+ // set destfile to the final destfile
+ if(_config->FindB("Acquire::GzipIndexes",false) == false)
+ {
+ DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+ DestFile += URItoFileName(RealURI);
+ }
+
ReverifyAfterIMS(FileName);
return;
}
string decompProg;
// If we enable compressed indexes, queue for hash verification
- if (_config->FindB("Acquire::GzipIndexes",false) && compExt == "gz" && !Local)
+ if (_config->FindB("Acquire::GzipIndexes",false))
{
DestFile = _config->FindDir("Dir::State::lists");
- DestFile += URItoFileName(RealURI) + ".gz";
+ DestFile += URItoFileName(RealURI) + '.' + compExt;
Decompression = true;
Desc.URI = "copy:" + FileName;
@@ -1315,11 +1324,11 @@ pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner, IndexTarget const * const
// ---------------------------------------------------------------------
string pkgAcqIndexTrans::Custom600Headers() const
{
+ std::string const compExt = CompressionExtension.substr(0, CompressionExtension.find(' '));
string Final = _config->FindDir("Dir::State::lists");
Final += URItoFileName(RealURI);
-
if (_config->FindB("Acquire::GzipIndexes",false))
- Final += ".gz";
+ Final += compExt;
struct stat Buf;
if (stat(Final.c_str(),&Buf) != 0)
@@ -1697,8 +1706,12 @@ void pkgAcqMetaIndex::AuthDone(string Message) /*{{{*/
URItoFileName((*Target)->URI);
unlink(index.c_str());
// and also old gzipindexes
- index += ".gz";
- unlink(index.c_str());
+ std::vector<std::string> types = APT::Configuration::getCompressionTypes();
+ for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
+ {
+ index += '.' + (*t);
+ unlink(index.c_str());
+ }
}
}
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index c35a89ade..f90731dd2 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -81,14 +81,18 @@ pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
{
string SourcesURI = _config->FindDir("Dir::State::lists") +
URItoFileName(IndexURI("Sources"));
- string SourcesURIgzip = SourcesURI + ".gz";
- if (!FileExists(SourcesURI) && !FileExists(SourcesURIgzip))
- return NULL;
- else if (!FileExists(SourcesURI) && FileExists(SourcesURIgzip))
- SourcesURI = SourcesURIgzip;
-
- return new debSrcRecordParser(SourcesURI,this);
+ std::vector<std::string> types = APT::Configuration::getCompressionTypes();
+ for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
+ {
+ string p;
+ p = SourcesURI + '.' + *t;
+ if (FileExists(p))
+ return new debSrcRecordParser(p, this);
+ }
+ if (FileExists(SourcesURI))
+ return new debSrcRecordParser(SourcesURI, this);
+ return NULL;
}
/*}}}*/
// SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
@@ -130,11 +134,15 @@ string debSourcesIndex::Info(const char *Type) const
inline string debSourcesIndex::IndexFile(const char *Type) const
{
string s = URItoFileName(IndexURI(Type));
- string sgzip = s + ".gz";
- if (!FileExists(s) && FileExists(sgzip))
- return sgzip;
- else
- return s;
+
+ std::vector<std::string> types = APT::Configuration::getCompressionTypes();
+ for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
+ {
+ string p = s + '.' + *t;
+ if (FileExists(p))
+ return p;
+ }
+ return s;
}
string debSourcesIndex::IndexURI(const char *Type) const
@@ -260,11 +268,15 @@ string debPackagesIndex::Info(const char *Type) const
inline string debPackagesIndex::IndexFile(const char *Type) const
{
string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
- string sgzip = s + ".gz";
- if (!FileExists(s) && FileExists(sgzip))
- return sgzip;
- else
- return s;
+
+ std::vector<std::string> types = APT::Configuration::getCompressionTypes();
+ for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
+ {
+ string p = s + '.' + *t;
+ if (FileExists(p))
+ return p;
+ }
+ return s;
}
string debPackagesIndex::IndexURI(const char *Type) const
{
@@ -412,11 +424,15 @@ debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section
inline string debTranslationsIndex::IndexFile(const char *Type) const
{
string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
- string sgzip = s + ".gz";
- if (!FileExists(s) && FileExists(sgzip))
- return sgzip;
- else
- return s;
+
+ std::vector<std::string> types = APT::Configuration::getCompressionTypes();
+ for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
+ {
+ string p = s + '.' + *t;
+ if (FileExists(p))
+ return p;
+ }
+ return s;
}
string debTranslationsIndex::IndexURI(const char *Type) const
{
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index 860d84b86..1cf3012ed 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -56,10 +56,17 @@ bool DoUpdate(CommandLine &CmdL)
if (List->GetIndexes(&Fetcher,true) == false)
return false;
+ std::string compExt = APT::Configuration::getCompressionTypes()[0];
pkgAcquire::UriIterator I = Fetcher.UriBegin();
for (; I != Fetcher.UriEnd(); ++I)
- c1out << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
+ {
+ std::string FileName = flNotDir(I->Owner->DestFile);
+ if(compExt.empty() == false &&
+ APT::String::Endswith(FileName, compExt))
+ FileName = FileName.substr(0, FileName.size() - compExt.size() - 1);
+ c1out << '\'' << I->URI << "' " << FileName << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << std::endl;
+ }
return true;
}
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index c8c3ca56b..0cea05cb3 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -673,7 +673,7 @@ static bool DoDownload(CommandLine &CmdL)
{
pkgAcquire::UriIterator I = Fetcher.UriBegin();
for (; I != Fetcher.UriEnd(); ++I)
- cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
+ cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
return true;
}
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index 98eecdbd2..ab3fc0a7c 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -152,7 +152,7 @@ FULL_PATH_NAMES = YES
# will be relative from the directory where doxygen is started.
# This tag requires that the tag FULL_PATH_NAMES is set to YES.
-STRIP_FROM_PATH =
+STRIP_FROM_PATH = @top_srcdir@
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
# path mentioned in the documentation of a class, which tells the reader which
@@ -161,7 +161,7 @@ STRIP_FROM_PATH =
# specify the list of include paths that are normally passed to the compiler
# using the -I flag.
-STRIP_FROM_INC_PATH =
+STRIP_FROM_INC_PATH = @top_srcdir@
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
# less readable) file names. This can be useful is your file systems doesn't
diff --git a/methods/copy.cc b/methods/copy.cc
index b65bc4dd5..f542a27c0 100644
--- a/methods/copy.cc
+++ b/methods/copy.cc
@@ -37,15 +37,12 @@ class CopyMethod : public pkgAcqMethod
void CopyMethod::CalculateHashes(FetchResult &Res)
{
- // For gzip indexes we need to look inside the gzip for the hash
- // We can not use the extension here as its not used in partial
- // on a IMS hit
- FileFd::OpenMode OpenMode = FileFd::ReadOnly;
+ Hashes Hash;
+ FileFd::CompressMode CompressMode = FileFd::None;
if (_config->FindB("Acquire::GzipIndexes", false) == true)
- OpenMode = FileFd::ReadOnlyGzip;
+ CompressMode = FileFd::Extension;
- Hashes Hash;
- FileFd Fd(Res.Filename, OpenMode);
+ FileFd Fd(Res.Filename, FileFd::ReadOnly, CompressMode);
Hash.AddFD(Fd);
Res.TakeHashes(Hash);
}
diff --git a/test/integration/framework b/test/integration/framework
index fcdca34ce..e83606fae 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -320,6 +320,36 @@ configcompression() {
done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
}
+forcecompressor() {
+ COMPRESSOR="$1"
+ COMPRESSOR_CMD="$1"
+ case $COMPRESSOR in
+ gzip) COMPRESS='gz';;
+ bzip2) COMPRESS='bz2';;
+ lzma) COMPRESS='lzma';;
+ xz) COMPRESS='xz';;
+ *) msgdie "Compressor $COMPRESSOR is unknown to framework, so can't be forced by forcecompressor!";;
+ esac
+ local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
+ echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
+Dir::Bin::uncompressed \"/does/not/exist\";
+Dir::Bin::gzip \"/does/not/exist\";
+Dir::Bin::bzip2 \"/does/not/exist\";
+Dir::Bin::lzma \"/does/not/exist\";
+Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
+ if [ -e "/bin/${COMPRESSOR}" ]; then
+ echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+ elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
+ echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
+ elif [ "${COMPRESSOR}" = 'lzma' ]; then
+ echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE"
+ COMPRESSOR_CMD='xz --format=lzma'
+ else
+ msgtest 'Test for availability of compressor' "${COMPRESSOR}"
+ msgfail
+ fi
+}
+
setupsimplenativepackage() {
local NAME="$1"
local ARCH="$2"
diff --git a/test/integration/test-bug-595691-empty-and-broken-archive-files b/test/integration/test-bug-595691-empty-and-broken-archive-files
index 8da0a52d2..683c174bd 100755
--- a/test/integration/test-bug-595691-empty-and-broken-archive-files
+++ b/test/integration/test-bug-595691-empty-and-broken-archive-files
@@ -48,37 +48,8 @@ createemptyfile() {
rm -f aptarchive/Packages
}
-setupcompressor() {
- COMPRESSOR="$1"
- COMPRESSOR_CMD="$1"
- case $COMPRESSOR in
- gzip) COMPRESS="gz";;
- bzip2) COMPRESS="bz2";;
- lzma) COMPRESS="lzma";;
- xz) COMPRESS="xz";;
- esac
- echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
-Dir::Bin::uncompressed \"/does/not/exist\";
-Dir::Bin::gzip \"/does/not/exist\";
-Dir::Bin::bzip2 \"/does/not/exist\";
-Dir::Bin::lzma \"/does/not/exist\";
-Dir::Bin::xz \"/does/not/exist\";" > rootdir/etc/apt/apt.conf.d/00compressor
- if [ -e "/bin/${COMPRESSOR}" ]; then
- echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor
- elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
- echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor
- elif [ "${COMPRESSOR}" = 'lzma' ]; then
- echo "Dir::Bin::xz \"/usr/bin/xz\";" >> rootdir/etc/apt/apt.conf.d/00compressor
- COMPRESSOR_CMD='xz --format=lzma'
- else
- msgtest "Test for availability of compressor" "${COMPRESSOR}"
- msgfail
- #exit 1
- fi
-}
-
testoverfile() {
- setupcompressor "$1"
+ forcecompressor "$1"
createemptyfile 'en'
testaptgetupdate 'Reading package lists...' "empty file en.$COMPRESS over file"
@@ -100,7 +71,7 @@ E: Some index files failed to download. They have been ignored, or old ones used
}
testoverhttp() {
- setupcompressor "$1"
+ forcecompressor "$1"
createemptyfile 'en'
testaptgetupdate "Get: http://localhost:8080 Packages []
@@ -121,7 +92,7 @@ Reading package lists..." "empty archive Packages.$COMPRESS over http"
testaptgetupdate "Get: http://localhost:8080 Packages
Err http://localhost:8080 Packages
Empty files can't be valid archives
-W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages) Empty files can't be valid archives
+W: Failed to fetch ${COMPRESSOR}:$(readlink -f rootdir/var/lib/apt/lists/partial/localhost:8080_Packages.${COMPRESS}) Empty files can't be valid archives
E: Some index files failed to download. They have been ignored, or old ones used instead." "empty file Packages.$COMPRESS over http"
}
diff --git a/test/integration/test-compressed-indexes b/test/integration/test-compressed-indexes
index 6671dd75a..805ed5964 100755
--- a/test/integration/test-compressed-indexes
+++ b/test/integration/test-compressed-indexes
@@ -5,53 +5,68 @@ TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
-configcompression '.' 'gz' # only gz is supported for this, so ensure it is used
-configarchitecture "i386"
-
-buildsimplenativepackage "testpkg" "i386" "1.0"
-setupaptarchive
-
-GOODSHOW="$(aptcache show testpkg)
-"
-GOODPOLICY="$(aptcache policy testpkg)"
-GOODSHOWSRC="$(aptcache showsrc testpkg)
-"
-
-test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
-testequal "$GOODSHOW" aptcache show testpkg
-test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'policy is broken'
-testequal "$GOODPOLICY" aptcache policy testpkg
-test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
-testequal "$GOODSHOWSRC" aptcache showsrc testpkg
-
+configcompression '.' 'xz' 'bz2' 'lzma' 'gz'
+configarchitecture 'i386'
+
+buildsimplenativepackage 'testpkg' 'i386' '1.0'
+
+buildaptarchive
+setupdistsaptarchive
+# fake a pdiff setup as apt wouldn't try pdiffs otherwise
+find aptarchive -name 'Packages' -o -name 'Sources' | while read file; do
+ mkdir "${file}.diff"
+ PATCHINDEX="${file}.diff/Index"
+ echo 'SHA1-Current: adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 0
+SHA1-History:
+ adc83b19e793491b1c6ea0fd8b46cd9f32e592fc 33053002 2010-08-18-2013.28
+ ecfd1b19e793491b1c6ea123eabdcd9f32e592fc 33053001 2010-08-18-2013.29
+SHA1-Patches:
+ abc1fc0ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.28
+ dfe3444ac57cd83d41c63195a9342e2db5650257 19722 2010-08-18-0814.29' > $PATCHINDEX
+done
+generatereleasefiles
+signreleasefiles
testrun() {
local F
- if [ -e rootdir/var/lib/apt/lists/*localhost*Release ]; then
- msgtest "Check if all index files are" "${1:-uncompressed}"
- if [ "$1" = "compressed" ]; then
- ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
- ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
- test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
- test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
- else
- test -e rootdir/var/lib/apt/lists/*_Packages || F=1
- test -e rootdir/var/lib/apt/lists/*_Sources || F=1
- ! test -e rootdir/var/lib/apt/lists/*_Packages.gz || F=1
- ! test -e rootdir/var/lib/apt/lists/*_Sources.gz || F=1
- fi
- if [ -n "$F" ]; then
- ls -laR rootdir/var/lib/apt/lists/
- msgfail
- else
- msgpass
- fi
- msgtest "Check if package is downloadable"
- testsuccess --nomsg aptget install -d testpkg
- msgtest "\tdeb file is present"; testsuccess --nomsg test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb
- aptget clean
- msgtest "\tdeb file is gone"; testfailure --nomsg test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb
+ msgtest 'Check if all index files are' "${1:-uncompressed}"
+ if [ "$1" = 'compressed' ]; then
+ ! test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+ ! test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+ ! test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
+ test -e rootdir/var/lib/apt/lists/*_Packages.${COMPRESS} || F=1
+ test -e rootdir/var/lib/apt/lists/*_Sources.${COMPRESS} || F=1
+ test -e rootdir/var/lib/apt/lists/*_Translation-en.${COMPRESS} || F=1
+ # there is no point in trying pdiff if we have compressed indexes
+ # as we can't patch compressed files (well, we can, but what is the point?)
+ ! test -e rootdir/var/lib/apt/lists/*.IndexDiff || F=1
+ else
+ # clear the faked pdiff indexes so the glob below works
+ rm -f rootdir/var/lib/apt/lists/*.IndexDiff
+ test -e rootdir/var/lib/apt/lists/*_Packages || F=1
+ test -e rootdir/var/lib/apt/lists/*_Sources || F=1
+ test -e rootdir/var/lib/apt/lists/*_Translation-en || F=1
+ ! test -e rootdir/var/lib/apt/lists/*_Packages.* || F=1
+ ! test -e rootdir/var/lib/apt/lists/*_Sources.* || F=1
+ ! test -e rootdir/var/lib/apt/lists/*_Translation-en.* || F=1
fi
+ if [ -n "$F" ]; then
+ ls -laR rootdir/var/lib/apt/lists/
+ msgfail
+ else
+ msgpass
+ fi
+ msgtest 'Check if package is downloadable'
+ testsuccess --nomsg aptget download testpkg
+ msgtest '\tdeb file is present'; testsuccess --nomsg test -f testpkg_1.0_i386.deb
+ rm testpkg_1.0_i386.deb
+ testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ testpkg
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst testpkg (1.0 unstable [i386])
+Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s
rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin
testequal "$GOODSHOW" aptcache show testpkg
testequal "$GOODSHOW" aptcache show testpkg
@@ -62,73 +77,68 @@ testrun() {
testequal "$GOODSHOWSRC" aptcache showsrc testpkg
testequal "$GOODSHOWSRC" aptcache showsrc testpkg
aptget clean
- msgtest "Check if the source is aptgetable"
+ msgtest 'Check if the source is aptgetable'
testsuccess --nomsg aptget source testpkg
- msgtest "\tdsc file is present"; testsuccess --nomsg test -f testpkg_1.0.dsc
- msgtest "\tdirectory is present"; testsuccess --nomsg test -d testpkg-1.0
- rm -rf testpkg-1.0
+ msgtest '\tdsc file is present'; testsuccess --nomsg test -f testpkg_1.0.dsc
+ msgtest '\tdirectory is present'; testsuccess --nomsg test -d testpkg-1.0
+ rm -rf testpkg-1.0*
testequal "$(aptcache show testpkg -o Acquire::Languages=none)
" aptcache dumpavail
}
-echo 'Acquire::GzipIndexes "false";' > rootdir/etc/apt/apt.conf.d/02compressindex
-msgmsg "File: Test with uncompressed indexes"
-testrun
+echo 'Debug::pkgAcquire::worker "true";
+debug::pkgAcquire::Auth "true";
+Debug::pkgAcquire::Diffs "true";' > rootdir/etc/apt/apt.conf.d/99debugconf
-testsuccess aptget update -o Acquire::Pdiffs=1
-msgmsg "File: Test with uncompressed indexes (update unchanged with pdiffs)"
-testrun
+testovermethod() {
+ forcecompressor $2
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "File: Test with uncompressed indexes (update unchanged without pdiffs)"
-testrun
+ for INDEX in 'false' 'true'; do
+ rm -rf rootdir/var/lib/apt/lists
+ echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex
+ local INDCOMP
+ if [ "$INDEX" = 'false' ]; then
+ INDCOMP='uncompressed'
+ else
+ INDCOMP='compressed'
+ fi
-rm -rf rootdir/var/lib/apt/lists
-echo 'Acquire::CompressionTypes::Order:: "gz";
-Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
+ testsuccess aptget update
+ msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes"
+ testrun "$INDCOMP"
-testsuccess aptget update
-msgmsg "File: Test with compressed indexes"
-testrun "compressed"
+ testsuccess aptget update -o Acquire::Pdiffs=1
+ msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged with pdiffs)"
+ testrun "$INDCOMP"
-testsuccess aptget update -o Acquire::Pdiffs=1
-msgmsg "File: Test with compressed indexes (update unchanged with pdiffs)"
-testrun "compressed"
+ testsuccess aptget update -o Acquire::Pdiffs=0
+ msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged without pdiffs)"
+ testrun "$INDCOMP"
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "File: Test with compressed indexes (update unchanged without pdiffs)"
-testrun "compressed"
+ rm rootdir/etc/apt/apt.conf.d/02compressindex
+ done
+}
-rm rootdir/etc/apt/apt.conf.d/02compressindex
-changetowebserver
testsuccess aptget update
+GOODSHOW="$(aptcache show testpkg)
+"
+test $(echo "$GOODSHOW" | grep -e '^Package: testpkg' -e '^Version: 1.0' -e '^Architecture: i386' | wc -l) -eq 3 || msgdie 'show is broken'
+testequal "$GOODSHOW" aptcache show testpkg
+GOODSHOWSRC="$(aptcache showsrc testpkg)
+"
+test $(echo "$GOODSHOWSRC" | grep -e '^Package: testpkg' -e '^Format: 3.0 (native)' -e '^Files:' -e '^Checksums-Sha256:' | wc -l) -eq 4 || msgdie 'showsrc is broken'
+testequal "$GOODSHOWSRC" aptcache showsrc testpkg
GOODPOLICY="$(aptcache policy testpkg)"
-test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4
+test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 file:/' | wc -l) -eq 4 || msgdie 'policy is broken'
testequal "$GOODPOLICY" aptcache policy testpkg
-msgmsg "HTTP: Test with uncompressed indexes"
-testrun
-
-testsuccess aptget update -o Acquire::Pdiffs=1
-msgmsg "HTTP: Test with uncompressed indexes (update unchanged with pdiffs)"
-testrun
-
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "HTTP: Test with uncompressed indexes (update unchanged without pdiffs)"
-testrun
+for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'file' $COMPRESSOR; done
+changetowebserver
rm -rf rootdir/var/lib/apt/lists
-echo 'Acquire::CompressionTypes::Order:: "gz";
-Acquire::GzipIndexes "true";' > rootdir/etc/apt/apt.conf.d/02compressindex
-
testsuccess aptget update
-msgmsg "HTTP: Test with compressed indexes"
-testrun "compressed"
-
-testsuccess aptget update -o Acquire::Pdiffs=1
-msgmsg "HTTP: Test with compressed indexes (update unchanged with pdiffs)"
-testrun "compressed"
+GOODPOLICY="$(aptcache policy testpkg)"
+test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4 || msgdie 'policy is broken'
+testequal "$GOODPOLICY" aptcache policy testpkg
-testsuccess aptget update -o Acquire::Pdiffs=0
-msgmsg "HTTP: Test with compressed indexes (update unchanged without pdiffs)"
-testrun "compressed"
+for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'http' $COMPRESSOR; done