summaryrefslogtreecommitdiff
path: root/build/parsePrep.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2022-03-25 11:32:27 +0200
committerPanu Matilainen <pmatilai@redhat.com>2022-04-04 10:04:25 +0300
commitcd5d667e99f931504a512b591fcde7ed92cee344 (patch)
tree881d7669f1d6301db95b775153b086782a8f5cc2 /build/parsePrep.c
parent96de5c1f02e69a7ae37bcc8437451dfa35c87ae1 (diff)
downloadrpm-cd5d667e99f931504a512b591fcde7ed92cee344.tar.gz
Move source uncompress logic from spec parse to build time
Traditionally, %setup processing has figured out the commands needed to extract the source in question. The problem with this is that it happens at spec parse time, requiring access to sources that may not even be there in plain spec queries. Move the unpack logic from %setup internals to an `rpmuncompress` helper executable which is now the only command %setup needs to know. This way, spec parsing never needs to look at the actual source files, their presence is only required for an actual build. Another advantage is that the extraction machinery is now available to packagers without having to call %setup with its side-effects on %buildsubdir and such. Split the rpmbuild -ba test on missing sources into separate -bb and -bs tests as these are now rather different: binary build only tests for source presence if %prep is actually executed, and missing files at source build stage are discovered at a later stage as well.
Diffstat (limited to 'build/parsePrep.c')
-rw-r--r--build/parsePrep.c91
1 files changed, 8 insertions, 83 deletions
diff --git a/build/parsePrep.c b/build/parsePrep.c
index 9b6b30445..64ade7846 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -128,98 +128,23 @@ exit:
static char *doUntar(rpmSpec spec, uint32_t c, int quietly)
{
char *buf = NULL;
- char *tar = NULL;
- const char *taropts = ((rpmIsVerbose() && !quietly) ? "-xvvof" : "-xof");
struct Source *sp;
- rpmCompressedMagic compressed = COMPRESSED_NOT;
if ((sp = findSource(spec, c, RPMBUILD_ISSOURCE)) == NULL) {
rpmlog(RPMLOG_ERR, _("No source number %u\n"), c);
goto exit;
}
- const char *fn = sp->path;
- /* XXX On non-build parse's, file cannot be stat'd or read */
- if (!(spec->flags & RPMSPEC_FORCE) && (checkOwners(fn) || rpmFileIsCompressed(fn, &compressed))) {
- goto exit;
- }
-
- tar = rpmGetPath("%{__tar}", NULL);
- if (compressed != COMPRESSED_NOT) {
- char *zipper = NULL;
- const char *t = NULL;
- int needtar = 1;
- int needgemspec = 0;
-
- switch (compressed) {
- case COMPRESSED_NOT: /* XXX can't happen */
- case COMPRESSED_OTHER:
- t = "%{__gzip} -dc";
- break;
- case COMPRESSED_BZIP2:
- t = "%{__bzip2} -dc";
- break;
- case COMPRESSED_ZIP:
- if (rpmIsVerbose() && !quietly)
- t = "%{__unzip}";
- else
- t = "%{__unzip} -qq";
- needtar = 0;
- break;
- case COMPRESSED_LZMA:
- case COMPRESSED_XZ:
- t = "%{__xz} -dc";
- break;
- case COMPRESSED_LZIP:
- t = "%{__lzip} -dc";
- break;
- case COMPRESSED_LRZIP:
- t = "%{__lrzip} -dqo-";
- break;
- case COMPRESSED_7ZIP:
- t = "%{__7zip} x";
- needtar = 0;
- break;
- case COMPRESSED_ZSTD:
- t = "%{__zstd} -dc";
- break;
- case COMPRESSED_GEM:
- t = "%{__gem} unpack";
- needtar = 0;
- needgemspec = 1;
- break;
- }
- zipper = rpmGetPath(t, NULL);
- if (needtar) {
- rasprintf(&buf, "%s '%s' | %s %s -", zipper, fn, tar, taropts);
- } else if (needgemspec) {
- char *gem = rpmGetPath("%{__gem}", NULL);
- char *gemspec = NULL;
- char gemnameversion[strlen(sp->source) - 3];
-
- rstrlcpy(gemnameversion, sp->source, strlen(sp->source) - 3);
- gemspec = rpmGetPath("%{_builddir}/", gemnameversion, ".gemspec", NULL);
-
- rasprintf(&buf, "%s '%s' && %s spec '%s' --ruby > '%s'",
- zipper, fn, gem, fn, gemspec);
-
- free(gemspec);
- free(gem);
- } else {
- rasprintf(&buf, "%s '%s'", zipper, fn);
- }
- free(zipper);
- } else {
- rasprintf(&buf, "%s %s '%s'", tar, taropts, fn);
- }
+ buf = rpmExpand("%{__rpmuncompress} -x ",
+ quietly ? "" : "-v", sp->path, NULL);
+ rstrcat(&buf,
+ "\nSTATUS=$?\n"
+ "if [ $STATUS -ne 0 ]; then\n"
+ " exit $STATUS\n"
+ "fi");
exit:
- free(tar);
- return buf ? rstrcat(&buf,
- "\nSTATUS=$?\n"
- "if [ $STATUS -ne 0 ]; then\n"
- " exit $STATUS\n"
- "fi") : NULL;
+ return buf;
}
/**