Commit d8202d8a authored by Bernhard Link's avatar Bernhard Link

fix bug not deleting packages if none added in update.

The 'update' command was finishing without doing anything if there
are no new packages to add. This is incorrect if there are
only deletes.

Thanks to Modestas Vainius for reporting the problem.
parent b52fa81b
......@@ -8,6 +8,7 @@ buildneeding.test \
check.test \
copy.test \
diffgeneration.test \
easyupdate.test \
exporthooks.test \
flat.test \
flood.test \
......
set -u
. "$TESTSDIR"/test.inc
mkdir -p test/a test/dists/name/comp/source
mkdir bla
tar -czf test/a/a.tar.gz bla
rmdir bla
cat > test/a/a.dsc <<EOF
Format: 3.0 (native)
Source: apackage
Version: 0-1
Maintainer: noone <noone@nowhere.tld>
Checksums-Sha1:
$(sha1andsize test/a/a.tar.gz) a.tar.gz
EOF
cat > test/dists/name/comp/source/Sources <<EOF
Package: apackage
Version: 0-1
Priority: extra
Section: devel
Maintainer: noone <noone@nowhere.tld>
Directory: a
Files:
$(mdandsize test/a/a.dsc) a.dsc
$(mdandsize test/a/a.tar.gz) a.tar.gz
Checksums-Sha1:
$(sha1andsize test/a/a.dsc) a.dsc
$(sha1andsize test/a/a.tar.gz) a.tar.gz
EOF
mkdir conf
cat > conf/distributions <<EOF
Codename: test1
Architectures: source
Components: everything
Update: u
Codename: test2
Architectures: source
Components: everything
Update: - u
EOF
cat > conf/updates <<EOF
Name: u
Method: file:${WORKDIR}/test
Suite: name
Components: comp>everything
IgnoreRelease: Yes
DownloadListsAs: .
EOF
testrun - update test1 3<<EOF
-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
-v1*=aptmethod got 'file:${WORKDIR}/test/a/a.dsc'
-v2*=Linking file '${WORKDIR}/test/a/a.dsc' to './pool/everything/a/apackage/a.dsc'...
-v1*=aptmethod got 'file:${WORKDIR}/test/a/a.tar.gz'
-v2*=Linking file '${WORKDIR}/test/a/a.tar.gz' to './pool/everything/a/apackage/a.tar.gz'...
stdout
$(odb)
-v2*=Created directory "./lists"
-v0*=Calculating packages to get...
-v3*= processing updates for 'test1|everything|source'
-v5*= reading './lists/u_name_comp_Sources'
-v2*=Created directory "./pool"
-v2*=Created directory "./pool/everything"
-v2*=Created directory "./pool/everything/a"
-v2*=Created directory "./pool/everything/a/apackage"
-v0*=Getting packages...
$(ofa pool/everything/a/apackage/a.dsc)
$(ofa pool/everything/a/apackage/a.tar.gz)
-v1*=Shutting down aptmethods...
-v0*=Installing (and possibly deleting) packages...
$(opa apackage 0-1 test1 everything source dsc)
-v0*=Exporting indices...
-v2*=Created directory "./dists"
-v2*=Created directory "./dists/test1"
-v2*=Created directory "./dists/test1/everything"
-v2*=Created directory "./dists/test1/everything/source"
-v6*= looking for changes in 'test1|everything|source'...
-v6*= creating './dists/test1/everything/source/Sources' (gzipped)
EOF
testrun - update test2 3<<EOF
-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
stdout
-v0*=Calculating packages to get...
-v3*= processing updates for 'test2|everything|source'
-v5*= marking everything to be deleted
-v5*= reading './lists/u_name_comp_Sources'
-v0*=Getting packages...
-v1*=Shutting down aptmethods...
-v0*=Installing (and possibly deleting) packages...
$(opa apackage 0-1 test2 everything source dsc)
-v0*=Exporting indices...
-v2*=Created directory "./dists/test2"
-v2*=Created directory "./dists/test2/everything"
-v2*=Created directory "./dists/test2/everything/source"
-v6*= looking for changes in 'test2|everything|source'...
-v6*= creating './dists/test2/everything/source/Sources' (gzipped)
EOF
testrun - update test2 3<<EOF
-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
stdout
-v0*=Calculating packages to get...
-v3*= processing updates for 'test2|everything|source'
-v5*= marking everything to be deleted
-v5*= reading './lists/u_name_comp_Sources'
EOF
true > test/dists/name/comp/source/Sources
testrun - update test2 3<<EOF
-v1*=aptmethod got 'file:${WORKDIR}/test/dists/name/comp/source/Sources'
-v2*=Copy file '${WORKDIR}/test/dists/name/comp/source/Sources' to './lists/u_name_comp_Sources'...
stdout
-v0*=Calculating packages to get...
-v3*= processing updates for 'test2|everything|source'
-v5*= marking everything to be deleted
-v5*= reading './lists/u_name_comp_Sources'
-v0*=Getting packages...
-v1*=Shutting down aptmethods...
-v0*=Installing (and possibly deleting) packages...
$(opd apackage 0-1 test2 everything source dsc)
-v0*=Exporting indices...
-v6*= looking for changes in 'test2|everything|source'...
-v6*= replacing './dists/test2/everything/source/Sources' (gzipped)
EOF
testsuccess
......@@ -190,6 +190,14 @@ opa() {
printf -- "-d1*=db: '%s' added to packages.db(%s%s|%s|%s)." \
"$name" "$u" "$codename" "$component" "$arch"
}
opd() {
local name="$1" version="$2" codename="$3" component="$4" arch="$5" type="$6" u=""
if test "$type" = "udeb" ; then u='u|' ; fi
printf -- "-v1*=removing '%s' from '%s%s|%s|%s'...\n" \
"$name" "$u" "$codename" "$component" "$arch"
printf -- "-d1*=db: '%s' removed from packages.db(%s%s|%s|%s)." \
"$name" "$u" "$codename" "$component" "$arch"
}
cat > empty.rules <<EOF
stdout
......
......@@ -184,6 +184,7 @@ runtest() {
if test x"$testtorun" != x"all" ; then
runtest "$testtorun"
else
runtest easyupdate
runtest srcfilterlist
runtest uploaders
runtest wrongarch
......
......@@ -1839,6 +1839,7 @@ static retvalue updates_readindices(/*@null@*/FILE *out, struct update_distribut
****************************************************************************/
static retvalue enqueue_upgrade_package(void *calldata, const struct checksumsarray *origfiles, const struct strlist *filekeys, void *privdata) {
retvalue r;
struct update_index_connector *uindex = privdata;
struct aptmethod *aptmethod;
struct downloadcache *cache = calldata;
......@@ -2143,6 +2144,21 @@ retvalue updates_update(struct update_distribution *distributions, bool nolistsd
r = space_check(cache->devices);
RET_ENDUPDATE(result, r);
}
if (!RET_WAS_ERROR(result) && !todo) {
for (d=distributions ; !todo && d != NULL ; d=d->next) {
struct update_target *u;
if (d->distribution->omitted)
continue;
for (u = d->targets ; u != NULL ; u = u->next) {
if (u->nothingnew || u->ignoredelete)
continue;
if (upgradelist_woulddelete(u->upgradelist)) {
todo = true;
break;
}
}
}
}
if (RET_WAS_ERROR(result) || !todo) {
for (d=distributions ; d != NULL ; d=d->next) {
......
......@@ -680,6 +680,21 @@ bool upgradelist_isbigdelete(const struct upgradelist *upgrade) {
return deleted >= 10 && all/deleted < 5;
}
bool upgradelist_woulddelete(const struct upgradelist *upgrade) {
struct package_data *pkg;
long long deleted = 0, all = 0;
if (upgrade->list == NULL)
return false;
for (pkg = upgrade->list ; pkg != NULL ; pkg = pkg->next) {
if (pkg->version_in_use == NULL)
continue;
if (pkg->deleted)
return true;
}
return false;
}
retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger, bool ignoredelete, void (*callback)(void *, const char **, const char **)){
struct package_data *pkg;
retvalue result, r;
......
......@@ -34,6 +34,7 @@ typedef retvalue enqueueaction(void *, const struct checksumsarray *, const stru
retvalue upgradelist_enqueue(struct upgradelist *, enqueueaction *, void *);
bool upgradelist_isbigdelete(const struct upgradelist *);
bool upgradelist_woulddelete(const struct upgradelist *);
retvalue upgradelist_install(struct upgradelist *, /*@null@*/struct logger *, bool /*ignoredelete*/, void (*)(void *, const char **, const char **));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment