richardphibel / rpms / rpm

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