Browse Source

call URIStart in cdrom and file method

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.
tags/debian/1.1.exp9
David Kalnischkies 6 years ago
parent
commit
ff86d7df6a
9 changed files with 42 additions and 40 deletions
  1. +4
    -9
      apt-pkg/acquire-item.cc
  2. +0
    -1
      apt-pkg/acquire-worker.cc
  3. +2
    -1
      methods/cdrom.cc
  4. +10
    -8
      methods/file.cc
  5. +4
    -2
      test/integration/test-apt-cdrom
  6. +7
    -0
      test/integration/test-apt-get-update-unauth-warning
  7. +4
    -2
      test/integration/test-apt-progress-fd
  8. +4
    -16
      test/integration/test-bug-595691-empty-and-broken-archive-files
  9. +7
    -1
      test/integration/test-bug-596498-trusted-unsigned-repo

+ 4
- 9
apt-pkg/acquire-item.cc View 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();


+ 0
- 1
apt-pkg/acquire-worker.cc View 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;


+ 2
- 1
methods/cdrom.cc View 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;


+ 10
- 8
methods/file.cc View 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)


+ 4
- 2
test/integration/test-apt-cdrom View File

@@ -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'


+ 7
- 0
test/integration/test-apt-get-update-unauth-warning View File

@@ -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


+ 4
- 2
test/integration/test-apt-progress-fd View File

@@ -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)


+ 4
- 16
test/integration/test-bug-595691-empty-and-broken-archive-files View File

@@ -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



+ 7
- 1
test/integration/test-bug-596498-trusted-unsigned-repo View File

@@ -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

Loading…
Cancel
Save