headerNVR() replaced by the new header{NVRD,Name{,Version}}() in trivial cases

These are the cases where even the release was not needed (so, the
disttag is not needed, too), or one case where the filename is
contructed (and it doesn't include the disttag).

Now grep -Ee 'headerNVR[^D]' will show the remaining non-trivial
cases, where adapting to disttags may be needed.
This commit is contained in:
Ivan Zakharyaschev 2019-02-25 05:06:13 +03:00
parent fa7947df25
commit 6be20da468
13 changed files with 35 additions and 24 deletions

View File

@ -908,7 +908,7 @@ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char * buf,
custom = 1;
} else {
const char *n, *v;
(void) headerNVR(pkg->header, &n, &v, NULL);
(void) headerNameVersion(pkg->header, &n, &v);
ddir = rpmGetPath("%{_docdir}/", n, "-", v, NULL);
}
strcpy(buf, ddir);
@ -2547,7 +2547,7 @@ const char *saveInstScript(Spec spec, Package pkg, const char *scriptname)
assert(buildroot);
const char *N = NULL;
headerNVR(pkg->header, &N, NULL, NULL);
headerName(pkg->header, &N);
assert(N);
const char *path =
@ -2729,10 +2729,10 @@ checkProvides(Spec spec, Package pkg)
if (p == pkg)
continue;
const char *n = NULL;
headerNVR(p->header, &n, NULL, NULL);
headerName(p->header, &n);
for (i = 0; i < len; ++i) {
if (!strcmp(n, names[i])) {
headerNVR(pkg->header, &n, NULL, NULL);
headerName(pkg->header, &n);
rpmMessage(RPMMESS_WARNING,
"%s provides another subpackage: %s\n", n, names[i]);
break;
@ -3062,13 +3062,14 @@ int processBinaryFiles(Spec spec, int installSpecialDoc, int test)
int rc = 0;
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
const char *n, *v, *r;
if (pkg->fileList == NULL)
continue;
(void) headerNVR(pkg->header, &n, &v, &r);
rpmMessage(RPMMESS_NORMAL, _("Processing files: %s-%s-%s\n"), n, v, r);
{
const char *n, *v, *r;
(void) headerNVRD(pkg->header, &n, &v, &r, NULL);
rpmMessage(RPMMESS_NORMAL, _("Processing files: %s-%s-%s\n"), n, v, r);
}
rc = processPackageFiles(spec, pkg, installSpecialDoc, test);
if (rc) break;

View File

@ -18,7 +18,7 @@ const char *pkgName(Package pkg)
if (fi)
return fi->name;
const char *name;
headerNVR(pkg->header, &name, NULL, NULL);
headerName(pkg->header, &name);
return name;
}

View File

@ -29,7 +29,7 @@ static inline int genSourceRpmName(Spec spec)
const char *name, *version, *release;
char fileName[BUFSIZ];
(void) headerNVR(spec->packages->header, &name, &version, &release);
(void) headerNVRD(spec->packages->header, &name, &version, &release, NULL);
sprintf(fileName, "%s-%s-%s.%ssrc.rpm", name, version, release,
spec->noSource ? "no" : "");
spec->sourceRpmName = xstrdup(fileName);
@ -488,7 +488,7 @@ int writeRPM(Header *hdrp, const char *fileName, int type,
rpmio_flags = rpmExpand("%{?_source_payload}", NULL);
break;
case RPMLEAD_BINARY:
headerNVR(h, &N, NULL, NULL);
headerName(h, &N);
dash = strrchr(N, '-');
if (dash && strcmp(dash, "-debuginfo") == 0)
rpmio_flags = rpmExpand("%{?_debuginfo_payload}", NULL);
@ -837,7 +837,7 @@ int packageBinaries(Spec spec)
binFormat = _free(binFormat);
if (binRpm == NULL) {
const char *name;
(void) headerNVR(pkg->header, &name, NULL, NULL);
(void) headerName(pkg->header, &name);
rpmError(RPMERR_BADFILENAME, _("Could not generate output "
"filename for package %s: %s\n"), name, errorString);
return RPMERR_BADFILENAME;

View File

@ -917,7 +917,7 @@ int parsePreamble(Spec spec, int initialPackage)
/* Construct the package */
if (flag == PART_SUBNAME) {
const char * mainName;
xx = headerNVR(spec->packages->header, &mainName, NULL, NULL);
xx = headerName(spec->packages->header, &mainName);
sprintf(NVR, "%s-%s", mainName, name);
} else
strcpy(NVR, name);

View File

@ -364,7 +364,7 @@ static int doSetupMacro(Spec spec, char *line)
spec->buildSubdir = xstrdup(dirName);
} else {
const char *name, *version;
(void) headerNVR(spec->packages->header, &name, &version, NULL);
(void) headerNameVersion(spec->packages->header, &name, &version);
snprintf(buf, sizeof(buf), "%s-%s", name, version);
spec->buildSubdir = xstrdup(buf);
}

View File

@ -860,7 +860,7 @@ fprintf(stderr, "*** PS buildRootURL(%s) %p macro set to %s\n", spec->buildRootU
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
if (!headerIsEntry(pkg->header, RPMTAG_DESCRIPTION)) {
const char * name;
(void) headerNVR(pkg->header, &name, NULL, NULL);
(void) headerName(pkg->header, &name);
rpmError(RPMERR_BADSPEC, _("Package has no %%description: %s\n"),
name);
spec = freeSpec(spec);

View File

@ -74,7 +74,7 @@ int lookupPackage(Spec spec, const char *name, int flag, /*@out@*/Package *pkg)
/* Construct package name */
{ char *n;
if (flag == PART_SUBNAME) {
(void) headerNVR(spec->packages->header, &pname, NULL, NULL);
(void) headerName(spec->packages->header, &pname);
fullName = n = alloca(strlen(pname) + 1 + strlen(name) + 1);
while (*pname != '\0') *n++ = *pname++;
*n++ = '-';
@ -88,7 +88,7 @@ int lookupPackage(Spec spec, const char *name, int flag, /*@out@*/Package *pkg)
/* Locate package with fullName */
for (p = spec->packages; p != NULL; p = p->next) {
(void) headerNVR(p->header, &pname, NULL, NULL);
(void) headerName(p->header, &pname);
if (pname && (! strcmp(fullName, pname))) {
break;
}

View File

@ -448,7 +448,7 @@ int rpmtransAddPackage(rpmTransactionSet ts, Header h, FD_t fd,
if (headerIsEntry(h, RPMTAG_SOURCEPACKAGE))
return 0;
(void) headerNVR(h, &name, NULL, NULL);
(void) headerName(h, &name);
{ rpmdbMatchIterator mi;
Header h2;

View File

@ -631,7 +631,7 @@ static int i18nTag(Header h, int_32 tag, /*@out@*/ rpmTagType * type,
const char * n;
char * mk;
size_t nb = sizeof("()");
int xx = headerNVR(h, &n, NULL, NULL);
int xx = headerName(h, &n);
if (tn) nb += strlen(tn);
if (n) nb += strlen(n);
mk = alloca(nb);

View File

@ -1048,7 +1048,7 @@ static int handleOneTrigger(PSM_t psm, Header sourceH, Header triggeredH,
)
return 0;
xx = headerNVR(sourceH, &sourceName, NULL, NULL);
xx = headerName(sourceH, &sourceName);
for (i = 0; i < numTriggers; i++) {
rpmTagType tit, tst, tpt;
@ -1082,7 +1082,7 @@ static int handleOneTrigger(PSM_t psm, Header sourceH, Header triggeredH,
)
continue;
xx = headerNVR(triggeredH, &triggerPackageName, NULL, NULL);
xx = headerName(triggeredH, &triggerPackageName);
{ int arg1;
int index;

View File

@ -446,7 +446,7 @@ printNewSpecfile(Spec spec)
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
const char *pkgname;
h = pkg->header;
(void) headerNVR(h, &pkgname, NULL, NULL);
(void) headerName(h, &pkgname);
if (!strcmp(pkgname, fmt))
/*@innerbreak@*/ break;
}

View File

@ -467,7 +467,7 @@ restart:
paths = headerFreeData(paths, pft);
} else {
const char * name;
xx = headerNVR(eiu->h, &name, NULL, NULL);
xx = headerName(eiu->h, &name);
rpmMessage(RPMMESS_ERROR,
_("package %s is not relocatable\n"), name);
eiu->numFailed++;
@ -483,7 +483,7 @@ restart:
Header oldH;
int count;
xx = headerNVR(eiu->h, &name, NULL, NULL);
xx = headerName(eiu->h, &name);
/*@-onlytrans@*/
mi = rpmdbInitIterator(eiu->db, RPMTAG_NAME, name, 0);
/*@=onlytrans@*/

View File

@ -119,6 +119,16 @@ int headerNVRD(Header h,
/*@null@*/ /*@out@*/ const char ** dp)
/*@modifies *np, *vp, *rp, *dp @*/;
static inline int headerNameVersion(Header h, const char **np, const char **vp)
{
return headerNVRD(h, np, vp, NULL, NULL);
}
static inline int headerName(Header h, const char **np)
{
return headerNVRD(h, np, NULL, NULL, NULL);
}
/** \ingroup header
* Return name, epoch, version, release, arch strings from header.
* @param h header