diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-10-15 19:11:45 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-10-15 19:11:45 +0200 |
commit | 70b63c573fc532f7e1a9de82eb81385a8cca0cec (patch) | |
tree | 5d446431891c69e25bba22f1c5fbcfce0e921615 | |
parent | 0977f81757f42889a9edb761061529041afe0a06 (diff) | |
download | apt-70b63c573fc532f7e1a9de82eb81385a8cca0cec.tar.gz |
ignore Acquire::GzipIndexes for cdrom sources
We do not support compressed indexes for cdrom sources as we rewrite
some of them, so supporting it correctly could be hard. What we do
instead in the meantime is probably disabling it for cdrom sources.
-rw-r--r-- | apt-pkg/acquire-item.cc | 47 | ||||
-rwxr-xr-x | test/integration/test-compressed-indexes | 35 |
2 files changed, 52 insertions, 30 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 5187738e9..c58d43a3f 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -65,7 +65,7 @@ static void printHashSumComparision(std::string const &URI, HashStringList const std::cerr << "\t- " << hs->toStr() << std::endl; } /*}}}*/ -static void ChangeOwnerAndPermissionOfFile(char const * const requester, char const * const file, char const * const user, char const * const group, mode_t const mode) +static void ChangeOwnerAndPermissionOfFile(char const * const requester, char const * const file, char const * const user, char const * const group, mode_t const mode) /*{{{*/ { // ensure the file is owned by root and has good permissions struct passwd const * const pw = getpwnam(user); @@ -78,17 +78,35 @@ static void ChangeOwnerAndPermissionOfFile(char const * const requester, char co if (chmod(file, mode) != 0) _error->WarningE(requester, "chmod 0%o of file %s failed", mode, file); } -static std::string GetPartialFileName(std::string const &file) + /*}}}*/ +static std::string GetPartialFileName(std::string const &file) /*{{{*/ { std::string DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += file; return DestFile; } -static std::string GetPartialFileNameFromURI(std::string const &uri) + /*}}}*/ +static std::string GetPartialFileNameFromURI(std::string const &uri) /*{{{*/ { return GetPartialFileName(URItoFileName(uri)); } + /*}}}*/ +static std::string GetCompressedFileName(std::string const &URI, std::string const &Name, std::string const &Ext) /*{{{*/ +{ + if (Ext.empty() || Ext == "uncompressed") + return Name; + + // do not reverify cdrom sources as apt-cdrom may rewrite the Packages + // file when its doing the indexcopy + if (URI.substr(0,6) == "cdrom:") + return Name; + // adjust DestFile if its compressed on disk + if (_config->FindB("Acquire::GzipIndexes",false) == true) + return Name + '.' + Ext; + return Name; +} + /*}}}*/ // Acquire::Item::Item - Constructor /*{{{*/ #if __GNUC__ >= 4 @@ -211,8 +229,7 @@ bool pkgAcquire::Item::Rename(string From,string To) return true; } /*}}}*/ - -void pkgAcquire::Item::QueueURI(ItemDesc &Item) +void pkgAcquire::Item::QueueURI(ItemDesc &Item) /*{{{*/ { if (RealFileExists(DestFile)) { @@ -222,11 +239,12 @@ void pkgAcquire::Item::QueueURI(ItemDesc &Item) } Owner->Enqueue(Item); } -void pkgAcquire::Item::Dequeue() + /*}}}*/ +void pkgAcquire::Item::Dequeue() /*{{{*/ { Owner->Dequeue(this); } - + /*}}}*/ bool pkgAcquire::Item::RenameOnError(pkgAcquire::Item::RenameOnErrorState const error)/*{{{*/ { if(FileExists(DestFile)) @@ -1276,9 +1294,7 @@ std::string pkgAcqIndex::GetFinalFilename() const { std::string FinalFile = _config->FindDir("Dir::State::lists"); FinalFile += URItoFileName(RealURI); - if (_config->FindB("Acquire::GzipIndexes",false) == true) - FinalFile += '.' + CurrentCompressionExtension; - return FinalFile; + return GetCompressedFileName(RealURI, FinalFile, CurrentCompressionExtension); } /*}}}*/ // AcqIndex::ReverifyAfterIMS - Reverify index after an ims-hit /*{{{*/ @@ -1286,16 +1302,7 @@ void pkgAcqIndex::ReverifyAfterIMS() { // update destfile to *not* include the compression extension when doing // a reverify (as its uncompressed on disk already) - DestFile = GetPartialFileNameFromURI(RealURI); - - // do not reverify cdrom sources as apt-cdrom may rewrite the Packages - // file when its doing the indexcopy - if (RealURI.substr(0,6) == "cdrom:") - return; - - // adjust DestFile if its compressed on disk - if (_config->FindB("Acquire::GzipIndexes",false) == true) - DestFile += '.' + CurrentCompressionExtension; + DestFile = GetCompressedFileName(RealURI, GetPartialFileNameFromURI(RealURI), CurrentCompressionExtension); // copy FinalFile into partial/ so that we check the hash again string FinalFile = GetFinalFilename(); diff --git a/test/integration/test-compressed-indexes b/test/integration/test-compressed-indexes index f67077973..72b262e84 100755 --- a/test/integration/test-compressed-indexes +++ b/test/integration/test-compressed-indexes @@ -89,7 +89,8 @@ Conf testpkg (1.0 unstable [i386])' aptget install testpkg -s echo 'Debug::pkgAcquire::worker "true"; debug::pkgAcquire::Auth "true"; -Debug::pkgAcquire::Diffs "true";' > rootdir/etc/apt/apt.conf.d/99debugconf +Debug::pkgAcquire::Diffs "true"; +Debug::Acquire::http "true";' > rootdir/etc/apt/apt.conf.d/99debugconf testovermethod() { forcecompressor $2 @@ -98,23 +99,28 @@ testovermethod() { rm -rf rootdir/var/lib/apt/lists echo "Acquire::GzipIndexes \"${INDEX}\";" > rootdir/etc/apt/apt.conf.d/02compressindex local INDCOMP - if [ "$INDEX" = 'false' ]; then + if [ "$INDEX" = 'false' -o "$1" = 'cdrom' ]; then INDCOMP='uncompressed' else INDCOMP='compressed' fi - testsuccess aptget update -o Debug::Acquire::http=1 - msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes" + msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX" + if [ "${1}" = 'cdrom' ]; then + testsuccess aptcdrom add </dev/null + fi + testsuccess aptget update testrun "$INDCOMP" - testsuccess aptget update -o Acquire::Pdiffs=1 -o Debug::Acquire::http=1 - msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged with pdiffs)" - testrun "$INDCOMP" + if [ "${1}" != 'cdrom' ]; then + testsuccess aptget update -o Acquire::Pdiffs=1 + msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged with pdiffs)" + testrun "$INDCOMP" - testsuccess aptget update -o Acquire::Pdiffs=0 -o Debug::Acquire::http=1 - msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes (update unchanged without pdiffs)" - testrun "$INDCOMP" + testsuccess aptget update -o Acquire::Pdiffs=0 + msgmsg "${1}: ${COMPRESSOR}: Test with $INDCOMP indexes gzip=$INDEX (update unchanged without pdiffs)" + testrun "$INDCOMP" + fi rm rootdir/etc/apt/apt.conf.d/02compressindex done @@ -143,3 +149,12 @@ test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Instal testequal "$GOODPOLICY" aptcache policy testpkg for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'http' $COMPRESSOR; done + +changetocdrom 'Debian APT Testdisk 0.8.15' +rm -rf rootdir/var/lib/apt/lists +testsuccess aptcdrom add </dev/null +GOODPOLICY="$(aptcache policy testpkg)" +test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 cdrom://' | wc -l) -eq 4 || msgdie 'policy is broken' +testequal "$GOODPOLICY" aptcache policy testpkg + +for COMPRESSOR in 'gzip' 'bzip2' 'lzma' 'xz'; do testovermethod 'cdrom' $COMPRESSOR; done |