Commit a64bd1a0 authored by Bernhard Link's avatar Bernhard Link

add REPREPRO_CAUSING_RULE and REPREPRO_FROM

parent 7ecbef3f
2009-02-23
* log notifiers get variables REPREPRO_CAUSING_RULE and
REPREPRO_FROM set when adding packages via update/pull.
The later also in copy* and restore* commands.
2009-02-21
* add --keeptemporaries and without it delete all .new files when
exporting fails (and not only Release) and with it keep all
......
......@@ -614,7 +614,8 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
filekeys,
false,
trackingdata,
deb->architecture_atom);
deb->architecture_atom,
NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......@@ -636,7 +637,8 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
filekeys,
false,
trackingdata,
deb->architecture_atom);
deb->architecture_atom,
NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......@@ -662,7 +664,8 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
filekeys,
false,
trackingdata,
deb->architecture_atom);
deb->architecture_atom,
NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......
......@@ -145,7 +145,8 @@ retvalue dsc_addprepared(struct database *database, const struct dsc_headers *ds
dsc->name, dsc->version,
dsc->control, filekeys,
false, trackingdata,
architecture_source);
architecture_source,
NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......
......@@ -246,7 +246,7 @@ static retvalue list_prepareadd(struct database *database, struct package_list *
return RET_OK;
}
static retvalue package_add(struct database *database, struct distribution *into, /*@null@*/trackingdb tracks, struct target *target, const struct package *package) {
static retvalue package_add(struct database *database, struct distribution *into, /*@null@*/trackingdb tracks, struct target *target, const struct package *package, /*@null@*/ const char *suitefrom) {
struct trackingdata trackingdata;
retvalue r;
......@@ -276,7 +276,8 @@ static retvalue package_add(struct database *database, struct distribution *into
&package->filekeys, true,
(tracks != NULL)?
&trackingdata:NULL,
package->architecture);
package->architecture,
NULL, suitefrom);
RET_UPDATE(into->status, r);
if( tracks != NULL ) {
retvalue r2;
......@@ -288,7 +289,7 @@ static retvalue package_add(struct database *database, struct distribution *into
return r;
}
static retvalue packagelist_add(struct database *database, struct distribution *into, const struct package_list *list) {
static retvalue packagelist_add(struct database *database, struct distribution *into, const struct package_list *list, /*@null@*/const char *suitefrom) {
retvalue result, r;
struct target_package_list *tpl;
struct package *package;
......@@ -315,7 +316,7 @@ static retvalue packagelist_add(struct database *database, struct distribution *
break;
for( package = tpl->packages; package != NULL ; package = package->next ) {
r = package_add(database, into, tracks, target,
package);
package, suitefrom);
RET_UPDATE(result, r);
}
r = target_closepackagesdb(target);
......@@ -438,7 +439,7 @@ retvalue copy_by_name(struct database *database, struct distribution *into, stru
free(names.warnedabout);
if( !RET_IS_OK(r) )
return r;
r = packagelist_add(database, into, &list);
r = packagelist_add(database, into, &list, from->codename);
packagelist_done(&list);
return r;
}
......@@ -524,7 +525,7 @@ retvalue copy_by_source(struct database *database, struct distribution *into, st
r = copy_by_func(&list, database, into, from, component, architecture, packagetype, by_source, &names);
if( !RET_IS_OK(r) )
return r;
r = packagelist_add(database, into, &list);
r = packagelist_add(database, into, &list, from->codename);
packagelist_done(&list);
return r;
}
......@@ -581,7 +582,7 @@ retvalue copy_by_formula(struct database *database, struct distribution *into, s
term_free(condition);
if( !RET_IS_OK(r) )
return r;
r = packagelist_add(database, into, &list);
r = packagelist_add(database, into, &list, from->codename);
packagelist_done(&list);
return r;
}
......@@ -710,7 +711,7 @@ retvalue copy_from_file(struct database *database, struct distribution *into, co
r = indexfile_close(i);
RET_ENDUPDATE(result, r);
if( RET_IS_OK(result) )
result = packagelist_add(database, into, &list);
result = packagelist_add(database, into, &list, NULL);
packagelist_done(&list);
return result;
}
......@@ -809,7 +810,7 @@ static retvalue restore_from_snapshot(struct database *database, struct distribu
free(basedir);
if( !RET_IS_OK(result) )
return result;
r = packagelist_add(database, into, &list);
r = packagelist_add(database, into, &list, snapshotname);
packagelist_done(&list);
return r;
}
......
......@@ -11,6 +11,7 @@ retvalue copy_by_formula(struct database *, struct distribution *into, struct di
retvalue copy_from_file(struct database *, struct distribution *into, component_t, architecture_t, packagetype_t, const char *filename, int, const char **);
/* note that snapshotname must live till logger_wait has run */
retvalue restore_by_name(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, int, const char **);
retvalue restore_by_source(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, int, const char **);
retvalue restore_by_formula(struct database *, struct distribution *, component_t, architecture_t, packagetype_t, const char *snapshotname, const char *filter);
......
......@@ -1073,6 +1073,16 @@ given at the command line causing this package to be changed,
if there is one.
(i.e. with <tt class="command">includedeb</tt>,
<tt class="command">includedsc</tt> and <tt class="command">include</tt>).
The environment variable <tt class="env">REPREPRO_CAUSING_COMMAND</tt>
contains since 3.8.0 the command of the action causing this change.
Since reprepro 3.8.2 there are the addional environment variables
<tt class="env">REPREPRO_CAUSING_RULE</tt> and
<tt class="env">REPREPRO_FROM</tt>.
The first is the name of the update or pull rule pulling in a package,
and the second is the name of the distribution
a package is coming from.
What this name is depends on the command and for most commands
it is simply not set at all.)
<h2><a name="maintainance">Maintenance</a></h2>
This section lists some commands you can use to check and improve the health
of you repository.
......
......@@ -1494,7 +1494,8 @@ static retvalue add_dsc(struct database *database, struct distribution *into, st
p->control,
&p->filekeys,
false, trackingdata,
architecture_source);
architecture_source,
NULL, NULL);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......
......@@ -435,6 +435,8 @@ static retvalue notificator_parse(struct notificator *n, struct configiterator *
/*@null@*/struct notification_process *next;
char **arguments;
/*@null@*/char *causingfile;
/*@null@*/char *causingrule;
/*@null@*/char *suitefrom;
command_t causingcommand_atom;
/* data to send to the process */
size_t datalen, datasent;
......@@ -452,6 +454,8 @@ static void notification_process_free(/*@only@*/struct notification_process *p)
for( a = p->arguments ; *a != NULL ; a++ )
free(*a);
free(p->causingfile);
free(p->causingrule);
free(p->suitefrom);
free(p->arguments);
free(p->data);
free(p);
......@@ -605,6 +609,14 @@ static retvalue startchild(void) {
setenv("REPREPRO_CAUSING_FILE", p->causingfile, true);
else
unsetenv("REPREPRO_CAUSING_FILE");
if( p->causingrule != NULL )
setenv("REPREPRO_CAUSING_RULE", p->causingrule, true);
else
unsetenv("REPREPRO_CAUSING_RULE");
if( p->suitefrom != NULL )
setenv("REPREPRO_FROM", p->suitefrom, true);
else
unsetenv("REPREPRO_FROM");
if( atom_defined(p->causingcommand_atom) )
setenv("REPREPRO_CAUSING_COMMAND",
atoms_commands[p->causingcommand_atom],
......@@ -752,6 +764,8 @@ static retvalue notificator_enqueuechanges(struct notificator *n,const char *cod
}
} else
p->causingfile = NULL;
p->causingrule = NULL;
p->suitefrom = NULL;
p->arguments = arguments;
p->next = NULL;
p->child = 0;
......@@ -768,7 +782,7 @@ static retvalue notificator_enqueuechanges(struct notificator *n,const char *cod
return RET_OK;
}
static retvalue notificator_enqueue(struct notificator *n, struct target *target, const char *name, /*@null@*/const char *version, /*@null@*/const char *oldversion, /*@null@*/const char *control, /*@null@*/const char *oldcontrol, /*@null@*/const struct strlist *filekeys, /*@null@*/const struct strlist *oldfilekeys, bool renotification) {
static retvalue notificator_enqueue(struct notificator *n, struct target *target, const char *name, /*@null@*/const char *version, /*@null@*/const char *oldversion, /*@null@*/const char *control, /*@null@*/const char *oldcontrol, /*@null@*/const struct strlist *filekeys, /*@null@*/const struct strlist *oldfilekeys, bool renotification, /*@null@*/const char *causingrule, /*@null@*/ const char *suitefrom) {
size_t count, i;
char **arguments;
const char *action = NULL;
......@@ -891,6 +905,33 @@ static retvalue notificator_enqueue(struct notificator *n, struct target *target
}
} else
p->causingfile = NULL;
if( causingrule != NULL ) {
size_t j;
p->causingrule = strdup(causingrule);
if( FAILEDTOALLOC(p->causingrule) ) {
for( j = 0 ; j < count ; j++ )
free(arguments[j]);
free(arguments);
free(p->causingfile);
free(p);
return RET_ERROR_OOM;
}
} else
p->causingrule = NULL;
if( suitefrom != NULL ) {
size_t j;
p->suitefrom = strdup(suitefrom);
if( FAILEDTOALLOC(p->suitefrom) ) {
for( j = 0 ; j < count ; j++ )
free(arguments[j]);
free(arguments);
free(p->causingfile);
free(p->causingrule);
free(p);
return RET_ERROR_OOM;
}
} else
p->suitefrom = NULL;
p->arguments = arguments;
p->next = NULL;
p->child = 0;
......@@ -1061,7 +1102,7 @@ bool logger_isprepared(/*@null@*/const struct logger *logger) {
return true;
}
void logger_log(struct logger *log,struct target *target,const char *name,const char *version,const char *oldversion,const char *control,const char *oldcontrol,const struct strlist *filekeys, const struct strlist *oldfilekeys) {
void logger_log(struct logger *log,struct target *target,const char *name,const char *version,const char *oldversion,const char *control,const char *oldcontrol,const struct strlist *filekeys, const struct strlist *oldfilekeys, const char *causingrule, const char *suitefrom) {
size_t i;
assert( name != NULL );
......@@ -1080,7 +1121,8 @@ void logger_log(struct logger *log,struct target *target,const char *name,const
notificator_enqueue(&log->notificators[i], target,
name, version, oldversion,
control, oldcontrol,
filekeys, oldfilekeys, false);
filekeys, oldfilekeys, false,
causingrule, suitefrom);
}
}
......@@ -1131,7 +1173,8 @@ retvalue logger_reruninfo(struct logger *logger,struct target *target,const char
r = notificator_enqueue(&logger->notificators[i], target,
name, version, NULL,
control, NULL,
filekeys, NULL, true);
filekeys, NULL, true,
NULL, NULL);
RET_UPDATE(result,r);
}
return result;
......
......@@ -26,7 +26,7 @@ bool logger_isprepared(/*@null@*/const struct logger *logger);
void logger_logchanges(struct logger *,const char *codename,const char *name,const char *version,const char *data,const char *safefilename,/*@null@*/const char *changesfilekey);
void logger_log(struct logger *,struct target *,const char *name,/*@null@*/const char *version,/*@null@*/const char *oldversion,/*@null@*/const char *control,/*@null@*/const char *oldcontrol,/*@null@*/const struct strlist *filekeys,/*@null@*/const struct strlist *oldfilekeys);
void logger_log(struct logger *,struct target *,const char *name,/*@null@*/const char *version,/*@null@*/const char *oldversion,/*@null@*/const char *control,/*@null@*/const char *oldcontrol,/*@null@*/const struct strlist *filekeys,/*@null@*/const struct strlist *oldfilekeys, /*@null@*/const char *causingrule, /*@null@*/const char *suitefrom);
bool logger_rerun_needs_target(const struct logger *, const struct target *);
retvalue logger_reruninfo(struct logger *,struct target *,const char *name,const char *version,const char *control,/*@null@*/const struct strlist *filekeys);
......
......@@ -753,6 +753,13 @@ static retvalue pull_search(/*@null@*/FILE *out,struct database *database,struct
return result;
}
static void pull_from_callback(void *privdata, const char **rule_p, const char **from_p) {
struct pull_source *source = privdata;
*rule_p = source->rule->name;
*from_p = source->rule->from;
}
static retvalue pull_install(struct database *database, struct pull_distribution *distribution) {
retvalue result,r;
struct pull_target *u;
......@@ -763,7 +770,8 @@ static retvalue pull_install(struct database *database, struct pull_distribution
for( u=distribution->targets ; u != NULL ; u=u->next ) {
r = upgradelist_install(u->upgradelist,
distribution->distribution->logger,
database, u->ignoredelete);
database, u->ignoredelete,
pull_from_callback);
RET_UPDATE(distribution->distribution->status, r);
RET_UPDATE(result,r);
upgradelist_free(u->upgradelist);
......
......@@ -239,7 +239,8 @@ retvalue target_removereadpackage(struct target *target, struct logger *logger,
logger_log(logger, target, name,
NULL, oldpversion,
NULL, oldcontrol,
NULL, &files);
NULL, &files,
NULL, NULL);
r = references_delete(database, target->identifier, &files,
NULL);
RET_UPDATE(result, r);
......@@ -321,7 +322,8 @@ retvalue target_removepackage_by_cursor(struct target_cursor *tc, struct logger
logger_log(logger, target, name,
NULL, oldpversion,
NULL, control,
NULL, &files);
NULL, &files,
NULL, NULL);
r = references_delete(database, target->identifier, &files,
NULL);
RET_UPDATE(result, r);
......@@ -340,7 +342,8 @@ static retvalue addpackages(struct target *target, struct database *database,
/*@null@*/struct logger *logger,
/*@null@*/struct trackingdata *trackingdata,
architecture_t architecture,
/*@null@*//*@only@*/char *oldsource,/*@null@*//*@only@*/char *oldsversion) {
/*@null@*//*@only@*/char *oldsource,/*@null@*//*@only@*/char *oldsversion,
/*@null@*/const char *causingrule, /*@null@*/const char *suitefrom) {
retvalue result,r;
struct table *table = target->packages;
......@@ -385,7 +388,7 @@ static retvalue addpackages(struct target *target, struct database *database,
logger_log(logger, target, packagename,
version, oldversion,
controlchunk, oldcontrolchunk,
files, oldfiles);
files, oldfiles, causingrule, suitefrom);
r = trackingdata_insert(trackingdata, filetype, files,
oldsource, oldsversion, oldfiles, database);
......@@ -403,7 +406,7 @@ static retvalue addpackages(struct target *target, struct database *database,
return result;
}
retvalue target_addpackage(struct target *target, struct logger *logger, struct database *database, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, struct trackingdata *trackingdata, enum filetype filetype) {
retvalue target_addpackage(struct target *target, struct logger *logger, struct database *database, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, struct trackingdata *trackingdata, enum filetype filetype, const char *causingrule, const char *suitefrom) {
struct strlist oldfilekeys,*ofk;
char *oldcontrol,*oldsource,*oldsversion;
char *oldpversion;
......@@ -487,7 +490,8 @@ retvalue target_addpackage(struct target *target, struct logger *logger, struct
version, oldpversion,
filekeys, ofk,
logger,
trackingdata, filetype, oldsource, oldsversion);
trackingdata, filetype, oldsource, oldsversion,
causingrule, suitefrom);
if( RET_IS_OK(r) ) {
target->wasmodified = true;
}
......
......@@ -141,7 +141,7 @@ 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 *, struct database *, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, /*@null@*/struct trackingdata *, enum filetype);
retvalue target_addpackage(struct target *, /*@null@*/struct logger *, struct database *, const char *name, const char *version, const char *control, const struct strlist *filekeys, bool downgrade, /*@null@*/struct trackingdata *, enum filetype, /*@null@*/const char *causingrule, /*@null@*/const char *suitefrom);
retvalue target_checkaddpackage(struct target *target, const char *name, const char *version, bool tracking, bool permitnewerold);
retvalue target_removepackage(struct target *, /*@null@*/struct logger *, struct database *, const char *name, struct trackingdata *);
/* like target_removepackage, but do not read control data yourself but use available */
......
......@@ -1609,6 +1609,13 @@ static retvalue updates_enqueue(struct downloadcache *cache,struct database *dat
* (missing files should have been downloaded first) *
****************************************************************************/
static void updates_from_callback(void *privdata, const char **rule_p, const char **from_p) {
struct update_index_connector *uindex = privdata;
*from_p = uindex->origin->suite_from;
*rule_p = uindex->origin->pattern->name;
}
static retvalue updates_install(struct database *database, struct update_distribution *distribution) {
retvalue result,r;
struct update_target *u;
......@@ -1622,7 +1629,7 @@ static retvalue updates_install(struct database *database, struct update_distrib
r = upgradelist_install(u->upgradelist,
distribution->distribution->logger,
database,
u->ignoredelete);
u->ignoredelete, updates_from_callback);
RET_UPDATE(distribution->distribution->status, r);
if( RET_WAS_ERROR(r) )
u->incomplete = true;
......
......@@ -591,7 +591,7 @@ retvalue upgradelist_predelete(struct upgradelist *upgrade, struct logger *logge
return result;
}
retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger, struct database *database, bool ignoredelete){
retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger, struct database *database, bool ignoredelete, void (*callback)(void *, const char **, const char **)){
struct package_data *pkg;
retvalue result,r;
......@@ -609,6 +609,10 @@ retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger,
pkg->new_origfiles.checksums);
if( ! RET_WAS_ERROR(r) ) {
/* upgrade (or possibly downgrade) */
const char *causingrule = NULL,
*suitefrom = NULL;
callback(pkg->privdata, &causingrule, &suitefrom);
// TODO: trackingdata?
if( interrupted() )
r = RET_ERROR_INTERRUPTED;
......@@ -619,7 +623,8 @@ retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger,
pkg->new_version,
pkg->new_control,
&pkg->new_filekeys, true,
NULL, pkg->architecture);
NULL, pkg->architecture,
causingrule, suitefrom);
}
RET_UPDATE(result,r);
if( RET_WAS_ERROR(r) )
......
......@@ -36,7 +36,7 @@ typedef retvalue enqueueaction(void *, struct database *, const struct checksums
/* request all wanted files refering the methods given before */
retvalue upgradelist_enqueue(struct upgradelist *, enqueueaction *, void *, struct database *);
retvalue upgradelist_install(struct upgradelist *upgrade, /*@null@*/struct logger *, struct database *, bool ignoredelete);
retvalue upgradelist_install(struct upgradelist *upgrade, /*@null@*/struct logger *, struct database *, bool ignoredelete, void (*callback)(void *, const char **, const char **));
/* remove all packages that would either be removed or upgraded by an upgrade */
retvalue upgradelist_predelete(struct upgradelist *, /*@null@*/struct logger *, struct database *);
......
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