Commit b3e030ef authored by Bernhard Link's avatar Bernhard Link

add FilterSrcList

parent 4978bd00
2010-04-16
* add 'FilterSrcList'.
2010-04-15
* Many clean-ups and coding style fixes.
2010-03-30
* Support specifying a version in FilterList
......
Updates between 4.5.1 and 4.5.2:
- add 'FilterSrcList' for update and pull
Updates between 4.5.0 and 4.5.1:
- 'check' also checks if architectures match
- buffix in 'sourcemissing', 'unusedsources' and 'reportcruft' without tracking
......
......@@ -1541,10 +1541,10 @@ Dependency lines. To get only architecture all packages use
"architecture (== all)", to get only at least important
packages use "priority (==required) | priority (==important)".
.TP
.B FilterList
This takes at least two arguments: The first one is the default action
when something is not found in the list, then a list of
filenames (relative to
.B FilterList\fR, \fPFilterSrcList
These take at least two arguments:
The first one is the default action when something is not found in the list,
then a list of filenames (relative to
.B \-\-confdir\fR,
if not starting with a slash),
in the format of dpkg \-\-get\-selections and only packages listed in
......@@ -1572,6 +1572,13 @@ is treated like \fBinstall\fP if the version matches and like no
entry if it does not match.
Only one such entry per package is currently supported and the version
is currently compared as string.
If there is both \fBFilterList\fP and \fBFilterSrcList\fP then
the first is used for \fB.deb\fP and \fB.udeb\fP and the second for
\fB.dsc\fP packages.
If there is only \fBFilterList\fP that is applied to everything.
If there is only \fBFilterSrcList\fP that is applied to everything, too,
but the source package name (and source version) is used to do the lookup.
.TP
.B ListHook
If this is given, it is executed for all downloaded index files
......@@ -1676,6 +1683,8 @@ but for the udebs.
.B FilterFormula
.TP
.B FilterList
.TP
.B FilterSrcList
The same as with update rules.
.SH "OVERRIDE FILES"
The format of override files used by reprepro
......
......@@ -62,6 +62,7 @@ struct pull_rule {
// NULL means no condition
/*@null@*/term *includecondition;
struct filterlist filterlist;
struct filterlist filtersrclist;
/*----only set after _addsourcedistribution----*/
/*@NULL@*/ struct distribution *distribution;
bool used;
......@@ -78,6 +79,7 @@ static void pull_rule_free(/*@only@*/struct pull_rule *pull) {
atomlist_done(&pull->udebcomponents);
term_free(pull->includecondition);
filterlist_release(&pull->filterlist);
filterlist_release(&pull->filtersrclist);
free(pull);
}
......@@ -97,6 +99,7 @@ CFvalueSETPROC(pull_rule, from)
CFatomlistSETPROC(pull_rule, components, at_component)
CFatomlistSETPROC(pull_rule, udebcomponents, at_component)
CFfilterlistSETPROC(pull_rule, filterlist)
CFfilterlistSETPROC(pull_rule, filtersrclist)
CFtermSETPROC(pull_rule, includecondition)
CFUSETPROC(pull_rule, architectures) {
......@@ -125,6 +128,7 @@ static const struct configfield pullconfigfields[] = {
CF("Components", pull_rule, components),
CF("UDebComponents", pull_rule, udebcomponents),
CF("FilterFormula", pull_rule, includecondition),
CF("FilterSrcList", pull_rule, filtersrclist),
CF("FilterList", pull_rule, filterlist)
};
......@@ -644,12 +648,35 @@ retvalue pull_prepare(struct distribution *alldistributions, struct pull_rule *r
* decide what gets pulled *
**************************************************************************/
static upgrade_decision ud_decide_by_rule(void *privdata, const struct target *target, const char *package, /*@null@*/const char *old_version, const char *new_version, const char *newcontrolchunk) {
static upgrade_decision ud_decide_by_rule(void *privdata, const struct target *target, const char *package, const char *sourcename, /*@null@*/const char *old_version, const char *new_version, const char *sourceversion, const char *newcontrolchunk) {
struct pull_rule *rule = privdata;
upgrade_decision decision = UD_UPGRADE;
retvalue r;
struct filterlist *fl;
const char *n, *v;
if (target->packagetype == pt_dsc) {
assert (strcmp(package, sourcename) == 0);
assert (strcmp(new_version, sourceversion) == 0);
if (rule->filtersrclist.set)
fl = &rule->filtersrclist;
else
fl = &rule->filterlist;
n = package;
v = new_version;
} else {
if (rule->filterlist.set) {
fl = &rule->filterlist;
n = package;
v = new_version;
} else {
fl = &rule->filtersrclist;
n = sourcename;
v = sourceversion;
}
}
switch (filterlist_find(package, new_version, &rule->filterlist)) {
switch (filterlist_find(n, v, fl)) {
case flt_deinstall:
case flt_purge:
return UD_NO;
......
......@@ -159,6 +159,7 @@ struct update_pattern {
// NULL means no condition
/*@null@*/term *includecondition;
struct filterlist filterlist;
struct filterlist filtersrclist;
// NULL means nothing to execute after lists are downloaded...
/*@null@*/char *listhook;
/*@null@*/char *shellhook;
......@@ -259,6 +260,7 @@ static void update_pattern_free(/*@only@*/struct update_pattern *update) {
strlist_done(&update->udebcomponents_into);
term_free(update->includecondition);
filterlist_release(&update->filterlist);
filterlist_release(&update->filtersrclist);
free(update->listhook);
free(update->shellhook);
remote_repository_free(update->repository);
......@@ -352,6 +354,7 @@ CFtruthSETPROC(update_pattern, ignorerelease)
CFscriptSETPROC(update_pattern, listhook)
CFallSETPROC(update_pattern, shellhook)
CFfilterlistSETPROC(update_pattern, filterlist)
CFfilterlistSETPROC(update_pattern, filtersrclist)
CFtermSSETPROC(update_pattern, includecondition)
CFUSETPROC(update_pattern, downloadlistsas) {
......@@ -529,6 +532,7 @@ static const struct configfield updateconfigfields[] = {
CF("ListShellHook", update_pattern, shellhook),
CF("FilterFormula", update_pattern, includecondition),
CF("FilterList", update_pattern, filterlist),
CF("FilterSrcList", update_pattern, filtersrclist),
CF("DownloadListsAs", update_pattern, downloadlistsas)
};
......@@ -1590,20 +1594,48 @@ static retvalue updates_calllisthooks(struct update_distribution *distributions)
* (all the logic in upgradelist.c, this is only clue code) *
****************************************************************************/
static upgrade_decision ud_decide_by_pattern(void *privdata, const struct target *target, const char *package, /*@null@*/const char *old_version, const char *new_version, const char *newcontrolchunk) {
static upgrade_decision ud_decide_by_pattern(void *privdata, const struct target *target, const char *package, const char *source, /*@null@*/const char *old_version, const char *new_version, const char *new_src_version, const char *newcontrolchunk) {
const struct update_pattern *pattern = privdata, *p;
retvalue r;
upgrade_decision decision = UD_UPGRADE;
enum filterlisttype listdecision;
p = pattern;
while (p != NULL && !p->filterlist.set)
p = p->pattern_from;
if (p == NULL)
listdecision = flt_install;
else
listdecision = filterlist_find(package, new_version,
&p->filterlist);
if (target->packagetype == pt_dsc) {
p = pattern;
while (p != NULL && !p->filtersrclist.set)
p = p->pattern_from;
if (p != NULL)
listdecision = filterlist_find(package, new_version,
&p->filtersrclist);
else {
p = pattern;
while (p != NULL && !p->filterlist.set)
p = p->pattern_from;
if (p == NULL)
listdecision = flt_install;
else
listdecision = filterlist_find(package,
new_version, &p->filterlist);
}
} else {
p = pattern;
while (p != NULL && !p->filterlist.set)
p = p->pattern_from;
if (p != NULL)
listdecision = filterlist_find(package, new_version,
&p->filterlist);
else {
p = pattern;
while (p != NULL && !p->filtersrclist.set)
p = p->pattern_from;
if (p == NULL)
listdecision = flt_install;
else
listdecision = filterlist_find(source,
new_src_version,
&p->filtersrclist);
}
}
switch (listdecision) {
case flt_deinstall:
......
......@@ -192,7 +192,7 @@ void upgradelist_free(struct upgradelist *upgrade) {
return;
}
static retvalue upgradelist_trypackage(struct upgradelist *upgrade, void *privdata, upgrade_decide_function *predecide, void *predecide_data, const char *packagename_const, /*@null@*//*@only@*/char *packagename, /*@only@*/char *version, architecture_t architecture, const char *chunk) {
static retvalue upgradelist_trypackage(struct upgradelist *upgrade, void *privdata, upgrade_decide_function *predecide, void *predecide_data, const char *packagename_const, /*@null@*//*@only@*/char *packagename, const char *sourcename, /*@only@*/char *version, const char *sourceversion, architecture_t architecture, const char *chunk) {
retvalue r;
upgrade_decision decision;
struct package_data *current, *insertafter;
......@@ -278,7 +278,9 @@ static retvalue upgradelist_trypackage(struct upgradelist *upgrade, void *privda
char *newcontrol;
decision = predecide(predecide_data, upgrade->target,
packagename_const, NULL, version, chunk);
packagename_const, sourcename,
NULL, version, sourceversion,
chunk);
if (decision != UD_UPGRADE) {
upgrade->last = insertafter;
if (decision == UD_LOUDNO)
......@@ -385,8 +387,9 @@ static retvalue upgradelist_trypackage(struct upgradelist *upgrade, void *privda
"'%s' from '%s' is newer than '%s' currently\n",
version, packagename_const, current->version);
decision = predecide(predecide_data, upgrade->target,
current->name, current->version,
version, chunk);
current->name, sourcename,
current->version,
version, sourceversion, chunk);
if (decision != UD_UPGRADE) {
if (decision == UD_LOUDNO)
fprintf(stderr,
......@@ -483,7 +486,7 @@ static retvalue upgradelist_trypackage(struct upgradelist *upgrade, void *privda
retvalue upgradelist_update(struct upgradelist *upgrade, void *privdata, const char *filename, upgrade_decide_function *decide, void *decide_data, bool ignorewrongarchitecture) {
struct indexfile *i;
char *packagename, *version;
char *packagename, *version, *sourcename, *sourceversion;
const char *control;
retvalue result, r;
architecture_t package_architecture;
......@@ -497,11 +500,18 @@ retvalue upgradelist_update(struct upgradelist *upgrade, void *privdata, const c
while (indexfile_getnext(i, &packagename, &version, &control,
&package_architecture,
upgrade->target, ignorewrongarchitecture)) {
r = upgradelist_trypackage(upgrade, privdata,
decide, decide_data,
packagename, packagename, version,
package_architecture, control);
RET_UPDATE(result, r);
r = upgrade->target->getsourceandversion(control, packagename,
&sourcename, &sourceversion);
if (RET_IS_OK(r)) {
r = upgradelist_trypackage(upgrade, privdata,
decide, decide_data,
packagename, packagename, sourcename,
version, sourceversion,
package_architecture, control);
RET_UPDATE(result, r);
free(sourcename);
free(sourceversion);
}
if (RET_WAS_ERROR(r)) {
if (verbose > 0)
fprintf(stderr,
......@@ -531,6 +541,7 @@ retvalue upgradelist_pull(struct upgradelist *upgrade, struct target *source, up
while (target_nextpackage(&iterator, &package, &control)) {
char *version;
architecture_t package_architecture;
char *sourcename, *sourceversion;
assert (source->packagetype == upgrade->target->packagetype);
......@@ -570,11 +581,19 @@ retvalue upgradelist_pull(struct upgradelist *upgrade, struct target *source, up
free(version);
continue;
}
r = upgradelist_trypackage(upgrade, privdata,
predecide, decide_data,
package, NULL, version,
package_architecture, control);
RET_UPDATE(result, r);
r = upgrade->target->getsourceandversion(control, package,
&sourcename, &sourceversion);
if (RET_IS_OK(r)) {
r = upgradelist_trypackage(upgrade, privdata,
predecide, decide_data,
package, NULL, sourcename,
version, sourceversion,
package_architecture, control);
RET_UPDATE(result, r);
free(sourcename);
free(sourceversion);
}
if (RET_WAS_ERROR(r))
break;
if (interrupted()) {
......
......@@ -5,7 +5,7 @@
typedef enum { UD_ERROR, UD_LOUDNO, UD_NO, UD_UPGRADE, UD_HOLD } upgrade_decision;
typedef upgrade_decision upgrade_decide_function(void *privdata, const struct target *, const char *package, const char *old_version, const char *new_version, const char *newcontrolchunk);
typedef upgrade_decision upgrade_decide_function(void *privdata, const struct target *, const char *package, const char *source, const char *old_version, const char *new_version, const char *new_src_version, const char *newcontrolchunk);
/* The main part: */
......
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