distromatic.c: add a sources file with the list of number of requirements per package to detect leaves (package that can be removed without breaking deps)

This commit is contained in:
Silvan Calarco 2021-03-20 11:28:21 +01:00
parent 8445407e9c
commit 04d323e9a7
4 changed files with 53 additions and 5 deletions

View File

@ -1264,6 +1264,40 @@ main(int argc, char *argv[])
currheadersourcelist = currheadersourcelist->next;
}
}
// write list of left packages (not required by any other package)
char allsources_filename[PATH_MAX];
FILE *afs;
snprintf(allsources_filename, PATH_MAX, "%ssources", configtag->html_dir);
afs=fopen(allsources_filename,"w");
if (!afs) {
fprintf(stderr, "Error: can't open file for writing: %s. Aborting.\n", allsources_filename);
exit(1);
}
currheadersourcelist = configtag->headersourcelist;
long tot;
fprintf(afs,"# Number of times each source and related builds are internally required\n# src");
for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
tot += currheadersourcelist->childrenrequiredcount[i];
fprintf(afs," %s", configtag->arch[i]);
}
fprintf(afs," tot\n");
while (currheadersourcelist != NULL) {
tot = 0;
fprintf(afs,"%s:", currheadersourcelist->name);
for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++) {
tot += currheadersourcelist->childrenrequiredcount[i];
if (currheadersourcelist->firstchild[i])
fprintf(afs," %ld",
currheadersourcelist->childrenrequiredcount[i]);
else
fprintf(afs," -");
}
fprintf(afs," %ld\n", tot);
currheadersourcelist = currheadersourcelist->next;
}
fclose(afs);
} // if (genheader_mode)
if (mode & MODE_SQLITE3) {

View File

@ -1084,6 +1084,7 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) {
newheadersourcelist->next = NULL;
for (arch = 0; arch < ARCHS_MAX; arch++) {
newheadersourcelist->firstchild[arch] = NULL;
newheadersourcelist->childrenrequiredcount[arch] = 0;
}
newheadersourcelist->updatingparent = NULL;
newheadersourcelist->altrepository = altrepository;
@ -1231,6 +1232,7 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) {
newheadersourcelist->next = NULL;
for (arch = 0; arch < ARCHS_MAX; arch++) {
newheadersourcelist->firstchild[arch] = NULL;
newheadersourcelist->childrenrequiredcount[arch] = 0;
}
newheadersourcelist->updatingparent = NULL;
newheadersourcelist->altrepository = altrepository;

View File

@ -140,6 +140,7 @@ struct headerSourceList {
struct warningList *firstwarning;
struct headerSourceList *updatingparent;
struct rebuildList *firstrebuild;
long childrenrequiredcount[ARCHS_MAX];
long id;
};

View File

@ -1760,9 +1760,9 @@ int print_datatables(struct configTag *ct, int arch) {
logmsg(LOG_DEBUG,"writing deps files (1)");
struct providedList* provided = ct->providedlist_idx[arch][0];
while (provided) {
if (!strncmp("debuginfo(build-id)", provided->name, 20)) {
provided = provided->next;
continue;
if (!strncmp("debuginfo(build-id)", provided->name, 20)) {
provided = provided->next;
continue;
}
nonobsoletednumproviders=0;
for (i = 0; i < provided->numproviders; i++) {
@ -1849,18 +1849,23 @@ int print_datatables(struct configTag *ct, int arch) {
strcmp(currheaderlist->require[i-1]->resolved->provider[0]->name,
currheaderlist->require[i]->resolved->provider[0]->name)) &&
strcmp(currheaderlist->name,
currheaderlist->require[i]->resolved->provider[0]->name))
currheaderlist->require[i]->resolved->provider[0]->name)) {
fprintf(fd,"%s ",currheaderlist->require[i]->resolved->provider[0]->name);
}
} else {
if (i == 0 ||
!currheaderlist->require[i-1]->resolved ||
!currheaderlist->require[i-1]->resolved->numproviders ||
strcmp(currheaderlist->require[i-1]->resolved->name,
currheaderlist->require[i]->resolved->name)) {
currheaderlist->require[i]->resolved->name)) {
fprintf_depstable_filtered_var(fd,currheaderlist->require[i]->resolved->name);
fprintf(fd," ");
}
}
for (int j = 0; j < currheaderlist->require[i]->resolved->numproviders; j++) {
if (currheaderlist->require[i]->resolved->provider[j]->sourceheader != currheaderlist->sourceheader)
currheaderlist->require[i]->resolved->provider[j]->sourceheader->childrenrequiredcount[arch]++;
}
}
}
fprintf(fd,"\n");
@ -1874,6 +1879,12 @@ int print_datatables(struct configTag *ct, int arch) {
strncmp("debuginfo(build-id)",currheaderlist->sourceheader->require[i]->name,20)) {
fprintf(fbd," ");
fprintf_depstable_filtered_var(fbd,currheaderlist->sourceheader->require[i]->name);
if (currheaderlist->sourceheader->require[i]->resolved) {
for (int j = 0; j < currheaderlist->sourceheader->require[i]->resolved->numproviders; j++) {
if (currheaderlist->sourceheader->require[i]->resolved->provider[j]->sourceheader != currheaderlist->sourceheader)
currheaderlist->sourceheader->require[i]->resolved->provider[j]->sourceheader->childrenrequiredcount[arch]++;
}
}
}
}