]> TLD Linux GIT Repositories - packages/rpm.git/blob - rpm-ruby-gem-build.patch
- package /usr/lib/rpm/macros.d dir
[packages/rpm.git] / rpm-ruby-gem-build.patch
1 diff -urpa rpm-4.5.orig/build/parsePrep.c rpm-4.5/build/parsePrep.c
2 --- rpm-4.5.orig/build/parsePrep.c      2007-11-08 00:26:48.000000000 +0000
3 +++ rpm-4.5/build/parsePrep.c   2018-02-23 11:51:54.161446282 +0000
4 @@ -189,11 +189,13 @@ static const char *doUntar(Spec spec, in
5  {
6      const char *fn, *Lurlfn;
7      static char buf[BUFSIZ];
8 -    char *taropts;
9 +    char taropts[8];
10      char *t = NULL;
11      struct Source *sp;
12      rpmCompressedMagic compressed = COMPRESSED_NOT;
13      int urltype;
14 +    const char *tar;
15 +    int rubygem = 0;
16  
17      for (sp = spec->sources; sp != NULL; sp = sp->next) {
18         if ((sp->flags & RPMFILE_SOURCE) && (sp->num == c)) {
19 @@ -205,8 +207,18 @@ static const char *doUntar(Spec spec, in
20         return NULL;
21      }
22  
23 +    t = strrchr(sp->source, '.');
24 +    if(t && !strcasecmp(t, ".gem"))
25 +       rubygem = 1;
26 +
27 +    t = stpcpy(taropts, "-x");
28      /*@-internalglobs@*/ /* FIX: shrug */
29 -    taropts = ((rpmIsVerbose() && !quietly) ? "-xvvf" : "-xf");
30 +    if(rpmIsVerbose() && !quietly)
31 +       t = stpcpy(t, "vv");
32 +    if(rubygem)
33 +       t = stpcpy(t, "m");
34 +
35 +    t = stpcpy(t, "f");
36      /*@=internalglobs@*/
37  
38      Lurlfn = rpmGenPath(NULL, "%{_sourcedir}/", sp->source);
39 @@ -233,6 +245,12 @@ static const char *doUntar(Spec spec, in
40         /*@notreached@*/ break;
41      }
42  
43 +    tar = rpmGetPath("%{?__tar}", NULL);
44 +    if (!(tar && *tar != '\0')) {
45 +       tar = _free(tar);
46 +       tar = xstrdup("tar");
47 +    }
48 +
49      if (compressed != COMPRESSED_NOT) {
50         const char *zipper;
51         int needtar = 1;
52 @@ -267,8 +285,13 @@ static const char *doUntar(Spec spec, in
53         *t++ = '\'';
54         t = stpcpy(t, fn);
55         *t++ = '\'';
56 -       if (needtar)
57 -           t = stpcpy( stpcpy( stpcpy(t, " | tar "), taropts), " -");
58 +       if (needtar) {
59 +           t = stpcpy(t, " | ");
60 +           t = stpcpy(t, tar);
61 +           t = stpcpy(t, " ");
62 +           t = stpcpy(t, taropts);
63 +           t = stpcpy(t, " -");
64 +       }
65         t = stpcpy(t,
66                 "\n"
67                 "STATUS=$?\n"
68 @@ -277,11 +300,24 @@ static const char *doUntar(Spec spec, in
69                 "fi");
70      } else {
71         buf[0] = '\0';
72 -       t = stpcpy( stpcpy(buf, "tar "), taropts);
73 +       t = stpcpy(buf, tar);
74 +       t = stpcpy(t, " ");
75 +       t = stpcpy(t, taropts);
76         *t++ = ' ';
77         t = stpcpy(t, fn);
78 +       if(rubygem) {
79 +           t = stpcpy(t,
80 +                   "\n"
81 +                   "if [ -f data.tar.gz ]; then\n"
82 +                   "  tar ");
83 +            t = stpcpy(t, taropts);
84 +           t = stpcpy(t,
85 +                   " data.tar.gz\n"
86 +                   "fi");
87 +       }
88      }
89  
90 +    tar = _free(tar);
91      Lurlfn = _free(Lurlfn);
92      return buf;
93  }
94 @@ -390,6 +426,20 @@ static int doSetupMacro(Spec spec, char
95         appendLineStringBuf(spec->prep, buf);
96      }
97  
98 +    /* check if source is a ruby gem */
99 +    {   struct Source *sp;
100 +       for (sp = spec->sources; sp != NULL; sp = sp->next) {
101 +           if ((sp->flags & RPMFILE_SOURCE) && (sp->num == 0)) {
102 +               break;
103 +           }
104 +       }
105 +       if (sp != NULL) {
106 +           char *t = strrchr(sp->source, '.');
107 +           if(t && !strcasecmp(t, ".gem"))
108 +               createDir = 1;
109 +       }
110 +    }
111 +
112      /* if necessary, create and cd into the proper dir */
113      if (createDir) {
114         sprintf(buf, MKDIR_P " '%s'\ncd '%s'",