Commit 833de6bf authored by Bernhard Link's avatar Bernhard Link

add ReadOnly option for conf/distributions

parent e0b8bafa
2009-02-13
* add ReadOnly option for conf/distributions
2009-02-08
* processincoming support includebyhand and includelogs tracking
options
......
reprepro (3.8.2-0) UNRELEASED; urgency=low
* add conf/distribution ReadOnly: option (Closes: 515030)
-- Bernhard R. Link <brlink@debian.org> Fri, 13 Feb 2009 21:37:43 +0100
reprepro (3.8.1-1) experimental; urgency=low
* fix typo making copyfilter unuseable (Closes: 512586)
......
......@@ -129,7 +129,8 @@ static retvalue createtargets(struct distribution *distribution) {
r = target_initialize_binary(
distribution->codename,
c, a,
&distribution->deb, &t);
&distribution->deb,
distribution->readonly, &t);
if( RET_IS_OK(r) ) {
if( last != NULL ) {
last->next = t;
......@@ -144,7 +145,8 @@ static retvalue createtargets(struct distribution *distribution) {
r = target_initialize_ubinary(
distribution->codename,
c, a,
&distribution->udeb, &t);
&distribution->udeb,
distribution->readonly, &t);
if( RET_IS_OK(r) ) {
if( last != NULL ) {
last->next = t;
......@@ -163,7 +165,8 @@ static retvalue createtargets(struct distribution *distribution) {
* the .changes files started with this...) */
if( has_source ) {
r = target_initialize_source(distribution->codename,
c, &distribution->dsc, &t);
c, &distribution->dsc,
distribution->readonly, &t);
if( last != NULL ) {
last->next = t;
} else {
......@@ -322,6 +325,7 @@ CFallSETPROC(distribution, suite)
CFallSETPROC(distribution, version)
CFallSETPROC(distribution, origin)
CFallSETPROC(distribution, notautomatic)
CFtruthSETPROC2(distribution, readonly, readonly)
CFallSETPROC(distribution, label)
CFallSETPROC(distribution, description)
CFkeySETPROC(distribution, signwith)
......@@ -378,6 +382,7 @@ static const struct configfield distributionconfigfields[] = {
CF("NotAutomatic", distribution, notautomatic),
CF("Origin", distribution, origin),
CF("Pull", distribution, pulls),
CF("ReadOnly", distribution, readonly),
CF("SignWith", distribution, signwith),
CF("Suite", distribution, suite),
CF("Tracking", distribution, Tracking),
......@@ -545,7 +550,7 @@ struct target *distribution_getpart(const struct distribution *distribution, com
}
/* mark all distributions matching one of the first argc argv */
retvalue distribution_match(struct distribution *alldistributions, int argc, const char *argv[], bool lookedat) {
retvalue distribution_match(struct distribution *alldistributions, int argc, const char *argv[], bool lookedat, bool allowreadonly) {
struct distribution *d;
bool found[argc], unusable_as_suite[argc];
struct distribution *has_suite[argc];
......@@ -555,6 +560,8 @@ retvalue distribution_match(struct distribution *alldistributions, int argc, con
if( argc <= 0 ) {
for( d = alldistributions ; d != NULL ; d = d->next ) {
if( !allowreadonly && d->readonly )
continue;
d->selected = true;
d->lookedat = lookedat;
}
......@@ -572,6 +579,12 @@ retvalue distribution_match(struct distribution *alldistributions, int argc, con
d->selected = true;
if( lookedat )
d->lookedat = lookedat;
if( !allowreadonly && d->readonly ) {
fprintf(stderr,
"Error: %s is readonly, so operation not allowed!\n",
d->codename);
return RET_ERROR;
}
} else if( d->suite != NULL &&
strcmp(argv[i], d->suite) == 0 ) {
if( has_suite[i] != NULL )
......@@ -583,6 +596,12 @@ retvalue distribution_match(struct distribution *alldistributions, int argc, con
for( i = 0 ; i < argc ; i++ ) {
if( !found[i] ) {
if( has_suite[i] != NULL && !unusable_as_suite[i] ) {
if( !allowreadonly && has_suite[i]->readonly ) {
fprintf(stderr,
"Error: %s is readonly, so operation not allowed!\n",
has_suite[i]->codename);
return RET_ERROR;
}
has_suite[i]->selected = true;
if( lookedat )
has_suite[i]->lookedat = lookedat;
......@@ -691,6 +710,12 @@ static retvalue export(struct distribution *distribution, struct database *datab
assert( distribution != NULL );
if( distribution->readonly ) {
fprintf(stderr, "Error: trying to re-export read-only distribution %s\n",
distribution->codename);
return RET_ERROR;
}
r = release_init(&release, database,
distribution->codename, distribution->suite,
distribution->fakecomponentprefix);
......@@ -975,6 +1000,12 @@ void distribution_unloaduploaders(struct distribution *distribution) {
retvalue distribution_prepareforwriting(struct distribution *distribution) {
retvalue r;
if( distribution->readonly ) {
fprintf(stderr, "Error: distribution %s is read-only. Current operation not possible because it needs write access.\n",
distribution->codename);
return RET_ERROR;
}
if( distribution->logger != NULL ) {
r = logger_prepare(distribution->logger);
if( RET_WAS_ERROR(r) )
......@@ -991,6 +1022,12 @@ retvalue distribution_remove_packages(struct distribution *distribution, struct
struct target_cursor iterator;
const char *package, *control;
if( distribution->readonly ) {
fprintf(stderr, "Error: trying to delete packages in read-only distribution %s.\n",
distribution->codename);
return RET_ERROR;
}
result = RET_NOTHING;
for( t = distribution->targets ; t != NULL ; t = t->next ) {
if( !target_matches(t, component, architecture, packagetype) )
......
......@@ -96,6 +96,8 @@ struct distribution {
bool lookedat;
/* false: not requested, do not handle at all */
bool selected;
/* forbid all writing operations and exports if true */
bool readonly;
};
retvalue distribution_get(struct distribution *all, const char *name, bool lookedat, /*@out@*/struct distribution **);
......@@ -132,7 +134,7 @@ retvalue distribution_snapshot(struct distribution *distribution, struct databas
retvalue distribution_readall(/*@out@*/struct distribution **distributions);
/* mark all dists from <conf> fitting in the filter given in <argc,argv> */
retvalue distribution_match(struct distribution *alldistributions, int argc, const char *argv[], bool lookedat);
retvalue distribution_match(struct distribution *alldistributions, int argc, const char *argv[], bool lookedat, bool readonly);
/* get a pointer to the apropiate part of the linked list */
struct distribution *distribution_find(struct distribution *distributions, const char *name);
......
......@@ -1050,6 +1050,10 @@ So
causes the generation of a
.B Valid-Until:
header in Release files that points 42 days into the future.
.TP
.B ReadOnly
Disallow all modifications of this distribution or its directory
in \fBdists/\fP\fIcodename\fP (with the exception of snapshot subdirectories).
.SS conf/updates
.TP
.B Name
......
This diff is collapsed.
......@@ -59,7 +59,7 @@ static char *calc_identifier(const char *codename, component_t component, archit
}
static retvalue target_initialize(const char *codename, component_t component, architecture_t architecture, packagetype_t packagetype, get_version getversion, get_installdata getinstalldata, get_architecture getarchitecture, get_filekeys getfilekeys, get_checksums getchecksums, get_sourceandversion getsourceandversion, do_reoverride doreoverride, do_retrack doretrack, /*@null@*//*@only@*/char *directory, /*@dependent@*/const struct exportmode *exportmode, /*@out@*/struct target **d) {
static retvalue target_initialize(const char *codename, component_t component, architecture_t architecture, packagetype_t packagetype, get_version getversion, get_installdata getinstalldata, get_architecture getarchitecture, get_filekeys getfilekeys, get_checksums getchecksums, get_sourceandversion getsourceandversion, do_reoverride doreoverride, do_retrack doretrack, /*@null@*//*@only@*/char *directory, /*@dependent@*/const struct exportmode *exportmode, bool readonly, /*@out@*/struct target **d) {
struct target *t;
assert(exportmode != NULL);
......@@ -93,11 +93,12 @@ static retvalue target_initialize(const char *codename, component_t component, a
t->getsourceandversion = getsourceandversion;
t->doreoverride = doreoverride;
t->doretrack = doretrack;
t->readonly = readonly;
*d = t;
return RET_OK;
}
retvalue target_initialize_ubinary(const char *codename, component_t component, architecture_t architecture, const struct exportmode *exportmode, struct target **target) {
retvalue target_initialize_ubinary(const char *codename, component_t component, architecture_t architecture, const struct exportmode *exportmode, bool readonly, struct target **target) {
return target_initialize(codename, component, architecture, pt_udeb,
binaries_getversion,
binaries_getinstalldata,
......@@ -108,9 +109,9 @@ retvalue target_initialize_ubinary(const char *codename, component_t component,
mprintf("%s/debian-installer/binary-%s",
atoms_components[component],
atoms_architectures[architecture]),
exportmode, target);
exportmode, readonly, target);
}
retvalue target_initialize_binary(const char *codename, component_t component, architecture_t architecture, const struct exportmode *exportmode, struct target **target) {
retvalue target_initialize_binary(const char *codename, component_t component, architecture_t architecture, const struct exportmode *exportmode, bool readonly, struct target **target) {
return target_initialize(codename, component, architecture, pt_deb,
binaries_getversion,
binaries_getinstalldata,
......@@ -121,10 +122,10 @@ retvalue target_initialize_binary(const char *codename, component_t component, a
mprintf("%s/binary-%s",
atoms_components[component],
atoms_architectures[architecture]),
exportmode, target);
exportmode, readonly, target);
}
retvalue target_initialize_source(const char *codename, component_t component, const struct exportmode *exportmode, struct target **target) {
retvalue target_initialize_source(const char *codename, component_t component, const struct exportmode *exportmode, bool readonly, struct target **target) {
return target_initialize(codename, component, architecture_source, pt_dsc,
sources_getversion,
sources_getinstalldata,
......@@ -133,7 +134,7 @@ retvalue target_initialize_source(const char *codename, component_t component, c
sources_getsourceandversion,
sources_doreoverride, sources_retrack,
mprintf("%s/source", atoms_components[component]),
exportmode, target);
exportmode, readonly, target);
}
retvalue target_free(struct target *target) {
......@@ -160,6 +161,12 @@ retvalue target_free(struct target *target) {
retvalue target_initpackagesdb(struct target *target, struct database *database, bool readonly) {
retvalue r;
if( !readonly && target->readonly ) {
fprintf(stderr, "Error trying to open '%s' read-write in read-only distribution '%s'\n",
target->identifier, target->codename);
return RET_ERROR;
}
assert( target->packages == NULL );
if( target->packages != NULL )
return RET_OK;
......
......@@ -63,11 +63,13 @@ struct target {
struct target *next;
/* is initialized as soon as needed: */
struct table *packages;
/* do not allow write operations */
bool readonly;
};
retvalue target_initialize_ubinary(const char *codename, component_t, architecture_t, /*@dependent@*/const struct exportmode *, /*@out@*/struct target **);
retvalue target_initialize_binary(const char *codename, component_t, architecture_t, /*@dependent@*/const struct exportmode *, /*@out@*/struct target **);
retvalue target_initialize_source(const char *codename, component_t, /*@dependent@*/const struct exportmode *, /*@out@*/struct target **);
retvalue target_initialize_ubinary(const char *codename, component_t, architecture_t, /*@dependent@*/const struct exportmode *, bool readonly, /*@out@*/struct target **);
retvalue target_initialize_binary(const char *codename, component_t, architecture_t, /*@dependent@*/const struct exportmode *, bool readonly, /*@out@*/struct target **);
retvalue target_initialize_source(const char *codename, component_t, /*@dependent@*/const struct exportmode *, bool readonly, /*@out@*/struct target **);
retvalue target_free(struct target *target);
retvalue target_export(struct target *target, struct database *, bool onlyneeded, bool snapshot, struct release *release);
......
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