version 1.57, 1998/09/13 03:54:34
|
version 1.58, 1998/09/14 14:46:12
|
Line 45 static int getTagNumber(char *tag) {
|
Line 45 static int getTagNumber(char *tag) {
|
} |
} |
|
|
/* |
/* |
|
* Free up the extra data not needed for the last stage processing. |
|
*/ |
|
|
|
void rpmFreeExtraData(rpmDataPtr rpm) { |
|
rpmExtraDataPtr extra; |
|
|
|
if ((rpm == NULL) || (rpm->extra == NULL)) return; |
|
extra = rpm->extra; |
|
if (extra->packager != NULL) free(extra->packager); |
|
if (extra->description != NULL) free(extra->description); |
|
if (extra->copyright != NULL) free(extra->copyright); |
|
if (extra->changelog != NULL) free(extra->changelog); |
|
if (extra->srcrpm != NULL) free(extra->srcrpm); |
|
if (extra->host != NULL) free(extra->host); |
|
if (extra->resources != NULL) free(extra->resources); |
|
if (extra->requires != NULL) free(extra->requires); |
|
if (extra->filelist != NULL) free(extra->filelist); |
|
free(extra); |
|
} |
|
|
|
/* |
* Check a dependancy name to get rid of bad deps due to bad scripts |
* Check a dependancy name to get rid of bad deps due to bad scripts |
* or spec files. |
* or spec files. |
*/ |
*/ |
Line 118 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 139 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
return(NULL); |
return(NULL); |
} |
} |
|
|
/* allocate a new rpmData block, fill it */ |
/* allocate a new rpmData block, and an rpmExtraData block fill them */ |
rpm = (rpmDataPtr) malloc(sizeof(rpmData)); |
rpm = (rpmDataPtr) malloc(sizeof(rpmData)); |
if (rpm == NULL) { |
if (rpm == NULL) { |
fprintf(stderr, "cannot allocate %d bytes: %s\n", sizeof(rpmData), |
fprintf(stderr, "cannot allocate %d bytes: %s\n", sizeof(rpmData), |
Line 126 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 147 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
return(NULL); |
return(NULL); |
} |
} |
memset(rpm, 0, sizeof(rpmData)); |
memset(rpm, 0, sizeof(rpmData)); |
|
rpm->extra = (rpmExtraDataPtr) malloc(sizeof(rpmExtraData)); |
|
if (rpm == NULL) { |
|
fprintf(stderr, "cannot allocate %d bytes: %s\n", sizeof(rpmExtraData), |
|
strerror(errno)); |
|
return(NULL); |
|
} |
|
memset(rpm->extra, 0, sizeof(rpmExtraData)); |
rpm->dir = dir; |
rpm->dir = dir; |
if (tree) { |
if (tree) { |
if ((tree->rpmpath != NULL) && (tree->rpmpath[0] != '\0')) |
if ((tree->rpmpath != NULL) && (tree->rpmpath[0] != '\0')) |
Line 134 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 162 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
rpm->subdir = NULL; |
rpm->subdir = NULL; |
} else |
} else |
rpm->subdir = NULL; |
rpm->subdir = NULL; |
rpm->stamp = stamp; |
rpm->extra->stamp = stamp; |
rpm->name = strdup(name); |
rpm->name = strdup(name); |
rpm->version = strdup(version); |
rpm->version = strdup(version); |
rpm->release = strdup(release); |
rpm->release = strdup(release); |
Line 147 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 175 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
} |
} |
if (!headerGetEntry(h, RPMTAG_DESCRIPTION, &type, &p, &count) || !p || |
if (!headerGetEntry(h, RPMTAG_DESCRIPTION, &type, &p, &count) || !p || |
(type != RPM_STRING_TYPE)) { |
(type != RPM_STRING_TYPE)) { |
rpm->description = strdup(localizedStrings[LANG_NO_DESCRIPTION]); |
rpm->extra->description = strdup(localizedStrings[LANG_NO_DESCRIPTION]); |
} else { |
} else { |
rpm->description = strdup((char *) p); |
rpm->extra->description = strdup((char *) p); |
} |
} |
if (!headerGetEntry(h, RPMTAG_DISTRIBUTION, &type, &p, &count) || !p || |
if (!headerGetEntry(h, RPMTAG_DISTRIBUTION, &type, &p, &count) || !p || |
(type != RPM_STRING_TYPE)) { |
(type != RPM_STRING_TYPE)) { |
Line 227 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 255 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
} |
} |
if (!headerGetEntry(h, RPMTAG_BUILDHOST, &type, &p, &count) || !p || |
if (!headerGetEntry(h, RPMTAG_BUILDHOST, &type, &p, &count) || !p || |
(type != RPM_STRING_TYPE)) { |
(type != RPM_STRING_TYPE)) { |
rpm->host = strdup(localizedStrings[LANG_NO_HOST]); |
rpm->extra->host = strdup(localizedStrings[LANG_NO_HOST]); |
} else { |
} else { |
rpm->host = strdup((char *) p); |
rpm->extra->host = strdup((char *) p); |
} |
} |
if (!headerGetEntry(h, RPMTAG_SIZE, &type, &p, &count) || !p) { |
if (!headerGetEntry(h, RPMTAG_SIZE, &type, &p, &count) || !p) { |
rpm->size = 0; |
rpm->size = 0; |
Line 251 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 279 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
} |
} |
if (!headerGetEntry(h, RPMTAG_SOURCERPM, &type, &p, &count) || !p || |
if (!headerGetEntry(h, RPMTAG_SOURCERPM, &type, &p, &count) || !p || |
(type != RPM_STRING_TYPE)) { |
(type != RPM_STRING_TYPE)) { |
rpm->srcrpm = strdup(""); |
rpm->extra->srcrpm = strdup(""); |
} else { |
} else { |
rpm->srcrpm = strdup((char *) p); |
rpm->extra->srcrpm = strdup((char *) p); |
} |
} |
if (!headerGetEntry(h, RPMTAG_URL, &type, &p, &count) || !p || |
if (!headerGetEntry(h, RPMTAG_URL, &type, &p, &count) || !p || |
(type != RPM_STRING_TYPE)) { |
(type != RPM_STRING_TYPE)) { |
Line 263 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 291 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
} |
} |
if (!headerGetEntry(h, RPMTAG_PACKAGER, &type, &p, &count) || !p || |
if (!headerGetEntry(h, RPMTAG_PACKAGER, &type, &p, &count) || !p || |
(type != RPM_STRING_TYPE)) { |
(type != RPM_STRING_TYPE)) { |
rpm->packager = NULL; |
rpm->extra->packager = NULL; |
} else { |
} else { |
rpm->packager = strdup((char *) p); |
rpm->extra->packager = strdup((char *) p); |
} |
} |
if (!headerGetEntry(h, RPMTAG_COPYRIGHT, &type, &p, &count) || !p || |
if (!headerGetEntry(h, RPMTAG_COPYRIGHT, &type, &p, &count) || !p || |
(type != RPM_STRING_TYPE)) { |
(type != RPM_STRING_TYPE)) { |
rpm->copyright = NULL; |
rpm->extra->copyright = NULL; |
} else { |
} else { |
rpm->copyright = strdup((char *) p); |
rpm->extra->copyright = strdup((char *) p); |
} |
} |
/* Pick up changelog entries */ |
/* Pick up changelog entries */ |
if (!headerGetEntry(h, RPMTAG_CHANGELOGTEXT, &type, &p, &count) || !p) { |
if (!headerGetEntry(h, RPMTAG_CHANGELOGTEXT, &type, &p, &count) || !p) { |
rpm->changelog = NULL; |
rpm->extra->changelog = NULL; |
} else { |
} else { |
time_t *dates; |
time_t *dates; |
char **names; |
char **names; |
Line 319 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 347 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
*res++ = '\n'; |
*res++ = '\n'; |
} |
} |
*res = '\0'; |
*res = '\0'; |
rpm->changelog = strdup(buffer); |
rpm->extra->changelog = strdup(buffer); |
} |
} |
if (rpm->vendor == NULL) { |
if (rpm->vendor == NULL) { |
if (rpm->packager != NULL) rpm->vendor = strdup(rpm->packager); |
if (rpm->extra->packager != NULL) rpm->vendor = strdup(rpm->extra->packager); |
else rpm->vendor = strdup(localizedStrings[LANG_UNKNOWN]); |
else rpm->vendor = strdup(localizedStrings[LANG_UNKNOWN]); |
} |
} |
|
|
Line 331 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 359 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
/* package-xxx.rpm provides at least the resource "package" */ |
/* package-xxx.rpm provides at least the resource "package" */ |
val = getTagNumber("RPMTAG_PROVIDES"); |
val = getTagNumber("RPMTAG_PROVIDES"); |
if (!headerGetEntry(h, val, &type, &p, &count) || !p) { |
if (!headerGetEntry(h, val, &type, &p, &count) || !p) { |
rpm->nb_resources = 1; |
rpm->extra->nb_resources = 1; |
rpm->max_resources = 1; |
rpm->extra->max_resources = 1; |
rpm->resources = (rpmRessPtr *) malloc(sizeof(rpmRessPtr) * |
rpm->extra->resources = (rpmRessPtr *) malloc(sizeof(rpmRessPtr) * |
rpm->max_resources); |
rpm->extra->max_resources); |
if (rpm->resources == NULL) { |
if (rpm->extra->resources == NULL) { |
fprintf(stderr, ": ran out of memory\n"); |
fprintf(stderr, ": ran out of memory\n"); |
exit(1); |
exit(1); |
} |
} |
rpm->resources[0] = rpmRessAdd(name, rpm, installed); |
rpm->extra->resources[0] = rpmRessAdd(name, rpm, installed); |
} else { |
} else { |
rpm->max_resources = count + 1; |
rpm->extra->max_resources = count + 1; |
rpm->resources = (rpmRessPtr *) malloc(sizeof(rpmRessPtr) * |
rpm->extra->resources = (rpmRessPtr *) malloc(sizeof(rpmRessPtr) * |
rpm->max_resources); |
rpm->extra->max_resources); |
if (rpm->resources == NULL) { |
if (rpm->extra->resources == NULL) { |
fprintf(stderr, ": ran out of memory\n"); |
fprintf(stderr, ": ran out of memory\n"); |
exit(1); |
exit(1); |
} |
} |
rpm->resources[0] = rpmRessAdd(name, rpm, installed); |
rpm->extra->resources[0] = rpmRessAdd(name, rpm, installed); |
rpm->nb_resources = 1; |
rpm->extra->nb_resources = 1; |
|
|
for (i = 0, j = rpm->nb_resources; i < count;i++) { |
for (i = 0, j = rpm->extra->nb_resources; i < count;i++) { |
if (!checkResourceName(((char **) p)[i])) continue; |
if (!checkResourceName(((char **) p)[i])) continue; |
rpm->resources[j++] = rpmRessAdd(((char **) p)[i], rpm, installed); |
rpm->extra->resources[j++] = rpmRessAdd(((char **) p)[i], rpm, installed); |
} |
} |
rpm->nb_resources = j; |
rpm->extra->nb_resources = j; |
} |
} |
|
|
val = getTagNumber("RPMTAG_REQUIRENAME"); |
val = getTagNumber("RPMTAG_REQUIRENAME"); |
if (!headerGetEntry(h, val, &type, &p, &count) || !p) { |
if (!headerGetEntry(h, val, &type, &p, &count) || !p) { |
rpm->nb_requires = 0; |
rpm->extra->nb_requires = 0; |
rpm->requires = NULL; |
rpm->extra->requires = NULL; |
} else { |
} else { |
rpm->max_requires = count; |
rpm->extra->max_requires = count; |
rpm->requires = (rpmRessPtr *) malloc(sizeof(rpmRessPtr) * |
rpm->extra->requires = (rpmRessPtr *) malloc(sizeof(rpmRessPtr) * |
rpm->max_requires); |
rpm->extra->max_requires); |
if (rpm->requires == NULL) { |
if (rpm->extra->requires == NULL) { |
fprintf(stderr, ": ran out of memory\n"); |
fprintf(stderr, ": ran out of memory\n"); |
exit(1); |
exit(1); |
} |
} |
|
|
rpm->nb_requires = 0; |
rpm->extra->nb_requires = 0; |
for (i = 0, j = 0; i < count;i++) { |
for (i = 0, j = 0; i < count;i++) { |
if (!checkResourceName(((char **) p)[i])) continue; |
if (!checkResourceName(((char **) p)[i])) continue; |
rpm->requires[j++] = rpmRequAdd(((char **) p)[i], rpm, installed); |
rpm->extra->requires[j++] = rpmRequAdd(((char **) p)[i], rpm, installed); |
} |
} |
rpm->nb_requires = j; |
rpm->extra->nb_requires = j; |
} |
} |
val = getTagNumber("RPMTAG_FILENAMES"); |
val = getTagNumber("RPMTAG_FILENAMES"); |
if (!headerGetEntry(h, val, &type, &p, &count) || !p) { |
if (!headerGetEntry(h, val, &type, &p, &count) || !p) { |
rpm->filelist = NULL; /* No filelist in the package ! */ |
rpm->extra->filelist = NULL; /* No filelist in the package ! */ |
} else { |
} else { |
char *ptr = buffer; |
char *ptr = buffer; |
|
|
Line 399 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 427 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
} |
} |
ptr += sprintf(ptr, "%s\n", ((char **) p)[i]); |
ptr += sprintf(ptr, "%s\n", ((char **) p)[i]); |
} |
} |
rpm->filelist = strdup(buffer); |
rpm->extra->filelist = strdup(buffer); |
} |
} |
|
|
/* Add the package files to the real filesystem tree if asked for */ |
/* Add the package files to the real filesystem tree if asked for */ |
if ((dir->build_tree != 0) && (rpm->filelist != NULL)) { |
if ((dir->build_tree != 0) && (rpm->extra->filelist != NULL)) { |
char *cur, *filename; |
char *cur, *filename; |
|
|
cur = rpm->filelist; |
cur = rpm->extra->filelist; |
while ((*cur != '\0') && (*cur != '/')) cur++; |
while ((*cur != '\0') && (*cur != '/')) cur++; |
filename = cur; |
filename = cur; |
while (*cur != '\0') { |
while (*cur != '\0') { |
Line 431 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
Line 459 rpmDataPtr rpmAnalyze(char *nameRpm, Hea
|
if (rpm2html_dump_rdf) |
if (rpm2html_dump_rdf) |
dumpRpmRdf(rpm, tree); |
dumpRpmRdf(rpm, tree); |
|
|
/* free large amount of data not used later */ |
/* free the extra data */ |
if (rpm->filelist) free(rpm->filelist); |
rpmFreeExtraData(rpm); |
rpm->filelist = NULL; |
|
if (rpm->copyright) free(rpm->copyright); |
|
rpm->copyright = NULL; |
|
if (rpm->changelog) free(rpm->changelog); |
|
rpm->changelog = NULL; |
|
if (rpm->description) free(rpm->description); |
|
rpm->description = NULL; |
|
|
|
/* increment the counters */ |
/* increment the counters */ |
if (installed) { |
if (installed) { |