alexk / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
976aaf
diff -up rpm-4.14.3/lib/rpmscript.c.orig rpm-4.14.3/lib/rpmscript.c
976aaf
--- rpm-4.14.3/lib/rpmscript.c.orig	2021-02-08 14:07:44.527197946 +0100
976aaf
+++ rpm-4.14.3/lib/rpmscript.c	2021-02-08 14:09:05.732749080 +0100
976aaf
@@ -46,27 +46,27 @@ struct scriptInfo_s {
976aaf
 };
976aaf
 
976aaf
 static const struct scriptInfo_s scriptInfo[] = {
976aaf
-    { RPMSCRIPT_PREIN, "%prein", 0,
976aaf
+    { RPMSCRIPT_PREIN, "prein", 0,
976aaf
 	RPMTAG_PREIN, RPMTAG_PREINPROG, RPMTAG_PREINFLAGS },
976aaf
-    { RPMSCRIPT_PREUN, "%preun", 0,
976aaf
+    { RPMSCRIPT_PREUN, "preun", 0,
976aaf
 	RPMTAG_PREUN, RPMTAG_PREUNPROG, RPMTAG_PREUNFLAGS },
976aaf
-    { RPMSCRIPT_POSTIN, "%post", 0,
976aaf
+    { RPMSCRIPT_POSTIN, "post", 0,
976aaf
 	RPMTAG_POSTIN, RPMTAG_POSTINPROG, RPMTAG_POSTINFLAGS },
976aaf
-    { RPMSCRIPT_POSTUN, "%postun", 0,
976aaf
+    { RPMSCRIPT_POSTUN, "postun", 0,
976aaf
 	RPMTAG_POSTUN, RPMTAG_POSTUNPROG, RPMTAG_POSTUNFLAGS },
976aaf
-    { RPMSCRIPT_PRETRANS, "%pretrans", 0,
976aaf
+    { RPMSCRIPT_PRETRANS, "pretrans", 0,
976aaf
 	RPMTAG_PRETRANS, RPMTAG_PRETRANSPROG, RPMTAG_PRETRANSFLAGS },
976aaf
-    { RPMSCRIPT_POSTTRANS, "%posttrans", 0,
976aaf
+    { RPMSCRIPT_POSTTRANS, "posttrans", 0,
976aaf
 	RPMTAG_POSTTRANS, RPMTAG_POSTTRANSPROG, RPMTAG_POSTTRANSFLAGS },
976aaf
-    { RPMSCRIPT_TRIGGERPREIN, "%triggerprein", RPMSENSE_TRIGGERPREIN,
976aaf
+    { RPMSCRIPT_TRIGGERPREIN, "triggerprein", RPMSENSE_TRIGGERPREIN,
976aaf
 	RPMTAG_TRIGGERPREIN, 0, 0 },
976aaf
-    { RPMSCRIPT_TRIGGERUN, "%triggerun", RPMSENSE_TRIGGERUN,
976aaf
+    { RPMSCRIPT_TRIGGERUN, "triggerun", RPMSENSE_TRIGGERUN,
976aaf
 	RPMTAG_TRIGGERUN, 0, 0 },
976aaf
-    { RPMSCRIPT_TRIGGERIN, "%triggerin", RPMSENSE_TRIGGERIN,
976aaf
+    { RPMSCRIPT_TRIGGERIN, "triggerin", RPMSENSE_TRIGGERIN,
976aaf
 	RPMTAG_TRIGGERIN, 0, 0 },
976aaf
-    { RPMSCRIPT_TRIGGERPOSTUN, "%triggerpostun", RPMSENSE_TRIGGERPOSTUN,
976aaf
+    { RPMSCRIPT_TRIGGERPOSTUN, "triggerpostun", RPMSENSE_TRIGGERPOSTUN,
976aaf
 	RPMTAG_TRIGGERPOSTUN, 0, 0 },
976aaf
-    { RPMSCRIPT_VERIFY, "%verify", 0,
976aaf
+    { RPMSCRIPT_VERIFY, "verify", 0,
976aaf
 	RPMTAG_VERIFYSCRIPT, RPMTAG_VERIFYSCRIPTPROG, RPMTAG_VERIFYSCRIPTFLAGS},
976aaf
     { 0, "unknown", 0,
976aaf
 	RPMTAG_NOT_FOUND, RPMTAG_NOT_FOUND, RPMTAG_NOT_FOUND }
976aaf
@@ -457,7 +457,7 @@ static const char * tag2sln(rpmTagVal ta
976aaf
 }
976aaf
 
976aaf
 static rpmScript rpmScriptNew(Header h, rpmTagVal tag, const char *body,
976aaf
-			      rpmscriptFlags flags)
976aaf
+			      rpmscriptFlags flags, const char *prefix)
976aaf
 {
976aaf
     char *nevra = headerGetAsString(h, RPMTAG_NEVRA);
976aaf
     rpmScript script = xcalloc(1, sizeof(*script));
976aaf
@@ -465,7 +465,7 @@ static rpmScript rpmScriptNew(Header h,
976aaf
     script->type = getScriptType(tag);
976aaf
     script->flags = flags;
976aaf
     script->body = (body != NULL) ? xstrdup(body) : NULL;
976aaf
-    rasprintf(&script->descr, "%s(%s)", tag2sln(tag), nevra);
976aaf
+    rasprintf(&script->descr, "%%%s%s(%s)", prefix, tag2sln(tag), nevra);
976aaf
 
976aaf
     /* macros need to be expanded before possible queryformat */
976aaf
     if (script->body && (script->flags & RPMSCRIPT_FLAG_EXPAND)) {
976aaf
@@ -556,6 +556,7 @@ rpmScript rpmScriptFromTriggerTag(Header
976aaf
     rpmScript script = NULL;
976aaf
     struct rpmtd_s tscripts, tprogs, tflags;
976aaf
     headerGetFlags hgflags = HEADERGET_MINMEM;
976aaf
+    const char *prefix = "";
976aaf
 
976aaf
     switch (tm) {
976aaf
 	case RPMSCRIPT_NORMALTRIGGER:
976aaf
@@ -567,11 +568,13 @@ rpmScript rpmScriptFromTriggerTag(Header
976aaf
 	    headerGet(h, RPMTAG_FILETRIGGERSCRIPTS, &tscripts, hgflags);
976aaf
 	    headerGet(h, RPMTAG_FILETRIGGERSCRIPTPROG, &tprogs, hgflags);
976aaf
 	    headerGet(h, RPMTAG_FILETRIGGERSCRIPTFLAGS, &tflags, hgflags);
976aaf
+	    prefix = "file";
976aaf
 	    break;
976aaf
 	case RPMSCRIPT_TRANSFILETRIGGER:
976aaf
 	    headerGet(h, RPMTAG_TRANSFILETRIGGERSCRIPTS, &tscripts, hgflags);
976aaf
 	    headerGet(h, RPMTAG_TRANSFILETRIGGERSCRIPTPROG, &tprogs, hgflags);
976aaf
 	    headerGet(h, RPMTAG_TRANSFILETRIGGERSCRIPTFLAGS, &tflags, hgflags);
976aaf
+	    prefix = "transfile";
976aaf
 	    break;
976aaf
     }
976aaf
 
976aaf
@@ -582,7 +585,8 @@ rpmScript rpmScriptFromTriggerTag(Header
976aaf
 	if (rpmtdSetIndex(&tflags, ix) >= 0)
976aaf
 	    sflags = rpmtdGetNumber(&tflags);
976aaf
 
976aaf
-	script = rpmScriptNew(h, triggerTag, rpmtdGetString(&tscripts), sflags);
976aaf
+	script = rpmScriptNew(h, triggerTag,
976aaf
+				rpmtdGetString(&tscripts), sflags, prefix);
976aaf
 
976aaf
 	/* hack up a hge-style NULL-terminated array */
976aaf
 	script->args = xmalloc(2 * sizeof(*script->args) + strlen(prog) + 1);
976aaf
@@ -608,7 +612,7 @@ rpmScript rpmScriptFromTag(Header h, rpm
976aaf
 
976aaf
 	script = rpmScriptNew(h, scriptTag,
976aaf
 			      headerGetString(h, scriptTag),
976aaf
-			      headerGetNumber(h, getFlagTag(scriptTag)));
976aaf
+			      headerGetNumber(h, getFlagTag(scriptTag)), "");
976aaf
 
976aaf
 	if (headerGet(h, progTag, &prog, (HEADERGET_ALLOC|HEADERGET_ARGV))) {
976aaf
 	    script->args = prog.data;