Add --excludeartifacts install option

Like docs, configs etc, excluding artifacts from installation might
sometimes be desireable to eg save space. Inspired by
https://bugzilla.redhat.com/show_bug.cgi?id=1848199
This commit is contained in:
Panu Matilainen 2020-06-18 08:44:14 +03:00
parent 1870f4df16
commit 07ed169da3
5 changed files with 34 additions and 1 deletions

View File

@ -263,6 +263,10 @@ included in the binary package relocation hint(s).
Don't install files whose name begins with Don't install files whose name begins with
\fIOLDPATH\fR. \fIOLDPATH\fR.
.TP .TP
\fB--excludeartifacts\fR
Don't install any files which are marked as artifacts,
such as build-id links.
.TP
\fB--excludedocs\fR \fB--excludedocs\fR
Don't install any files which are marked as documentation Don't install any files which are marked as documentation
(which includes man pages and texinfo documents). (which includes man pages and texinfo documents).

View File

@ -133,6 +133,9 @@ struct poptOption rpmInstallPoptTable[] = {
{ "erase", 'e', POPT_BIT_SET, { "erase", 'e', POPT_BIT_SET,
&rpmIArgs.installInterfaceFlags, INSTALL_ERASE, &rpmIArgs.installInterfaceFlags, INSTALL_ERASE,
N_("erase (uninstall) package"), N_("<package>+") }, N_("erase (uninstall) package"), N_("<package>+") },
{ "excludeartifacts", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_NOARTIFACTS,
N_("do not install artifacts"), NULL},
{ "excludeconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, { "excludeconfigs", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN,
&rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS, &rpmIArgs.transFlags, RPMTRANS_FLAG_NOCONFIGS,
N_("do not install configuration files"), NULL}, N_("do not install configuration files"), NULL},

View File

@ -51,7 +51,8 @@ enum rpmtransFlags_e {
/* bit 26 unused */ /* bit 26 unused */
RPMTRANS_FLAG_NOMD5 = (1 << 27), /*!< from --nomd5 */ RPMTRANS_FLAG_NOMD5 = (1 << 27), /*!< from --nomd5 */
RPMTRANS_FLAG_NOFILEDIGEST = (1 << 27), /*!< from --nofiledigest (alias to --nomd5) */ RPMTRANS_FLAG_NOFILEDIGEST = (1 << 27), /*!< from --nofiledigest (alias to --nomd5) */
/* bits 28-29 unused */ /* bit 28 unused */
RPMTRANS_FLAG_NOARTIFACTS = (1 << 29), /*!< from --noartifacts */
RPMTRANS_FLAG_NOCONFIGS = (1 << 30), /*!< from --noconfigs */ RPMTRANS_FLAG_NOCONFIGS = (1 << 30), /*!< from --noconfigs */
RPMTRANS_FLAG_DEPLOOPS = (1 << 31) /*!< from --deploops */ RPMTRANS_FLAG_DEPLOOPS = (1 << 31) /*!< from --deploops */
}; };

View File

@ -825,6 +825,7 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
rpm_color_t FColor; rpm_color_t FColor;
int noConfigs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONFIGS); int noConfigs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONFIGS);
int noDocs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NODOCS); int noDocs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NODOCS);
int noArtifacts = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOARTIFACTS);
int * drc; int * drc;
char * dff; char * dff;
int dc; int dc;
@ -924,6 +925,13 @@ static void skipInstallFiles(const rpmts ts, rpmfiles files, rpmfs fs)
rpmfsSetAction(fs, i, FA_SKIPNSTATE); rpmfsSetAction(fs, i, FA_SKIPNSTATE);
continue; continue;
} }
/* Skip artifacts if requested. */
if (noArtifacts && (rpmfiFFlags(fi) & RPMFILE_ARTIFACT)) {
drc[ix]--; dff[ix] = 1;
rpmfsSetAction(fs, i, FA_SKIPNSTATE);
continue;
}
} }
/* Skip (now empty) directories that had skipped files. */ /* Skip (now empty) directories that had skipped files. */

View File

@ -666,3 +666,20 @@ runroot rpm -e testdoc
[]) [])
AT_CLEANUP AT_CLEANUP
AT_SETUP([rpm -i --excludeartifacts])
AT_KEYWORDS([install])
RPMDB_INIT
runroot rpmbuild --quiet -bb /data/SPECS/vattrtest.spec
AT_CHECK([
RPMDB_INIT
runroot rpm -i --excludeartifacts /build/RPMS/noarch/vattrtest-1.0-1.noarch.rpm
test -e ${RPMTEST}/opt/vattrtest/a && exit 1
runroot rpm -e vattrtest
runroot rpm -i /build/RPMS/noarch/vattrtest-1.0-1.noarch.rpm
test -e ${RPMTEST}/opt/vattrtest/a || exit 1
],
[0],
[],
[])
AT_CLEANUP