Add a flag to allow quiet test for package existence with lookupPackage()

Turning "flag" into an actual bitfield requires testing for
PART_NAME/PART_SUBNAME differently, no actual changes here though.
This commit is contained in:
Panu Matilainen 2017-08-18 12:43:27 +03:00
parent 94e8cd6058
commit 4afe09cbcf
2 changed files with 10 additions and 7 deletions

View File

@ -138,6 +138,7 @@ struct Package_s {
#define PART_SUBNAME 0
#define PART_NAME 1
#define PART_QUIET 2
/** \ingroup rpmbuild
* rpmSpec file parser states.

View File

@ -73,7 +73,7 @@ rpmRC lookupPackage(rpmSpec spec, const char *name, int flag,Package *pkg)
}
/* Construct partial package name */
if (flag == PART_SUBNAME) {
if (!(flag & PART_NAME)) {
rasprintf(&fullName, "%s-%s",
headerGetString(spec->packages->header, RPMTAG_NAME), name);
name = fullName;
@ -87,12 +87,14 @@ rpmRC lookupPackage(rpmSpec spec, const char *name, int flag,Package *pkg)
}
}
if (p == NULL && pkg != NULL) {
rpmlog(RPMLOG_ERR, _("line %d: %s: package %s does not exist\n"),
spec->lineNum, spec->line, name);
} else if (p != NULL && pkg == NULL) {
rpmlog(RPMLOG_ERR, _("line %d: %s: package %s already exists\n"),
spec->lineNum, spec->line, name);
if (!(flag & PART_QUIET)) {
if (p == NULL && pkg != NULL) {
rpmlog(RPMLOG_ERR, _("line %d: %s: package %s does not exist\n"),
spec->lineNum, spec->line, name);
} else if (p != NULL && pkg == NULL) {
rpmlog(RPMLOG_ERR, _("line %d: %s: package %s already exists\n"),
spec->lineNum, spec->line, name);
}
}
if (fullName == name)