Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > 94f9b84572f77e893fcbd79e99b78816 > files > 11

rpm-4.11.0.1-1.mga3.src.rpm

diff -p -up rpm-4.10.0/build/parsePrep.c.2006 rpm-4.10.0/build/parsePrep.c
--- rpm-4.10.0/build/parsePrep.c.2006	2012-05-22 10:53:51.000000000 +0000
+++ rpm-4.10.0/build/parsePrep.c	2012-06-15 09:17:31.945151263 +0000
@@ -138,7 +138,10 @@ static char *doUntar(rpmSpec spec, uint3
     char *fn = NULL;
     char *buf = NULL;
     char *tar = NULL;
-    const char *taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf");
+    char taropts[8];
+    char *t;
+    char *rubygemopts = NULL;
+    int rubygem = 0;
     struct Source *sp;
     rpmCompressedMagic compressed = COMPRESSED_NOT;
 
@@ -158,6 +161,25 @@ static char *doUntar(rpmSpec spec, uint3
 
     fn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
 
+     t = strrchr(sp->source, '.');
+     if(t && !strcasecmp(t, ".gem"))
+        rubygem = 1;
+ 
+     t = stpcpy(taropts, "-x");
+     if(rpmIsVerbose() && !quietly)
+        t = stpcpy(t, "vv");
+     if(rubygem)
+        t = stpcpy(t, "m");
+     t = stpcpy(t, "f");
+
+     if (rubygem) {
+	 rasprintf(&rubygemopts,
+		 "\n"
+		 "if [ -f data.tar.gz ]; then\n"
+		 "  tar %s data.tar.gz\n"
+		 "fi", taropts);
+     }
+
     /* XXX On non-build parse's, file cannot be stat'd or read */
     if (!(spec->flags & RPMSPEC_FORCE) && (rpmFileIsCompressed(fn, &compressed) || checkOwners(fn))) {
 	goto exit;
@@ -204,7 +226,7 @@ static char *doUntar(rpmSpec spec, uint3
 		"STATUS=$?\n"
 		"if [ $STATUS -ne 0 ]; then\n"
 		"  exit $STATUS\n"
-		"fi", zipper, fn, tar, taropts);
+		"fi%s", zipper, fn, tar, taropts, rubygem ? rubygemopts : "");
 	} else {
 	    rasprintf(&buf, "%s '%s'\n"
 		"STATUS=$?\n"
@@ -214,7 +236,7 @@ static char *doUntar(rpmSpec spec, uint3
 	}
 	free(zipper);
     } else {
-	rasprintf(&buf, "%s %s %s", tar, taropts, fn);
+	rasprintf(&buf, "%s %s %s%s", tar, taropts, fn, rubygem ? rubygemopts : "");
     }
 
 exit:
@@ -316,6 +338,20 @@ static int doSetupMacro(rpmSpec spec, co
 	free(buf);
     }
 
+    /* check if source is a ruby gem */
+    {   struct Source *sp;
+       for (sp = spec->sources; sp != NULL; sp = sp->next) {
+           if ((sp->flags & RPMBUILD_ISSOURCE) && (sp->num == 0)) {
+               break;
+           }
+       }
+       if (sp != NULL) {
+           char *t = strrchr(sp->source, '.');
+           if(t && !strcasecmp(t, ".gem"))
+               createDir = 1;
+       }
+    }
+
     /* if necessary, create and cd into the proper dir */
     if (createDir) {
 	buf = rpmExpand("%{__mkdir_p} ", spec->buildSubdir, "\n",