Skip to contentSkip to conversation

gitpkgv.bbclass: inspect repository in UNPACKDIR

PATCH Gyorgy Sarvari 2 participants 3 messages Aug 17, 2025 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

In my testing it looks okay, but if someone else could test/review it also to see if it makes sense, it would be useful.

Quoted 73 lines · Gyorgy Sarvari via lists.openembedded.org

When BB_GIT_SHALLOW = "1" is used, the unpacked gir repository doesn't exist in the download folder, and the class isn't able to instect the details of the repository.

Instead inspect the repository it the UNPACKDIR.

---
 meta-oe/classes/gitpkgv.bbclass | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
meta-oe/classes/gitpkgv.bbclass +12 -6
index eb4b1eae9a..1afe9c53d8 100644
@@ -59,6 +59,9 @@ def get_git_pkgv(d, use_tags):
     from shlex import quote
 
     src_uri = d.getVar('SRC_URI').split()
+    unpackdir = d.getVar('UNPACKDIR')
+    def_destsuffix = (d.getVar("BB_GIT_DEFAULT_DESTSUFFIX") or "git") + "/"
+
     fetcher = bb.fetch2.Fetch(src_uri, d)
     ud = fetcher.ud
 
@@ -78,20 +81,24 @@ def get_git_pkgv(d, use_tags):
     found = False
     for url in ud.values():
         if url.type == 'git' or url.type == 'gitsm':
-            if not os.path.exists(url.localpath):
+            destsuffix = url.parm.get("destsuffix", def_destsuffix)
+            subdir = url.parm.get('subdir', '')
+            destdir = os.path.join(unpackdir, destsuffix, subdir)
+
+            if not os.path.exists(destdir):
                 return None
 
             found = True
 
-            vars = { 'repodir' : quote(url.localpath),
+            vars = { 'repodir' : quote(destdir),
                      'rev' : quote(url.revision) }
 
             rev = bb.fetch2.get_srcrev(d).split('+')[1]
-            rev_file = os.path.join(url.localpath, "oe-gitpkgv_" + url.revision)
+            rev_file = os.path.join(destdir, "oe-gitpkgv_" + url.revision)
 
             if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
                 commits = bb.fetch2.runfetchcmd(
-                    "git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
+                    "git -C %(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
                     % vars, d, quiet=True).strip().lstrip('0')
 
                 if commits != "":
@@ -107,7 +114,7 @@ def get_git_pkgv(d, use_tags):
             if use_tags:
                 try:
                     output = bb.fetch2.runfetchcmd(
-                        "git --git-dir=%(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null"
+                        "git -C %(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null"
                         % vars, d, quiet=True).strip()
                     ver = gitpkgv_drop_tag_prefix(d, output)
                 except Exception:
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#118981): https://lists.openembedded.org/g/openembedded-devel/message/118981
Mute This Topic: https://lists.openembedded.org/mt/114745266/6084445
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
In reply to a message not in the archive
Quoted 2 lines · Gyorgy Sarvari via lists.openembedded.org

In my testing it looks okay, but if someone else could test/review it also to see if it makes sense, it would be useful.

A short off-list exchange with WXbet made me look a bit more, and there is a gotcha.

Looking at older releases, BB_GIT_SHALLOW used to have effect on mirror tarball fetching and generation only, not on fetching from git.

But now there is actual shallow cloning, which changes the behavior of this class beyond the folder issue: it's not possible to determine the real number of commits, so the versions generated by this class won't be very sortable.

Should there be maybe a bb.warn/fatal error if shallow clone is enabled? Or just a comment in the class? Or just drop this change, and keep it as it is?

Does anyone have any preference/suggestion?

Quoted 78 lines · Gyorgy Sarvari via lists.openembedded.org
Quoted 59 lines

When BB_GIT_SHALLOW = "1" is used, the unpacked gir repository doesn't exist in the download folder, and the class isn't able to instect the details of the repository.

Instead inspect the repository it the UNPACKDIR.

---
 meta-oe/classes/gitpkgv.bbclass | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
meta-oe/classes/gitpkgv.bbclass +11 -4
index eb4b1eae9a..1afe9c53d8 100644
@@ -59,6 +59,9 @@ def get_git_pkgv(d, use_tags):
     from shlex import quote
 
     src_uri = d.getVar('SRC_URI').split()
+    unpackdir = d.getVar('UNPACKDIR')
+    def_destsuffix = (d.getVar("BB_GIT_DEFAULT_DESTSUFFIX") or "git") + "/"
+
     fetcher = bb.fetch2.Fetch(src_uri, d)
     ud = fetcher.ud
 
@@ -78,20 +81,24 @@ def get_git_pkgv(d, use_tags):
     found = False
     for url in ud.values():
         if url.type == 'git' or url.type == 'gitsm':
-            if not os.path.exists(url.localpath):
+            destsuffix = url.parm.get("destsuffix", def_destsuffix)
+            subdir = url.parm.get('subdir', '')
+            destdir = os.path.join(unpackdir, destsuffix, subdir)
+
+            if not os.path.exists(destdir):
                 return None
 
             found = True
 
-            vars = { 'repodir' : quote(url.localpath),
+            vars = { 'repodir' : quote(destdir),
                      'rev' : quote(url.revision) }
 
             rev = bb.fetch2.get_srcrev(d).split('+')[1]
-            rev_file = os.path.join(url.localpath, "oe-gitpkgv_" + url.revision)
+            rev_file = os.path.join(destdir, "oe-gitpkgv_" + url.revision)
 
             if not os.path.exists(rev_file) or os.path.getsize(rev_file)==0:
                 commits = bb.fetch2.runfetchcmd(
-                    "git --git-dir=%(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
+                    "git -C %(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
                     % vars, d, quiet=True).strip().lstrip('0')
 
                 if commits != "":

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 120

Quoted 8 lines
meta-oe/classes/gitpkgv.bbclass +1 -1
@@ -107,7 +114,7 @@ def get_git_pkgv(d, use_tags):
             if use_tags:
                 try:
                     output = bb.fetch2.runfetchcmd(
-                        "git --git-dir=%(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null"
+                        "git -C %(repodir)s describe %(rev)s --tags --exact-match 2>/dev/null"
                         % vars, d, quiet=True).strip()
                     ver = gitpkgv_drop_tag_prefix(d, output)
                 except Exception:

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#118982): https://lists.openembedded.org/g/openembedded-devel/message/118982
Mute This Topic: https://lists.openembedded.org/mt/114745266/6084445
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 15 lines · Gyorgy Sarvari via lists.openembedded.org
Quoted 2 lines · Gyorgy Sarvari via lists.openembedded.org

In my testing it looks okay, but if someone else could test/review it also to see if it makes sense, it would be useful.

A short off-list exchange with WXbet made me look a bit more, and there is a gotcha.

Looking at older releases, BB_GIT_SHALLOW used to have effect on mirror tarball fetching and generation only, not on fetching from git.

But now there is actual shallow cloning, which changes the behavior of this class beyond the folder issue: it's not possible to determine the real number of commits, so the versions generated by this class won't be very sortable.

Quoted 6 lines

Should there be maybe a bb.warn/fatal error if shallow clone is enabled? Or just a comment in the class? Or just drop this change, and keep it as it is?

Does anyone have any preference/suggestion?

I think we should also look at if this class still is valuable a warning is perhaps better here

Quoted 95 lines
Quoted 9 lines · Gyorgy Sarvari via lists.openembedded.org
Quoted 6 lines

When BB_GIT_SHALLOW = "1" is used, the unpacked gir repository doesn't exist in the download folder, and the class isn't able to instect the details of the repository.

Instead inspect the repository it the UNPACKDIR.

Quoted 7 lines

Review

Quoted 7 lines
---
 meta-oe/classes/gitpkgv.bbclass | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/meta-oe/classes/gitpkgv.bbclass

Quoted 9 lines

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 63

Quoted 9 lines

index eb4b1eae9a..1afe9c53d8 100644

meta-oe/classes/gitpkgv.bbclass +2 -0
@@ -59,6 +59,9 @@ def get_git_pkgv(d, use_tags):
     from shlex import quote
 
     src_uri = d.getVar('SRC_URI').split()
+    unpackdir = d.getVar('UNPACKDIR')
+    def_destsuffix = (d.getVar("BB_GIT_DEFAULT_DESTSUFFIX") or "git")

+ "/"

Quoted 16 lines
Quoted 16 lines
meta-oe/classes/gitpkgv.bbclass +6 -1
+
     fetcher = bb.fetch2.Fetch(src_uri, d)
     ud = fetcher.ud
 
@@ -78,20 +81,24 @@ def get_git_pkgv(d, use_tags):
     found = False
     for url in ud.values():
         if url.type == 'git' or url.type == 'gitsm':
-            if not os.path.exists(url.localpath):
+            destsuffix = url.parm.get("destsuffix", def_destsuffix)
+            subdir = url.parm.get('subdir', '')
+            destdir = os.path.join(unpackdir, destsuffix, subdir)
+
+            if not os.path.exists(destdir):
                 return None
 
Quoted 8 lines

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 90

Quoted 8 lines
meta-oe/classes/gitpkgv.bbclass +1 -2
             found = True
 
-            vars = { 'repodir' : quote(url.localpath),
+            vars = { 'repodir' : quote(destdir),
                      'rev' : quote(url.revision) }
 
             rev = bb.fetch2.get_srcrev(d).split('+')[1]
-            rev_file = os.path.join(url.localpath, "oe-gitpkgv_" +

url.revision)

Quoted 1 line

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 97

Quoted 1 line
meta-oe/classes/gitpkgv.bbclass +1 -0
+            rev_file = os.path.join(destdir, "oe-gitpkgv_" +

url.revision)

Quoted 2 lines

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 98

Quoted 2 lines
meta-oe/classes/gitpkgv.bbclass +0 -0
             if not os.path.exists(rev_file) or

os.path.getsize(rev_file)==0:

Quoted 2 lines

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 93

Quoted 2 lines
meta-oe/classes/gitpkgv.bbclass +0 -1
                 commits = bb.fetch2.runfetchcmd(
-                    "git --git-dir=%(repodir)s rev-list %(rev)s --

2>/dev/null | wc -l"

Quoted 1 line

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 100

Quoted 1 line
meta-oe/classes/gitpkgv.bbclass +1 -0
+                    "git -C %(repodir)s rev-list %(rev)s --

2>/dev/null | wc -l"

Quoted 8 lines

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 110

Quoted 8 lines
meta-oe/classes/gitpkgv.bbclass +0 -1
                     % vars, d, quiet=True).strip().lstrip('0')
 
                 if commits != "":
@@ -107,7 +114,7 @@ def get_git_pkgv(d, use_tags):
             if use_tags:
                 try:
                     output = bb.fetch2.runfetchcmd(
-                        "git --git-dir=%(repodir)s describe %(rev)s

--tags --exact-match 2>/dev/null"

Quoted 1 line

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 117

Quoted 1 line
meta-oe/classes/gitpkgv.bbclass +1 -0
+                        "git -C %(repodir)s describe %(rev)s --tags

--exact-match 2>/dev/null"

Quoted 9 lines

meta-oe/classes/gitpkgv.bbclass def get_git_pkgv(d, use_tags): · line 120

Quoted 6 lines
meta-oe/classes/gitpkgv.bbclass +0 -0
                         % vars, d, quiet=True).strip()
                     ver = gitpkgv_drop_tag_prefix(d, output)
                 except Exception:

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#118983):
https://lists.openembedded.org/g/openembedded-devel/message/118983
Mute This Topic: https://lists.openembedded.org/mt/114745266/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-