From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH] dpkg-base: Expand adjust_git to all git SRC_URIs
Date: Fri, 22 Nov 2019 13:05:06 +0100 [thread overview]
Message-ID: <424d8510-009d-069e-0b74-3f265c402dd6@siemens.com> (raw)
From: Jan Kiszka <jan.kiszka@siemens.com>
Make sure that not only the first git SRC_URI is adjusted in case a
package builds from multiple repos. That's a common case for modern
U-Boot (ATF, OP-TEE...).
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta/classes/dpkg-base.bbclass | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 0be1627..af9c984 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -10,11 +10,37 @@ inherit terminal
DEPENDS ?= ""
-do_adjust_git() {
- if [ -f ${S}/.git/objects/info/alternates ]; then
- sed -i ${S}/.git/objects/info/alternates \
- -e 's|${DL_DIR}|/downloads|'
- fi
+python do_adjust_git() {
+ import subprocess
+
+ rootdir = d.getVar('WORKDIR', True)
+
+ for src_uri in (d.getVar("SRC_URI", True) or "").split():
+ try:
+ fetcher = bb.fetch2.Fetch([src_uri], d)
+ ud = fetcher.ud[src_uri]
+ if ud.type != 'git':
+ continue
+
+ subdir = ud.parm.get("subpath", "")
+ if subdir != "":
+ def_destsuffix = "%s/" % os.path.basename(subdir.rstrip('/'))
+ else:
+ def_destsuffix = "git/"
+
+ destsuffix = ud.parm.get("destsuffix", def_destsuffix)
+ destdir = ud.destdir = os.path.join(rootdir, destsuffix)
+
+ alternates = os.path.join(destdir, ".git/objects/info/alternates")
+
+ if os.path.exists(alternates):
+ cmd = ["sed", "-i", alternates, "-e",
+ "s|{}|/downloads|".format(d.getVar("DL_DIR"))]
+ bb.note(' '.join(cmd))
+ if subprocess.call(cmd) != 0:
+ bb.fatal("git alternates adjustment failed")
+ except bb.fetch2.BBFetchException as e:
+ raise bb.build.FuncFailed(e)
}
addtask adjust_git after do_unpack before do_patch
--
2.16.4
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
next reply other threads:[~2019-11-22 12:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-22 12:05 Jan Kiszka [this message]
2019-11-28 15:25 ` Baurzhan Ismagulov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=424d8510-009d-069e-0b74-3f265c402dd6@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox