From 657ecd4a08d5e979a7f66109d371904ec64a2d3d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 18 Aug 2011 11:45:51 +0200 Subject: * cmdline/apt-get.cc: - remove the binary caches in 'apt-get clean' as it is the first thing recommend by many supporters in case of APT segfaults --- cmdline/apt-get.cc | 20 +++++++++++++++----- debian/changelog | 5 ++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1849f1335..2dd1c2bce 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2203,10 +2203,14 @@ bool DoDSelectUpgrade(CommandLine &CmdL) /* */ bool DoClean(CommandLine &CmdL) { + std::string const archivedir = _config->FindDir("Dir::Cache::archives"); + std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); + std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache"); + if (_config->FindB("APT::Get::Simulate") == true) { - cout << "Del " << _config->FindDir("Dir::Cache::archives") << "* " << - _config->FindDir("Dir::Cache::archives") << "partial/*" << endl; + cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< endl + << "Del " << pkgcache << " " << srcpkgcache << endl; return true; } @@ -2214,14 +2218,20 @@ bool DoClean(CommandLine &CmdL) FileFd Lock; if (_config->FindB("Debug::NoLocking",false) == false) { - Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock")); + Lock.Fd(GetLock(archivedir + "lock")); if (_error->PendingError() == true) return _error->Error(_("Unable to lock the download directory")); } pkgAcquire Fetcher; - Fetcher.Clean(_config->FindDir("Dir::Cache::archives")); - Fetcher.Clean(_config->FindDir("Dir::Cache::archives") + "partial/"); + Fetcher.Clean(archivedir); + Fetcher.Clean(archivedir + "partial/"); + + if (pkgcache.empty() == false && RealFileExists(pkgcache) == true) + unlink(pkgcache.c_str()); + if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) + unlink(srcpkgcache.c_str()); + return true; } /*}}}*/ diff --git a/debian/changelog b/debian/changelog index 56d4c7e0e..137e3a740 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,8 +11,11 @@ apt (0.8.15.7) UNRELEASED; urgency=low - run the test/libapt testcases at package build-time * debian/apt.symbols: - add the newly added symbols since 0.8.15.3 + * cmdline/apt-get.cc: + - remove the binary caches in 'apt-get clean' as it is the first + thing recommend by many supporters in case of APT segfaults - -- David Kalnischkies Wed, 17 Aug 2011 15:09:16 +0200 + -- David Kalnischkies Thu, 18 Aug 2011 11:41:31 +0200 apt (0.8.15.6) unstable; urgency=low -- cgit v1.2.3 From 1207cf3f9bd77664d6b7de9b8a7fdd33c0bed23a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 22 Aug 2011 22:52:25 +0200 Subject: * apt-pkg/acquire-item.cc: - if no Release.gpg file is found try to verify with hashes, but do not fail if a hash can't be found --- apt-pkg/acquire-item.cc | 47 ++++++++++++++++++++++------------------------- debian/changelog | 5 ++++- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 566f51606..39ce90dda 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1258,9 +1258,9 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash, /*{{{* if (SigFile == "") { // There was no signature file, so we are finished. Download - // the indexes and do only hashsum verification + // the indexes and do only hashsum verification if possible MetaIndexParser->Load(DestFile); - QueueIndexes(true); + QueueIndexes(false); } else { @@ -1378,33 +1378,30 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ ++Target) { HashString ExpectedIndexHash; - if (verify) + const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey); + if (Record == NULL) { - const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey); - if (Record == NULL) + if (verify == true && (*Target)->IsOptional() == false) { - if ((*Target)->IsOptional() == false) - { - Status = StatAuthError; - strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str()); - return; - } + Status = StatAuthError; + strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str()); + return; } - else + } + else + { + ExpectedIndexHash = Record->Hash; + if (_config->FindB("Debug::pkgAcquire::Auth", false)) { - ExpectedIndexHash = Record->Hash; - if (_config->FindB("Debug::pkgAcquire::Auth", false)) - { - std::cerr << "Queueing: " << (*Target)->URI << std::endl; - std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl; - std::cerr << "For: " << Record->MetaKeyFilename << std::endl; - } - if (ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false) - { - Status = StatAuthError; - strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str()); - return; - } + std::cerr << "Queueing: " << (*Target)->URI << std::endl; + std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl; + std::cerr << "For: " << Record->MetaKeyFilename << std::endl; + } + if (verify == true && ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false) + { + Status = StatAuthError; + strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str()); + return; } } diff --git a/debian/changelog b/debian/changelog index 137e3a740..eea258ccb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,8 +14,11 @@ apt (0.8.15.7) UNRELEASED; urgency=low * cmdline/apt-get.cc: - remove the binary caches in 'apt-get clean' as it is the first thing recommend by many supporters in case of APT segfaults + * apt-pkg/acquire-item.cc: + - if no Release.gpg file is found try to verify with hashes, + but do not fail if a hash can't be found - -- David Kalnischkies Thu, 18 Aug 2011 11:41:31 +0200 + -- David Kalnischkies Mon, 22 Aug 2011 22:50:44 +0200 apt (0.8.15.6) unstable; urgency=low -- cgit v1.2.3 From 95b5f6c19d361745c4e11b214f0f07ad10c9b5b3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 22 Aug 2011 23:08:16 +0200 Subject: * apt-pkg/acquire.cc: - non-existing directories are by definition clean --- apt-pkg/acquire.cc | 4 ++++ debian/changelog | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index a2da196be..ef120d8e9 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -445,6 +445,10 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I) if it is part of the download set. */ bool pkgAcquire::Clean(string Dir) { + // non-existing directories are by definition clean… + if (DirectoryExists(Dir) == false) + return true; + DIR *D = opendir(Dir.c_str()); if (D == 0) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); diff --git a/debian/changelog b/debian/changelog index eea258ccb..495249855 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,8 +17,10 @@ apt (0.8.15.7) UNRELEASED; urgency=low * apt-pkg/acquire-item.cc: - if no Release.gpg file is found try to verify with hashes, but do not fail if a hash can't be found + * apt-pkg/acquire.cc: + - non-existing directories are by definition clean - -- David Kalnischkies Mon, 22 Aug 2011 22:50:44 +0200 + -- David Kalnischkies Mon, 22 Aug 2011 23:07:29 +0200 apt (0.8.15.6) unstable; urgency=low -- cgit v1.2.3 From 8de79b68a834a6cc7abb8976e96ed19374fc02a2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 22 Aug 2011 23:10:15 +0200 Subject: remove the caches in 'apt-get update', too, as they will be invalid in most cases anyway --- apt-pkg/cachefile.cc | 14 ++++++++++++++ apt-pkg/cachefile.h | 1 + cmdline/apt-get.cc | 8 +++----- debian/changelog | 4 +++- .../test-bug-254770-segfault-if-cache-not-buildable | 1 - .../test-bug-590438-broken-provides-thanks-to-remove-order | 2 -- .../test-bug-595691-empty-and-broken-archive-files | 2 +- test/integration/test-bug-601016-description-translation | 2 +- .../test-bug-633350-do-not-kill-last-char-in-Release | 2 +- test/integration/test-compressed-indexes | 9 ++++----- test/integration/test-hashsum-verification | 2 -- test/integration/test-policy-pinning | 7 ------- test/integration/test-releasefile-verification | 3 +-- 13 files changed, 29 insertions(+), 28 deletions(-) diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 964c5bd8b..a76cfc08e 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -163,6 +163,20 @@ bool pkgCacheFile::Open(OpProgress *Progress, bool WithLock) return true; } /*}}}*/ +// CacheFile::RemoveCaches - remove all cache files from disk /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgCacheFile::RemoveCaches() +{ + std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); + std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache"); + + if (pkgcache.empty() == false && RealFileExists(pkgcache) == true) + unlink(pkgcache.c_str()); + if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) + unlink(srcpkgcache.c_str()); +} + /*}}}*/ // CacheFile::Close - close the cache files /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h index 09d3ec267..b4f41c6f4 100644 --- a/apt-pkg/cachefile.h +++ b/apt-pkg/cachefile.h @@ -57,6 +57,7 @@ class pkgCacheFile bool Open(OpProgress *Progress = NULL, bool WithLock = true); inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); }; __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; + static void RemoveCaches(); void Close(); inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; }; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 2dd1c2bce..69b9dcda9 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1625,7 +1625,8 @@ bool DoUpdate(CommandLine &CmdL) if (_config->FindB("APT::Get::Download",true) == true) ListUpdate(Stat, *List); - // Rebuild the cache. + // Rebuild the cache. + pkgCacheFile::RemoveCaches(); if (Cache.BuildCaches() == false) return false; @@ -2227,10 +2228,7 @@ bool DoClean(CommandLine &CmdL) Fetcher.Clean(archivedir); Fetcher.Clean(archivedir + "partial/"); - if (pkgcache.empty() == false && RealFileExists(pkgcache) == true) - unlink(pkgcache.c_str()); - if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) - unlink(srcpkgcache.c_str()); + pkgCacheFile::RemoveCaches(); return true; } diff --git a/debian/changelog b/debian/changelog index 495249855..e1c9ac350 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,13 +14,15 @@ apt (0.8.15.7) UNRELEASED; urgency=low * cmdline/apt-get.cc: - remove the binary caches in 'apt-get clean' as it is the first thing recommend by many supporters in case of APT segfaults + - remove the caches in 'apt-get update', too, as they will be + invalid in most cases anyway * apt-pkg/acquire-item.cc: - if no Release.gpg file is found try to verify with hashes, but do not fail if a hash can't be found * apt-pkg/acquire.cc: - non-existing directories are by definition clean - -- David Kalnischkies Mon, 22 Aug 2011 23:07:29 +0200 + -- David Kalnischkies Mon, 22 Aug 2011 23:08:47 +0200 apt (0.8.15.6) unstable; urgency=low diff --git a/test/integration/test-bug-254770-segfault-if-cache-not-buildable b/test/integration/test-bug-254770-segfault-if-cache-not-buildable index b9f45b131..8fa337ccc 100755 --- a/test/integration/test-bug-254770-segfault-if-cache-not-buildable +++ b/test/integration/test-bug-254770-segfault-if-cache-not-buildable @@ -12,7 +12,6 @@ trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM chmod a-x rootdir/var/lib/dpkg testsegfault() { - rm -f rootdir/var/cache/apt/*.bin msgtest "No segfault in" "$*" local TEST="$($* 2>&1 | grep -v 'E:')" if [ -z "$TEST" ]; then diff --git a/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order index 0f6493948..645e86d7d 100755 --- a/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order +++ b/test/integration/test-bug-590438-broken-provides-thanks-to-remove-order @@ -25,7 +25,6 @@ MD5sum: 8489687ce10e656babd467c9ee389349 Description-de: Verschiedene Dateien für das Basis-System von Debian" predependsgawk() { - rm rootdir/var/cache/apt/*.bin cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status echo "$pkgbasefile Pre-Depends: $1 @@ -57,7 +56,6 @@ predependsgawk "awk | aawk" predependsgawk "awk" predependsgawk2() { - rm rootdir/var/cache/apt/*.bin cp $TESTDIR/$(echo "$(basename $0)" | sed 's/test-/status-/') rootdir/var/lib/dpkg/status echo "$pkgbasefile Pre-Depends: $1 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 11dee0628..5c103da6f 100755 --- a/test/integration/test-bug-595691-empty-and-broken-archive-files +++ b/test/integration/test-bug-595691-empty-and-broken-archive-files @@ -11,7 +11,7 @@ touch aptarchive/Packages setupflataptarchive testaptgetupdate() { - rm -rf rootdir/var/lib/apt rootdir/var/cache/apt + rm -rf rootdir/var/lib/apt aptget update 2>> testaptgetupdate.diff >> testaptgetupdate.diff || true sed -i -e '/^Fetched / d' -e 's#\[[0-9]* [kMGTPY]*B\]#\[\]#' testaptgetupdate.diff GIVEN="$1" diff --git a/test/integration/test-bug-601016-description-translation b/test/integration/test-bug-601016-description-translation index 2a323a201..44ab91900 100755 --- a/test/integration/test-bug-601016-description-translation +++ b/test/integration/test-bug-601016-description-translation @@ -57,7 +57,7 @@ Description-${LOCALE}: Mächtige Oberfläche für dpkg testrun() { echo "Acquire::Languages { \"${LOCALE}\"; \"en\"; };" > rootdir/etc/apt/apt.conf.d/00languages export LC_ALL="" - rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt/ + rm -rf rootdir/var/lib/apt/lists setupaptarchive testequal "$LOCALESTANZA" aptcache show apt -o Test=File-${LOCALE} testequal "$NOLONGSTANZA" aptcache show apt -o Acquire::Languages="ww" -o Test=File-${LOCALE} diff --git a/test/integration/test-bug-633350-do-not-kill-last-char-in-Release b/test/integration/test-bug-633350-do-not-kill-last-char-in-Release index 3d3835507..2aae7cfcc 100755 --- a/test/integration/test-bug-633350-do-not-kill-last-char-in-Release +++ b/test/integration/test-bug-633350-do-not-kill-last-char-in-Release @@ -15,7 +15,7 @@ echo 'NotAutomatic: yes' >> aptarchive/dists/unstable/Release signreleasefiles find aptarchive/dists -name 'InRelease' -delete -rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt +rm -rf rootdir/var/lib/apt/lists OUTPUT="$(aptget update 2>&1)" msgtest 'Check that parsing happens without warnings' 'with missing newline' diff --git a/test/integration/test-compressed-indexes b/test/integration/test-compressed-indexes index 99943574e..26a45812e 100755 --- a/test/integration/test-compressed-indexes +++ b/test/integration/test-compressed-indexes @@ -51,17 +51,16 @@ testrun() { aptget clean msgtest "\tdeb file is gone"; ! test -f rootdir/var/cache/apt/archives/testpkg_1.0_i386.deb && msgpass || msgfail fi - rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin + rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin testequal "$GOODSHOW" aptcache show testpkg testequal "$GOODSHOW" aptcache show testpkg - rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin + rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin testequal "$GOODPOLICY" aptcache policy testpkg testequal "$GOODPOLICY" aptcache policy testpkg - rm rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin + rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin testequal "$GOODSHOWSRC" aptcache showsrc testpkg testequal "$GOODSHOWSRC" aptcache showsrc testpkg - rm -f rootdir/var/cache/apt/pkgcache.bin rootdir/var/cache/apt/srcpkgcache.bin - rm -rf rootdir/var/cache/apt/archives + aptget clean msgtest "Check if the source is aptgetable" aptget source testpkg -qq 2> /dev/null > /dev/null && msgpass || msgfail msgtest "\tdsc file is present"; test -f testpkg_1.0.dsc && msgpass || msgfail diff --git a/test/integration/test-hashsum-verification b/test/integration/test-hashsum-verification index 033096ee8..3ac9eccfb 100755 --- a/test/integration/test-hashsum-verification +++ b/test/integration/test-hashsum-verification @@ -19,8 +19,6 @@ prepare() { for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do touch -d 'now - 6 hours' $release done - rm -rf rootdir/var/cache/apt/archives - rm -f rootdir/var/cache/apt/*.bin cp $1 aptarchive/Packages find aptarchive -name 'Release' -delete cat aptarchive/Packages | gzip > aptarchive/Packages.gz diff --git a/test/integration/test-policy-pinning b/test/integration/test-policy-pinning index fa356ed54..6b1473564 100755 --- a/test/integration/test-policy-pinning +++ b/test/integration/test-policy-pinning @@ -30,21 +30,18 @@ testequalpolicy 100 500 testequalpolicy 990 500 -t now sed -i aptarchive/Release -e 1i"NotAutomatic: yes" -rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin aptget update -qq testequalpolicy 100 1 -o Test=NotAutomatic testequalpolicy 990 1 -o Test=NotAutomatic -t now sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes" -rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin aptget update -qq testequalpolicy 100 100 -o Test=ButAutomaticUpgrades testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d' -rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin aptget update -qq testequalpolicy 100 500 -o Test=Automatic @@ -135,7 +132,6 @@ Pin-Priority: -1" > rootdir/etc/apt/preferences rm rootdir/etc/apt/preferences sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes" signreleasefiles -rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin aptget update -qq testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic @@ -164,7 +160,6 @@ testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t s rm rootdir/etc/apt/preferences sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes" signreleasefiles -rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin aptget update -qq testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades @@ -211,7 +206,6 @@ setupaptarchive sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes" signreleasefiles -rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin aptget update -qq testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic @@ -220,7 +214,6 @@ testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=N sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes" signreleasefiles -rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin aptget update -qq testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades diff --git a/test/integration/test-releasefile-verification b/test/integration/test-releasefile-verification index 961c49895..8bf02a78f 100755 --- a/test/integration/test-releasefile-verification +++ b/test/integration/test-releasefile-verification @@ -19,8 +19,7 @@ prepare() { for release in $(find rootdir/var/lib/apt/lists 2> /dev/null); do touch -d 'now - 6 hours' $release done - rm -rf rootdir/var/cache/apt/archives - rm -f rootdir/var/cache/apt/*.bin + aptget clean cp $1 aptarchive/Packages find aptarchive -name 'Release' -delete cat aptarchive/Packages | gzip > aptarchive/Packages.gz -- cgit v1.2.3 From 9120d409efc74891d008a7cfc5180c1ac8645c8c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 23 Aug 2011 11:20:51 +0200 Subject: * cmdline/apt-key: - if command is 'add' do not error out if the specified keyring doesn't exist, it will be created by gpg --- cmdline/apt-key | 2 +- debian/changelog | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmdline/apt-key b/cmdline/apt-key index e632be706..97d6e0323 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -152,7 +152,7 @@ if [ "$1" = "--keyring" ]; then #echo "keyfile given" shift TRUSTEDFILE="$1" - if [ -r "$TRUSTEDFILE" ]; then + if [ -r "$TRUSTEDFILE" ] || [ "$2" = 'add' ]; then GPG="$GPG --keyring $TRUSTEDFILE --primary-keyring $TRUSTEDFILE" else echo >&2 "Error: The specified keyring »$TRUSTEDFILE« is missing or not readable" diff --git a/debian/changelog b/debian/changelog index e1c9ac350..0311979af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,8 +21,11 @@ apt (0.8.15.7) UNRELEASED; urgency=low but do not fail if a hash can't be found * apt-pkg/acquire.cc: - non-existing directories are by definition clean + * cmdline/apt-key: + - if command is 'add' do not error out if the specified + keyring doesn't exist, it will be created by gpg - -- David Kalnischkies Mon, 22 Aug 2011 23:08:47 +0200 + -- David Kalnischkies Tue, 23 Aug 2011 11:19:47 +0200 apt (0.8.15.6) unstable; urgency=low -- cgit v1.2.3 From 3b8d17737d840f48a60f1d4d1af3c285047ad61e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 23 Aug 2011 20:17:19 +0200 Subject: print from their the visit came from --- apt-pkg/orderlist.cc | 22 +++++++++++----------- apt-pkg/orderlist.h | 4 +++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index a58efa987..2fc0b6927 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -152,7 +152,7 @@ bool pkgOrderList::DoRun() iterator OldEnd = End; End = NList; for (iterator I = List; I != OldEnd; ++I) - if (VisitNode(PkgIterator(Cache,*I)) == false) + if (VisitNode(PkgIterator(Cache,*I), "DoRun") == false) { End = OldEnd; return false; @@ -519,7 +519,7 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical) if (Critical == false && IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(Pkg) == false) + if (VisitNode(Pkg, "Provides") == false) return false; } return true; @@ -530,7 +530,7 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical) /* This is the core ordering routine. It calls the set dependency consideration functions which then potentialy call this again. Finite depth is achived through the colouring mechinism. */ -bool pkgOrderList::VisitNode(PkgIterator Pkg) +bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from) { // Looping or irrelevent. // This should probably trancend not installed packages @@ -541,7 +541,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg) if (Debug == true) { for (int j = 0; j != Depth; j++) clog << ' '; - clog << "Visit " << Pkg.FullName() << endl; + clog << "Visit " << Pkg.FullName() << " from " << from << endl; } Depth++; @@ -636,7 +636,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D) if (CheckDep(D) == true) continue; - if (VisitNode(D.ParentPkg()) == false) + if (VisitNode(D.ParentPkg(), "UnPackCrit") == false) return false; } else @@ -811,7 +811,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D) if (IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(D.ParentPkg()) == false) + if (VisitNode(D.ParentPkg(), "UnPackDep-Parent") == false) return false; } else @@ -825,7 +825,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D) if (CheckDep(D) == true) continue; - if (VisitNode(D.TargetPkg()) == false) + if (VisitNode(D.TargetPkg(), "UnPackDep-Target") == false) return false; } } @@ -924,7 +924,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsFlag(P, InList) == true && IsFlag(P, AddPending) == false && Cache[P].InstallVer != 0 && - VisitNode(P) == true) + VisitNode(P, "Remove-P") == true) { Flag(P, Immediate); tryFixDeps = false; @@ -960,7 +960,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsFlag(F.TargetPkg(), InList) == true && IsFlag(F.TargetPkg(), AddPending) == false && Cache[F.TargetPkg()].InstallVer != 0 && - VisitNode(F.TargetPkg()) == true) + VisitNode(F.TargetPkg(), "Remove-Target") == true) { Flag(F.TargetPkg(), Immediate); tryFixDeps = false; @@ -974,7 +974,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsFlag(Prv.OwnerPkg(), InList) == true && IsFlag(Prv.OwnerPkg(), AddPending) == false && Cache[Prv.OwnerPkg()].InstallVer != 0 && - VisitNode(Prv.OwnerPkg()) == true) + VisitNode(Prv.OwnerPkg(), "Remove-Owner") == true) { Flag(Prv.OwnerPkg(), Immediate); tryFixDeps = false; @@ -994,7 +994,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(D.ParentPkg()) == false) + if (VisitNode(D.ParentPkg(), "Remove-Parent") == false) return false; } diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index bbceb3879..264f7ba03 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -18,6 +18,7 @@ #include +#include class pkgDepCache; class pkgOrderList : protected pkgCache::Namespace @@ -45,7 +46,8 @@ class pkgOrderList : protected pkgCache::Namespace bool Debug; // Main visit function - bool VisitNode(PkgIterator Pkg); + __deprecated bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); }; + bool VisitNode(PkgIterator Pkg, char const* from); bool VisitDeps(DepFunc F,PkgIterator Pkg); bool VisitRDeps(DepFunc F,PkgIterator Pkg); bool VisitRProvides(DepFunc F,VerIterator Ver); -- cgit v1.2.3 From 05b64a6f78e3bf39142808a3dae41a2c4618f6b0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 24 Aug 2011 00:41:30 +0200 Subject: * apt-pkg/orderlist.cc: - prefer visiting packages marked for deletion in VisitProvides if we are operating on a negative dependency so that we can deal early with the fallout of this remove --- apt-pkg/orderlist.cc | 50 +++++++++++++++++++++++++++++++++++++++++++------- debian/changelog | 6 +++++- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 2fc0b6927..cae5b0a48 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -495,33 +495,69 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver) /*}}}*/ // OrderList::VisitProvides - Visit all of the providing packages /*{{{*/ // --------------------------------------------------------------------- -/* This routine calls visit on all providing packages. */ +/* This routine calls visit on all providing packages. + + If the dependency is negative it first visits packages which are + intended to be removed and after that all other packages. + It does so to avoid situations in which this package is used to + satisfy a (or-group/provides) dependency of another package which + could have been satisfied also by upgrading another package - + otherwise we have more broken packages dpkg needs to auto- + deconfigure and in very complicated situations it even decides + against it! */ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical) -{ +{ SPtrArray List = D.AllTargets(); - for (Version **I = List; *I != 0; I++) + for (Version **I = List; *I != 0; ++I) { VerIterator Ver(Cache,*I); PkgIterator Pkg = Ver.ParentPkg(); + if (D.IsNegative() == true && Cache[Pkg].Delete() == false) + continue; + if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing) continue; - + if (D.IsNegative() == false && Cache[Pkg].InstallVer != *I) continue; - + if (D.IsNegative() == true && (Version *)Pkg.CurrentVer() != *I) continue; - + + // Skip over missing files + if (Critical == false && IsMissing(D.ParentPkg()) == true) + continue; + + if (VisitNode(Pkg, "Provides-1") == false) + return false; + } + if (D.IsNegative() == false) + return true; + for (Version **I = List; *I != 0; ++I) + { + VerIterator Ver(Cache,*I); + PkgIterator Pkg = Ver.ParentPkg(); + + if (Cache[Pkg].Delete() == true) + continue; + + if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing) + continue; + + if ((Version *)Pkg.CurrentVer() != *I) + continue; + // Skip over missing files if (Critical == false && IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(Pkg, "Provides") == false) + if (VisitNode(Pkg, "Provides-2") == false) return false; } + return true; } /*}}}*/ diff --git a/debian/changelog b/debian/changelog index 0311979af..44ad1dfcf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,8 +24,12 @@ apt (0.8.15.7) UNRELEASED; urgency=low * cmdline/apt-key: - if command is 'add' do not error out if the specified keyring doesn't exist, it will be created by gpg + * apt-pkg/orderlist.cc: + - prefer visiting packages marked for deletion in VisitProvides + if we are operating on a negative dependency so that we can + deal early with the fallout of this remove - -- David Kalnischkies Tue, 23 Aug 2011 11:19:47 +0200 + -- David Kalnischkies Wed, 24 Aug 2011 00:41:18 +0200 apt (0.8.15.6) unstable; urgency=low -- cgit v1.2.3 From 884a4c0a3a6cba654e77478a086f26539bc5bd32 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Sep 2011 14:50:30 +0200 Subject: * apt-pkg/indexrecords.cc: - fix Acquire::Max-ValidTime option by interpreting it really as seconds as specified in the manpage and not as days --- apt-pkg/indexrecords.cc | 4 +- debian/changelog | 5 +- test/integration/framework | 31 +++++++------ test/integration/test-releasefile-valid-until | 66 +++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 16 deletions(-) create mode 100755 test/integration/test-releasefile-valid-until diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 10e154ad2..7852b99f0 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -113,7 +113,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/ } // get the user settings for this archive and use what expires earlier int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0); - if (Label.empty() == true) + if (Label.empty() == false) MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge); if(MaxAge == 0) // No user settings, use the one from the Release file @@ -125,7 +125,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/ strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str()); return false; } - date += 24*60*60*MaxAge; + date += MaxAge; if (ValidUntil == 0 || ValidUntil > date) ValidUntil = date; diff --git a/debian/changelog b/debian/changelog index 44ad1dfcf..de4a9ef0a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,8 +28,11 @@ apt (0.8.15.7) UNRELEASED; urgency=low - prefer visiting packages marked for deletion in VisitProvides if we are operating on a negative dependency so that we can deal early with the fallout of this remove + * apt-pkg/indexrecords.cc: + - fix Acquire::Max-ValidTime option by interpreting it really + as seconds as specified in the manpage and not as days - -- David Kalnischkies Wed, 24 Aug 2011 00:41:18 +0200 + -- David Kalnischkies Mon, 05 Sep 2011 13:24:37 +0200 apt (0.8.15.6) unstable; urgency=low diff --git a/test/integration/framework b/test/integration/framework index 45c1f156a..322cf2875 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -515,8 +515,9 @@ getcodenamefromsuite() { echo -n "$1"; } getreleaseversionfromsuite() { true; } generatereleasefiles() { + # $1 is the Date header and $2 is the ValidUntil header to be set + # both should be given in notation date/touch can understand msgninfo "\tGenerate Release files… " - local DATE="${1:-now}" if [ -e aptarchive/dists ]; then for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index @@ -525,27 +526,31 @@ generatereleasefiles() { local SUITE="$(echo "$dir" | cut -d'/' -f 4)" local CODENAME="$(getcodenamefromsuite $SUITE)" local VERSION="$(getreleaseversionfromsuite $SUITE)" - if [ -z "$VERSION" ]; then - aptftparchive -qq release $dir \ - -o APT::FTPArchive::Release::Suite="${SUITE}" \ - -o APT::FTPArchive::Release::Codename="${CODENAME}" \ - | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference - else - aptftparchive -qq release $dir \ - -o APT::FTPArchive::Release::Suite="${SUITE}" \ - -o APT::FTPArchive::Release::Codename="${CODENAME}" \ - -o APT::FTPArchive::Release::Version="${VERSION}" \ - | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference + if [ -n "$VERSION" ]; then + VERSION="-o APT::FTPArchive::Release::Version='${VERSION}'" fi + aptftparchive -qq release $dir \ + -o APT::FTPArchive::Release::Suite="${SUITE}" \ + -o APT::FTPArchive::Release::Codename="${CODENAME}" \ + -o APT::FTPArchive::Release::Label="Testcases" \ + ${VERSION} \ + | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then sed -i '/^Date: / a\ NotAutomatic: yes' $dir/Release fi + if [ -n "$1" -a "$1" != "now" ]; then + sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release + fi + if [ -n "$2" ]; then + sed -i "/^Date: / a\ +Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release + fi done else aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference fi - if [ "$DATE" != "now" ]; then + if [ -n "$1" -a "$1" != "now" ]; then for release in $(find ./aptarchive -name 'Release'); do touch -d "$1" $release done diff --git a/test/integration/test-releasefile-valid-until b/test/integration/test-releasefile-valid-until new file mode 100755 index 000000000..35498f6d1 --- /dev/null +++ b/test/integration/test-releasefile-valid-until @@ -0,0 +1,66 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +insertpackage 'wheezy' 'apt' 'all' '0.8.15' + +setupaptarchive + +setupreleasefile() { + rm -rf rootdir/var/lib/apt/lists + aptget clean + generatereleasefiles "$1" "$2" + signreleasefiles +} + +aptgetupdate() { + if aptget update $* 2>&1 | grep -q 'is expired'; then + return 1 + else + return 0 + fi +} + +setupreleasefile +msgtest 'Release file is accepted as it has' 'no Until' +aptgetupdate && msgpass || msgfail + +setupreleasefile +msgtest 'Release file is accepted as it has' 'no Until and good Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=3600 && msgpass || msgfail + +setupreleasefile 'now - 2 days' +msgtest 'Release file is rejected as it has' 'no Until, but bad Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=3600 && msgfail || msgpass + +setupreleasefile 'now - 3 days' 'now + 1 day' +msgtest 'Release file is accepted as it has' 'good Until' +aptgetupdate && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is rejected as it has' 'bad Until' +aptgetupdate && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is rejected as it has' 'bad Until (ignore good Max-Valid)' +aptgetupdate -o Acquire::Max-ValidTime=1209600 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until)' +aptgetupdate -o Acquire::Max-ValidTime=86400 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now + 4 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (good Until)' +aptgetupdate -o Acquire::Max-ValidTime=86400 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now + 4 days' +msgtest 'Release file is accepted as it has' 'good labeled Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=86400 -o Acquire::Max-ValidTime::Testcases=1209600 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now + 4 days' +msgtest 'Release file is rejected as it has' 'bad labeled Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=1209600 -o Acquire::Max-ValidTime::Testcases=86400 && msgfail || msgpass -- cgit v1.2.3 From 89500a25b30d53ea0f5ae213c4207e13f35d1d61 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Sep 2011 15:58:19 +0200 Subject: - add an Acquire::Min-ValidTime option (Closes: #640122) * doc/apt.conf.5.xml: - reword Acquire::Max-ValidTime documentation to make clear that it doesn't provide the new Min-ValidTime functionality --- apt-pkg/indexrecords.cc | 19 +++++++++++++++---- debian/changelog | 6 +++++- doc/apt.conf.5.xml | 25 +++++++++++++++++-------- test/integration/test-releasefile-valid-until | 24 ++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 13 deletions(-) diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 7852b99f0..ba5b7c846 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -115,8 +115,12 @@ bool indexRecords::Load(const string Filename) /*{{{*/ int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0); if (Label.empty() == false) MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge); + int MinAge = _config->FindI("Acquire::Min-ValidTime", 0); + if (Label.empty() == false) + MinAge = _config->FindI(string("Acquire::Min-ValidTime::" + Label).c_str(), MinAge); - if(MaxAge == 0) // No user settings, use the one from the Release file + if(MaxAge == 0 && + (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file return true; time_t date; @@ -125,10 +129,17 @@ bool indexRecords::Load(const string Filename) /*{{{*/ strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str()); return false; } - date += MaxAge; - if (ValidUntil == 0 || ValidUntil > date) - ValidUntil = date; + if (MinAge != 0 && ValidUntil != 0) { + time_t const min_date = date + MinAge; + if (ValidUntil < min_date) + ValidUntil = min_date; + } + if (MaxAge != 0) { + time_t const max_date = date + MaxAge; + if (ValidUntil == 0 || ValidUntil > max_date) + ValidUntil = max_date; + } return true; } diff --git a/debian/changelog b/debian/changelog index de4a9ef0a..39445f443 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,8 +31,12 @@ apt (0.8.15.7) UNRELEASED; urgency=low * apt-pkg/indexrecords.cc: - fix Acquire::Max-ValidTime option by interpreting it really as seconds as specified in the manpage and not as days + - add an Acquire::Min-ValidTime option (Closes: #640122) + * doc/apt.conf.5.xml: + - reword Acquire::Max-ValidTime documentation to make clear + that it doesn't provide the new Min-ValidTime functionality - -- David Kalnischkies Mon, 05 Sep 2011 13:24:37 +0200 + -- David Kalnischkies Mon, 05 Sep 2011 15:53:12 +0200 apt (0.8.15.6) unstable; urgency=low diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml index 2634c47a9..1adc868e0 100644 --- a/doc/apt.conf.5.xml +++ b/doc/apt.conf.5.xml @@ -267,14 +267,23 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";}; Max-ValidTime Seconds the Release file should be considered valid after - it was created. The default is "for ever" (0) if the Release file of the - archive doesn't include a Valid-Until header. - If it does then this date is the default. The date from the Release file or - the date specified by the creation time of the Release file - (Date header) plus the seconds specified with this - options are used to check if the validation of a file has expired by using - the earlier date of the two. Archive specific settings can be made by - appending the label of the archive to the option name. + it was created (indicated by the Date header). + If the Release file itself includes a Valid-Until header + the earlier date of the two is used as the expiration date. + The default value is 0 which stands for "for ever". + Archive specific settings can be made by appending the label of the archive + to the option name. + + + + Min-ValidTime + Minimum of seconds the Release file should be considered + valid after it was created (indicated by the Date header). + Use this if you need to use a seldomly updated (local) mirror of a more + regular updated archive with a Valid-Until header + instead of competely disabling the expiration date checking. + Archive specific settings can and should be used by appending the label of + the archive to the option name. diff --git a/test/integration/test-releasefile-valid-until b/test/integration/test-releasefile-valid-until index 35498f6d1..c35fe97ff 100755 --- a/test/integration/test-releasefile-valid-until +++ b/test/integration/test-releasefile-valid-until @@ -64,3 +64,27 @@ aptgetupdate -o Acquire::Max-ValidTime=86400 -o Acquire::Max-ValidTime::Testcase setupreleasefile 'now - 7 days' 'now + 4 days' msgtest 'Release file is rejected as it has' 'bad labeled Max-Valid' aptgetupdate -o Acquire::Max-ValidTime=1209600 -o Acquire::Max-ValidTime::Testcases=86400 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now + 1 days' +msgtest 'Release file is accepted as it has' 'good Until (good Min-Valid, no Max-Valid)' +aptgetupdate -o Acquire::Min-ValidTime=1209600 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, no Max-Valid)' +aptgetupdate -o Acquire::Min-ValidTime=1209600 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, good Max-Valid) <' +aptgetupdate -o Acquire::Min-ValidTime=1209600 -o Acquire::Max-ValidTime=2419200 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, good Min-Valid) >' +aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=2419200 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) <' +aptgetupdate -o Acquire::Min-ValidTime=12096 -o Acquire::Max-ValidTime=241920 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) >' +aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=241920 && msgfail || msgpass -- cgit v1.2.3 From 718f797cef0fb766b6f7cfa1d34b617ad047dbc5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Sep 2011 10:56:42 +0200 Subject: fix bashism (local outside function) and releasefile creation in testcases --- test/integration/framework | 9 +++++++-- test/integration/test-compressed-indexes | 8 ++++---- test/integration/test-disappearing-packages | 8 ++++---- test/integration/test-releasefile-valid-until | 5 +++++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/test/integration/framework b/test/integration/framework index 322cf2875..a2e71760e 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -513,6 +513,7 @@ buildaptarchivefromfiles() { # can be overridden by testcases for their pleasure getcodenamefromsuite() { echo -n "$1"; } getreleaseversionfromsuite() { true; } +getlabelfromsuite() { true; } generatereleasefiles() { # $1 is the Date header and $2 is the ValidUntil header to be set @@ -526,13 +527,17 @@ generatereleasefiles() { local SUITE="$(echo "$dir" | cut -d'/' -f 4)" local CODENAME="$(getcodenamefromsuite $SUITE)" local VERSION="$(getreleaseversionfromsuite $SUITE)" + local LABEL="$(getlabelfromsuite $SUITE)" if [ -n "$VERSION" ]; then - VERSION="-o APT::FTPArchive::Release::Version='${VERSION}'" + VERSION="-o APT::FTPArchive::Release::Version=${VERSION}" + fi + if [ -n "$LABEL" ]; then + LABEL="-o APT::FTPArchive::Release::Label=${LABEL}" fi aptftparchive -qq release $dir \ -o APT::FTPArchive::Release::Suite="${SUITE}" \ -o APT::FTPArchive::Release::Codename="${CODENAME}" \ - -o APT::FTPArchive::Release::Label="Testcases" \ + ${LABEL} \ ${VERSION} \ | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then diff --git a/test/integration/test-compressed-indexes b/test/integration/test-compressed-indexes index 26a45812e..a5e885745 100755 --- a/test/integration/test-compressed-indexes +++ b/test/integration/test-compressed-indexes @@ -10,10 +10,10 @@ configarchitecture "i386" buildsimplenativepackage "testpkg" "i386" "1.0" setupaptarchive -local GOODSHOW="$(aptcache show testpkg) +GOODSHOW="$(aptcache show testpkg) " -local GOODPOLICY="$(aptcache policy testpkg)" -local GOODSHOWSRC="$(aptcache showsrc 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' @@ -99,7 +99,7 @@ testrun "compressed" rm rootdir/etc/apt/apt.conf.d/02compressindex changetowebserver aptget update -qq -local GOODPOLICY="$(aptcache policy testpkg)" +GOODPOLICY="$(aptcache policy testpkg)" test $(echo "$GOODPOLICY" | grep -e '^testpkg:' -e '^ Candidate:' -e '^ Installed: (none)' -e '500 http://' | wc -l) -eq 4 testequal "$GOODPOLICY" aptcache policy testpkg diff --git a/test/integration/test-disappearing-packages b/test/integration/test-disappearing-packages index b5d565c2f..82ba9e592 100755 --- a/test/integration/test-disappearing-packages +++ b/test/integration/test-disappearing-packages @@ -12,13 +12,13 @@ buildsimplenativepackage "unrelated" "all" "0.5" "unstable" setupsimplenativepackage "new-pkg" "i386" "2.0" "unstable" "Provides: old-pkg Replaces: old-pkg Conflicts: old-pkg (<< 2.0)" -local BUILDDIR="incoming/new-pkg-2.0" +BUILDDIR="incoming/new-pkg-2.0" echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/new-pkg.links buildpackage "$BUILDDIR" "unstable" "main" rm -rf "$BUILDDIR" setupsimplenativepackage "old-pkg" "all" "2.0" "unstable" "Depends: new-pkg" -local BUILDDIR="incoming/old-pkg-2.0" +BUILDDIR="incoming/old-pkg-2.0" echo "/usr/share/doc/new-pkg /usr/share/doc/old-pkg" > ${BUILDDIR}/debian/old-pkg.links echo " override_dh_link: @@ -33,9 +33,9 @@ aptget install old-pkg=1.0 --trivial-only -qq 2>&1 > /dev/null testmarkedauto # old-pkg is manual installed -local CMD="aptget dist-upgrade -y -q=0" +CMD="aptget dist-upgrade -y -q=0" msgtest "Test for equality of" "$CMD" -local COMPAREFILE=$(mktemp) +COMPAREFILE=$(mktemp) echo "The following package disappeared from your system as all files have been overwritten by other packages: old-pkg diff --git a/test/integration/test-releasefile-valid-until b/test/integration/test-releasefile-valid-until index c35fe97ff..680a370cb 100755 --- a/test/integration/test-releasefile-valid-until +++ b/test/integration/test-releasefile-valid-until @@ -8,6 +8,11 @@ configarchitecture 'i386' insertpackage 'wheezy' 'apt' 'all' '0.8.15' +getlabelfromsuite() { + echo -n 'Testcases' +} + + setupaptarchive setupreleasefile() { -- cgit v1.2.3 From 30426f4822516bdd26528aa2e6d8d69c1291c8d3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Sep 2011 12:35:22 +0200 Subject: M-A:same lockstep unpack should operate on installed packages first (LP: #835625) --- apt-pkg/packagemanager.cc | 31 ++++++++++++++++++---- debian/changelog | 4 ++- .../test-bug-618288-multiarch-same-lockstep | 4 +-- .../test-bug-632221-cross-dependency-satisfaction | 16 +++++------ ...u-bug-835625-multiarch-lockstep-installed-first | 31 ++++++++++++++++++++++ 5 files changed, 70 insertions(+), 16 deletions(-) create mode 100755 test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 6601d9f6b..8b73b9980 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -603,18 +603,39 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - if (instVer->MultiArch == pkgCache::Version::Same) + if (Immediate == true && instVer->MultiArch == pkgCache::Version::Same) + { + /* Do lockstep M-A:same unpacking in two phases: + First unpack all installed architectures, then the not installed. + This way we avoid that M-A: enabled packages are installed before + their older non-M-A enabled packages are replaced by newer versions */ + bool const installed = Pkg->CurrentVer != 0; + if (installed == true && Install(Pkg,FileNames[Pkg->ID]) == false) + return false; for (PkgIterator P = Pkg.Group().PackageList(); P.end() == false; P = Pkg.Group().NextPkg(P)) { - if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true || + if (P->CurrentVer == 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true || Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) continue; - SmartUnPack(P, false); + if (SmartUnPack(P, false) == false) + return false; } - - if(Install(Pkg,FileNames[Pkg->ID]) == false) + if (installed == false && Install(Pkg,FileNames[Pkg->ID]) == false) + return false; + for (PkgIterator P = Pkg.Group().PackageList(); + P.end() == false; P = Pkg.Group().NextPkg(P)) + { + if (P->CurrentVer != 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true || + Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && + (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) + continue; + if (SmartUnPack(P, false) == false) + return false; + } + } + else if (Install(Pkg,FileNames[Pkg->ID]) == false) return false; // Perform immedate configuration of the package. diff --git a/debian/changelog b/debian/changelog index 39445f443..4c677784f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ apt (0.8.15.7) UNRELEASED; urgency=low - ignore "self"-conflicts for all architectures of a package instead of just for the architecture of the package locked at in the ordering of installations too (Closes: #802901) + - M-A:same lockstep unpack should operate on installed + packages first (LP: #835625) * test/* - reorganize the various testcases and helper we have and integrate them better into the buildsystem @@ -36,7 +38,7 @@ apt (0.8.15.7) UNRELEASED; urgency=low - reword Acquire::Max-ValidTime documentation to make clear that it doesn't provide the new Min-ValidTime functionality - -- David Kalnischkies Mon, 05 Sep 2011 15:53:12 +0200 + -- David Kalnischkies Fri, 09 Sep 2011 12:34:04 +0200 apt (0.8.15.6) unstable; urgency=low diff --git a/test/integration/test-bug-618288-multiarch-same-lockstep b/test/integration/test-bug-618288-multiarch-same-lockstep index 7e384e428..a05f03df4 100755 --- a/test/integration/test-bug-618288-multiarch-same-lockstep +++ b/test/integration/test-bug-618288-multiarch-same-lockstep @@ -22,8 +22,8 @@ Building dependency tree... The following packages will be upgraded: apt:i386 apt2 libsame libsame:i386 4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. -Inst libsame [1] (2 unstable [amd64]) [libsame:amd64 on libsame:i386] [libsame:i386 on libsame:amd64] [libsame:i386 apt2:amd64 ] -Inst libsame:i386 [1] (2 unstable [i386]) [apt2:amd64 apt:i386 ] +Inst libsame:i386 [1] (2 unstable [i386]) [libsame:amd64 on libsame:i386] [libsame:i386 on libsame:amd64] [libsame:amd64 apt:i386 ] +Inst libsame [1] (2 unstable [amd64]) [apt2:amd64 apt:i386 ] Conf libsame:i386 (2 unstable [i386]) [apt2:amd64 apt:i386 ] Conf libsame (2 unstable [amd64]) [apt2:amd64 apt:i386 ] Inst apt2 [1] (2 unstable [amd64]) [apt:i386 ] diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction index 58de44843..4299f052f 100755 --- a/test/integration/test-bug-632221-cross-dependency-satisfaction +++ b/test/integration/test-bug-632221-cross-dependency-satisfaction @@ -47,10 +47,10 @@ Inst amdboot (1.0 unstable [amd64]) Inst cool (1.0 unstable [amd64]) Inst doxygen (1.0 unstable [amd64]) Inst foreigner (1.0 unstable [amd64]) -Inst libc6:armel (1.0 unstable [armel]) Inst libc6 (1.0 unstable [amd64]) -Inst libc6-dev:armel (1.0 unstable [armel]) +Inst libc6:armel (1.0 unstable [armel]) Inst libc6-dev (1.0 unstable [amd64]) +Inst libc6-dev:armel (1.0 unstable [armel]) Conf amdboot (1.0 unstable [amd64]) Conf cool (1.0 unstable [amd64]) Conf doxygen (1.0 unstable [amd64]) @@ -90,10 +90,10 @@ Inst amdboot:amd64 (1.0 unstable [amd64]) Inst cool (1.0 unstable [armel]) Inst doxygen (1.0 unstable [armel]) Inst foreigner (1.0 unstable [armel]) -Inst libc6 (1.0 unstable [armel]) Inst libc6:amd64 (1.0 unstable [amd64]) -Inst libc6-dev (1.0 unstable [armel]) +Inst libc6 (1.0 unstable [armel]) Inst libc6-dev:amd64 (1.0 unstable [amd64]) +Inst libc6-dev (1.0 unstable [armel]) Conf amdboot:amd64 (1.0 unstable [amd64]) Conf cool (1.0 unstable [armel]) Conf doxygen (1.0 unstable [armel]) @@ -129,10 +129,10 @@ The following NEW packages will be installed: 0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded. Inst amdboot (1.0 unstable [amd64]) Inst doxygen (1.0 unstable [amd64]) -Inst libc6:armel (1.0 unstable [armel]) Inst libc6 (1.0 unstable [amd64]) -Inst libc6-dev:armel (1.0 unstable [armel]) +Inst libc6:armel (1.0 unstable [armel]) Inst libc6-dev (1.0 unstable [amd64]) +Inst libc6-dev:armel (1.0 unstable [armel]) Conf amdboot (1.0 unstable [amd64]) Conf doxygen (1.0 unstable [amd64]) Conf libc6 (1.0 unstable [amd64]) @@ -169,10 +169,10 @@ The following NEW packages will be installed: 0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded. Inst amdboot:amd64 (1.0 unstable [amd64]) Inst doxygen (1.0 unstable [armel]) -Inst libc6 (1.0 unstable [armel]) Inst libc6:amd64 (1.0 unstable [amd64]) -Inst libc6-dev (1.0 unstable [armel]) +Inst libc6 (1.0 unstable [armel]) Inst libc6-dev:amd64 (1.0 unstable [amd64]) +Inst libc6-dev (1.0 unstable [armel]) Conf amdboot:amd64 (1.0 unstable [amd64]) Conf doxygen (1.0 unstable [armel]) Conf libc6:amd64 (1.0 unstable [amd64]) diff --git a/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first b/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first new file mode 100755 index 000000000..a9a4069cf --- /dev/null +++ b/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first @@ -0,0 +1,31 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' + +insertinstalledpackage 'libsame' 'i386' '1' +insertinstalledpackage 'apt' 'i386' '1' 'Depends: libsame (= 1)' + +insertpackage 'unstable' 'libsame' 'i386,amd64' '2' 'Multi-Arch: same' +insertpackage 'unstable' 'apt' 'i386' '2' 'Depends: libsame (= 2)' + +setupaptarchive + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + apt:i386 libsame:i386 +The following NEW packages will be installed: + libsame +The following packages will be upgraded: + apt:i386 libsame:i386 +2 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst libsame:i386 [1] (2 unstable [i386]) [apt:i386 ] +Inst libsame (2 unstable [amd64]) [apt:i386 ] +Conf libsame:i386 (2 unstable [i386]) [apt:i386 ] +Conf libsame (2 unstable [amd64]) [apt:i386 ] +Inst apt:i386 [1] (2 unstable [i386]) +Conf apt:i386 (2 unstable [i386])' aptget install libsame:amd64 -s -- cgit v1.2.3 From 02679bb36369dce76f3a2159dbb829ba221c1e67 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Sep 2011 12:51:18 +0200 Subject: fix changelog typos and bugfix-link --- debian/changelog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4c677784f..7d005475d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,8 +3,8 @@ apt (0.8.15.7) UNRELEASED; urgency=low [ David Kalnischkies ] * apt-pkg/packagemanager.cc, apt-pkg/pkgcache.cc: - ignore "self"-conflicts for all architectures of a package - instead of just for the architecture of the package locked at - in the ordering of installations too (Closes: #802901) + instead of just for the architecture of the package look at + in the ordering of installations, too (LP: #802901) - M-A:same lockstep unpack should operate on installed packages first (LP: #835625) * test/* @@ -38,7 +38,7 @@ apt (0.8.15.7) UNRELEASED; urgency=low - reword Acquire::Max-ValidTime documentation to make clear that it doesn't provide the new Min-ValidTime functionality - -- David Kalnischkies Fri, 09 Sep 2011 12:34:04 +0200 + -- David Kalnischkies Fri, 09 Sep 2011 12:49:24 +0200 apt (0.8.15.6) unstable; urgency=low -- cgit v1.2.3