Commit f44dc78a authored by Bernhard Link's avatar Bernhard Link

add FakeComponentPrefix

parent 8020489c
......@@ -328,6 +328,7 @@ CFexportmodeSETPROC(distribution, dsc)
CFcheckuniqstrlistSETPROC(distribution, components, checkforcomponent)
CFcheckuniqstrlistSETPROC(distribution, architectures, checkforarchitecture)
CFcheckvalueSETPROC(distribution, codename, checkforcodename)
CFcheckvalueSETPROC(distribution, fakecomponentprefix, checkfordirectoryandidentifier)
CFUSETPROC(distribution, Contents) {
CFSETPROCVAR(distribution, d);
......@@ -356,6 +357,7 @@ static const struct configfield distributionconfigfields[] = {
CF("Description", distribution, description),
CF("DscIndices", distribution, dsc),
CF("DscOverride", distribution, dsc_override),
CF("FakeComponentPrefix", distribution, fakecomponentprefix),
CF("Label", distribution, label),
CF("Log", distribution, logger),
CF("NotAutomatic", distribution, notautomatic),
......@@ -705,7 +707,9 @@ static retvalue export(struct distribution *distribution, struct database *datab
assert( distribution != NULL );
r = release_init(&release, database, distribution->codename);
r = release_init(&release, database,
distribution->codename, distribution->suite,
distribution->fakecomponentprefix);
if( RET_WAS_ERROR(r) )
return r;
......
......@@ -46,6 +46,8 @@ struct distribution {
/*@null@*/char *signwith;
/* the override file to use by default */
/*@null@*/char *deb_override,*udeb_override,*dsc_override;
/* fake component prefix (and codename antisuffix) for Release files: */
/*@null@*/char *fakecomponentprefix;
/* only loaded when you've done it yourself: */
struct {
/*@null@*/struct overrideinfo *dsc,*deb,*udeb;
......
......@@ -686,6 +686,25 @@ stable, testing or unstable. To create symlinks
from the Suite to the Codename, use the
\fBcreatesymlinks\fP command of reprepro.
.TP
.B FakeComponentPrefix
If this field is present,
its argument is added before every Component written to the main
Release file,
and removed from the end of the Codename and Suite fields in that file.
.br
So \fB
Codename: bla/updates
Suite: foo/updates
FakeComponentPrefix: updates
Components: main bad
\fP will create a Release file with \fB
Codename: bla
Suite: foo
Components: updates/main updates/bad
\fP in it, but otherwise nothing is changed.
This makes the distribution look more like Debian's security archive,
thus work around problems with apt's workarounds for that.
.TP
.B AlsoAcceptFor
A list of distribution names.
When a \fB.changes\fP file is told to be included
......
......@@ -60,6 +60,8 @@ struct release {
/* snapshot */
bool snapshot;
/*@null@*/char *fakesuite;
/*@null@*/char *fakecodename;
/*@null@*/const char *fakecomponentprefix;
/* the files yet for the list */
struct release_entry {
struct release_entry *next;
......@@ -80,6 +82,7 @@ void release_free(struct release *release) {
free(release->dirofdist);
free(release->fakesuite);
free(release->fakecodename);
while( (e = release->files) != NULL ) {
release->files = e->next;
free(e->relativefilename);
......@@ -124,8 +127,9 @@ static retvalue newreleaseentry(struct release *release, /*@only@*/ char *relati
return RET_OK;
}
retvalue release_init(struct release **release, struct database *database, const char *codename) {
retvalue release_init(struct release **release, struct database *database, const char *codename, const char *suite, const char *fakecomponentprefix) {
struct release *n;
size_t len, suitelen, codenamelen;
retvalue r;
n = calloc(1,sizeof(struct release));
......@@ -134,10 +138,43 @@ retvalue release_init(struct release **release, struct database *database, const
free(n);
return RET_ERROR_OOM;
}
if( fakecomponentprefix != NULL ) {
len = strlen(fakecomponentprefix);
codenamelen = strlen(codename);
n->fakecomponentprefix = fakecomponentprefix;
if( codenamelen > len &&
codename[codenamelen - len - 1] == '/' &&
memcmp(codename + (codenamelen - len),
fakecomponentprefix, len) == 0) {
n->fakecodename = strndup(codename,
codenamelen - len - 1);
if( FAILEDTOALLOC(n->fakecodename) ) {
free(n->dirofdist);
free(n);
return RET_ERROR_OOM;
}
}
if( suite != NULL && (suitelen = strlen(suite)) > len &&
suite[suitelen - len - 1] == '/' &&
memcmp(suite + (suitelen - len),
fakecomponentprefix, len) == 0) {
n->fakesuite = strndup(suite,
suitelen - len - 1);
if( FAILEDTOALLOC(n->fakesuite) ) {
free(n->fakecodename);
free(n->dirofdist);
free(n);
return RET_ERROR_OOM;
}
}
}
r = database_openreleasecache(database, codename, &n->cachedb);
assert( r != RET_NOTHING );
if( RET_WAS_ERROR(r) ) {
n->cachedb = NULL;
free(n->fakecodename);
free(n->fakesuite);
free(n->dirofdist);
free(n);
return r;
......@@ -163,6 +200,8 @@ retvalue release_initsnapshot(const char *codename, const char *name, struct rel
free(n);
return RET_ERROR_OOM;
}
n->fakecodename = NULL;
n->fakecomponentprefix = NULL;
n->cachedb = NULL;
n->snapshot = true;
*release = n;
......@@ -1162,6 +1201,9 @@ retvalue release_prepare(struct release *release, struct distribution *distribut
writechar('\n');
}
writestring("Codename: ");
if( release->fakecodename != NULL )
writestring(release->fakecodename);
else
writestring(distribution->codename);
if( distribution->version != NULL ) {
writestring("\nVersion: ");
......@@ -1180,6 +1222,10 @@ retvalue release_prepare(struct release *release, struct distribution *distribut
writestring("\nComponents:");
for( i = 0 ; i < distribution->components.count ; i++ ) {
writechar(' ');
if( release->fakecomponentprefix != NULL ) {
writestring(release->fakecomponentprefix);
writechar('/');
}
writestring(distribution->components.values[i]);
}
if( distribution->description != NULL ) {
......
......@@ -25,7 +25,7 @@ typedef unsigned int compressionset; /* 1 << indexcompression */
#define IC_FLAG(a) (1<<(a))
/* Initialize Release generation */
retvalue release_init(struct release **release, struct database *database, const char *codename);
retvalue release_init(struct release **release, struct database *database, const char *codename, /*@null@*/const char *suite, /*@null@*/const char *fakeprefix);
/* same but for a snapshot */
retvalue release_initsnapshot(const char *codename, const char *name, 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