summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-09-05 14:50:30 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-09-05 14:50:30 +0200
commit884a4c0a3a6cba654e77478a086f26539bc5bd32 (patch)
tree97c2aeedf0e53478784e9d797108fe30e0e84669
parent05b64a6f78e3bf39142808a3dae41a2c4618f6b0 (diff)
downloadapt-884a4c0a3a6cba654e77478a086f26539bc5bd32.tar.gz
* apt-pkg/indexrecords.cc:
- fix Acquire::Max-ValidTime option by interpreting it really as seconds as specified in the manpage and not as days
-rw-r--r--apt-pkg/indexrecords.cc4
-rw-r--r--debian/changelog5
-rw-r--r--test/integration/framework31
-rwxr-xr-xtest/integration/test-releasefile-valid-until66
4 files changed, 90 insertions, 16 deletions
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 <kalnischkies@gmail.com> Wed, 24 Aug 2011 00:41:18 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com> 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