From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.5263.1796244899511201807 for ; Wed, 02 Dec 2026 12:55:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@snap.com header.s=google header.b=FFxzT/LX; spf=pass (domain: snapchat.com, ip: 209.85.128.42, mailfrom: ecordonnier@snapchat.com) Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4bb606491faso69744525e9.3 for ; Wed, 02 Dec 2026 12:54:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=snap.com; s=google; t=1796244898; x=1796849698; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BgoX8LY/8wnxcCBvrE7vPzMDu/5J3w+EDj5wZOPkJk8=; b=FFxzT/LXX0BY791pITwXezT3U2QvpnB7qvYBYk7BK9WzhLJ49JJXaQfS6+iaLP8lNJ WTSSYDUXp4EMUGVT96lZSgKLTDFpoC5gcPwUNFRNHGqBRQCUeKiqgI5d8Pz+tfR/S+Io ZkEH6nxuwonRLpktDAOOZ+S/Fe/v5mOCRtiuQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796244898; x=1796849698; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=BgoX8LY/8wnxcCBvrE7vPzMDu/5J3w+EDj5wZOPkJk8=; b=Q9YLQixpV0AWkRNAZ1FnTCWFvYM66vpCXS0qKK+hNbQCp+YdnsceQedItoulHc2xNg cOefYRaWI2C0i9KvmlqJUvAtknSk7nxicq83HmQ5Wi53VRdHNWsmOKdlwB8K20qjxtL0 kTWUlnWwmwJl/jfuy3+WtjY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JtvVg54Ap+OPXB+fY9JRQ3V6NpCNh2 I= X-Received: by 2002:a05:600c:1384:b0:4a2:1612:6367 with SMTP id 5b1f17b1804b1-4bb88816c44mr822847325e9.15.1796244898058; Wed, 02 Dec 2026 12:54:58 -0800 (PST) Return-Path: Received: from localhost.localdomain (80-108-196-96.cable.dynamic.surfer.at. [80.108.196.96]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe00a30absm14983325e9.10.2026.12.02.12.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 12:54:57 -0800 (PST) From: ecordonnier@snap.com To: openembedded-core@lists.openembedded.org Cc: Etienne Cordonnier Subject: [PATCH v4 1/2] archiver.bbclass: unpack original sources without a localpath Date: Wed, 2 Dec 2026 21:54:45 +0100 Message-ID: <20261202205446.2442999-2-ecordonnier@snap.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202205446.2442999-1-ecordonnier@snap.com> References: <20261202205446.2442999-1-ecordonnier@snap.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Wed, 02 Dec 2026 20:55:05 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/251856 Content-Type: text/plain; charset="utf-8" From: Etienne Cordonnier In "original" mode, do_ar_original only archived a source whose localpath() was a file or a directory, and silently skipped any other. A shallow git fetch which uses only the gitshallow tarball has no clone, so localpath() is missing and the source was not archived at all. Unpack every source which is not a file with fetch.unpack(), which works from the shallow tarball. Fail if nothing was unpacked, so an incomplete archive is no longer silent. AI-Generated: Claude Code with Claude Haiku 5.5 Signed-off-by: Etienne Cordonnier --- meta/classes/archiver.bbclass | 10 +++-- meta/lib/oeqa/selftest/cases/archiver.py | 48 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass index 792e85445f..9ce12b0e9b 100644 --- a/meta/classes/archiver.bbclass +++ b/meta/classes/archiver.bbclass @@ -166,8 +166,8 @@ do_ar_prepare() { } # Take all the sources for a recipe and put them in WORKDIR/archiver-work/. -# Files in SRC_URI are copied directly, anything that's a directory -# (e.g. git repositories) is "unpacked" and then put into a tarball. +# Files in SRC_URI are copied directly, anything else (e.g. git repositories, +# which may have no clone in DL_DIR) is "unpacked" and then put into a tarball. python do_ar_original() { import shutil, tempfile @@ -207,9 +207,13 @@ python do_ar_original() { local = fetch.localpath(url).rstrip("/"); if os.path.isfile(local): shutil.copy(local, ar_outdir) - elif os.path.isdir(local): + else: + # Unpack whatever the fetcher has, even when localpath() does not + # exist: a shallow git fetch may have no clone, only the tarball. tmpdir = tempfile.mkdtemp(dir=d.getVar('ARCHIVER_WORKDIR')) fetch.unpack(tmpdir, (url,)) + if not os.listdir(tmpdir): + bb.fatal("Cannot archive original source %s: nothing was unpacked" % url) # To handle recipes with more than one source, we add the "name" # URL parameter as suffix. We treat it as an error when # there's more than one URL without a name, or a name gets reused. diff --git a/meta/lib/oeqa/selftest/cases/archiver.py b/meta/lib/oeqa/selftest/cases/archiver.py index 8c5aa75e9b..629b5eb63a 100644 --- a/meta/lib/oeqa/selftest/cases/archiver.py +++ b/meta/lib/oeqa/selftest/cases/archiver.py @@ -7,6 +7,8 @@ import os import glob import re +import shutil +import tarfile from oeqa.utils.commands import bitbake, get_bb_vars from oeqa.selftest.case import OESelftestTestCase @@ -176,6 +178,52 @@ class Archiver(OESelftestTestCase): self._test_archiver_mode('original', 'ed-1.21.1.tar.lz') + def test_archiver_mode_original_git_shallow(self): + """ + Test that the archiver archives a shallow git source with + `ARCHIVER_MODE[src] = "original"` when only the shallow tarball is + available, but not the clone. This is what happens with the fast + initial shallow fetch, or when the shallow tarball is fetched from a + mirror. + """ + target = 'gitrepotest' + + features = 'INHERIT += "archiver"\n' + features += 'ARCHIVER_MODE[src] = "original"\n' + features += 'BB_GIT_SHALLOW = "1"\n' + features += 'BB_GENERATE_SHALLOW_TARBALLS = "1"\n' + features += 'DL_DIR = "${TOPDIR}/downloads-shallow"\n' + self.write_config(features) + + # Fetch to create the shallow tarball, then remove the clone if the + # fetcher fell back to a full clone, so that the second fetch has to + # use the shallow tarball. cleansstate makes sure that the archive is + # created again and not restored from sstate. + bitbake('-c cleansstate %s' % target) + bitbake('-c fetch %s' % target) + bb_vars = get_bb_vars(['DL_DIR']) + self.track_for_cleanup(bb_vars['DL_DIR']) + self.assertTrue(glob.glob(os.path.join(bb_vars['DL_DIR'], 'gitshallow_*.tar.gz')), + 'Missing shallow tarball in DL_DIR') + shutil.rmtree(os.path.join(bb_vars['DL_DIR'], 'git2'), ignore_errors=True) + bitbake('-c cleansstate %s' % target) + + bitbake('-c deploy_archives %s' % target) + + names = self._get_original_git_archive_names(target) + self.assertTrue([n for n in names if n.endswith('/COPYING')], 'Archive has no source files: %s' % names[:20]) + + def _get_original_git_archive_names(self, target): + """ + Return the names of the files in the original source archive of the + git source of target. + """ + bb_vars = get_bb_vars(['DEPLOY_DIR_SRC'], target) + archives = glob.glob(os.path.join(bb_vars['DEPLOY_DIR_SRC'], '*', '%s-*' % target, '%s-*.tar.*' % target)) + self.assertEqual(len(archives), 1, 'Expected one source archive for %s, found %s' % (target, archives)) + with tarfile.open(archives[0]) as tar: + return tar.getnames() + def test_archiver_mode_patched(self): """ Test that the archiver works with `ARCHIVER_MODE[src] = "patched"`. -- 2.43.0