Commit 5894639b authored by Bernhard Link's avatar Bernhard Link

add support for .buildinfo files in .changes files 2/4

- new tracking mode includebuildinfos to store them in pool/

Thanks to Guillem Jover for most of the patch.
parent e8ed95d1
2016-12-21 Bernhard R. Link <brlink@debian.org>
* add support for .buildinfo files in .changes files:
- new tracking mode includebuildinfos to store them in pool/
- ignored by 'include' unless Tracking: includebuildinfos
- ignored by 'processincoming', unless stored by tracking.
......
......@@ -548,7 +548,9 @@ static retvalue changes_fixfields(const struct distribution *distribution, const
const struct overridedata *oinfo = NULL;
const char *force = NULL;
if (e->type == fe_BYHAND || e->type == fe_LOG) {
if (e->type == fe_BYHAND ||
e->type == fe_BUILDINFO ||
e->type == fe_LOG) {
needsourcedir = true;
continue;
}
......@@ -810,8 +812,10 @@ static retvalue changes_check(const struct distribution *distribution, const cha
/* Then check for each file, if its architecture is sensible
* and listed. */
for (e = changes->files ; e != NULL ; e = e->next) {
if (e->type == fe_BYHAND || e->type == fe_LOG)
if (e->type == fe_BYHAND || e->type == fe_LOG) {
/* don't insist on a single architecture for those */
continue;
}
if (atom_defined(e->architecture_into)) {
if (e->architecture_into == architecture_all) {
/* "all" can be added if at least one binary
......@@ -921,7 +925,8 @@ static retvalue changes_checkfiles(const char *filename, struct changes *changes
changes->source,
changes->changesversion,
e->basename);
} else if (FE_SOURCE(e->type) || e->type == fe_LOG) {
} else if (FE_SOURCE(e->type) || e->type == fe_LOG
|| e->type == fe_BUILDINFO) {
assert(changes->srcdirectory!=NULL);
e->filekey = calc_dirconcat(changes->srcdirectory,
e->basename);
......@@ -1267,6 +1272,11 @@ static retvalue changes_includepkgs(struct distribution *distribution, struct ch
distribution, trackingdata);
if (r == RET_NOTHING)
*missed_p = true;
} else if (e->type == fe_BUILDINFO && trackingdata != NULL) {
r = trackedpackage_addfilekey(trackingdata->tracks,
trackingdata->pkg,
ft_BUILDINFO, e->filekey, false);
e->filekey = NULL;
} else if (e->type == fe_LOG && trackingdata != NULL) {
r = trackedpackage_addfilekey(trackingdata->tracks,
trackingdata->pkg,
......@@ -1385,7 +1395,7 @@ retvalue changes_add(trackingdb const tracks, const struct atomlist *packagetype
packagetypes, forcearchitectures,
distribution->trackingoptions.includebyhand,
distribution->trackingoptions.includelogs,
false);
distribution->trackingoptions.includebuildinfos);
if (RET_WAS_ERROR(r))
return r;
......
......@@ -70,6 +70,7 @@ struct distribution {
enum trackingtype { dt_NONE=0, dt_KEEP, dt_ALL, dt_MINIMAL } tracking;
struct trackingoptions { bool includechanges;
bool includebyhand;
bool includebuildinfos;
bool includelogs;
bool needsources;
bool keepsources;
......
......@@ -1514,6 +1514,9 @@ Thus it is also put into the pool.
Add \fBbyhand\fP and \fBraw\-\fP\fI*\fP files to the tracked
files and thus in the pool.
.br
.B includebuildinfos
Add buildinfo files to the tracked files and thus in the pool.
.br
.B includelogs
Add log files to the tracked files and thus in the pool.
(Not that putting log files in changes files is a reprepro
......
......@@ -1116,6 +1116,79 @@ static retvalue candidate_read_files(struct incoming *i, struct candidate *c) {
return RET_OK;
}
static retvalue candidate_preparebuildinfos(const struct incoming *i, const struct candidate *c, struct candidate_perdistribution *per) {
retvalue r;
struct candidate_package *package;
struct candidate_file *firstbuildinfo = NULL, *file;
component_t component = component_strange;
int count = 0;
for (file = c->files ; file != NULL ; file = file->next) {
if (file->type == fe_BUILDINFO) {
count++;
if (firstbuildinfo == NULL)
firstbuildinfo = file;
}
}
if (count == 0)
return RET_NOTHING;
/* search for a component to use */
for (package = per->packages ; package != NULL ;
package = package->next) {
if (atom_defined(package->component)) {
component = package->component;
break;
}
}
if (!atom_defined(component)) {
/* How can this happen? */
fprintf(stderr,
"Found no component to put %s into. (Why is there a buildinfo processed without an corresponding package?)\n", firstbuildinfo->name);
return RET_ERROR;
}
/* pseudo package containing buildinfo files */
package = candidate_newpackage(per, firstbuildinfo);
if (FAILEDTOALLOC(package))
return RET_ERROR_OOM;
r = strlist_init_n(count, &package->filekeys);
if (RET_WAS_ERROR(r))
return r;
package->files = nzNEW(count, const struct candidate_file *);
if (FAILEDTOALLOC(package->files))
return RET_ERROR_OOM;
for (file = c->files ; file != NULL ; file = file->next) {
char *filekey;
if (file->type != fe_BUILDINFO)
continue;
r = candidate_usefile(i, c, file);
if (RET_WAS_ERROR(r))
return r;
// TODO: add same checks on the basename contents?
filekey = calc_filekey(component, c->source, BASENAME(i, file->ofs));
if (FAILEDTOALLOC(filekey))
return RET_ERROR_OOM;
r = files_canadd(filekey, file->checksums);
if (RET_WAS_ERROR(r))
return r;
if (RET_IS_OK(r))
package->files[package->filekeys.count] = file;
r = strlist_add(&package->filekeys, filekey);
assert (r == RET_OK);
}
assert (package->filekeys.count == count);
return RET_OK;
}
static retvalue candidate_preparechangesfile(const struct candidate *c, struct candidate_perdistribution *per) {
retvalue r;
char *basefilename, *filekey;
......@@ -1508,6 +1581,12 @@ static retvalue candidate_preparelogs(const struct incoming *i, const struct can
break;
}
}
/* if there somehow were no packages to get an component from,
put in the main one of this distribution. */
if (!atom_defined(component)) {
assert (per->into->components.count > 0);
component = per->into->components.atoms[0];
}
/* pseudo package containing log files */
package = candidate_newpackage(per, firstlog);
......@@ -1614,6 +1693,11 @@ static retvalue prepare_for_distribution(const struct incoming *i, const struct
if (RET_WAS_ERROR(r))
return r;
}
if (d->into->trackingoptions.includebuildinfos) {
r = candidate_preparebuildinfos(i, c, d);
if (RET_WAS_ERROR(r))
return r;
}
if (d->into->trackingoptions.includechanges) {
r = candidate_preparechangesfile(c, d);
if (RET_WAS_ERROR(r))
......@@ -1795,6 +1879,12 @@ static retvalue candidate_add_into(const struct incoming *i, const struct candid
r = trackedpackage_adddupfilekeys(trackingdata.tracks,
trackingdata.pkg,
ft_XTRA_DATA, &p->filekeys, false);
} else if (p->master->type == fe_BUILDINFO) {
assert (tracks != NULL);
r = trackedpackage_adddupfilekeys(trackingdata.tracks,
trackingdata.pkg,
ft_BUILDINFO, &p->filekeys, false);
} else if (p->master->type == fe_LOG) {
assert (tracks != NULL);
......@@ -1838,6 +1928,7 @@ static inline retvalue candidate_checkadd_into(const struct incoming *i, const s
i->permit[pmf_oldpackagenewer]);
} else if (p->master->type == fe_CHANGES
|| p->master->type == fe_BYHAND
|| p->master->type == fe_BUILDINFO
|| p->master->type == fe_LOG) {
continue;
} else
......
......@@ -91,7 +91,7 @@ static retvalue tracked_source_needs_build(architecture_t architecture, const ch
so nothing is to be done */
return RET_NOTHING;
}
if (ft == ft_LOG || ft == ft_CHANGES) {
if (ft == ft_LOG || ft == ft_BUILDINFO || ft == ft_CHANGES) {
const char *a = strrchr(fk, '_');
const char *e;
......
......@@ -286,6 +286,147 @@ $(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
EOF
rm -r pool db
echo now the same with tracking information:
cat > conf/distributions <<EOF
Codename: test
Architectures: coal source
Components: main
Tracking: minimal includebuildinfos
EOF
mkdir -p pool/main/s/source-a pool/main/s/source-b
echo Check that include properly ignores a .buildinfo file
testrun - include test source-a_1_binary.changes 3<<EOF
stderr
=Warning: database 'test|main|coal' was modified but no index file was exported.
=Changes will only be visible after the next 'export'!
stdout
$(odb)
$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
$(ofa 'pool/main/s/source-a/source-a_1_all.buildinfo')
$(opa 'onlyall' '1' 'test' 'main' 'coal' 'deb')
$(ota 'test' 'source-a')
EOF
rm -r pool db
mkdir pool
testrun - -A coal include test source-b_2_binary.changes 3<<EOF
stderr
-v1*=Skipping 'source-b_2_abacus.buildinfo' as architecture is not in the requested set.
-v1*=Skipping 'onlyany_2_abacus.deb' as architecture is not in the requested set.
*=source-b_2_binary.changes: Not enough files in .changes!
-v0*=There have been errors!
returns 255
stdout
$(odb)
EOF
rm -r pool db
mkdir pool
testrun - -A coal include test source-b_2_source.changes 3<<EOF
stderr
-v1*=Skipping 'source-b_2.dsc' as architecture 'source' is not in the requested set.
-v1*=Skipping 'source-b_2.tar.gz' as architecture 'source' is not in the requested set.
*=source-b_2_source.changes: Not enough files in .changes!
-v0*=There have been errors!
returns 255
stdout
$(odb)
EOF
rm -r pool db
mkdir pool
testrun - -A coal include test source-b_2_sourceandbuild.changes 3<<EOF
stderr
-v1*=Skipping 'source-b_2_source.buildinfo' as architecture 'source' is not in the requested set.
-v1*=Skipping 'source-b_2.dsc' as architecture 'source' is not in the requested set.
-v1*=Skipping 'source-b_2.tar.gz' as architecture 'source' is not in the requested set.
*=source-b_2_sourceandbuild.changes: Not enough files in .changes!
-v0*=There have been errors!
returns 255
stdout
$(odb)
EOF
rm -r pool db
mkdir -p pool/main/s/source-a pool/main/s/source-b
testrun - include test source-b_2_sourceandbuild.changes 3<<EOF
stderr
=Warning: database 'test|main|source' was modified but no index file was exported.
=Changes will only be visible after the next 'export'!
stdout
$(odb)
$(ofa 'pool/main/s/source-b/source-b_2_source.buildinfo')
$(ofa 'pool/main/s/source-b/source-b_2.dsc')
$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
$(ota 'test' 'source-b')
EOF
rm -r pool db
cat > conf/distributions <<EOF
Codename: test
Architectures: abacus source
Components: main
Tracking: minimal includebuildinfos
EOF
mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
echo Check that include properly ignores a .buildinfo file
testrun - include test source-a_1_binary.changes 3<<EOF
stderr
=Warning: database 'test|main|abacus' was modified but no index file was exported.
=Changes will only be visible after the next 'export'!
stdout
$(odb)
$(ofa 'pool/main/s/source-a/source-a_1_all.buildinfo')
$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
$(ota 'test' 'source-a')
EOF
testrun - include test source-b_2_binary.changes 3<<EOF
stderr
=Warning: database 'test|main|abacus' was modified but no index file was exported.
=Changes will only be visible after the next 'export'!
stdout
$(ofa 'pool/main/s/source-b/source-b_2_abacus.buildinfo')
$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
$(ota 'test' 'source-b')
EOF
testrun - include test source-b_2_sourceandbuild.changes 3<<EOF
stderr
=Warning: database 'test|main|source' was modified but no index file was exported.
=Changes will only be visible after the next 'export'!
stdout
$(ofa 'pool/main/s/source-b/source-b_2_source.buildinfo')
$(ofa 'pool/main/s/source-b/source-b_2.dsc')
$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
EOF
testrun - include test source-c_3_full.changes 3<<EOF
stderr
=Warning: database 'test|main|source' was modified but no index file was exported.
=Warning: database 'test|main|abacus' was modified but no index file was exported.
=Changes will only be visible after the next 'export'!
stdout
$(ofa 'pool/main/s/source-c/source-c_3_abacus.buildinfo')
$(ofa 'pool/main/s/source-c/source-c_3.dsc')
$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
$(ota 'test' 'source-c')
EOF
rm -r pool db
mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
mkdir i j tmp
......@@ -302,6 +443,72 @@ EOF
rm './i/source-b_2_source.changes'
rm './i/source-a_1_source.changes'
echo check to process all .changes at the same time with tracking:
testrun - processincoming foo 3<<EOF
stderr
=Warning: database 'test|main|source' was modified but no index file was exported.
=Warning: database 'test|main|abacus' was modified but no index file was exported.
=Changes will only be visible after the next 'export'!
stdout
$(odb)
$(ofa 'pool/main/s/source-a/source-a_1_all.buildinfo')
$(ofa 'pool/main/s/source-a/onlyall_1_all.deb')
$(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
$(ofa 'pool/main/s/source-a/source-a_1_source.buildinfo')
$(ofa 'pool/main/s/source-a/source-a_1.dsc')
$(ofa 'pool/main/s/source-a/source-a_1.tar.gz')
$(opa 'source-a' '1' 'test' 'main' 'source' 'dsc')
$(ota 'test' 'source-a')
$(ofa 'pool/main/s/source-b/source-b_2_abacus.buildinfo')
$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
$(ofa 'pool/main/s/source-b/source-b_2_source.buildinfo')
$(ofa 'pool/main/s/source-b/source-b_2.dsc')
$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
$(ota 'test' 'source-b')
$(ofa 'pool/main/s/source-c/source-c_3_abacus.buildinfo')
$(ofa 'pool/main/s/source-c/source-c_3.dsc')
$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
$(ofa 'pool/main/s/source-c/someindep_3_all.deb')
$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
$(ota 'test' 'source-c')
-v3*=deleting './i/onlyall_1_all.deb'...
-v3*=deleting './i/onlyany_2_abacus.deb'...
-v3*=deleting './i/somearch_3_abacus.deb'...
-v3*=deleting './i/someindep_3_all.deb'...
-v3*=deleting './i/source-a_1.dsc'...
-v3*=deleting './i/source-a_1.tar.gz'...
-v3*=deleting './i/source-a_1_all.buildinfo'...
-v3*=deleting './i/source-a_1_binary.changes'...
-v3*=deleting './i/source-a_1_source.buildinfo'...
-v3*=deleting './i/source-a_1_sourceandbuild.changes'...
-v3*=deleting './i/source-b_2.dsc'...
-v3*=deleting './i/source-b_2.tar.gz'...
-v3*=deleting './i/source-b_2_abacus.buildinfo'...
-v3*=deleting './i/source-b_2_binary.changes'...
-v3*=deleting './i/source-b_2_source.buildinfo'...
-v3*=deleting './i/source-b_2_sourceandbuild.changes'...
-v3*=deleting './i/source-c_3.dsc'...
-v3*=deleting './i/source-c_3.tar.gz'...
-v3*=deleting './i/source-c_3_abacus.buildinfo'...
-v3*=deleting './i/source-c_3_full.changes'...
EOF
rm -r db pool
mkdir -p pool/main/s/source-a pool/main/s/source-b pool/main/s/source-c
cp j/* i/
rm './i/source-b_2_source.changes'
rm './i/source-a_1_source.changes'
ed -s conf/distributions <<EOF
g/^Tracking: /s/include[^ ]*//g
w
q
EOF
echo check to process all .changes at the same time without storing buildinfo:
testrun - processincoming foo 3<<EOF
......@@ -316,11 +523,13 @@ $(opa 'onlyall' '1' 'test' 'main' 'abacus' 'deb')
$(ofa 'pool/main/s/source-a/source-a_1.dsc')
$(ofa 'pool/main/s/source-a/source-a_1.tar.gz')
$(opa 'source-a' '1' 'test' 'main' 'source' 'dsc')
$(ota 'test' 'source-a')
$(ofa 'pool/main/s/source-b/onlyany_2_abacus.deb')
$(opa 'onlyany' '2' 'test' 'main' 'abacus' 'deb')
$(ofa 'pool/main/s/source-b/source-b_2.dsc')
$(ofa 'pool/main/s/source-b/source-b_2.tar.gz')
$(opa 'source-b' '2' 'test' 'main' 'source' 'dsc')
$(ota 'test' 'source-b')
$(ofa 'pool/main/s/source-c/source-c_3.dsc')
$(ofa 'pool/main/s/source-c/source-c_3.tar.gz')
$(ofa 'pool/main/s/source-c/somearch_3_abacus.deb')
......@@ -328,6 +537,7 @@ $(ofa 'pool/main/s/source-c/someindep_3_all.deb')
$(opa 'source-c' '3' 'test' 'main' 'source' 'dsc')
$(opa 'somearch' '3' 'test' 'main' 'abacus' 'deb')
$(opa 'someindep' '3' 'test' 'main' 'abacus' 'deb')
$(ota 'test' 'source-c')
-v3*=deleting './i/onlyall_1_all.deb'...
-v3*=deleting './i/onlyany_2_abacus.deb'...
-v3*=deleting './i/somearch_3_abacus.deb'...
......
......@@ -86,6 +86,7 @@ retvalue tracking_initialize(/*@out@*/trackingdb *db, const struct distribution
static inline enum filetype filetypechar(enum filetype filetype) {
switch (filetype) {
case ft_LOG:
case ft_BUILDINFO:
case ft_CHANGES:
case ft_ALL_BINARY:
case ft_ARCH_BINARY:
......@@ -698,6 +699,7 @@ retvalue tracking_foreach_ro(struct distribution *d, tracking_foreach_ro_action
retvalue tracking_parse(struct distribution *d, struct configiterator *iter) {
enum trackingflags { tf_keep, tf_all, tf_minimal,
tf_includechanges, tf_includebyhand, tf_includelogs,
tf_includebuildinfos,
tf_keepsources,
tf_needsources, tf_embargoalls,
tf_COUNT /* must be last */
......@@ -707,6 +709,7 @@ retvalue tracking_parse(struct distribution *d, struct configiterator *iter) {
{"all", tf_all},
{"minimal", tf_minimal},
{"includechanges", tf_includechanges},
{"includebuildinfos", tf_includebuildinfos},
{"includelogs", tf_includelogs},
{"includebyhand", tf_includebyhand},
{"keepsources", tf_keepsources},
......@@ -750,6 +753,7 @@ retvalue tracking_parse(struct distribution *d, struct configiterator *iter) {
d->trackingoptions.includechanges = flags[tf_includechanges];
d->trackingoptions.includebyhand = flags[tf_includebyhand];
d->trackingoptions.includebuildinfos = flags[tf_includebuildinfos];
d->trackingoptions.includelogs = flags[tf_includelogs];
d->trackingoptions.keepsources = flags[tf_keepsources];
d->trackingoptions.needsources = flags[tf_needsources];
......@@ -953,10 +957,12 @@ static inline retvalue trackedpackage_removeall(trackingdb tracks, struct tracke
static inline bool tracking_needed(trackingdb tracks, struct trackedpackage *pkg, int ofs) {
if (pkg->refcounts[ofs] > 0)
return true;
// TODO: add checks so that only .changes and .log files belonging
// to still existing binaries are kept in minimal mode
// TODO: add checks so that only .changes, .buildinfo and .log files
// belonging to still existing binaries are kept in minimal mode
if (pkg->filetypes[ofs] == ft_LOG && tracks->options.includelogs)
return true;
if (pkg->filetypes[ofs] == ft_BUILDINFO && tracks->options.includebuildinfos)
return true;
if (pkg->filetypes[ofs] == ft_CHANGES && tracks->options.includechanges)
return true;
if (pkg->filetypes[ofs] == ft_XTRA_DATA)
......
......@@ -5,6 +5,7 @@ enum filetype { ft_ALL_BINARY='a',
ft_ARCH_BINARY='b',
ft_CHANGES = 'c',
ft_LOG='l',
ft_BUILDINFO='i',
ft_SOURCE='s',
ft_XTRA_DATA='x'};
......
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