Commit 626c7956 authored by Bernhard Link's avatar Bernhard Link

always fix descriptions when adding a package (especially when updateing from another distribution)

parent 992b8d50
2013-11-21 Bernhard R. Link <brlink@debian.org>
* automatically add long Descriptions when updating from a source that
does not have them in the Packages files.
2013-10-05 Bernhard R. Link <brlink@debian.org>
* fix docs/outstore.py to work with newer python3 dbm behaviour
* more strict checking of all size information in .changes files
......
......@@ -668,7 +668,7 @@ static retvalue floodlist_install(struct floodlist *list, struct logger *logger,
logger, pkg->name, pkg->new_version,
pkg->new_control, &pkg->new_filekeys,
false, td, architecture_all,
NULL, NULL);
NULL, NULL, NULL);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
......
......@@ -676,7 +676,7 @@ retvalue binaries_adddeb(const struct deb_headers *deb, const struct atomlist *f
false,
trackingdata,
deb->architecture,
NULL, NULL);
NULL, NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r, r2);
}
......@@ -718,7 +718,7 @@ retvalue binaries_adddeb(const struct deb_headers *deb, const struct atomlist *f
false,
trackingdata,
deb->architecture,
NULL, NULL);
NULL, NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r, r2);
}
......
......@@ -147,7 +147,7 @@ retvalue dsc_addprepared(const struct dsc_headers *dsc, component_t component, c
dsc->control, filekeys,
false, trackingdata,
architecture_source,
NULL, NULL);
NULL, NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r, r2);
}
......
......@@ -278,7 +278,7 @@ static retvalue package_add(struct distribution *into, /*@null@*/trackingdb trac
(tracks != NULL)?
&trackingdata:NULL,
package->architecture,
NULL, suitefrom);
NULL, suitefrom, NULL);
RET_UPDATE(into->status, r);
if (tracks != NULL) {
retvalue r2;
......
......@@ -95,12 +95,20 @@ static void description_genmd5(const char *description, /*@out@*/ char *d, size_
*d = '\0';
}
retvalue description_complete(const char *package, const char *control, bool ignoreonlyshort, bool force, char **control_p) {
/* Currently only normalizing towards a full Description is supported,
* the cached description is not yet used, long descriptions are not stored elsewhere
* and thus also no reference counting is done. */
retvalue description_addpackage(struct target *target, const char *package, const char *control, const char *oldcontrol, struct description *cached, char **control_p) {
char *description, *description_md5, *deb_description, *newcontrol;
struct fieldtoadd *todo;
size_t dlen;
retvalue r;
/* source packages have no descriptions */
if (target->packagetype == pt_dsc)
return RET_NOTHING;
r = chunk_getwholedata(control, "Description", &description);
if (RET_WAS_ERROR(r))
return r;
......@@ -108,7 +116,7 @@ retvalue description_complete(const char *package, const char *control, bool ign
fprintf(stderr,
"Strange control data for '%s': no Description at all\n",
package);
return RET_ERROR;
return RET_NOTHING;
}
if (strchr(description, '\n') != NULL) {
/* there already is a long description, nothing to do */
......@@ -123,13 +131,10 @@ retvalue description_complete(const char *package, const char *control, bool ign
return r;
}
if (r == RET_NOTHING) {
/* only short description and no -md5?*/
if (ignoreonlyshort) {
free(description);
return RET_NOTHING;
}
/* try to complete anyway... */
description_md5 = NULL;
/* only short description and no -md5?
* unusual but can happen, especially with .udeb */
free(description);
return RET_NOTHING;
}
r = description_from_package(control, &deb_description);
assert (r != RET_NOTHING);
......@@ -147,13 +152,13 @@ retvalue description_complete(const char *package, const char *control, bool ign
"Short Description of package '%s' does not match\n"
"the start of the long descriptiongfound in the .deb\n",
package);
if (!force) {
//if (!force) {
free(description);
free(description_md5);
free(deb_description);
/* not fatal, only not processed */
return RET_NOTHING;
}
//}
}
if (strlen(deb_description) == dlen) {
/* nothing new, only a short description in the .deb, too: */
......@@ -174,12 +179,12 @@ retvalue description_complete(const char *package, const char *control, bool ign
"the md5 of the description found in the .deb\n"
"('%s' != '%s')!\n",
package, description_md5, found);
if (!force) {
//if (!force) {
free(description_md5);
/* not fatal, only not processed */
free(deb_description);
return RET_NOTHING;
}
//}
}
free(description_md5);
}
......@@ -195,3 +200,8 @@ retvalue description_complete(const char *package, const char *control, bool ign
*control_p = newcontrol;
return RET_OK;
}
retvalue description_preparepackage(UNUSED(struct target *target), UNUSED(const char *package), UNUSED(const char *control), UNUSED(struct description **description_p)) {
/* everything yet done in description_addpackage */
return RET_NOTHING;
}
#ifndef REPREPRO_DESCRIPTIONS_H
#define REPREPRO_DESCRIPTIONS_H
struct description;
retvalue description_complete(const char *, const char *, bool, bool, char **);
retvalue description_preparepackage(struct target*, const char */*package*/, const char */*control*/, /*@out@*/struct description**);
/* Do what is needed description/translation wise for a new package added.
* control is the control chunk of the new package to be normalized
* (depending on the target, towards containing full Description or checksumed),
* oldcontrol is a old version of a package replaced or NULL
* (for repairdescriptions oldcontrol==control).
* newcontrol_p gets the new normalized control chunk.
* description is the data returned by a description_prepareaddpackage or NULL
* if that was not yet called
*/
retvalue description_addpackage(struct target*, const char */*package*/, const char */*control*/,/*@null@*/const char */*oldcontrol*/, /*@null@*/struct description*, /*@out@*/char **/*newcontrol_p*/);
#endif
......@@ -1044,11 +1044,6 @@ one of the selected ones).
Look for binary packages only having a short description
and try to get the long description from the .deb file
(and also remove a possible Description-md5 in this case).
The variant \fBforcerepairdescriptions\fP also replaces
descriptions that do not match the previous short Description
or the Description-md5 header.
.SS internal commands
These are hopefully never needed, but allow manual intervention.
.B WARNING:
......
......@@ -1648,7 +1648,7 @@ static retvalue add_dsc(struct distribution *into, struct trackingdata *tracking
&p->filekeys,
false, trackingdata,
architecture_source,
NULL, NULL);
NULL, NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r, r2);
}
......
......@@ -2484,7 +2484,7 @@ ACTION_F(y, n, y, y, reoverride) {
/*****************retrieving Description data from .deb files***************/
static retvalue repair_descriptions(struct target *target, bool force) {
static retvalue repair_descriptions(struct target *target) {
struct target_cursor iterator;
retvalue result, r;
const char *package, *controlchunk;
......@@ -2509,9 +2509,9 @@ static retvalue repair_descriptions(struct target *target, bool force) {
result = RET_ERROR_INTERRUPTED;
break;
}
r = description_complete(package, controlchunk,
target->packagetype == pt_udeb,
force, &newcontrolchunk);
/* replace it by itself to normalize the Description field */
r = description_addpackage(target, package, controlchunk,
controlchunk, NULL, &newcontrolchunk);
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
break;
......@@ -2538,7 +2538,6 @@ static retvalue repair_descriptions(struct target *target, bool force) {
ACTION_F(y, n, y, y, repairdescriptions) {
retvalue result, r;
struct distribution *d;
bool force = strcmp(argv[0], "forcerepairdescriptions") == 0;
result = distribution_match(alldistributions, argc-1, argv+1,
true, READWRITE);
......@@ -2567,7 +2566,7 @@ ACTION_F(y, n, y, y, repairdescriptions) {
continue;
if (t->packagetype == pt_dsc)
continue;
r = repair_descriptions(t, force);
r = repair_descriptions(t);
RET_UPDATE(result, r);
RET_UPDATE(d->status, r);
if (RET_WAS_ERROR(r))
......@@ -3892,7 +3891,7 @@ static const struct action {
{"reoverride", A_Fact(reoverride),
0, -1, "[-T ...] [-C ...] [-A ...] reoverride [<distributions>]"},
{"repairdescriptions", A_Fact(repairdescriptions),
0, -1, "[-C ...] [-A ...] [force]repairdescriptions [<distributions>]"},
0, -1, "[-C ...] [-A ...] repairdescriptions [<distributions>]"},
{"forcerepairdescriptions", A_Fact(repairdescriptions),
0, -1, "[-C ...] [-A ...] [force]repairdescriptions [<distributions>]"},
{"redochecksums", A_Fact(redochecksums),
......
......@@ -40,6 +40,7 @@
#include "tracking.h"
#include "log.h"
#include "files.h"
#include "descriptions.h"
#include "target.h"
static char *calc_identifier(const char *codename, component_t component, architecture_t architecture, packagetype_t packagetype) {
......@@ -422,8 +423,9 @@ static retvalue addpackages(struct target *target, const char *packagename, cons
return result;
}
retvalue target_addpackage(struct target *target, struct logger *logger, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, struct trackingdata *trackingdata, architecture_t architecture, const char *causingrule, const char *suitefrom) {
retvalue target_addpackage(struct target *target, struct logger *logger, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, struct trackingdata *trackingdata, architecture_t architecture, const char *causingrule, const char *suitefrom, struct description *description) {
struct strlist oldfilekeys, *ofk;
char *newcontrol;
char *oldcontrol, *oldsource, *oldsversion;
char *oldpversion;
retvalue r;
......@@ -519,7 +521,13 @@ retvalue target_addpackage(struct target *target, struct logger *logger, const c
}
}
r = addpackages(target, name, control, oldcontrol,
newcontrol = NULL;
r = description_addpackage(target, name, control, oldcontrol,
description, &newcontrol);
if (RET_IS_OK(r))
control = newcontrol;
if (!RET_WAS_ERROR(r))
r = addpackages(target, name, control, oldcontrol,
version, oldpversion,
filekeys, ofk,
logger,
......@@ -530,6 +538,7 @@ retvalue target_addpackage(struct target *target, struct logger *logger, const c
if (trackingdata == NULL)
target->staletracking = true;
}
free(newcontrol);
free(oldpversion);
free(oldcontrol);
......
......@@ -145,7 +145,8 @@ static inline retvalue target_closeiterator(struct target_cursor *tc) {
/* The following calls can only be called if target_initpackagesdb was called before: */
struct logger;
retvalue target_addpackage(struct target *, /*@null@*/struct logger *, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, /*@null@*/struct trackingdata *, architecture_t, /*@null@*/const char *causingrule, /*@null@*/const char *suitefrom);
struct description;
retvalue target_addpackage(struct target *, /*@null@*/struct logger *, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, /*@null@*/struct trackingdata *, architecture_t, /*@null@*/const char *causingrule, /*@null@*/const char *suitefrom, /*@null@*/struct description *);
retvalue target_checkaddpackage(struct target *, const char *name, const char *version, bool tracking, bool permitnewerold);
retvalue target_removepackage(struct target *, /*@null@*/struct logger *, const char *name, struct trackingdata *);
/* like target_removepackage, but do not read control data yourself but use available */
......
......@@ -35,6 +35,8 @@ Architecture: all
Filename: pool/c/p/pseudo/fake_0_all.deb
Section: base
Priority: extra
Description: test
test
Size: $fakesize
MD5Sum: $fakedeb1md
EOF
......@@ -202,6 +204,8 @@ Architecture: all
Filename: pool/c/p/pseudo/fake_0_all.deb
Section: base
Priority: extra
Description: test
test
Size: $fakesize
MD5Sum: $fakedeb1md
'
......
......@@ -88,6 +88,23 @@ stdout
-v6*= looking for changes in 'u|4321|a|abacus'...
EOF
dbversion="$(sed -n -e 's/^b\(db[0-9]\+\.[0-9]\+\)\.0$/\1/p;T;q' db/version)"
dodo ${dbversion}_dump -p -f db/packages.dump db/packages.db
dodo sed -e 's/\\0a blub\\0a/\\0aDescription-md5: 29e34048cfd56bbec39e6997af9c7057\\0a/' -i db/packages.dump
dodo ${dbversion}_load -f db/packages.dump db/packages.db
testrun - -b . export 4321 3<<EOF
stdout
-v0*=Exporting 4321...
-v6*= exporting '4321|a|abacus'...
-v6*= replacing './dists/4321/a/binary-abacus/Packages' (uncompressed)
-v6*= exporting '4321|a|source'...
-v6*= replacing './dists/4321/a/source/Sources' (uncompressed)
-v6*= exporting 'u|4321|a|abacus'...
-v6*= replacing './dists/4321/a/debian-installer/binary-abacus/Packages' (uncompressed)
EOF
if diff dists/1234/a/binary-abacus/Packages dists/4321/a/binary-abacus/Packages ; then
echo "Failed to include Description-md5 for test" 2>&1
exit 1
......@@ -108,29 +125,7 @@ EOF
dodiff dists/1234/a/binary-abacus/Packages dists/4321/a/binary-abacus/Packages
testrun - -b . remove 4321 hello 3<<EOF
stdout
-v1*=removing 'hello' from '4321|a|abacus'...
-v9*=Removing reference to 'pool/a/h/hello/hello_1_abacus.deb' from '4321|a|abacus'
-d1*=db: 'hello' removed from packages.db(4321|a|abacus).
-v0*=Exporting indices...
-v6*= looking for changes in '4321|a|abacus'...
-v6*= replacing './dists/4321/a/binary-abacus/Packages' (uncompressed)
-v6*= looking for changes in '4321|a|source'...
-v6*= looking for changes in 'u|4321|a|abacus'...
EOF
testrun - -b . -T deb -A abacus -C a _addpackage 4321 i/mangled hello 3<<EOF
stdout
-v1*=Adding 'hello' '1' to '4321|a|abacus'.
-v9*=Adding reference to 'pool/a/h/hello/hello_1_abacus.deb' by '4321|a|abacus'
-d1*=db: 'hello' added to packages.db(4321|a|abacus).
-v0*=Exporting indices...
-v6*= looking for changes in '4321|a|abacus'...
-v6*= replacing './dists/4321/a/binary-abacus/Packages' (uncompressed)
-v6*= looking for changes in '4321|a|source'...
-v6*= looking for changes in 'u|4321|a|abacus'...
EOF
dodo ${dbversion}_load -f db/packages.dump db/packages.db
rm pool/a/h/hello/hello_1_abacus.deb
......
......@@ -245,6 +245,8 @@ Architecture: all
Version: 0
Filename: flatsource/test.deb
Size: 0
Description: test
test
MD5Sum: $EMPTYMD5ONLY
EOF
pkgmd="$(mdandsize flatsource/Packages)"
......@@ -335,6 +337,8 @@ cat > flatsource/Packages <<EOF
Package: test
Architecture: yyyyyyyyyy
Version: 1
Description: test
test
Filename: flatsource/test.deb
Size: 0
MD5Sum: $EMPTYMD5ONLY
......@@ -395,6 +399,8 @@ touch fake.dsc
cat > flatsource/Sources <<EOF
Package: test
Version: 0
Description: test
test
Files:
$EMPTYMD5 fake.dsc
EOF
......
......@@ -226,6 +226,7 @@ EOF
testrun - -b . -T deb -A abacus -C dog _addpackage B importindex bar foo 3<<EOF
stderr
*=Strange control data for 'foo': no Description at all
stdout
-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
-d1*=db: 'foo' added to packages.db(B|dog|abacus).
......@@ -424,6 +425,7 @@ EOF
testrun - -b . restore B now foo 3<<EOF
stderr
*=Strange control data for 'foo': no Description at all
*=Warning: replacing 'foo' version '0' with equal version '0' in 'B|dog|abacus'!
*=Warning: replacing 'foo' version '1' with equal version '1' in 'B|dog|source'!
stdout
......@@ -456,6 +458,7 @@ EOF
testrun - -b . restoresrc B now foo 0 1 3<<EOF
stderr
*=Strange control data for 'foo': no Description at all
*=Warning: replacing 'foo' version '0' with equal version '0' in 'B|dog|abacus'!
*=Warning: replacing 'foo' version '1' with equal version '1' in 'B|dog|source'!
stdout
......@@ -477,6 +480,7 @@ EOF
testrun - -b . restoresrc B now foo 0 3<<EOF
stderr
*=Strange control data for 'foo': no Description at all
*=Warning: replacing 'foo' version '0' with equal version '0' in 'B|dog|abacus'!
stdout
-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
......@@ -551,6 +555,7 @@ dodo test -f pool/dog/f/foo/foo_1.dsc
testrun - -b . restore B now bar foo 3<<EOF
stderr
*=Strange control data for 'foo': no Description at all
stdout
-v1*=Adding 'foo' '0' to 'B|dog|abacus'.
-d1*=db: 'foo' added to packages.db(B|dog|abacus).
......
#!/bin/dash
# This needs installed:
# apt, dpkg-dev, ed, python-apt, lzma, python3
# apt, dpkg-dev, ed, python-apt, lzma, python3, dbX.Y-util
# it will fail if run over a changing hour
set -e -u
......
......@@ -29,6 +29,7 @@
#include "target.h"
#include "files.h"
#include "upgradelist.h"
#include "descriptions.h"
struct package_data {
struct package_data *next;
......@@ -58,6 +59,8 @@ struct package_data {
/* the list of files that will belong to this:
* same validity */
struct strlist new_filekeys;
/* cache/info what description is needed for this */
struct description *description;
struct checksumsarray new_origfiles;
/* to destinguish arch all from not arch all */
architecture_t architecture;
......@@ -728,6 +731,7 @@ retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger,
&pkg->new_filekeys,
pkg->new_origfiles.checksums,
&newcontrol);
assert (r != RET_NOTHING);
}
if (! RET_WAS_ERROR(r)) {
/* upgrade (or possibly downgrade) */
......@@ -736,6 +740,7 @@ retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger,
free(pkg->new_control);
pkg->new_control = newcontrol;
newcontrol = NULL;
callback(pkg->privdata,
&causingrule, &suitefrom);
// TODO: trackingdata?
......@@ -748,7 +753,8 @@ retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger,
pkg->new_control,
&pkg->new_filekeys, true,
NULL, pkg->architecture,
causingrule, suitefrom);
causingrule, suitefrom,
pkg->description);
}
RET_UPDATE(result, r);
if (RET_WAS_ERROR(r))
......
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