public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Uladzimir Bely <ubely@ilbers.de>,
	Henning Schild <henning.schild@siemens.com>
Subject: [PATCH v3 3/4] Rework do_adjust_git to support inside and outside usage
Date: Thu, 26 Aug 2021 11:22:58 +0200	[thread overview]
Message-ID: <4e97ea09e60757ca9e1a2c7ac3076e013d3fc312.1629969778.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1629969778.git.jan.kiszka@siemens.com>

From: Jan Kiszka <jan.kiszka@siemens.com>

Rewrite the alternates entry to use a relative path outside of the
workdir. That linke can then be created independently of the outer build
environment as well as inside the buildchroot.

We use ${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/.git-downloads outside
and /home/.git-downloads inside the buildchroot.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/dpkg-base.bbclass                    | 11 ++++++++++-
 meta/conf/bitbake.conf                            |  1 +
 meta/recipes-devtools/buildchroot/buildchroot.inc |  2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index ca1dccf..9a18acb 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -19,6 +19,12 @@ python do_adjust_git() {
 
     rootdir = d.getVar('WORKDIR', True)
 
+    git_link = os.path.join(d.getVar('GIT_DL_LINK_DIR'), '.git-downloads')
+    git_dl = os.path.join(d.getVar("DL_DIR"), "git")
+
+    if not os.path.exists(git_link) or os.path.realpath(git_link) != git_dl:
+        os.symlink(git_dl, git_link)
+
     for src_uri in (d.getVar("SRC_URI", True) or "").split():
         try:
             fetcher = bb.fetch2.Fetch([src_uri], d)
@@ -44,11 +50,14 @@ python do_adjust_git() {
             destsuffix = ud.parm.get("destsuffix", def_destsuffix)
             destdir = ud.destdir = os.path.join(rootdir, destsuffix)
 
+            git_link_rel = os.path.relpath(git_link,
+                                           os.path.join(destdir, ".git/objects"))
+
             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"))]
+                       "s|{}|{}|".format(git_dl, git_link_rel)]
                 bb.note(' '.join(cmd))
                 if subprocess.call(cmd) != 0:
                     bb.fatal("git alternates adjustment failed")
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 9859456..7f5901d 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -48,6 +48,7 @@ GITPKGV = "${@bb.fetch2.get_srcrev(d, 'gitpkgv_revision')}"
 
 # isar specific config
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}/${PV}-${PR}"
+GIT_DL_LINK_DIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}"
 DEPLOY_DIR_BOOTSTRAP = "${DEPLOY_DIR}/bootstrap"
 DEPLOY_DIR_BUILDCHROOT = "${DEPLOY_DIR}/buildchroot"
 DEPLOY_DIR_SDKCHROOT = "${DEPLOY_DIR}/sdkchroot"
diff --git a/meta/recipes-devtools/buildchroot/buildchroot.inc b/meta/recipes-devtools/buildchroot/buildchroot.inc
index 0c1fb7f..52a5f1c 100644
--- a/meta/recipes-devtools/buildchroot/buildchroot.inc
+++ b/meta/recipes-devtools/buildchroot/buildchroot.inc
@@ -67,6 +67,8 @@ buildchroot_install_files() {
     sudo install -m 755 ${WORKDIR}/common.sh ${BUILDCHROOT_DIR}/isar/
     sudo install -m 755 ${WORKDIR}/deps.sh ${BUILDCHROOT_DIR}/isar/
 
+    sudo ln -s /downloads/git "${BUILDCHROOT_DIR}/home/.git-downloads"
+
     # Configure root filesystem
     sudo install -m 755 ${WORKDIR}/configscript.sh ${BUILDCHROOT_DIR}
     USER_ID=$(id -u)
-- 
2.31.1


  parent reply	other threads:[~2021-08-26  9:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26  9:22 [PATCH v3 0/4] Make adjust_git work in both worlds Jan Kiszka
2021-08-26  9:22 ` [PATCH v3 1/4] dpkg-base: Lock do_adjust_git against each other Jan Kiszka
2021-08-26  9:22 ` [PATCH v3 2/4] dpkg-base: Make mirror link relative Jan Kiszka
2021-08-26  9:22 ` Jan Kiszka [this message]
2021-08-26  9:22 ` [PATCH v3 4/4] Revert "dpkg: adjust task order to allow using "git" for patching" Jan Kiszka
2021-09-09 10:42 ` [PATCH v3 0/4] Make adjust_git work in both worlds Anton Mikanovich

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=4e97ea09e60757ca9e1a2c7ac3076e013d3fc312.1629969778.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=ubely@ilbers.de \
    /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