Commit 7e1af8bf authored by Bernhard Link's avatar Bernhard Link

harmonize --export handling (plus some manpage typos fixed)

parent 6f739dad
2006-04-28 Bernhard R. Link <brlink@debian.org>
* rewrite decision for exporting distributions a bit:
export all distributions that did not have errors by default
(it did not export anything when an error occured)
added new --export option with possible values
never, changed, normal and forced.
2006-04-25 Bernhard R. Link <brlink@debian.org>
* do not export indices if all upgrades were skipped
......
Updates since 0.8.2:
- added --export= option and harmonized exporting of
distributions. (Now every distribution processed
without errors is exported by default, with options
for always, never or only export it when changed)
Updates since 0.8.1:
- mark process list files and only skip those not marked
as processed instead those not newly downloaded.
......
......@@ -476,6 +476,7 @@ retvalue deb_addprepared(const struct debpackage *pkg, const char *dbdir,referen
}
RET_UPDATE(result,r);
}
RET_UPDATE(distribution->status, result);
// deb_free(pkg);
......
......@@ -443,6 +443,7 @@ retvalue dsc_addprepared(const struct dscpackage *pkg,const char *dbdir,referenc
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
RET_UPDATE(distribution->status, r);
return r;
}
......
......@@ -314,12 +314,12 @@ NULL};
return ret;
}
ret = createtargets(r);
if( RET_WAS_ERROR(ret) ) {
(void)distribution_free(r);
return ret;
}
r->status = RET_NOTHING;
*distribution = r;
return RET_OK;
......@@ -330,7 +330,7 @@ NULL};
}
/* call <action> for each part of <distribution>. */
retvalue distribution_foreach_part(const struct distribution *distribution,const char *component,const char *architecture,const char *packagetype,distribution_each_action action,void *data,int force) {
retvalue distribution_foreach_part(struct distribution *distribution,const char *component,const char *architecture,const char *packagetype,distribution_each_action action,void *data,int force) {
retvalue result,r;
struct target *t;
......@@ -342,7 +342,7 @@ retvalue distribution_foreach_part(const struct distribution *distribution,const
continue;
if( packagetype != NULL && strcmp(packagetype,t->packagetype) != 0 )
continue;
r = action(data,t);
r = action(data,t,distribution);
RET_UPDATE(result,r);
if( RET_WAS_ERROR(r) && force <= 0 )
return result;
......@@ -466,7 +466,7 @@ retvalue distribution_get(struct distribution **distribution,const char *confdir
return RET_OK;
}
retvalue distribution_export(struct distribution *distribution,
static retvalue export(struct distribution *distribution,
const char *confdir, const char *dbdir, const char *distdir,
bool_t onlyneeded) {
struct target *target;
......@@ -504,9 +504,15 @@ retvalue distribution_export(struct distribution *distribution,
r = release_write(release,distribution,onlyneeded);
RET_UPDATE(result,r);
}
if( RET_IS_OK(result) )
distribution->status = RET_NOTHING;
return result;
}
retvalue distribution_fullexport(struct distribution *distribution,const char *confdir,const char *dbdir,const char *distdir) {
return export(distribution,confdir,dbdir,distdir,FALSE);
}
retvalue distribution_freelist(struct distribution *distributions) {
retvalue result,r;
......@@ -520,20 +526,121 @@ retvalue distribution_freelist(struct distribution *distributions) {
return result;
}
retvalue distribution_exportandfreelist(struct distribution *distributions,
retvalue distribution_exportandfreelist(enum exportwhen when,
struct distribution *distributions,
const char *confdir,const char *dbdir, const char *distdir) {
retvalue result,r;
bool_t todo = FALSE;
struct distribution *d;
if( when == EXPORT_NEVER ) {
if( verbose > 10 )
fprintf(stderr, "Not exporting anything as --export=never specified\n");
return distribution_freelist(distributions);
}
for( d=distributions; d != NULL; d = d->next ) {
if( RET_IS_OK(d->status) ||
( d->status == RET_NOTHING && when != EXPORT_CHANGED) ||
when == EXPORT_FORCE) {
todo = TRUE;
}
}
if( (verbose >= 0 && todo) || verbose >= 10 )
fprintf(stderr,"Exporting indices...\n");
result = RET_NOTHING;
while( distributions != NULL ) {
struct distribution *d = distributions->next;
r = distribution_export(distributions,confdir,dbdir,distdir,TRUE);
RET_UPDATE(result,r);
d = distributions;
distributions = d->next;
if( RET_WAS_ERROR(d->status) && when != EXPORT_FORCE ) {
if( verbose >= 10 )
fprintf(stderr,
" Not exporting %s because there have been errors and no --export=force.\n",
d->codename);
} else if( d->status==RET_NOTHING && when==EXPORT_CHANGED ) {
struct target *t;
if( verbose >= 10 )
fprintf(stderr,
" Not exporting %s because of no recorded changes and --export=changed.\n",
d->codename);
/* some paranoid check */
for( t = d->targets ; t != NULL ; t = t->next ) {
if( t->wasmodified ) {
fprintf(stderr,
"A paranoid check found distribution %s would not have been exported,\n"
"despite having parts that are marked changed by deeper code.\n"
"Please report this and how you got this message as bugreport. Thanks.\n"
"Doing a export despite --export=changed....\n",
d->codename);
r = export(d,confdir,dbdir,distdir,TRUE);
RET_UPDATE(result,r);
break;
}
}
} else {
assert( RET_IS_OK(d->status) ||
( d->status == RET_NOTHING &&
when != EXPORT_CHANGED) ||
when == EXPORT_FORCE);
r = export(d,confdir,dbdir,distdir,TRUE);
RET_UPDATE(result,r);
}
r = distribution_free(distributions);
r = distribution_free(d);
RET_ENDUPDATE(result,r);
distributions = d;
}
return result;
}
retvalue distribution_export(enum exportwhen when, struct distribution *distribution,const char *confdir,const char *dbdir,const char *distdir) {
if( when == EXPORT_NEVER ) {
if( verbose >= 10 )
fprintf(stderr,
"Not exporting %s because of --export=never.\n"
"Make sure to run a full export soon.\n", distribution->codename);
return RET_NOTHING;
}
if( when != EXPORT_FORCE && RET_WAS_ERROR(distribution->status) ) {
if( verbose >= 10 )
fprintf(stderr,
"Not exporting %s because there have been errors and no --export=force.\n"
"Make sure to run a full export soon.\n", distribution->codename);
return RET_NOTHING;
}
if( when == EXPORT_CHANGED && distribution->status == RET_NOTHING ) {
struct target *t;
if( verbose >= 10 )
fprintf(stderr,
"Not exporting %s because of no recorded changes and --export=changed.\n",
distribution->codename);
/* some paranoid check */
for( t = distribution->targets ; t != NULL ; t = t->next ) {
if( t->wasmodified ) {
fprintf(stderr,
"A paranoid check found distribution %s would not have been exported,\n"
"despite having parts that are marked changed by deeper code.\n"
"Please report this and how you got this message as bugreport. Thanks.\n"
"Doing a export despite --export=changed....\n",
distribution->codename);
return export(distribution,
confdir,dbdir,distdir,TRUE);
break;
}
}
return RET_NOTHING;
}
if( verbose >= 0 )
fprintf(stderr, "Exporting indices...\n");
return export(distribution,confdir,dbdir,distdir,TRUE);
}
......@@ -47,25 +47,32 @@ struct distribution {
} trackingoptions;
/* A list of all targets contained in the distribution*/
struct target *targets;
/* RET_NOTHING: do not export with EXPORT_CHANGED, EXPORT_NEVER
* RET_OK: export unless EXPORT_NEVER
* RET_ERROR_*: only export with EXPORT_FORCE */
retvalue status;
};
retvalue distribution_get(/*@out@*/struct distribution **distribution,const char *conf,const char *name);
retvalue distribution_free(/*@only@*/struct distribution *distribution);
typedef retvalue distribution_each_action(void *data, struct target *t);
typedef retvalue distribution_each_action(void *data, struct target *t, struct distribution *d);
/* call <action> for each part of <distribution>, if component or architecture is
* not NULL or "all", only do those parts */
retvalue distribution_foreach_part(const struct distribution *distribution,/*@null@*/const char *component,/*@null@*/const char *architecture,/*@null@*/const char *packagetype,distribution_each_action action,/*@null@*/void *data,int force);
retvalue distribution_foreach_part(struct distribution *distribution,/*@null@*/const char *component,/*@null@*/const char *architecture,/*@null@*/const char *packagetype,distribution_each_action action,/*@null@*/void *data,int force);
/*@dependent@*/struct target *distribution_getpart(const struct distribution *distribution,const char *component,const char *architecture,const char *packagetype);
retvalue distribution_export(struct distribution *distribution,const char *confdir,const char *dbdir,const char *distdir,bool_t onlyneeded);
retvalue distribution_fullexport(struct distribution *distribution,const char *confdir,const char *dbdir,const char *distdir);
enum exportwhen {EXPORT_NEVER, EXPORT_CHANGED, EXPORT_NORMAL, EXPORT_FORCE };
retvalue distribution_export(enum exportwhen when, struct distribution *distribution,const char *confdir,const char *dbdir,const char *distdir);
/* get all dists from <conf> fitting in the filter given in <argc,argv> */
retvalue distribution_getmatched(const char *conf,int argc,const char *argv[],/*@out@*/struct distribution **distributions);
retvalue distribution_freelist(/*@only@*/struct distribution *distributions);
retvalue distribution_exportandfreelist(/*@only@*/struct distribution *distributions,const char *confdir, const char *dbdir, const char *distdir);
retvalue distribution_exportandfreelist(enum exportwhen when, /*@only@*/struct distribution *distributions,const char *confdir, const char *dbdir, const char *distdir);
#endif
......@@ -65,7 +65,7 @@ If none is given, \fIbasedir\fP\fB/dists\fP is used.
.B Note:
apt has
.B dists
hardcoded in it, so this is mostly only useful for testing or when your webserver
hard-coded in it, so this is mostly only useful for testing or when your webserver
pretends another directory structure than your physical layout.
.B Warning:
......@@ -125,6 +125,34 @@ Overrides the section of inclusions. (Also override possible override files)
.TP
.B \-P, \-\-priority \fIpriority\fP
Overrides the priority of inclusions. (Also override possible override files)
.TP
.BR \-\-export= ( never | changed | normal | force )
This option specify weather and how the high level actions
(e.g. install, update, delete)
should export the index files of the distributions they work with.
.TP
.BR \-\-export=normal " (default)"
In this mode every distribution the action handled without error
will be exported.
.br
\fINote\fP that only missing files and files whose intended content changed
between before and after the action will be written.
To get a guaranteed current export, use the \fBexport\fP action.
.TP
.BR \-\-export=changed
Like \fBnormal\fP but do not look for missing files in distributions where
nothing changed.
.TP
.BR \-\-export=force
Like \fBnormal\rP, but exporting also happens for distributions where
some error occurred.
.TP
.BR \-\-export=never
No index files are exported. You will have to call \fBexport\fP later.
.br
\fINote\fP that you most likely additionally need the \fB\-\-keepunreferenced\fP
option, if you do want some of the files pointed to by the untouched index
files to vanish.
.TP
.B \-\-ignore=\fIwhat\fP
Ignore errors of type \fIwhat\fP. See the section \fBERROR IGNORING\fP
......@@ -208,7 +236,7 @@ matching the given condition.
will e.g. find all .deb Packages with Source blub. (Except those also specifying a version
number with its Source, as binary and source version differ).
.TP
.B remove \fIcodename\fP \fIpackagename\fP
.B remove \fIcodename\fP \fIpackage name\fP
same as list, but remove instead of list.
.TP
.BR update " [ " \fIcodenames\fP " ]"
......@@ -455,7 +483,7 @@ for rules which component packages are included into
by default. This will also be copied into the Release files.
.TP
.B UDebComponents
Components with a debian\-installer subhierachy containing .udebs.
Components with a debian\-installer subhierarchy containing .udebs.
(E.g. simply "main")
.TP
.B Update
......@@ -479,7 +507,7 @@ when including .deb files.
.TP
.B UDebOverride
When this field is present, it describes the override file used
when including .ddeb files.
when including .deb files.
.TP
.B DscOverride
When this field is present, it describes the override file used
......@@ -575,7 +603,7 @@ The components to update. Each item can be either the name
of a component or a pair of a upstream component and a local
component separated with ">". (e.g. "main>all contrib>all non\-free>notall")
Items with a local part are ignored. If no items are there
all from the updated distribution are taken. (Use some nonexisting
all from the updated distribution are taken. (Use some non existing
like "none", if you want none).
.TP
.B Architectures
......@@ -644,7 +672,7 @@ not when imported while updating from an external source.
The format should resemble the extended ftp\-archive format,
to be specific it is:
.B \fIpackagename\fP \fIfieldname\fP \fInewvalue\fP
.B \fIpackagename\fP \fIfield name\fP \fInew value\fP
For example:
.br
......@@ -658,9 +686,9 @@ For example:
All fields of a given package will be replaced by the new value specified
in the override file.
While the fieldname is compared case-insensitive, it is copied in
While the field name is compared case-insensitive, it is copied in
exactly the form in the override file there.
(Thus I suggest to keep to the exact case it is normaly found in
(Thus I suggest to keep to the exact case it is normally found in
index files in case some other tool confuses them.)
More than copied is the Section header (unless \fB\-S\fP is supplied),
which is also used to guess the component (unless \fB\-C\fP is there).
......@@ -696,7 +724,7 @@ and versions.
Thus allowing all 7-bit characters but slashes (as they would
break the file storage) and things syntactically active
(spaces, underscores in filenames in .changes files, opening
parantheses in source names of binary packages).
parentheses in source names of binary packages).
To allow some 8-bit chars additionally, use \fB8bit\fP additionally.
.TP
.B 8bit \fR(more insecure)
......@@ -721,7 +749,7 @@ defined meaning.
.TP
.B missingfield \fR(save to ignore)
Ignore missing fields in a .changes file that are only checked but
not procesed.
not processed.
Those include: Format, Date, Urgency, Maintainer, Description, Changes
.TP
.B missingfile \fR(might be insecure)
......@@ -743,11 +771,11 @@ Allow gpg-keys to be specified with less than 8 hexdigits of their fingerprint.
.TP
.B spaceonlyline \fR(I hope you know what you do)
Allow lines containing only (but non-zero) spaces. As these
do not seperate chunks as thus will cause reprepro to behave
do not separate chunks as thus will cause reprepro to behave
unexpected, they cause error messages by default.
.TP
.B surprisingarch
No longer rejct a .changes file containing files for a
No longer reject a .changes file containing files for a
architecture not listed in the Architecture-header within it.
.TP
.B unknownfield \fR(for forward compatibility)
......@@ -755,7 +783,7 @@ Ignore unknown fields in the config files, instead of refusing to run
then.
.TP
.B unusedarch \fR(save to ignore)
No longer rejct a .changes file containing no files for any of the
No longer reject a .changes file containing no files for any of the
architectures listed in the Architecture-header within it.
.TP
.B wrongdistribution \fR(save to ignore)
......@@ -785,7 +813,7 @@ to end up there.
unlike in dak, non\-US and non\-us are different things...
.SH NOMENCLATURE
.B Codename
the primary identifier of a given distribution. This are normaly
the primary identifier of a given distribution. This are normally
things like \fBsarge\fP, \fBetch\fP or \fBsid\fP.
.TP
.B basename
......@@ -864,7 +892,7 @@ of a distribution, not only those some other update rule applies to.
.SH ENVIRONMENT VARIABLES
Environment variables are always overwritten by command line options,
but overwrite options set in the \fBoptions\fP file. (Even when the
options file is obiously parsed after the environment variables as
options file is obviously parsed after the environment variables as
the environment may determine the place of the options file).
.TP
.B REPREPRO_BASE_DIR
......@@ -889,11 +917,11 @@ some parts may still not use this notation.
.SH "WORK-AROUNDS TO COMMON PROBLEMS"
.TP
.B gpgme returned an impossible condition
With the woody version this normaly meant that there was no .gnupg
With the woody version this normally meant that there was no .gnupg
directory in $HOME, but it created one and reprepro succeeds when called
again with the same command.
Since sarge the problem sometimes shows up, too. But it is no longer
reproducible and it does not fix itself, neighter. Try running
reproducible and it does not fix itself, neither. Try running
\fBgpg \-\-verify \fP\fIfile-you-had-problems-with\fP manually as the
user reprepro is running and with the same $HOME. This alone might
fix the problem. It should not print any messages except perhaps
......@@ -923,7 +951,7 @@ call reprepro with \-\-ignore=missingfile (discouraged)
reprepro is sometimes a bit too timid of deleting stuff. When things
go wrong and there have been errors it sometimes just leaves everything
where it is.
To see what files reprepro rememberes to be in your pool directory but
To see what files reprepro remembers to be in your pool directory but
does not know anything needing them right know, you can use
.br
\fBreprepro dumpunreferenced\fP
......
......@@ -49,7 +49,7 @@ _reprepro()
--noonlyacceptsigned --noask-passphrase --skipold --noskipold --force'
options='-b -i --basedir --ignore --unignore --methoddir --distdir --dbdir\
--listdir --overridedir --confdir --section -S --priority -P --component -C\
--architecture -A --type -T'
--architecture -A --type -T --export'
i=1
prev=""
......@@ -80,7 +80,7 @@ _reprepro()
i=$((i+2))
;;
-i|--ignore|--unignore|--methoddir|--distdir|--dbdir|--listdir|--overridedir|--section|-S|--priority|-P|--component|-C|--architecture|-A|--type|-T)
-i|--ignore|--unignore|--methoddir|--distdir|--dbdir|--listdir|--overridedir|--section|-S|--priority|-P|--component|-C|--architecture|-A|--type|-T|--export)
prev="$cur"
i=$((i+2))
......@@ -129,6 +129,10 @@ _reprepro()
COMPREPLY=( $( compgen -W "$components" -- $cur ) )
return 0
;;
--export)
COMPREPLY=( $( compgen -W "never changed normal force" -- $cur ) )
return 0
;;
esac
fi
......
This diff is collapsed.
#!/bin/bash
set -e -v
set -e
WORKDIR="`pwd`/testdir"
......@@ -37,6 +37,9 @@ if ! [ -x "$REPREPRO" ] ; then
exit 1
fi
mkdir -p conf
cat > conf/options <<CONFEND
export changed
CONFEND
cat > conf/distributions <<CONFEND
Codename: test1
Architectures: abacus source
......@@ -62,6 +65,7 @@ DebOverride: binoverride
DscOverride: srcoverride
CONFEND
set -v
$HELPER "$REPREPRO" -b . export
test -f dists/test1/Release
test -f dists/test2/Release
......
......@@ -1477,6 +1477,7 @@ static retvalue updates_install(const char *dbdir,filesdb filesdb,references ref
if( u->nothingnew )
continue;
r = upgradelist_install(u->upgradelist,dbdir,filesdb,refs,force,u->ignoredelete,dereferencedfilekeys);
RET_UPDATE(distribution->distribution->status, r);
if( RET_WAS_ERROR(r) )
u->incomplete = TRUE;
RET_UPDATE(result,r);
......@@ -1922,7 +1923,7 @@ static retvalue singledistributionupdate(const char *dbdir,const char *methoddir
return result;
}
retvalue updates_iteratedupdate(const char *confdir,const char *dbdir,const char *distdir,const char *methoddir,filesdb filesdb,references refs,struct update_distribution *distributions,int force,bool_t nolistsdownload,bool_t skipold,struct strlist *dereferencedfilekeys) {
retvalue updates_iteratedupdate(const char *confdir,const char *dbdir,const char *distdir,const char *methoddir,filesdb filesdb,references refs,struct update_distribution *distributions,int force,bool_t nolistsdownload,bool_t skipold,struct strlist *dereferencedfilekeys, enum exportwhen export) {
retvalue result,r;
struct update_distribution *d;
......@@ -1947,11 +1948,10 @@ retvalue updates_iteratedupdate(const char *confdir,const char *dbdir,const char
fprintf(stderr,"WARNING: Updating does not update trackingdata. Trackingdata of %s will be outdated!\n",d->distribution->codename);
}
r = singledistributionupdate(dbdir,methoddir,filesdb,refs,d,force,nolistsdownload,skipold,dereferencedfilekeys);
RET_ENDUPDATE(d->distribution->status,r);
RET_UPDATE(result,r);
r = distribution_export(export,d->distribution,confdir,dbdir,distdir);
RET_UPDATE(result,r);
if( RET_IS_OK(r) ) {
r = distribution_export(d->distribution,confdir,dbdir,distdir,TRUE);
RET_UPDATE(result,r);
}
}
return result;
}
......@@ -11,6 +11,9 @@
#ifndef REPREPRO_RELEASE_H
#include "release.h"
#endif
#ifndef REPREPRO_DISTRIBUTION_H
#include "distribution.h"
#endif
#ifndef REPREPRO_STRLIST_H
#include "strlist.h"
#endif
......@@ -31,7 +34,7 @@ retvalue updates_calcindices(const char *listdir,const struct update_pattern *pa
retvalue updates_clearlists(const char *listdir,struct update_distribution *distributions);
retvalue updates_update(const char *dbdir,const char *methoddir,filesdb filesdb,references refs,struct update_distribution *distributions,int force,bool_t nolistsdownload,bool_t skipold,struct strlist *dereferencedfilekeys);
retvalue updates_iteratedupdate(const char *confdir,const char *dbdir,const char *distdir,const char *methoddir,filesdb filesdb,references refs,struct update_distribution *distributions,int force,bool_t nolistsdownload,bool_t skipold,struct strlist *dereferencedfilekeys);
retvalue updates_iteratedupdate(const char *confdir,const char *dbdir,const char *distdir,const char *methoddir,filesdb filesdb,references refs,struct update_distribution *distributions,int force,bool_t nolistsdownload,bool_t skipold,struct strlist *dereferencedfilekeys, enum exportwhen export);
retvalue updates_checkupdate(const char *dbdir,const char *methoddir,struct update_distribution *distributions,int force,bool_t nolistsdownload,bool_t skipold);
#endif
......@@ -484,6 +484,7 @@ retvalue upgradelist_install(struct upgradelist *upgrade,const char *dbdir,files
result = target_initpackagesdb(upgrade->target,dbdir);
if( RET_WAS_ERROR(result) )
return result;
result = RET_NOTHING;
for( pkg = upgrade->list ; pkg != NULL ; pkg = pkg->next ) {
if( pkg->version == pkg->new_version && !pkg->deleted ) {
r = files_expectfiles(files,&pkg->new_filekeys,
......
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