From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.5278.1796244902876191742 for ; Wed, 02 Dec 2026 12:55:03 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@snap.com header.s=google header.b=aOy3IKEe; spf=pass (domain: snapchat.com, ip: 209.85.128.51, mailfrom: ecordonnier@snapchat.com) Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4bb61185057so85668105e9.1 for ; Wed, 02 Dec 2026 12:55:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=snap.com; s=google; t=1796244901; x=1796849701; 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=7R6LG7WnVbCiGvYM4It8SzcBbBb2Opbd0Zdj+zjE+qc=; b=aOy3IKEecbcT42o00VOgh24D/sU7jJV/XH9OdH0+ZWg58xBq4Es/ZIMS7If1NnF6W0 1GNcdsDwzUk2a3/GyZrVccArJc4upyeuKciJ8UW5Gdqb/X+PabrKW86yYVYRzlWHHDgQ PolEStLtEZSKNRnRLw1b2S6LFSfPnLfkp+vec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796244901; x=1796849701; 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=7R6LG7WnVbCiGvYM4It8SzcBbBb2Opbd0Zdj+zjE+qc=; b=zUw7a3TKv5suvi6ir42AxhWZLx2LbUzqcIc/BTHpwVtMlOKDjZXwODn/jITtm222S0 P5S3y6zw6LMfGGAJQNkJxgPZ9FJ4Xun5zYqcs6caUAB3AvxEOIJQkUdGgMLQI/oFWNK6 k3UPyObGpRaEjltDjrK23qozc06xsy2U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yYo2RmL1979N RpQAAsMrQpkvGPuG/AnUsd X-Received: by 2002:a05:600c:1911:b0:4a2:150f:1607 with SMTP id 5b1f17b1804b1-4bb8880a584mr830142165e9.13.1796244901369; Wed, 02 Dec 2026 12:55:01 -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.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 12:55:01 -0800 (PST) From: ecordonnier@snap.com To: openembedded-core@lists.openembedded.org Cc: Etienne Cordonnier Subject: [PATCH v4 2/2] archiver.bbclass: remove .git from original git source archives Date: Wed, 2 Dec 2026 21:54:46 +0100 Message-ID: <20261202205446.2442999-3-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/251857 Content-Type: text/plain; charset="utf-8" From: Etienne Cordonnier The unpacked tree of a git source includes its .git, which has no use in the archive. The .git of a clone has no objects, only a reference to DL_DIR via objects/info/alternates, and the .git of a shallow tarball duplicates the sources, which roughly doubles the archive. Remove it, and the .git files of submodules. Keep it with nocheckout (and bareclone), where the repository is the source. AI-Generated: Claude Code with Claude Haiku 5.5 Signed-off-by: Etienne Cordonnier --- meta/classes/archiver.bbclass | 13 +++++ meta/lib/oeqa/selftest/cases/archiver.py | 63 ++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass index 9ce12b0e9b..3c201a9009 100644 --- a/meta/classes/archiver.bbclass +++ b/meta/classes/archiver.bbclass @@ -204,6 +204,7 @@ python do_ar_original() { fetch = bb.fetch.Fetch(urls, ld) tarball_suffix = {} for url in fetch.urls: + ud = fetch.ud[url] local = fetch.localpath(url).rstrip("/"); if os.path.isfile(local): shutil.copy(local, ar_outdir) @@ -214,6 +215,18 @@ python do_ar_original() { fetch.unpack(tmpdir, (url,)) if not os.listdir(tmpdir): bb.fatal("Cannot archive original source %s: nothing was unpacked" % url) + if isinstance(ud.method, bb.fetch.git.Git) and not ud.nocheckout: + # The .git of a clone has no objects (clone -s only references + # them via objects/info/alternates), and the one of a shallow + # tarball duplicates the sources, so it is of no use in the + # archive. This includes the .git files of submodules. Keep it + # with nocheckout (and bareclone), where it is the source. + for root, dirs, files in os.walk(ud.destdir): + if '.git' in dirs: + dirs.remove('.git') + bb.utils.remove(os.path.join(root, '.git'), recurse=True) + if '.git' in files: + os.remove(os.path.join(root, '.git')) # 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 629b5eb63a..0a85046cda 100644 --- a/meta/lib/oeqa/selftest/cases/archiver.py +++ b/meta/lib/oeqa/selftest/cases/archiver.py @@ -212,6 +212,69 @@ class Archiver(OESelftestTestCase): 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]) + self._assert_no_git(names) + + def test_archiver_mode_original_git(self): + """ + Test that the archive of a git source with + `ARCHIVER_MODE[src] = "original"` has no .git directory. + """ + target = 'gitrepotest' + + features = 'INHERIT += "archiver"\n' + features += 'ARCHIVER_MODE[src] = "original"\n' + self.write_config(features) + + 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]) + self._assert_no_git(names) + + def test_archiver_mode_original_gitsm(self): + """ + Test that the archive of a git source with submodules with + `ARCHIVER_MODE[src] = "original"` contains the submodules, but neither + the .git directory nor the .git files of the submodules. + """ + target = 'git-submodule-test' + + features = 'INHERIT += "archiver"\n' + features += 'ARCHIVER_MODE[src] = "original"\n' + features += 'COPYLEFT_LICENSE_INCLUDE = "*"\n' + self.write_config(features) + + 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('/.gitmodules')], 'Archive has no .gitmodules: %s' % names[:20]) + # .gitmodules is part of the superproject, check a file of a submodule + self.assertTrue([n for n in names if n.endswith('/bitbake/lib/bb/__init__.py')], 'Archive has no submodule content: %s' % names[:20]) + self._assert_no_git(names) + + def test_archiver_mode_original_git_nocheckout(self): + """ + Test that the archive of a git source with nocheckout=1 keeps the .git + directory, since the repository is the source in this case. + """ + target = 'gitrepotest' + + features = 'INHERIT += "archiver"\n' + features += 'ARCHIVER_MODE[src] = "original"\n' + features += 'SRC_URI:pn-%s = "git://git.yoctoproject.org/matchbox-panel-2;branch=master;protocol=https;nocheckout=1 file://0001-testpatch.patch"\n' % target + self.write_config(features) + + 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 '.git' in n.split('/')], 'Archive has no .git: %s' % names[:20]) + + def _assert_no_git(self, names): + git = [n for n in names if '.git' in n.split('/')] + self.assertFalse(git, 'Archive contains .git: %s' % git[:20]) def _get_original_git_archive_names(self, target): """ -- 2.43.0