Patch: allow forcing AutoReq on top of %%__noautoreq

This commit is contained in:
Mikhail Novosyolov 2019-04-16 10:10:51 +03:00
parent 5e882d4ae7
commit 279e18c8b9
2 changed files with 119 additions and 1 deletions

View file

@ -0,0 +1,114 @@
From d3fe91a3be1b0f05ef0b1a48da1e2ee7528637f9 Mon Sep 17 00:00:00 2001
From: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Date: Tue, 16 Apr 2019 10:07:38 +0300
Subject: [PATCH] Force AutoReq on top of noautoreq
Allow overriding %%__noautoreq by %%__forceautoreq
and %%__noautoreqfiles by %%__forceautoreqfiles
Will be used in the samba package
diff --git a/lib/rpmfc.c b/lib/rpmfc.c
index 8049ff5..da2b6de 100644
--- a/lib/rpmfc.c
+++ b/lib/rpmfc.c
@@ -822,7 +822,9 @@ static int rpmfcSCRIPT(rpmfc fc)
if (!_filter_values
|| (!fc->skipReq
- && !rpmfcMatchRegexps(fc->Rmires, fc->Rnmire, s, 'R')))
+ && !rpmfcMatchRegexps(fc->Rmires, fc->Rnmire, ds->N[0], 'R'))
+ || rpmfcMatchRegexps(fc->FARmires, fc->FARnmire, ds->N[0], 'R')
+ || fc->forceReq)
if (is_executable) {
/* Add to package requires. */
ds = rpmdsSingle(RPMTAG_REQUIRENAME, s, "", RPMSENSE_FIND_REQUIRES);
@@ -976,7 +978,9 @@ fprintf(stderr, "*** rpmfcMergePR(%p, %p) %s\n", context, ds, tagName(rpmdsTagN(
case RPMTAG_REQUIRENAME:
if (!_filter_values
|| (!fc->skipReq
- && !rpmfcMatchRegexps(fc->Rmires, fc->Rnmire, ds->N[0], 'R')))
+ && !rpmfcMatchRegexps(fc->Rmires, fc->Rnmire, ds->N[0], 'R'))
+ || rpmfcMatchRegexps(fc->FARmires, fc->FARnmire, ds->N[0], 'R')
+ || fc->forceReq)
{
/* Add to package requires. */
rc = rpmdsMerge(&fc->requires, ds);
@@ -1084,6 +1088,7 @@ rpmRC rpmfcApply(rpmfc fc)
miRE mire;
int skipProv = fc->skipProv;
int skipReq = fc->skipReq;
+ int forceReq = fc->forceReq;
int j;
if (_filter_execs) {
@@ -1097,6 +1102,12 @@ rpmRC rpmfcApply(rpmfc fc)
if (fc->RFnmire > 0)
rpmlog(RPMLOG_DEBUG, D_("added %d %%__noautoreqfiles patterns.\n"),
fc->RFnmire);
+ /* files matching __forceautoreqfiles will overwrite matches in __noautoreqfiles */
+ fc->FQRnmire = 0;
+ fc->FQRmires = rpmfcExpandRegexps("%{?__forceautoreqfiles}", &fc->FQRnmire);
+ if (fc->FQRnmire > 0)
+ rpmlog(RPMLOG_DEBUG, D_("added %d %%__forceautoreqfiles patterns.\n"),
+ fc->FQRnmire);
fc->Pnmire = 0;
fc->Pmires = rpmfcExpandRegexps("%{?__noautoprov}", &fc->Pnmire);
if (fc->Pnmire > 0)
@@ -1107,6 +1118,12 @@ rpmRC rpmfcApply(rpmfc fc)
if (fc->Rnmire > 0)
rpmlog(RPMLOG_DEBUG, D_("added %d %%__noautoreq patterns.\n"),
fc->Rnmire);
+ /* reqs matching __forceautoreq will overwrite __noautoreq */
+ fc->FARnmire = 0;
+ fc->FARmires = rpmfcExpandRegexps("%{?__forceautoreq}", &fc->FARnmire);
+ if (fc->FARnmire > 0)
+ rpmlog(RPMLOG_DEBUG, D_("added %d %%__forceautoreq patterns.\n"),
+ fc->FARnmire);
}
/* Make sure something didn't go wrong previously! */
@@ -1171,6 +1188,18 @@ assert(fc->fn != NULL);
fc->skipReq = 1;
/*@innerbreak@*/ break;
}
+ /* Now check that file is not in list of files from expanded %%__forceautoreqfiles
+ * If yes, then remove skipReq */
+ if ((mire = (miRE)fc->FQRmires) != NULL)
+ for (j = 0; j < fc->FQRnmire; j++, mire++) {
+ fn = fc->fn[fc->ix] + fc->brlen;
+ if ((xx = mireRegexec(mire, fn, 0)) < 0)
+ /*@innercontinue@*/ continue;
+ rpmlog(RPMLOG_NOTICE, _("Forcing %s requires detection\n"),
+ fn);
+ fc->forceReq = 1;
+ /*@innerbreak@*/ break;
+ }
}
xx = (*fcat->func) (fc);
diff --git a/lib/rpmfc.h b/lib/rpmfc.h
index b5d5430..1eac4c9 100644
--- a/lib/rpmfc.h
+++ b/lib/rpmfc.h
@@ -76,6 +76,7 @@ struct rpmfc_s {
size_t ix; /*!< current file index */
int skipProv; /*!< Don't auto-generate Provides:? */
int skipReq; /*!< Don't auto-generate Requires:? */
+ int forceReq; /*!< Force generating Requires despite skipReq:? */
int tracked; /*!< Versioned Provides: tracking dependency added? */
size_t brlen; /*!< strlen(spec->buildRoot) */
@@ -110,6 +111,12 @@ struct rpmfc_s {
/*@null@*/
void * RFmires; /*!< Filter patterns from %{__noautoreqfile} */
int RFnmire;
+/*@null@*/
+ void * FQRmires; /*!< Filter patterns from %{__forceautoreqfile} */
+ int FQRnmire;
+/*@null@*/
+ void * FARmires; /*!< Filter patterns from %{__forceautoreq} */
+ int FARnmire;
};

View file

@ -61,7 +61,7 @@ Summary: The RPM package management system
Name: rpm
Epoch: 1
Version: %{libver}.%{minorver}
Release: %{?prereldate:0.%{prereldate}.}87
Release: %{?prereldate:0.%{prereldate}.}89
License: LGPLv2.1+
Group: System/Configuration/Packaging
Url: http://rpm5.org/
@ -533,6 +533,7 @@ Patch520: rpm-5.4.10-Multithreaded-XZ.patch
Patch521: rpm-5.4.10-Use-multithreaded-XZ-by-default-for-both-binary-and-.patch
Patch522: rpm-5.4.10-multithreaded-xz-memlimit.patch
Patch523: rpm-5.4.10-Parse-private-dependencies-from-pkgconfig-files.patch
Patch524: rpm-5.4.10-Force-AutoReq-on-top-of-noautoreq.patch
BuildRequires: autoconf >= 2.57
BuildRequires: bzip2-devel
@ -1202,6 +1203,9 @@ This package contains the RPM API documentation generated in HTML format.
%patch521 -p1 -b .MultithreadedXZbyDefault
%patch522 -p1 -b .MultithreadedXZ32bitMemLimit
%patch523 -p1 -b .ParsePkgconfigPrivate
# rpm-5.4.10-Force-AutoReq-on-top-of-noautoreq.patch
# Apply it with offsets which appear because of a lot of previous patches
patch -p1 < %{PATCH524}
#required by P55, P80, P81, P94..
./autogen.sh