Commit b9ad6ba3 authored by Bernhard Link's avatar Bernhard Link

warn if update rules list components or architectures are always ignored

parent d55acd94
2007-09-09 Bernhard R. Link <brlink@debian.org>
* never hardlink index files, but copy them always into the lists
directory. (Should not make a difference yet, but feels safer).
* warn if update rules list components or architectures are always ignored
2007-09-08 Bernhard R. Link <brlink@debian.org>
* warn if pull rules list components or architectures are always ignored
......
......@@ -8,8 +8,8 @@ Updates between 2.2.4 and 2.3.0:
(avoids actions started in the wrong base directory and helps to catch more
disambiguities, may lead to the need of a valid config file for some actions
not needing one, though).
- check pull rules to not list any architectures or components that will never
be used, so typos won't go unnoticed.
- check pull and update rules to not list any architectures or components that
will never be used, so typos won't go unnoticed.
- obsolete --overridedir and searching files in overrides/ directory by default.
This places are still search, but so is the configuration directory now and
future version will stop accepting --overridedir and not search in that
......
TODO:
check for empty lists... (decide which should not be empty and which may)
test new config parser: do update's Config still work?
add --fast option, default --nofast and doing more consistency checks:
- check Component/Architecture lists in update rules
(both need having all distribtion specifications always available first)
do not put/leave files in pool when include gets an older version than already there
write more automated test-cases
finish import from incoming dir, implement sending mails to uploader
......
......@@ -718,7 +718,8 @@ ACTION_D(update) {
return result;
assert( RET_IS_OK(result) );
result = updates_calcindices(listdir, patterns, alldistributions, &u_distributions);
result = updates_calcindices(listdir, patterns, alldistributions, fast,
&u_distributions);
if( RET_WAS_ERROR(result) ) {
updates_freepatterns(patterns);
return result;
......@@ -763,7 +764,8 @@ ACTION_D(predelete) {
}
assert( RET_IS_OK(result) );
result = updates_calcindices(listdir, patterns, alldistributions, &u_distributions);
result = updates_calcindices(listdir, patterns, alldistributions, fast,
&u_distributions);
if( RET_WAS_ERROR(result) ) {
updates_freepatterns(patterns);
return result;
......@@ -804,7 +806,8 @@ ACTION_D(iteratedupdate) {
if( RET_WAS_ERROR(result) )
return result;
result = updates_calcindices(listdir, patterns, alldistributions, &u_distributions);
result = updates_calcindices(listdir, patterns, alldistributions, fast,
&u_distributions);
if( RET_WAS_ERROR(result) ) {
updates_freepatterns(patterns);
return result;
......@@ -841,7 +844,8 @@ ACTION_B(checkupdate) {
return result;
}
result = updates_calcindices(listdir, patterns, alldistributions, &u_distributions);
result = updates_calcindices(listdir, patterns, alldistributions, fast,
&u_distributions);
if( RET_WAS_ERROR(result) ) {
updates_freepatterns(patterns);
return result;
......
......@@ -416,23 +416,6 @@ static inline void markasused(const struct strlist *pulls, const char *rulename,
}
}
static bool *preparefoundlist(const struct strlist *list) {
bool *found;
int i, j;
found = calloc(list->count, sizeof(bool));
if( found == NULL )
return found;
for( i = 0 ; i < list->count ; i++ ) {
if( found[i] )
continue;
for( j = i + 1 ; j < list->count ; j++ )
if( strcmp(list->values[i], list->values[j]) == 0 )
found[j] = true;
}
return found;
}
static void checkifarchitectureisused(const struct strlist *architectures, const struct distribution *alldistributions, const struct pull_rule *rule, const char *action) {
bool *found;
const struct distribution *d;
......@@ -441,7 +424,7 @@ static void checkifarchitectureisused(const struct strlist *architectures, const
assert( rule != NULL );
if( architectures->count == 0 )
return;
found = preparefoundlist(architectures);
found = strlist_preparefoundlist(architectures);
if( found == NULL )
return;
for( d = alldistributions ; d != NULL ; d = d->next ) {
......@@ -473,7 +456,7 @@ static void checkifcomponentisused(const struct strlist *components, const struc
assert( rule != NULL );
if( components->count == 0 )
return;
found = preparefoundlist(components);
found = strlist_preparefoundlist(components);
if( found == NULL )
return;
for( d = alldistributions ; d != NULL ; d = d->next ) {
......@@ -505,7 +488,7 @@ static void checkifudebcomponentisused(const struct strlist *udebcomponents, con
assert( rule != NULL );
if( udebcomponents->count == 0 )
return;
found = preparefoundlist(udebcomponents);
found = strlist_preparefoundlist(udebcomponents);
if( found == NULL )
return;
for( d = alldistributions ; d != NULL ; d = d->next ) {
......
......@@ -268,3 +268,20 @@ bool strlist_intersects(const struct strlist *a, const struct strlist *b) {
return true;
return false;
}
bool *strlist_preparefoundlist(const struct strlist *list) {
bool *found;
int i, j;
found = calloc(list->count, sizeof(bool));
if( found == NULL )
return found;
for( i = 0 ; i < list->count ; i++ ) {
if( found[i] )
continue;
for( j = i + 1 ; j < list->count ; j++ )
if( strcmp(list->values[i], list->values[j]) == 0 )
found[j] = true;
}
return found;
}
......@@ -46,4 +46,6 @@ bool strlist_intersects(const struct strlist *, const struct strlist *);
/* if missing != NULL And subset no subset of strlist, set *missing to the first missing one */
bool strlist_subset(const struct strlist *strlist, const struct strlist *subset, const char **missing);
/* a list of bool for all values, duplicates already set to true */
bool *strlist_preparefoundlist(const struct strlist *);
#endif
......@@ -156,6 +156,7 @@ struct update_pattern {
struct filterlist filterlist;
// NULL means nothing to execute after lists are downloaded...
/*@null@*/char *listhook;
bool used;
};
struct update_origin {
......@@ -355,10 +356,84 @@ retvalue updates_getpatterns(const char *confdir, struct update_pattern **patter
fputs("To ignore unknown fields use --ignore=unknownfield\n", stderr);
updates_freepatterns(update);
}
/* check for unknown fields
return r;
}
static inline void markfound(const struct strlist *updates, const char *patternname, const struct strlist *searched, const struct strlist *have, bool *found) {
int i, j, o;
for( i = 0 ; i < updates->count ; i++ ) {
if( strcmp(updates->values[i], patternname) != 0 )
continue;
for( j = 0 ; j < have->count ; j++ ) {
o = strlist_ofs(searched, have->values[j]);
if( o > 0 )
found[o] = true;
}
}
}
/* TODO: move this into parsing? */
static void checkpatternsforunused(const struct update_pattern *patterns, const struct distribution *distributions) {
const struct distribution *d;
const struct update_pattern *p;
bool *found;
int i;
for( p = patterns ; p != NULL ; p = p->next ) {
if( !p->used )
continue;
found = strlist_preparefoundlist(&p->architectures_into);
if( found == NULL )
return;
for( d = distributions ; d != NULL ; d = d->next ) {
markfound(&d->updates, p->name, &p->architectures_into,
&d->architectures, found);
}
for( i = 0 ; i < p->architectures_into.count ; i++ ) {
if( found[i] )
continue;
fprintf(stderr,
"Warning: Update-pattern '%s' wants to put something in architecture '%s',\n"
"but no distribution using that rule has an architecture of that name.\n",
p->name, p->architectures_into.values[i]);
}
free(found);
found = strlist_preparefoundlist(&p->components_into);
if( found == NULL )
return;
for( d = distributions ; d != NULL ; d = d->next ) {
markfound(&d->updates, p->name, &p->components_into,
&d->components, found);
}
for( i = 0 ; i < p->components_into.count ; i++ ) {
if( found[i] )
continue;
fprintf(stderr,
"Warning: Update-pattern '%s' wants to put something in component '%s',\n"
"but no distribution using that rule has an component of that name.\n",
p->name, p->components_into.values[i]);
}
free(found);
found = strlist_preparefoundlist(&p->udebcomponents_into);
if( found == NULL )
return;
for( d = distributions ; d != NULL ; d = d->next ) {
markfound(&d->updates, p->name, &p->udebcomponents_into,
&d->udebcomponents, found);
}
for( i = 0 ; i < p->udebcomponents_into.count ; i++ ) {
if( found[i] )
continue;
fprintf(stderr,
"Warning: Update-pattern '%s' wants to put something in udebcomponent '%s',\n"
"but no distribution using that rule has an udebcomponent of that name.\n",
p->name, p->udebcomponents_into.values[i]);
}
free(found);
}
}
/****************************************************************************
* Step 2: create rules for some distribution based on those patterns *
****************************************************************************/
......@@ -375,10 +450,7 @@ static retvalue new_deleterule(struct update_origin **origins) {
return RET_OK;
}
static retvalue instance_pattern(const char *listdir,
const struct update_pattern *pattern,
const struct distribution *distribution,
struct update_origin **origins) {
static retvalue instance_pattern(const char *listdir, struct update_pattern *pattern, const struct distribution *distribution, struct update_origin **origins) {
struct update_origin *update;
......@@ -405,6 +477,7 @@ static retvalue instance_pattern(const char *listdir,
free(update);
return RET_ERROR_OOM;
}
pattern->used = true;
update->distribution = distribution;
update->pattern = pattern;
......@@ -430,7 +503,7 @@ static retvalue instance_pattern(const char *listdir,
return RET_OK;
}
static retvalue getorigins(const char *listdir,const struct update_pattern *patterns,const struct distribution *distribution,struct update_origin **origins) {
static retvalue getorigins(const char *listdir, struct update_pattern *patterns, const struct distribution *distribution, struct update_origin **origins) {
struct update_origin *updates = NULL;
retvalue result;
int i;
......@@ -438,7 +511,7 @@ static retvalue getorigins(const char *listdir,const struct update_pattern *patt
result = RET_NOTHING;
for( i = 0; i < distribution->updates.count ; i++ ) {
const char *name = distribution->updates.values[i];
const struct update_pattern *pattern;
struct update_pattern *pattern;
struct update_origin *update IFSTUPIDCC(=NULL);
retvalue r;
......@@ -653,7 +726,7 @@ static inline retvalue findmissingupdate(int count,const struct distribution *di
return result;
}
retvalue updates_calcindices(const char *listdir,const struct update_pattern *patterns,struct distribution *distributions,struct update_distribution **update_distributions) {
retvalue updates_calcindices(const char *listdir, struct update_pattern *patterns, struct distribution *distributions, bool fast, struct update_distribution **update_distributions) {
struct distribution *distribution;
struct update_distribution *u_ds;
retvalue r;
......@@ -703,9 +776,11 @@ retvalue updates_calcindices(const char *listdir,const struct update_pattern *pa
}
r = RET_OK;
}
if( RET_IS_OK(r) )
if( RET_IS_OK(r) ) {
if( !fast )
checkpatternsforunused(patterns, distributions);
*update_distributions = u_ds;
else
} else
updates_freeupdatedistributions(u_ds);
return r;
}
......
......@@ -29,7 +29,7 @@ retvalue updates_getpatterns(const char *confdir,/*@out@*/struct update_pattern
void updates_freepatterns(/*@only@*/struct update_pattern *p);
void updates_freeupdatedistributions(/*@only@*/struct update_distribution *d);
retvalue updates_calcindices(const char *listdir,const struct update_pattern *patterns,struct distribution *distributions,/*@out@*/struct update_distribution **update_distributions);
retvalue updates_calcindices(const char *listdir, struct update_pattern *, struct distribution *, bool fast, /*@out@*/struct update_distribution **);
/* remove all files ${listdir}/${distribution}_* that will not be needed. */
retvalue updates_clearlists(const char *listdir,struct update_distribution *distributions);
......
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