rpm/rpm-5.4.10-Force-AutoReq-on-top-of-noautoreq.patch
2019-04-16 11:40:58 +03:00

114 lines
4 KiB
Diff

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;
};