Skip to contentSkip to conversation

fetch/git: add support for disabling shared clones on unpack

PATCH Superseded Henning Schild 2 participants 5 messages Dec 12, 2017 – Feb 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch/git: add support for disabling shared clones on unpack

By default the unpacker will create a "shared" clone when cloning from the DL_DIR to the WORKDIR. This patch introduces an option to control that behaviour. Probably something that hardly anyone would want to do.

Imagine some recipe steps are executed in a namespace that is different from the one your downloader and unpacker ran in. (chroot) Because a "shared" clone has an absolute reference to its "alternate" you now have to make that "alternate" visible in that new namespace (chroot) at the exact place.

With this patch you can unpack "noshared" and get a stand-alone copy. This copy will also work if the "alternate" is not visible or existant.

---
 lib/bb/fetch2/git.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
lib/bb/fetch2/git.py +12 -1
index 5ef8cd69..30b88c83 100644
@@ -53,6 +53,13 @@ Supported SRC_URI options are:
    For local git:// urls to use the current branch HEAD as the revision for use with
    AUTOREV. Implies nobranch.
 
+- noshared
+   When unpacking do not clone with the parameter "--shared". This option will
+   allow the unpacked copy to work stand-alone i.e. if your recipe runs in a
+   chroot where the "alternate" can not be found. Setting this will increase
+   the unpack-time and the disk-usage.
+   The default is "0", set noshared=1 if needed.
+
 """
 
 #Copyright (C) 2005 Richard Purdie
@@ -159,6 +166,8 @@ class Git(FetchMethod):
 
         ud.nobranch = ud.parm.get("nobranch","0") == "1"
 
+        ud.noshared = ud.parm.get("noshared","0") == "1"
+
         # usehead implies nobranch
         ud.usehead = ud.parm.get("usehead","0") == "1"
         if ud.usehead:
@@ -176,7 +185,9 @@ class Git(FetchMethod):
         if len(branches) != len(ud.names):
             raise bb.fetch2.ParameterError("The number of name and branch parameters is not balanced", ud.url)
 
-        ud.cloneflags = "-s -n"
+        cloneflags = "-n"
+        if not ud.noshared:
+            cloneflags += " -s"
         if ud.bareclone:
             ud.cloneflags += " --mirror"
 
Signature · 1 line
2.13.6
#1 lore raw

PATCH v2 1/1 fetch/git: add support for disabling shared clones on unpack

By default the unpacker will create a "shared" clone when cloning from the DL_DIR to the WORKDIR. This patch introduces an option to control that behaviour. Probably something that hardly anyone would want to do.

Imagine some recipe steps are executed in a namespace that is different from the one your downloader and unpacker ran in. (chroot) Because a "shared" clone has an absolute reference to its "alternate" you now have to make that "alternate" visible in that new namespace (chroot) at the exact place.

With this patch you can unpack "noshared" and get a stand-alone copy. This copy will also work if the "alternate" is not visible or existant.

---
 lib/bb/fetch2/git.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
lib/bb/fetch2/git.py +12 -1
index 5ef8cd69..7b7f02b2 100644
@@ -53,6 +53,13 @@ Supported SRC_URI options are:
    For local git:// urls to use the current branch HEAD as the revision for use with
    AUTOREV. Implies nobranch.
 
+- noshared
+   When unpacking do not clone with the parameter "--shared". This option will
+   allow the unpacked copy to work stand-alone i.e. if your recipe runs in a
+   chroot where the "alternate" can not be found. Setting this will increase
+   the unpack-time and the disk-usage.
+   The default is "0", set noshared=1 if needed.
+
 """
 
 #Copyright (C) 2005 Richard Purdie
@@ -159,6 +166,8 @@ class Git(FetchMethod):
 
         ud.nobranch = ud.parm.get("nobranch","0") == "1"
 
+        ud.noshared = ud.parm.get("noshared","0") == "1"
+
         # usehead implies nobranch
         ud.usehead = ud.parm.get("usehead","0") == "1"
         if ud.usehead:
@@ -176,7 +185,9 @@ class Git(FetchMethod):
         if len(branches) != len(ud.names):
             raise bb.fetch2.ParameterError("The number of name and branch parameters is not balanced", ud.url)
 
-        ud.cloneflags = "-s -n"
+        ud.cloneflags = "-n"
+        if not ud.noshared:
+            ud.cloneflags += " -s"
         if ud.bareclone:
             ud.cloneflags += " --mirror"
 
Signature · 1 line
2.13.6
#2 lore raw
Quoted 4 lines · [ext] Henning Schild

By default the unpacker will create a "shared" clone when cloning from the DL_DIR to the WORKDIR. This patch introduces an option to control that behaviour. Probably something that hardly anyone would want to do.

Quoted 8 lines

Imagine some recipe steps are executed in a namespace that is different from the one your downloader and unpacker ran in. (chroot) Because a "shared" clone has an absolute reference to its "alternate" you now have to make that "alternate" visible in that new namespace (chroot) at the exact place.

With this patch you can unpack "noshared" and get a stand-alone copy. This copy will also work if the "alternate" is not visible or existant.

s/existant/existent/

Quoted 35 lines
---
 lib/bb/fetch2/git.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
lib/bb/fetch2/git.py +9 -0
index 5ef8cd69..7b7f02b2 100644
@@ -53,6 +53,13 @@ Supported SRC_URI options are:
    For local git:// urls to use the current branch HEAD as the revision for use with
    AUTOREV. Implies nobranch.
 
+- noshared
+   When unpacking do not clone with the parameter "--shared". This option will
+   allow the unpacked copy to work stand-alone i.e. if your recipe runs in a
+   chroot where the "alternate" can not be found. Setting this will increase
+   the unpack-time and the disk-usage.
+   The default is "0", set noshared=1 if needed.
+
 """
 
 #Copyright (C) 2005 Richard Purdie
@@ -159,6 +166,8 @@ class Git(FetchMethod):
 
         ud.nobranch = ud.parm.get("nobranch","0") == "1"
 
+        ud.noshared = ud.parm.get("noshared","0") == "1"
+
         # usehead implies nobranch
         ud.usehead = ud.parm.get("usehead","0") == "1"
         if ud.usehead:

lib/bb/fetch2/git.py class Git(FetchMethod): · line 193

Quoted 10 lines
lib/bb/fetch2/git.py +3 -1
@@ -176,7 +185,9 @@ class Git(FetchMethod):
         if len(branches) != len(ud.names):
             raise bb.fetch2.ParameterError("The number of name and branch parameters is not balanced", ud.url)
 
-        ud.cloneflags = "-s -n"
+        ud.cloneflags = "-n"
+        if not ud.noshared:
+            ud.cloneflags += " -s"
         if ud.bareclone:
             ud.cloneflags += " --mirror"
 

Ping on this feature: Could we get some feedback if/how such a configuration option would be acceptable for upstream? We'd like to avoid having to patch or fork bitbake downstream for such a tiny change.

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#3 lore raw
In reply to Henning Schild

We actually ran into that issue on a build system called Isar.

https://github.com/ilbers/isar

This build system executes some tasks in a chroot. In this chroot a "shared" clone will not work because it expects its "alternate" to be at the very same location it was outside the chroot. We considered several hacks in Isar
- patching the alternates before and after chroot
- mounting the "alternate" to the exact location in chroot None of this is really nice, so we decided to try and do something about it upstream.

regards,
Henning

Am Tue, 12 Dec 2017 15:44:43 +0100
schrieb Henning Schild <[email protected]>:

Quoted 61 lines

By default the unpacker will create a "shared" clone when cloning from the DL_DIR to the WORKDIR. This patch introduces an option to control that behaviour. Probably something that hardly anyone would want to do.

Imagine some recipe steps are executed in a namespace that is different from the one your downloader and unpacker ran in. (chroot) Because a "shared" clone has an absolute reference to its "alternate" you now have to make that "alternate" visible in that new namespace (chroot) at the exact place.

With this patch you can unpack "noshared" and get a stand-alone copy. This copy will also work if the "alternate" is not visible or existant.

---
 lib/bb/fetch2/git.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
lib/bb/fetch2/git.py +0 -0
index 5ef8cd69..30b88c83 100644
@@ -53,6 +53,13 @@ Supported SRC_URI options are:
    For local git:// urls to use the current branch HEAD as the

revision for use with AUTOREV. Implies nobranch.

+- noshared
+   When unpacking do not clone with the parameter "--shared". This

option will
+ allow the unpacked copy to work stand-alone i.e. if your recipe
runs in a
+ chroot where the "alternate" can not be found. Setting this will
increase

lib/bb/fetch2/git.py +8 -1
+   the unpack-time and the disk-usage.
+   The default is "0", set noshared=1 if needed.
+
 """
 
 #Copyright (C) 2005 Richard Purdie
@@ -159,6 +166,8 @@ class Git(FetchMethod):
 
         ud.nobranch = ud.parm.get("nobranch","0") == "1"
 
+        ud.noshared = ud.parm.get("noshared","0") == "1"
+
         # usehead implies nobranch
         ud.usehead = ud.parm.get("usehead","0") == "1"
         if ud.usehead:
@@ -176,7 +185,9 @@ class Git(FetchMethod):
         if len(branches) != len(ud.names):
             raise bb.fetch2.ParameterError("The number of name and
 branch parameters is not balanced", ud.url) 
-        ud.cloneflags = "-s -n"
+        cloneflags = "-n"
+        if not ud.noshared:
+            cloneflags += " -s"
         if ud.bareclone:
             ud.cloneflags += " --mirror"
 
#4 lore raw
In reply to Henning Schild

Am Tue, 12 Dec 2017 15:44:43 +0100
schrieb Henning Schild <[email protected]>:

Quoted 51 lines

By default the unpacker will create a "shared" clone when cloning from the DL_DIR to the WORKDIR. This patch introduces an option to control that behaviour. Probably something that hardly anyone would want to do.

Imagine some recipe steps are executed in a namespace that is different from the one your downloader and unpacker ran in. (chroot) Because a "shared" clone has an absolute reference to its "alternate" you now have to make that "alternate" visible in that new namespace (chroot) at the exact place.

With this patch you can unpack "noshared" and get a stand-alone copy. This copy will also work if the "alternate" is not visible or existant.

---
 lib/bb/fetch2/git.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
lib/bb/fetch2/git.py +0 -0
index 5ef8cd69..30b88c83 100644
@@ -53,6 +53,13 @@ Supported SRC_URI options are:
    For local git:// urls to use the current branch HEAD as the

revision for use with AUTOREV. Implies nobranch.

+- noshared
+   When unpacking do not clone with the parameter "--shared". This

option will
+ allow the unpacked copy to work stand-alone i.e. if your recipe
runs in a
+ chroot where the "alternate" can not be found. Setting this will
increase

lib/bb/fetch2/git.py +5 -0
+   the unpack-time and the disk-usage.
+   The default is "0", set noshared=1 if needed.
+
 """
 
 #Copyright (C) 2005 Richard Purdie
@@ -159,6 +166,8 @@ class Git(FetchMethod):
 
         ud.nobranch = ud.parm.get("nobranch","0") == "1"
 
+        ud.noshared = ud.parm.get("noshared","0") == "1"
+
         # usehead implies nobranch
         ud.usehead = ud.parm.get("usehead","0") == "1"
         if ud.usehead:

lib/bb/fetch2/git.py class Git(FetchMethod): · line 190

Quoted 7 lines
lib/bb/fetch2/git.py +3 -1
@@ -176,7 +185,9 @@ class Git(FetchMethod):
         if len(branches) != len(ud.names):
             raise bb.fetch2.ParameterError("The number of name and
 branch parameters is not balanced", ud.url) 
-        ud.cloneflags = "-s -n"
+        cloneflags = "-n"
+        if not ud.noshared:
+            cloneflags += " -s"

Rebase-mistake, forgot the "ud." before cloneflags. v2 is on the way

Henning

Quoted 3 lines
lib/bb/fetch2/git.py +0 -0
         if ud.bareclone:
             ud.cloneflags += " --mirror"