Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-updates-src > by-pkgid > 2d27fe3dff73e21c1aac97aebe0dff40 > files > 2

rpm-4.8.1-10.5.mga1.src.rpm

From 1526cb5161ffab5392c2a57517f1562e4f3ac003 Mon Sep 17 00:00:00 2001
From: Pascal "Pixel" Rigaux <pascal@rigaux.org>
Date: Thu, 29 Jan 2009 11:46:56 +0100
Subject: [PATCH 20/36] introduce %_after_setup which is called after %setup

%_after_setup is called after %setup with the various tarballs applied by %setup
(used by git-repository--after-tarball in rpm-mandriva-setup-build)
---
 build/parsePrep.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/build/parsePrep.c b/build/parsePrep.c
index 729bbca..984a606 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -129,7 +129,7 @@ exit:
  * @param quietly	should -vv be omitted from tar?
  * @return		expanded %setup macro (NULL on error)
  */
-static char *doUntar(rpmSpec spec, uint32_t c, int quietly)
+static char *doUntar(rpmSpec spec, uint32_t c, int quietly, StringBuf after_setup_cmd)
 {
     char *fn;
     char *buf = NULL;
@@ -151,6 +151,11 @@ static char *doUntar(rpmSpec spec, uint32_t c, int quietly)
 	return NULL;
     }
 
+    if (after_setup_cmd) {
+	appendStringBuf(after_setup_cmd, " ");
+	appendStringBuf(after_setup_cmd, sp->source);
+    }
+    
     fn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
 
     /* FIX: shrug */
@@ -270,6 +275,15 @@ static int doSetupMacro(rpmSpec spec, const char *line)
 	goto exit;
     }
 
+    StringBuf after_setup_cmd = NULL;
+    {	char *fix = rpmExpand("%{?_after_setup}", NULL);
+        if (fix && *fix) {
+	    after_setup_cmd = newStringBuf();
+	    appendStringBuf(after_setup_cmd, fix);
+	}
+	free(fix);
+    }
+
     optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
     while ((arg = poptGetNextOpt(optCon)) > 0) {
 	optArg = poptGetOptArg(optCon);
@@ -282,7 +296,7 @@ static int doSetupMacro(rpmSpec spec, const char *line)
 	    goto exit;
 	}
 
-	{   char *chptr = doUntar(spec, num, quietly);
+	{   char *chptr = doUntar(spec, num, quietly, after_setup_cmd);
 	    if (chptr == NULL)
 		goto exit;
 
@@ -334,7 +348,7 @@ static int doSetupMacro(rpmSpec spec, const char *line)
 
     /* do the default action */
    if (!createDir && !skipDefaultAction) {
-	char *chptr = doUntar(spec, 0, quietly);
+	char *chptr = doUntar(spec, 0, quietly, after_setup_cmd);
 	if (!chptr)
 	    goto exit;
 	appendLineStringBuf(spec->prep, chptr);
@@ -350,7 +364,7 @@ static int doSetupMacro(rpmSpec spec, const char *line)
     }
 
     if (createDir && !skipDefaultAction) {
-	char *chptr = doUntar(spec, 0, quietly);
+	char *chptr = doUntar(spec, 0, quietly, after_setup_cmd);
 	if (chptr == NULL)
 	    goto exit;
 	appendLineStringBuf(spec->prep, chptr);
@@ -368,6 +382,10 @@ static int doSetupMacro(rpmSpec spec, const char *line)
     }
     rc = RPMRC_OK;
 
+    if (after_setup_cmd) {
+	appendLineStringBuf(spec->prep, getStringBuf(after_setup_cmd));
+	after_setup_cmd = freeStringBuf(after_setup_cmd);
+    }
 exit:
     freeStringBuf(before);
     freeStringBuf(after);
-- 
1.6.4.4