Skip to contentSkip to conversation

classes/archiver: fix tarball content in "original" mode

PATCH Superseded João Marcos Costa 2 participants 2 messages Aug 18 – Aug 27

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes/archiver: fix tarball content in "original" mode

When ARCHIVER_MODE[src] is set to "original", a tarball is generated with the unpacked sources of a given recipe. Prior to it, a tmpdir (i.e. from tempfile.mkdtemp()) is created and the sources are unpacked inside:

(...)/vim/9.2.0340/archiver-work/tmp8pu2nsck
`-- vim-9.2.0340

    |-- READMEdir
    |-- ci
    |-- lang

This tmpdir, however, ends up being shipped in the deployed tarball:

$ tar -tf vim-9.2.0340-r0.tar.xz
(...)
tmp8pu2nsck/vim-9.2.0340/ci/config.mk.clang-12.sed
tmp8pu2nsck/vim-9.2.0340/LICENSE
tmp8pu2nsck/vim-9.2.0340/.git-blame-ignore-revs
(...)

This can be avoided by using "-C" option from tar's command, with which we can point to the tmpdir and to the content inside separately:

tar --exclude=temp --exclude=patches --exclude='.pc' \
-C (...)/vim/9.1.1683/archiver-work/tmpv0m93p52 -cf - . | \
xz --memlimit=50% --threads=64 > \
(...)/vim/9.1.1683/archiver-sources/(...)/vim-9.1.1683-r0/vim-9.1.1683-r0.tar.xz

and in the result:

./
./vim-9.1.1683/
./vim-9.1.1683/SECURITY.md
./vim-9.1.1683/.codecov.yml
(...)

---
 meta/classes/archiver.bbclass | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
meta/classes/archiver.bbclass +6 -1
index 3124b7040d..85b591c084 100644
@@ -424,7 +424,12 @@ def create_tarball(d, srcdir, suffix, ar_outdir):
     bb.note('Creating %s' % tarname)
     dirname = os.path.dirname(srcdir)
     basename = os.path.basename(srcdir)
-    tar_cmd = ["tar", "--exclude=temp", "--exclude=patches", "--exclude=.pc", '-cf', tarname, basename, '-I', compression_cmd]
+    if d.getVarFlag('ARCHIVER_MODE', 'src') == "original":
+        tar_dir, content = srcdir, "."
+    else:
+        tar_dir, content = dirname, basename
+
+    tar_cmd = ["tar", "--exclude=temp", "--exclude=patches", "--exclude=.pc", '-C', tar_dir, '-cf', tarname, content, '-I', compression_cmd]
     subprocess.check_call(tar_cmd, cwd=dirname)
 
 # creating .diff.gz between source.orig and source
Signature · 1 line
2.55.0
#1 lore raw
Quoted 29 lines · João Marcos Costa

When ARCHIVER_MODE[src] is set to "original", a tarball is generated with the unpacked sources of a given recipe. Prior to it, a tmpdir (i.e. from tempfile.mkdtemp()) is created and the sources are unpacked inside:

(...)/vim/9.2.0340/archiver-work/tmp8pu2nsck
`-- vim-9.2.0340

    |-- READMEdir
    |-- ci
    |-- lang

This tmpdir, however, ends up being shipped in the deployed tarball:

$ tar -tf vim-9.2.0340-r0.tar.xz
(...)
tmp8pu2nsck/vim-9.2.0340/ci/config.mk.clang-12.sed
tmp8pu2nsck/vim-9.2.0340/LICENSE
tmp8pu2nsck/vim-9.2.0340/.git-blame-ignore-revs
(...)

This can be avoided by using "-C" option from tar's command, with which we can point to the tmpdir and to the content inside separately:

tar --exclude=temp --exclude=patches --exclude='.pc' \
-C (...)/vim/9.1.1683/archiver-work/tmpv0m93p52 -cf - . | \
xz --memlimit=50% --threads=64 > \
(...)/vim/9.1.1683/archiver-sources/(...)/vim-9.1.1683-r0/vim-9.1.1683-r0.tar.xz

and in the result:

Quoted 7 lines

./
./vim-9.1.1683/
./vim-9.1.1683/SECURITY.md
./vim-9.1.1683/.codecov.yml
(...)

Reading this leaves me wondering why we're creating a tmpdir under ${ARCHIVER_WORKDIR}, why not just unpack the source directly under the archiver workdir?

If the tmpdir is needed, I think the issue is that we're passing the tmpdir path to create_tarball() in do_ar_original() instead of the full path to the extracted sources. I think fixing the call site in do_ar_original() would be cleaner if we can do that.

Best regards,

Signature · 1 line
Paul Barker