summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/cachefile.cc1
-rw-r--r--apt-private/private-source.cc11
-rwxr-xr-xtest/integration/test-bug-814139-pickup-of-different-cache-states58
3 files changed, 64 insertions, 6 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc
index 6db0749d4..909da5cb4 100644
--- a/apt-pkg/cachefile.cc
+++ b/apt-pkg/cachefile.cc
@@ -238,6 +238,7 @@ bool pkgCacheFile::AddIndexFile(pkgIndexFile * const File) /*{{{*/
ExternOwner = false;
Map = NULL;
}
+ _system->UnLock(true);
return true;
}
/*}}}*/
diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc
index 7126feb78..5aaf6f48b 100644
--- a/apt-private/private-source.cc
+++ b/apt-private/private-source.cc
@@ -73,8 +73,6 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name,
pkgSrcRecords &SrcRecs,std::string &Src,
CacheFile &Cache)
{
- if (Cache.BuildCaches(false) == false)
- return nullptr;
std::string VerTag, UserRequestedVerTag;
std::string ArchTag = "";
std::string RelTag = _config->Find("APT::Default-Release");
@@ -321,12 +319,11 @@ bool DoSource(CommandLine &CmdL)
return _error->Error(_("Must specify at least one package to fetch source for"));
CacheFile Cache;
- // Read the source list
- if (Cache.BuildSourceList() == false)
+ if (Cache.BuildCaches(false) == false)
return false;
- pkgSourceList *List = Cache.GetSourceList();
// Create the text record parsers
+ pkgSourceList * const List = Cache.GetSourceList();
pkgSrcRecords SrcRecs(*List);
if (_error->PendingError() == true)
return false;
@@ -725,8 +722,11 @@ bool DoBuildDep(CommandLine &CmdL)
VolatileCmdL.size());
}
+ bool const WantLock = _config->FindB("APT::Get::Print-URIs", false) == false;
if (CmdL.FileList[1] != 0)
{
+ if (Cache.BuildCaches(WantLock) == false)
+ return false;
// Create the text record parsers
pkgSrcRecords SrcRecs(*List);
if (_error->PendingError() == true)
@@ -747,7 +747,6 @@ bool DoBuildDep(CommandLine &CmdL)
Cache.AddIndexFile(new debStringPackageIndex(buildDepsPkgFile.str()));
- bool WantLock = _config->FindB("APT::Get::Print-URIs", false) == false;
if (Cache.Open(WantLock) == false)
return false;
pkgProblemResolver Fix(Cache.GetDepCache());
diff --git a/test/integration/test-bug-814139-pickup-of-different-cache-states b/test/integration/test-bug-814139-pickup-of-different-cache-states
new file mode 100755
index 000000000..a6c84d6cd
--- /dev/null
+++ b/test/integration/test-bug-814139-pickup-of-different-cache-states
@@ -0,0 +1,58 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'amd64'
+
+insertinstalledpackage 'build-essential' 'amd64' '1'
+
+buildsimplenativepackage 'foo' 'all' '1' 'stable' 'Build-Depends: bar'
+buildsimplenativepackage 'bar' 'all' '1' 'stable'
+
+setupaptarchive
+
+cp rootdir/var/lib/dpkg/status status.backup
+
+testrun() {
+ cp status.backup rootdir/var/lib/dpkg/status
+ cleanup
+ testdpkgnotinstalled 'bar'
+ testsuccess aptget build-dep foo -y
+ testdpkginstalled 'bar'
+ cleanup
+ testsuccess aptget source foo
+ testsuccess test -s foo_1.tar.xz -a -s foo_1.dsc
+ rm foo_1.tar.xz foo_1.dsc
+ testsuccess test -d foo-1
+ rm -rf foo-1
+ cleanup
+ testsuccess aptget install foo -y
+}
+
+msgmsg 'Caches fully up-to-date'
+cleanup() {
+ rm -f rootdir/var/cache/apt/*.bin
+ testsuccess aptcache gencaches
+}
+testrun
+
+msgmsg 'pkgcache.bin is missing'
+cleanup() {
+ rm -f rootdir/var/cache/apt/*.bin
+ testsuccess aptcache gencaches
+ rm rootdir/var/cache/apt/pkgcache.bin
+}
+testrun
+
+msgmsg 'Caches are not writeable'
+rm rootdir/var/cache/apt/*.bin
+addtrap 'prefix' 'chmod 755 rootdir/var/cache/apt;'
+chmod 555 rootdir/var/cache/apt
+testsuccess aptcache gencaches
+cleanup() {
+ testfilestats "${TMPWORKINGDIRECTORY}/rootdir/var/cache/apt" '%a' '=' '555'
+}
+testrun