summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/acquire-item.cc91
-rw-r--r--apt-pkg/acquire-item.h3
-rwxr-xr-xtest/integration/test-apt-update-ims34
3 files changed, 76 insertions, 52 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index b61a1d833..0a128f7d5 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1576,7 +1576,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
ShortDesc(ShortDesc)
{
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
- DestFile += URItoFileName(URI);
+ DestFile += URItoFileName(RealURI);
// remove any partial downloaded sig-file in partial/.
// it may confuse proxies and is too small to warrant a
@@ -1625,68 +1625,65 @@ void pkgAcqMetaSig::Done(string Message,unsigned long long Size,
{
Item::Done(Message, Size, Hashes, Cfg);
- string FileName = LookupTag(Message,"Filename");
- if (FileName.empty() == true)
+ if(AuthPass == false)
{
- Status = StatError;
- ErrorText = "Method gave a blank filename";
- return;
- }
+ // queue for verify, note that we change DestFile here to point to
+ // the file we want to verify (needed to make gpgv work)
- if (FileName != DestFile)
- {
- // We have to copy it into place
- Local = true;
- Desc.URI = "copy:" + FileName;
- QueueURI(Desc);
- return;
- }
+ string FileName = LookupTag(Message,"Filename");
+ if (FileName.empty() == true)
+ {
+ Status = StatError;
+ ErrorText = "Method gave a blank filename";
+ return;
+ }
- if(StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
- IMSHit = true;
+ if (FileName != DestFile)
+ {
+ // We have to copy it into place
+ Local = true;
+ Desc.URI = "copy:" + FileName;
+ QueueURI(Desc);
+ return;
+ }
- // adjust paths if its a ims-hit
- if(IMSHit)
- {
- string FinalFile = _config->FindDir("Dir::State::lists");
- FinalFile += URItoFileName(RealURI);
-
- TransactionManager->TransactionStageCopy(this, FinalFile, FinalFile);
- }
+ if(StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
+ {
+ IMSHit = true;
+ // adjust DestFile on i-m-s hit to the one we already have on disk
+ DestFile = _config->FindDir("Dir::State::lists");
+ DestFile += URItoFileName(RealURI);
+ }
+
+ // this is the file we verify from
+ MetaIndexFileSignature = DestFile;
- // queue for verify
- if(AuthPass == false)
- {
AuthPass = true;
- Desc.URI = "gpgv:" + DestFile;
+ Desc.URI = "gpgv:" + MetaIndexFileSignature;
DestFile = MetaIndexFile;
QueueURI(Desc);
+ ActiveSubprocess = "gpgv";
return;
}
-
- // queue to copy the file in place if it was not a ims hit, on ims
- // hit the file is already at the right place
- if(IMSHit == false)
+ else
{
- PartialFile = _config->FindDir("Dir::State::lists") + "partial/";
- PartialFile += URItoFileName(RealURI);
-
- std::string FinalFile = _config->FindDir("Dir::State::lists");
- FinalFile += URItoFileName(RealURI);
-
- TransactionManager->TransactionStageCopy(this, PartialFile, FinalFile);
- }
+ // verify was successful
- // we parse the MetaIndexFile here because at this point we can
- // trust the data
- if(AuthPass == true)
- {
+ // we parse the MetaIndexFile here (and not right after getting
+ // the pkgAcqMetaIndex) because at this point we can trust the data
+ //
// load indexes and queue further downloads
MetaIndexParser->Load(MetaIndexFile);
QueueIndexes(true);
- }
- Complete = true;
+ // DestFile points to the the MetaIndeFile at this point, make it
+ // point back to the Release.gpg file
+ std::string FinalFile = _config->FindDir("Dir::State::lists");
+ FinalFile += URItoFileName(RealURI);
+ TransactionManager->TransactionStageCopy(this, MetaIndexFileSignature, FinalFile);
+
+ Complete = true;
+ }
}
/*}}}*/
void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 97236f90a..083a73197 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -433,6 +433,9 @@ class pkgAcqMetaSig : public pkgAcqMetaBase
/** \brief The file we need to verify */
std::string MetaIndexFile;
+ /** \brief The file we use to verify the MetaIndexFile with */
+ std::string MetaIndexFileSignature;
+
/** \brief Long URI description used in the acquire system */
std::string URIDesc;
diff --git a/test/integration/test-apt-update-ims b/test/integration/test-apt-update-ims
index 946dfc7af..38dcd73fd 100755
--- a/test/integration/test-apt-update-ims
+++ b/test/integration/test-apt-update-ims
@@ -20,11 +20,7 @@ runtest() {
testfailure ls "rootdir/var/lib/apt/lists/partial/*"
# check that I-M-S header is kept in redirections
- testequal "Hit http://localhost:8080 unstable InRelease
-Hit http://localhost:8080 unstable/main Sources
-Hit http://localhost:8080 unstable/main amd64 Packages
-Hit http://localhost:8080 unstable/main Translation-en
-Reading package lists..." aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0
+ testequal "$EXPECT" aptget update -o Debug::pkgAcquire::Worker=0 -o Debug::Acquire::http=0
# ensure that we still do a hash check on ims hit
msgtest 'Test I-M-S reverify'
@@ -34,6 +30,34 @@ Reading package lists..." aptget update -o Debug::pkgAcquire::Worker=0 -o Debug
testfailure ls "rootdir/var/lib/apt/lists/partial/*"
}
+EXPECT="Hit http://localhost:8080 unstable InRelease
+Hit http://localhost:8080 unstable/main Sources
+Hit http://localhost:8080 unstable/main amd64 Packages
+Hit http://localhost:8080 unstable/main Translation-en
+Reading package lists..."
+# with InRelease
+runtest
+
+# with gzip
+echo "Acquire::GzipIndexes "1";" > rootdir/etc/apt/apt.conf.d/02compressindex
+runtest
+
+# FIXME: how can we get rid of this extra line
+# "Get:1 http://localhost:8080 unstable Release.gpg"
+#
+# with Release/Release.gpg
+EXPECT="Ign http://localhost:8080 unstable InRelease
+Hit http://localhost:8080 unstable Release
+Hit http://localhost:8080 unstable Release.gpg
+Get:1 http://localhost:8080 unstable Release.gpg
+Hit http://localhost:8080 unstable/main Sources
+Hit http://localhost:8080 unstable/main amd64 Packages
+Hit http://localhost:8080 unstable/main Translation-en
+Reading package lists..."
+
+find aptarchive -name "InRelease" | xargs rm -f
+
+echo "Acquire::GzipIndexes "0";" > rootdir/etc/apt/apt.conf.d/02compressindex
runtest
echo "Acquire::GzipIndexes "1";" > rootdir/etc/apt/apt.conf.d/02compressindex