Fixes for recent and old bugs

This commit is contained in:
Silvan Calarco 2021-02-16 20:24:29 +01:00
parent 019aa970f0
commit 39af94aa1d
5 changed files with 47 additions and 58 deletions

View File

@ -61,8 +61,8 @@ target_include_directories(distromatic PUBLIC
#
# NOTE: -fno-toplevel-reorder required to prevent Sqlite3 weird problems
#
target_compile_options(distromatic PUBLIC -O2 -fno-toplevel-reorder -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
target_compile_options(distromatic PUBLIC -O2 -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
# -fno-toplevel-reorder
add_executable(distroquery
distroquery.c
functions.c

View File

@ -944,6 +944,7 @@ main(int argc, char *argv[])
int i = 0,hasbuilds[ARCHS_MAX],ptharg[ARCHS_MAX];
int parallel = 0;
int current_archs = 0;
pthread_t pth[ARCHS_MAX];
char warning[8096];
@ -1123,13 +1124,13 @@ main(int argc, char *argv[])
}
if (passed_arch) {
configtag->arch[0] = malloc(sizeof passed_arch);
if (!configtag->arch[0]) {
fprintf(stderr, "The system is out of memory\n");
exit(1);
}
strcpy(configtag->arch[0], passed_arch);
configtag->arch[1] = NULL;
configtag->arch[0] = malloc(sizeof passed_arch);
if (!configtag->arch[0]) {
fprintf(stderr, "The system is out of memory\n");
exit(1);
}
strcpy(configtag->arch[0], passed_arch);
configtag->arch[1] = NULL;
}
rpminit();
@ -1190,7 +1191,10 @@ main(int argc, char *argv[])
pthread_join(pth[i], NULL);
}
if (!passed_arch) { // can't do missing builds and ports check in single arch mode
for (i = 0; i < ARCHS_MAX && configtag->arch[i]; i++)
current_archs++;
if (current_archs > 1) { // can't do missing builds and ports check in single arch mode
if (!quietmode)
fprintf(stdout, "Checking for SRPMS with no builds and missing ports...\n");
else

View File

@ -480,7 +480,7 @@ void logmsg(int level, const char *msg, ...) {
break;
}
if ((level == LOG_WARNING) || (level == LOG_ERROR)) {
strncpy(oldmsg[curroldmsg++],newmsg,PATH_MAX);
strncpy(oldmsg[curroldmsg++],newmsg,256);
if (curroldmsg >= 20) curroldmsg = 0;
}
}

View File

@ -664,8 +664,8 @@ struct repoData* getRepodata(char *repodata_url, char *arch) {
ret = lr_handle_perform(h, r, &tmp_err);
if (!ret) {
logmsg(LOG_ERROR, "cannot get repodata: %d: %s\n",
tmp_err->code, tmp_err->message);
logmsg(LOG_ERROR, "cannot get repodata from %s: %d: %s\n",
urls[0], tmp_err->code, tmp_err->message);
g_error_free(tmp_err);
lr_result_free(r);
lr_handle_free(h);
@ -1001,17 +1001,26 @@ int addToSourceHeaderList(struct configTag *ct, int mode, int altrepository) {
if (altrepository == ct->repository_level) {
scanpath = ct->repository_source_dir;
if (ct->repodata_url) repodata = getRepodata(ct->repodata_url, NULL);
if (ct->repodata_url) {
repodata = getRepodata(ct->repodata_url, NULL);
if (!repodata) return 1;
}
logmsg(LOG_DEBUG,"Scanning source packages in repository %s...", ct->tag);
} else if (altrepository == -1) {
// non-incremental mode
scanpath = ct->repository_source_dir;
altrepository = 0;
if (ct->repodata_url) repodata = getRepodata(ct->repodata_url, NULL);
if (ct->repodata_url) {
repodata = getRepodata(ct->repodata_url, NULL);
if (!repodata) return 1;
}
logmsg(LOG_DEBUG,"Scanning source packages in repository %s...", ct->tag);
} else {
scanpath = ct->repository[altrepository]->repository_source_dir;
if (ct->repodata_url) repodata = getRepodata(ct->repository[altrepository]->repodata_url, NULL);
if (ct->repodata_url) {
repodata = getRepodata(ct->repository[altrepository]->repodata_url, NULL);
if (!repodata) return 1;
}
logmsg(LOG_DEBUG,"Scanning source packages in repository %s...", ct->repository[altrepository]->tag);
}
if (repodata) {
@ -1412,18 +1421,28 @@ char* advanceXMLPackageNode(char* prevname, xmlNode **primary_node,
if (ct->repository[0]) {
snprintf(scanpath,bufsize,"%sRPMS.%s/",ct->repository[0]->repository_dir,ct->arch[arch]);
scantag = ct->repository[0]->tag;
if (ct->repository[0]->repodata_url) repodata[0] = getRepodata(
ct->repository[0]->repodata_url, ct->arch[arch]);
if (ct->repository[0]->repodata_url) {
repodata[0] = getRepodata(ct->repository[0]->repodata_url,
ct->arch[arch]);
if (!repodata[0]) return 1;
}
for (i = 1; i <= ct->repository_level; i++) {
if (ct->repository[i]) {
altscanpath[i-1] = malloc(bufsize);
snprintf(altscanpath[i-1], bufsize, "%sRPMS.%s/",ct->repository[i]->repository_dir,ct->arch[arch]);
altscantag[i-1] = ct->repository[i]->tag;
if (ct->repository[i]->repodata_url) {
if (!repodata[0]) logmsg(LOG_ERROR,
"repodata_url must be defined in main and parent repositories; aborting.");
if (!repodata[0]) {
logmsg(LOG_ERROR,
"repodata_url must be defined in main and parent repositories; aborting.");
return 1;
}
repodata[i] = getRepodata(
ct->repository[i]->repodata_url, ct->arch[arch]);
if (!repodata[i]) {
cleanRepodata(repodata[0]);
return 1;
}
}
alt_reps_num++;
} else {
@ -1438,8 +1457,10 @@ char* advanceXMLPackageNode(char* prevname, xmlNode **primary_node,
} else {
snprintf(scanpath,bufsize,"%sRPMS.%s/",ct->repository_dir,ct->arch[arch]);
scantag = ct->tag;
if (ct->repodata_url) repodata[0] = getRepodata(ct->repodata_url,
ct->arch[arch]);
if (ct->repodata_url) {
repodata[0] = getRepodata(ct->repodata_url, ct->arch[arch]);
if (!repodata[0]) return 1;
}
}
currheaderlist = ct->headerlist[arch];

View File

@ -679,42 +679,6 @@ generateStats(struct configTag *configtag,int arch)
fclose(htmlout);
}
/* create Smart Package Manager channel file */
snprintf(outfile, PATH_MAX, "%s%s-%s.smart",
configtag->html_dir,
configtag->configdefaults->distribution_name,
configtag->tag);
if ((htmlout = fopen(outfile, "w")) == NULL) {
perror(outfile);
return 1;
} else {
/* remove final slashes from download_prefix as required by apt */
strcpy(buffer, configtag->download_dir);
i=strlen(buffer);
while ((i > 0) && (buffer[i-1] == '/' )) {
buffer[i-1]='\0';
i--;
}
fprintf(htmlout, "#\n# %s %s channel configuration for Smart Package Manager\n#\n\n",
configtag->configdefaults->distribution_name,
configtag->tag);
fprintf(htmlout, "[%s]\ntype = apt-rpm\n",
configtag->tag);
fprintf(htmlout, "name = %s\n",
configtag->description);
fprintf(htmlout, "baseurl = http://%s%s\n",
configtag->configdefaults->url_address, buffer);
fprintf(htmlout, "components =");
for (i = 0; i < ARCHS_MAX; i++) {
if (configtag->arch[i]) fprintf(htmlout," %s", configtag->arch[i]);
}
fprintf(htmlout, "\n");
fclose(htmlout);
}
/* create Changelog page */
struct tm tmdate;
tmdate.tm_min = 0;