Add support for new virtual file attribute "%artifact"

This can be used to differentiate files that are not natural parts of
packages but created as by-products of our processing so they're easy
to filter out of queries.

Possible candidates include build-ids, byte compiled files etc, but this
nothing is automatically marked as artifact in this commit.
This commit is contained in:
Panu Matilainen 2017-11-08 10:53:15 +02:00
parent bcd2495534
commit 6f1e75ddd2
8 changed files with 24 additions and 4 deletions

View File

@ -857,6 +857,7 @@ static VFA_t const virtualAttrs[] = {
{ "%license", RPMFILE_LICENSE },
{ "%pubkey", RPMFILE_PUBKEY },
{ "%missingok", RPMFILE_MISSINGOK },
{ "%artifact", RPMFILE_ARTIFACT },
{ NULL, 0 }
};

View File

@ -74,7 +74,7 @@ Files:
[\fB-c,--configfiles\fR] [\fB-d,--docfiles\fR] [\fB--dump\fR] [\fB--fileclass\fR]
[\fB--filecolor\fR] [\fB--fileprovide\fR][\fB--filerequire\fR] [\fB--filecaps\fR]
[\fB--filesbypkg\fR] [\fB-l,--list\fR] [\fB-s,--state\fR]
[\fB--noghost\fR] [\fB--noconfig\fR]
[\fB--noartifact\fR] [\fB--noghost\fR] [\fB--noconfig\fR
.PP
Scripts and triggers:
[\fB--filetriggers\fR] [\fB--scripts\fR] [\fB--triggers,--triggerscripts\fR]
@ -632,6 +632,9 @@ Query all packages that enhance \fICAPABILITY\fR.
.SS "PACKAGE QUERY OPTIONS:"
.PP
.TP
\fB-d, --artifactfiles\fR
List only artifact files (implies \fB-l\fR).
.TP
\fB--changelog\fR
Display change information for the package.
.TP
@ -714,6 +717,8 @@ Display the \fIstates\fR of files in the package
Display the trigger scripts, if any, which are contained in
the package.
.TP
\fB--noartifact\fR
Don't display artifact files.
\fB--noghost\fR
Don't display ghost files. Useful in combination with option --list.
.TP

View File

@ -131,6 +131,7 @@ static void queryArgCallback(poptContext con,
case 'c': qva->qva_flags |= QUERY_FOR_CONFIG | QUERY_FOR_LIST; break;
case 'd': qva->qva_flags |= QUERY_FOR_DOCS | QUERY_FOR_LIST; break;
case 'L': qva->qva_flags |= QUERY_FOR_LICENSE | QUERY_FOR_LIST; break;
case 'A': qva->qva_flags |= QUERY_FOR_ARTIFACT | QUERY_FOR_LIST; break;
case 'l': qva->qva_flags |= QUERY_FOR_LIST; break;
case 's': qva->qva_flags |= QUERY_FOR_STATE | QUERY_FOR_LIST;
break;
@ -194,6 +195,8 @@ struct poptOption rpmQueryPoptTable[] = {
N_("list all documentation files"), NULL },
{ "licensefiles", 'L', 0, 0, 'L',
N_("list all license files"), NULL },
{ "artifactfiles", 'A', 0, 0, 'A',
N_("list all artifact files"), NULL },
{ "dump", '\0', 0, 0, POPT_DUMP,
N_("dump basic file information"), NULL },
{ NULL, 'i', POPT_ARGFLAG_DOC_HIDDEN, 0, 'i',
@ -208,6 +211,9 @@ struct poptOption rpmQueryPoptTable[] = {
{ "noconfig", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmQVKArgs.qva_fflags, RPMFILE_CONFIG,
N_("skip %%config files"), NULL },
{ "noartifact", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmQVKArgs.qva_fflags, RPMFILE_ARTIFACT,
N_("skip %%artifact files"), NULL },
{ "qf", '\0', POPT_ARG_STRING | POPT_ARGFLAG_DOC_HIDDEN, 0,
POPT_QUERYFORMAT, NULL, NULL },

View File

@ -147,6 +147,10 @@ int showQueryPackage(QVA_t qva, rpmts ts, Header h)
if ((qva->qva_flags & QUERY_FOR_LICENSE) && !(fflags & RPMFILE_LICENSE))
continue;
/* If querying only ... yes we know the drill, and this is dumb. */
if ((qva->qva_flags & QUERY_FOR_ARTIFACT) && !(fflags & RPMFILE_ARTIFACT))
continue;
/* Skip on attributes (eg from --noghost) */
if (fflags & qva->qva_fflags)
continue;

View File

@ -133,7 +133,8 @@ enum rpmQueryFlags_e {
QUERY_FOR_DOCS = (1 << 25), /*!< query: from --docfiles */
QUERY_FOR_CONFIG = (1 << 26), /*!< query: from --configfiles */
QUERY_FOR_DUMPFILES = (1 << 27), /*!< query: from --dump */
QUERY_FOR_LICENSE = (1 << 28) /*!< query: from --licensefiles */
QUERY_FOR_LICENSE = (1 << 28), /*!< query: from --licensefiles */
QUERY_FOR_ARTIFACT = (1 << 29), /*!< query: from --artifacts */
};
typedef rpmFlags rpmQueryFlags;

View File

@ -60,6 +60,7 @@ enum rpmfileAttrs_e {
RPMFILE_README = (1 << 8), /*!< from %%readme */
/* bits 9-10 unused */
RPMFILE_PUBKEY = (1 << 11), /*!< from %%pubkey */
RPMFILE_ARTIFACT = (1 << 12), /*!< from %%artifact */
};
typedef rpmFlags rpmfileAttrs;

View File

@ -315,7 +315,7 @@ char * rpmVerifyString(uint32_t verifyResult, const char *pad)
char * rpmFFlagsString(uint32_t fflags, const char *pad)
{
char *fmt = NULL;
rasprintf(&fmt, "%s%s%s%s%s%s%s%s",
rasprintf(&fmt, "%s%s%s%s%s%s%s%s%s",
(fflags & RPMFILE_DOC) ? "d" : pad,
(fflags & RPMFILE_CONFIG) ? "c" : pad,
(fflags & RPMFILE_SPECFILE) ? "s" : pad,
@ -323,7 +323,8 @@ char * rpmFFlagsString(uint32_t fflags, const char *pad)
(fflags & RPMFILE_NOREPLACE) ? "n" : pad,
(fflags & RPMFILE_GHOST) ? "g" : pad,
(fflags & RPMFILE_LICENSE) ? "l" : pad,
(fflags & RPMFILE_README) ? "r" : pad);
(fflags & RPMFILE_README) ? "r" : pad,
(fflags & RPMFILE_ARTIFACT) ? "a" : pad);
return fmt;
}

View File

@ -421,6 +421,7 @@ static int initModule(PyObject *m)
REGISTER_ENUM(RPMFILE_LICENSE);
REGISTER_ENUM(RPMFILE_README);
REGISTER_ENUM(RPMFILE_PUBKEY);
REGISTER_ENUM(RPMFILE_ARTIFACT);
REGISTER_ENUM(RPMDEP_SENSE_REQUIRES);
REGISTER_ENUM(RPMDEP_SENSE_CONFLICTS);