]> git.saurik.com Git - apt.git/commitdiff
call URIStart in cdrom and file method
authorDavid Kalnischkies <david@kalnischkies.de>
Mon, 15 Jun 2015 11:36:11 +0000 (13:36 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Mon, 15 Jun 2015 21:35:54 +0000 (23:35 +0200)
All other methods call it, so they should follow along even if the work
they do afterwards is hardly breathtaking and usually results in a
URIDone pretty soon, but the acquire system tells the individual item
about this via a virtual method call, so even through none of our
existing items contains any critical code in these, maybe one day they
might. Consistency at least once…

Which is also why this has a good sideeffect: file: and cdrom: requests
appear now in the 'apt-get update' output. Finally - it never made sense
to hide them for me. Okay, I guess it made before the new hit behavior,
but now that you can actually see the difference in an update it makes
sense to see if a file: repository changed or not as well.

apt-pkg/acquire-item.cc
apt-pkg/acquire-worker.cc
methods/cdrom.cc
methods/file.cc
test/integration/test-apt-cdrom
test/integration/test-apt-get-update-unauth-warning
test/integration/test-apt-progress-fd
test/integration/test-bug-595691-empty-and-broken-archive-files
test/integration/test-bug-596498-trusted-unsigned-repo

index dc4f61b56097814be192bceebbb7f13a666ad66e..50936b627da579a1caddec73e6f24c4acd058ec4 100644 (file)
@@ -519,19 +519,14 @@ void pkgAcquire::Item::Done(string const &Message, HashStringList const &Hashes,
                            pkgAcquire::MethodConfig const * const /*Cnf*/)
 {
    // We just downloaded something..
-   string FileName = LookupTag(Message,"Filename");
    UsedMirror = LookupTag(Message,"UsedMirror");
-   unsigned long long const downloadedSize = Hashes.FileSize();
-   if (downloadedSize != 0)
+   if (FileSize == 0)
    {
-      if (Complete == false && !Local && FileName == DestFile)
+      unsigned long long const downloadedSize = Hashes.FileSize();
+      if (downloadedSize != 0)
       {
-        if (Owner->Log != 0)
-           Owner->Log->Fetched(Hashes.FileSize(),atoi(LookupTag(Message,"Resume-Point","0").c_str()));
+        FileSize = downloadedSize;
       }
-
-      if (FileSize == 0)
-        FileSize= downloadedSize;
    }
    Status = StatDone;
    ErrorText = string();
index d6318a21b89999730e3652a77e498ca355898050..ef195d44bfb23541a27dfdd224e64691941e1f87 100644 (file)
@@ -362,7 +362,6 @@ bool pkgAcquire::Worker::RunMessages()
 
            bool const isIMSHit = StringToBool(LookupTag(Message,"IMS-Hit"),false) ||
               StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false);
-
            for (pkgAcquire::Queue::QItem::owner_iterator O = ItmOwners.begin(); O != ItmOwners.end(); ++O)
            {
               pkgAcquire::Item * const Owner = *O;
index 10cb29f662be05318858e671a382792d283d87bd..67265cfa37afc644459b000c8b35440b9c9d3340 100644 (file)
@@ -260,7 +260,8 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
    struct stat Buf;
    if (stat(Res.Filename.c_str(),&Buf) != 0)
       return _error->Error(_("File not found"));
-   
+
+   URIStart(Res);
    if (NewID.empty() == false)
       CurrentID = NewID;
    Res.LastModified = Buf.st_mtime;
index 5d5fffa67b289399165b53207a2575b98e263a37..5c76ec1224ef83bb019f2d82f47e67a62945b6c4 100644 (file)
@@ -58,7 +58,10 @@ bool FileMethod::Fetch(FetchItem *Itm)
         {
            HashStringList const hsl = Itm->ExpectedHashes;
            if (Itm->ExpectedHashes.VerifyFile(File))
+           {
+              Res.Filename = Itm->DestFile;
               Res.IMSHit = true;
+           }
         }
       }
    }
@@ -78,7 +81,14 @@ bool FileMethod::Fetch(FetchItem *Itm)
         if (filesize != 0 && filesize == Res.Size)
            Res.IMSHit = true;
       }
+
+      Hashes Hash(Itm->ExpectedHashes);
+      FileFd Fd(File, FileFd::ReadOnly);
+      Hash.AddFD(Fd);
+      Res.TakeHashes(Hash);
    }
+   if (Res.IMSHit == false)
+      URIStart(Res);
 
    // See if the uncompressed file exists and reuse it
    FetchResult AltRes;
@@ -103,14 +113,6 @@ bool FileMethod::Fetch(FetchItem *Itm)
       }
    }
 
-   if (Res.Filename.empty() == false)
-   {
-      Hashes Hash(Itm->ExpectedHashes);
-      FileFd Fd(Res.Filename, FileFd::ReadOnly);
-      Hash.AddFD(Fd);
-      Res.TakeHashes(Hash);
-   }
-
    if (AltRes.Filename.empty() == false)
       URIDone(Res,&AltRes);
    else if (Res.Filename.empty() == false)
index 34b35f745af8ec4ca2f96873ac9dc611cfcde7ca..6a218ffb848656354263f9dae8256e02eaaab33e 100755 (executable)
@@ -136,13 +136,15 @@ aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' &&
 mv rootdir/media/cdrom-unmounted rootdir/media/cdrom-ejected
 msgmsg "ensure an update doesn't mess with cdrom sources"
 testsuccess aptget update
-testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
+testfileequal rootdir/tmp/testsuccess.output 'Hit cdrom://Debian APT Testdisk 0.8.15 stable InRelease
+Reading package lists...'
 mv rootdir/media/cdrom-ejected rootdir/media/cdrom-unmounted
 testcdromusage
 
 msgmsg 'and again to check that it withstands the temptation even if it could mount'
 testsuccess aptget update
-testfileequal rootdir/tmp/testsuccess.output 'Reading package lists...'
+testfileequal rootdir/tmp/testsuccess.output 'Hit cdrom://Debian APT Testdisk 0.8.15 stable InRelease
+Reading package lists...'
 testcdromusage
 
 msgmsg 'Check that nothing touched our' 'CD-ROM'
index ada7f7a26769232c0faf12836b37be48dece6974..1f4a14e23d7c17fb413485d8fb93562915cf45fc 100755 (executable)
@@ -9,6 +9,7 @@ TESTDIR=$(readlink -f $(dirname $0))
 
 setupenvironment
 configarchitecture "i386"
+configcompression '.' 'gz'
 
 # a "normal" package with source and binary
 buildsimplenativepackage 'foo' 'all' '2.0'
@@ -31,11 +32,17 @@ testsuccessequal 'Listing...' apt list foo
 testequal 'lock
 partial' ls rootdir/var/lib/apt/lists
 
+filesize() {
+       stat -c%s "$(aptget files --no-release-info --format '$(URI)' "Created-By: $1" | cut -d'/' -f 3- ).gz"
+}
 # allow override
 testwarningequal "Ign file:$APTARCHIVE unstable InRelease
   File not found
 Ign file:$APTARCHIVE unstable Release
   File not found
+Get:1 file:$APTARCHIVE unstable/main Sources [$(filesize 'Sources') B]
+Get:2 file:$APTARCHIVE unstable/main i386 Packages [$(filesize 'Packages') B]
+Get:3 file:$APTARCHIVE unstable/main Translation-en [$(filesize 'Translations') B]
 Reading package lists...
 W: The repository 'file:$APTARCHIVE unstable Release' does not have a Release file. This is deprecated, please contact the owner of the repository." aptget update --allow-insecure-repositories
 # ensure we can not install the package
index 0c11aba7e83b6fddc71d2e4deb47c59d0b264121..99b4ea050f45d0debf785070c875fbbbbb8fa877 100755 (executable)
@@ -16,6 +16,7 @@ setupaptarchive
 exec 3> apt-progress.log
 testsuccess aptget install testing=0.1 -y -o APT::Status-Fd=3
 testfileequal './apt-progress.log' 'dlstatus:1:0:Retrieving file 1 of 1
+dlstatus:1:0:Retrieving file 1 of 1
 dlstatus:1:20:Retrieving file 1 of 1
 pmstatus:dpkg-exec:0:Running dpkg
 pmstatus:testing:0:Installing testing (amd64)
@@ -32,6 +33,7 @@ pmstatus:dpkg-exec:83.3333:Running dpkg'
 exec 3> apt-progress.log
 testsuccess aptget install testing=0.8.15 -y -o APT::Status-Fd=3
 testfileequal './apt-progress.log' 'dlstatus:1:0:Retrieving file 1 of 1
+dlstatus:1:0:Retrieving file 1 of 1
 dlstatus:1:20:Retrieving file 1 of 1
 pmstatus:dpkg-exec:0:Running dpkg
 pmstatus:testing:0:Installing testing (amd64)
@@ -48,6 +50,7 @@ pmstatus:dpkg-exec:83.3333:Running dpkg'
 exec 3> apt-progress.log
 testsuccess aptget install testing=0.8.15 --reinstall -y -o APT::Status-Fd=3
 testfileequal './apt-progress.log' 'dlstatus:1:0:Retrieving file 1 of 1
+dlstatus:1:0:Retrieving file 1 of 1
 dlstatus:1:20:Retrieving file 1 of 1
 pmstatus:dpkg-exec:0:Running dpkg
 pmstatus:testing:0:Installing testing (amd64)
@@ -73,9 +76,8 @@ pmstatus:dpkg-exec:75:Running dpkg'
 # install non-native and ensure we get proper progress info
 exec 3> apt-progress.log
 testsuccess aptget install testing2:i386 -y -o APT::Status-Fd=3
-
-# and compare
 testfileequal './apt-progress.log' 'dlstatus:1:0:Retrieving file 1 of 1
+dlstatus:1:0:Retrieving file 1 of 1
 dlstatus:1:20:Retrieving file 1 of 1
 pmstatus:dpkg-exec:0:Running dpkg
 pmstatus:testing2:0:Installing testing2 (i386)
index b42212f5ea32f9f70c9457fbe7ce68c0a6e537bc..3042d116d5211821c3b0a2d08f19539b270119b4 100755 (executable)
@@ -27,9 +27,6 @@ testaptgetupdate() {
 
 createemptyarchive() {
        find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
-       if [ "en" = "$1" ]; then
-               echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
-       fi
        touch aptarchive/Packages
        echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS
        generatereleasefiles
@@ -39,9 +36,6 @@ createemptyarchive() {
 
 createemptyfile() {
        find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete
-       if [ "en" = "$1" ]; then
-               echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS
-       fi
        touch aptarchive/Packages aptarchive/${1}.$COMPRESS
        generatereleasefiles
        signreleasefiles
@@ -52,19 +46,13 @@ testoverfile() {
        local APTARCHIVE="$(readlink -f ./aptarchive)"
        forcecompressor "$1"
 
-       createemptyfile 'en'
-       testaptgetupdate 'Reading package lists...' "empty file en.$COMPRESS over file"
-
-       createemptyarchive 'en'
-       testaptgetupdate 'Reading package lists...' "empty archive en.$COMPRESS over file"
-
        createemptyarchive 'Packages'
-       # FIXME: Why omits the file transport the Packages Get line?
-       #Get:3 file:  Packages []
-       testaptgetupdate 'Reading package lists...' "empty archive Packages.$COMPRESS over file"
+       testaptgetupdate "Get: file:$APTARCHIVE  Packages []
+Reading package lists..." "empty archive Packages.$COMPRESS over file"
 
        createemptyfile 'Packages'
-       testaptgetupdate "Err file:$APTARCHIVE  Packages
+       testaptgetupdate "Get: file:$APTARCHIVE  Packages
+Err file:$APTARCHIVE  Packages
   Empty files can't be valid archives
 W: Failed to fetch ${COMPRESSOR}:${APTARCHIVE}/Packages.$COMPRESS  Empty files can't be valid archives
 
index 4eb77b9a4fdc2dba99917b7fead5dbbdba1c196b..1ff0f1d8de1acd5d55cf69d4f43bd6135560da49 100755 (executable)
@@ -15,13 +15,17 @@ aptgetupdate() {
        ${1:-testwarning} aptget update --allow-insecure-repositories
 }
 
-PKGTEXT="$(aptget install cool --assume-no -d | head -n 7)"
+PKGTEXT="$(aptget install cool --assume-no -d | head -n 8)"
+DOWNLOG="$(echo "$PKGTEXT" | tail -n 1)"
+PKGTEXT="$(echo "$PKGTEXT" | head -n 7)"
 DEBFILE='rootdir/etc/apt/sources.list.d/apt-test-unstable-deb.list'
 
 testsuccessequal "$PKGTEXT
+$DOWNLOG
 Download complete and in download only mode" aptget install cool --assume-no -d
 
 testsuccessequal "$PKGTEXT
+$DOWNLOG
 Download complete and in download only mode" aptget install cool --assume-no -d --allow-unauthenticated
 
 sed -i -e 's#deb#deb [trusted=no]#' $DEBFILE
@@ -47,10 +51,12 @@ testsuccessequal "$PKGTEXT
 WARNING: The following packages cannot be authenticated!
   cool
 Authentication warning overridden.
+$DOWNLOG
 Download complete and in download only mode" aptget install cool --assume-no -d --allow-unauthenticated
 
 sed -i -e 's#deb#deb [trusted=yes]#' $DEBFILE
 aptgetupdate
 
 testsuccessequal "$PKGTEXT
+$DOWNLOG
 Download complete and in download only mode" aptget install cool --assume-no -d