* @param quietly should -vv be omitted from tar?
* @return expanded %setup macro (NULL on error)
*/
-static const char *doUntar(rpmSpec spec, int c, int quietly)
+static char *doUntar(rpmSpec spec, int c, int quietly)
{
const char *fn;
char *urlfn;
- static char buf[BUFSIZ];
+ char *buf = NULL;
char *tar, *taropts;
- char *t = NULL;
struct Source *sp;
rpmCompressedMagic compressed = COMPRESSED_NOT;
int urltype;
tar = rpmGetPath("%{__tar}", NULL);
if (compressed != COMPRESSED_NOT) {
- char *zipper;
+ char *zipper, *t = NULL;
int needtar = 1;
switch (compressed) {
break;
}
zipper = rpmGetPath(t, NULL);
- buf[0] = '\0';
- t = stpcpy(buf, zipper);
- zipper = _free(zipper);
- t = stpcpy(t, " '");
- t = stpcpy(t, fn);
- t = stpcpy(t, "'");
if (needtar) {
- t = stpcpy(t, " | ");
- t = stpcpy(t, tar);
- t = stpcpy(t, " ");
- t = stpcpy(t, taropts);
- t = stpcpy(t, " - ");
- }
- t = stpcpy(t,
- "\n"
+ rasprintf(&buf, "%s '%s' | %s %s - \n"
"STATUS=$?\n"
"if [ $STATUS -ne 0 ]; then\n"
" exit $STATUS\n"
- "fi");
+ "fi", zipper, fn, tar, taropts);
+ } else {
+ rasprintf(&buf, "%s '%s'\n"
+ "STATUS=$?\n"
+ "if [ $STATUS -ne 0 ]; then\n"
+ " exit $STATUS\n"
+ "fi", zipper, fn);
+ }
+ zipper = _free(zipper);
} else {
- buf[0] = '\0';
- t = stpcpy(buf, tar);
- t = stpcpy(t, " ");
- t = stpcpy(t, taropts);
- *t++ = ' ';
- t = stpcpy(t, fn);
+ rasprintf(&buf, "%s %s %s", tar, taropts, fn);
}
urlfn = _free(urlfn);
return RPMRC_FAIL;
}
- { const char *chptr = doUntar(spec, num, quietly);
+ { char *chptr = doUntar(spec, num, quietly);
if (chptr == NULL)
return RPMRC_FAIL;
appendLineStringBuf((arg == 'a' ? after : before), chptr);
+ free(chptr);
}
}
/* do the default action */
if (!createDir && !skipDefaultAction) {
- const char *chptr = doUntar(spec, 0, quietly);
+ char *chptr = doUntar(spec, 0, quietly);
if (!chptr)
return RPMRC_FAIL;
appendLineStringBuf(spec->prep, chptr);
+ free(chptr);
}
appendStringBuf(spec->prep, getStringBuf(before));
}
if (createDir && !skipDefaultAction) {
- const char * chptr = doUntar(spec, 0, quietly);
+ char *chptr = doUntar(spec, 0, quietly);
if (chptr == NULL)
return RPMRC_FAIL;
appendLineStringBuf(spec->prep, chptr);
+ free(chptr);
}
appendStringBuf(spec->prep, getStringBuf(after));