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 v2 3/4] Rework do_adjust_git to support inside and outside usage
Date: Thu, 12 Aug 2021 13:48:51 +0200	[thread overview]
Message-ID: <72d43790ce3598669890bc1279e2b835c415a5c6.1628768932.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1628768932.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 a4c8663..992f55a 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-12 11:48 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 11:48 [PATCH v2 0/4] Make adjust_git work in both worlds Jan Kiszka
2021-08-12 11:48 ` [PATCH v2 1/4] dpkg-base: Lock do_adjust_git against each other Jan Kiszka
2021-08-13 13:55   ` Henning Schild
2021-08-15 18:55     ` Jan Kiszka
2021-08-26  8:00   ` [PATCH v3 " Jan Kiszka
2021-08-26  8:06     ` Jan Kiszka
2021-08-12 11:48 ` [PATCH v2 2/4] dpkg-base: Make mirror link relative Jan Kiszka
2021-08-13 14:04   ` Henning Schild
2021-08-13 17:49     ` [PATCH] dpkg-base: "unshare" git clones in adjust_git Henning Schild
2021-08-13 20:13       ` [PATCH v2] " Henning Schild
2021-08-13 20:14         ` Henning Schild
2021-08-15 18:55       ` [PATCH] " Jan Kiszka
2021-08-16 11:36         ` Henning Schild
2021-08-16 16:57           ` Jan Kiszka
2021-08-12 11:48 ` Jan Kiszka [this message]
2021-08-12 11:48 ` [PATCH v2 4/4] Revert "dpkg: adjust task order to allow using "git" for patching" Jan Kiszka
2021-08-13  8:31 ` [PATCH v2 0/4] Make adjust_git work in both worlds Uladzimir Bely
2021-08-13 10:13   ` Jan Kiszka
2021-08-13 12:23     ` Uladzimir Bely
2021-08-13 12:28       ` Jan Kiszka
2021-08-13 12:40         ` Uladzimir Bely
2021-08-15 19:02           ` Jan Kiszka
2021-08-16  7:52             ` Uladzimir Bely
2021-08-16  7:55               ` Jan Kiszka
2021-08-16  8:27                 ` Uladzimir Bely
2021-08-16 10:45                   ` Jan Kiszka
2021-08-16 11:01                     ` Jan Kiszka
2021-08-16 11:26                       ` Henning Schild
2021-08-16 12:49                       ` Uladzimir Bely
2021-08-19  6:17                     ` Uladzimir Bely
2021-08-19  6:21                       ` Jan Kiszka
2021-08-26  7:57                         ` Jan Kiszka
2021-08-27  8:39                           ` ub...@ilbers.de

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=72d43790ce3598669890bc1279e2b835c415a5c6.1628768932.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