Commit 6cfc16fa authored by Bernhard Link's avatar Bernhard Link

add support to generate Valid-Until in Release

parent bafeecc5
2009-01-15
* add support to generate Valid-Until in Release
2009-01-09
* handle 'raw-*' sections like 'byhand' sections (i.e. mostly not
handle them, but give better error messages).
......
Updates between 3.8.0~alpha and 3.8.0:
- add support for generating Valid-Until fields in Release files
Updates between 3.6.2 and 3.8.0~alpha:
+ different small improvements:
- log notifiers can be limited to a specific command with --via
......
......@@ -445,6 +445,58 @@ retvalue config_getword(struct configiterator *iter, char **result_p) {
return config_completeword(iter, c, result_p);
}
retvalue config_gettimespan(struct configiterator *iter, const char *header, time_t *time_p) {
time_t currentnumber, currentsum = 0;
bool empty = true;
int c;
do {
c = config_nextnonspace(iter);
if( c == EOF ) {
if( empty ) {
configparser_errorlast(iter,
"Unexpected end of %s header (value expected).", header);
return RET_ERROR;
}
*time_p = currentsum;
return RET_OK;
}
iter->markerline = iter->line;
iter->markercolumn = iter->column;
currentnumber = 0;
if( c < '0' || c > '9' ) {
configparser_errorlast(iter,
"Unexpected character '%c' where a digit was expected in %s header.",
(char)c, header);
return RET_ERROR;
}
empty = false;
do {
currentnumber *= 10;
currentnumber += (c - '0');
c = config_nextchar(iter);
} while( c >= '0' && c <= '9');
if( c == ' ' || c == '\t' || c == '\n' )
c = config_nextnonspace(iter);
if( c == 'y' ) {
currentnumber *= 365*24*60*60;
} else if( c == 'm' ) {
currentnumber *= 31*24*60*60;
} else if( c == 'd' ) {
currentnumber *= 24*60*60;
} else {
currentnumber *= 24*60*60;
if( c != EOF ) {
configparser_errorlast(iter,
"Unexpected character '%c' where a 'd','m' or 'y' was expected in %s header.",
(char)c, header);
return RET_ERROR;
}
}
currentsum += currentnumber;
} while( true );
}
retvalue config_getonlyword(struct configiterator *iter, const char *header, checkfunc check, char **result_p) {
char *value;
retvalue r;
......
......@@ -61,6 +61,7 @@ retvalue config_getnumber(struct configiterator *, const char *, long long *, lo
retvalue config_getconstant(struct configiterator *, const struct constant *, int *);
#define config_getenum(iter,type,constants,result) ({int _val;retvalue _r = config_getconstant(iter, type ## _ ## constants, &_val);*(result) = (enum type)_val;_r;})
retvalue config_completeword(struct configiterator *, char, /*@out@*/char **);
retvalue config_gettimespan(struct configiterator *, const char *, /*@out@*/time_t *);
void config_overline(struct configiterator *);
bool config_nextline(struct configiterator *);
retvalue configfile_parse(const char *filename, bool ignoreunknown, configinitfunction, configfinishfunction, const struct configfield *, size_t, void *privdata);
......@@ -78,6 +79,11 @@ static retvalue configparser_ ## sname ## _init(void *rootptr, void *lastitem, v
*newptr = n; \
return RET_OK; \
}
#define CFtimespanSETPROC(sname, field) \
static retvalue configparser_ ## sname ## _set_ ## field(UNUSED(void *dummy), const char *name, void *data, struct configiterator *iter) { \
struct sname *item = data; \
return config_gettimespan(iter, name, &item->field); \
}
#define CFcheckvalueSETPROC(sname, field, checker) \
static retvalue configparser_ ## sname ## _set_ ## field(UNUSED(void *dummy), const char *name, void *data, struct configiterator *iter) { \
struct sname *item = data; \
......
......@@ -343,6 +343,7 @@ CFexportmodeSETPROC(distribution, deb)
CFexportmodeSETPROC(distribution, dsc)
CFcheckvalueSETPROC(distribution, codename, checkforcodename)
CFcheckvalueSETPROC(distribution, fakecomponentprefix, checkfordirectoryandidentifier)
CFtimespanSETPROC(distribution, validfor)
CFUSETPROC(distribution, Contents) {
CFSETPROCVAR(distribution, d);
......@@ -385,6 +386,7 @@ static const struct configfield distributionconfigfields[] = {
CF("UDebOverride", distribution, udeb_override),
CF("Update", distribution, updates),
CF("Uploaders", distribution, uploaders),
CF("ValidFor", distribution, validfor),
CF("Version", distribution, version)
};
......
......@@ -86,6 +86,8 @@ struct distribution {
/* a list of names beside Codename and Suite to accept .changes
* files via include */
struct strlist alsoaccept;
/* if != 0, number of seconds to add for Vaild-Until */
time_t validfor;
/* RET_NOTHING: do not export with EXPORT_CHANGED, EXPORT_NEVER
* RET_OK: export unless EXPORT_NEVER
* RET_ERROR_*: only export with EXPORT_FORCE */
......
......@@ -1015,6 +1015,22 @@ If the filename for the log files does not start with a slash,
it is relative to the directory specified with \fB\-\-logdir\fP,
the scripts are relative to \fB\-\-confdir\fP unless starting with
a slash.
.TP
.B ValidFor
If this field exists, an Valid-Until field is put into generated
.B Release
files for this distribution with an date as much in the future as the
argument specifies.
The argument has to be an number followed by one of the units
.BR d ", " m " or " y ,
where \fBd\fP means days, \fBm\fP means 31 days and \fBy\fP means
365 days.
So
.B ValidFor: 1m 11 d
causes the generation of a
.B Valid-Until:
header in Release files that points 42 days into the future.
.SS conf/updates
.TP
.B Name
......
......@@ -1146,7 +1146,7 @@ static retvalue storechecksums(struct release *release) {
retvalue release_prepare(struct release *release, struct distribution *distribution, bool onlyifneeded) {
size_t s;
retvalue r;
char buffer[100];
char buffer[100], untilbuffer[100];
time_t t;
struct tm *gmt;
struct release_entry *file;
......@@ -1170,6 +1170,18 @@ retvalue release_prepare(struct release *release, struct distribution *distribut
fprintf(stderr,"strftime is doing strange things...\n");
return RET_ERROR;
}
if( distribution->validfor > 0 ) {
t += distribution->validfor;
gmt = gmtime(&t);
if( gmt == NULL ) {
return RET_ERROR_OOM;
}
s=strftime(untilbuffer,99,"%a, %d %b %Y %H:%M:%S +0000",gmt);
if( s == 0 || s >= 99) {
fprintf(stderr,"strftime is doing strange things...\n");
return RET_ERROR;
}
}
if( distribution->signwith != NULL )
r = signature_startsignedfile(release->dirofdist, "Release",
......@@ -1214,6 +1226,10 @@ retvalue release_prepare(struct release *release, struct distribution *distribut
}
writestring("\nDate: ");
writestring(buffer);
if( distribution->validfor > 0 ) {
writestring("\nValid-Until: ");
writestring(untilbuffer);
}
writestring("\nArchitectures:");
for( i = 0 ; i < distribution->architectures.count ; i++ ) {
architecture_t a = distribution->architectures.atoms[i];
......
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