Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
138 lines (119 loc) · 4.81 KB

File metadata and controls

138 lines (119 loc) · 4.81 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# gitpkgv.bbclass provides a GITPKGV and GITPKGVTAG variables to be
# used in PKGV, as described bellow:
#
# - GITPKGV which is a sortable version with the format NN+GITHASH, to
# be used in PKGV, where
#
# NN equals the total number of revs up to SRCREV
# GITHASH is SRCREV's (full) hash
#
# - GITPKGVTAG which is the output of 'git describe --tags --exact-match'
# allowing for automatic versioning
#
# gitpkgv.bbclass assumes the git repository has been cloned, and
# contains SRCREV. So ${GITPKGV} and ${GITPKGVTAG} should never be
# used in PV, only in PKGV. It can handle SRCREV = ${AUTOREV}, as
# well as SRCREV = "<some fixed git hash>".
#
# WARNING: if upstream repository is always using consistent and
# sortable tag name scheme you can get sortable version including tag
# name with ${GITPKGVTAG}, but be aware that ie tag sequence "v1.0,
# v1.2, xtest, v2.0" will force you to increment PE to get upgradeable
# path to v2.0 revisions
#
# Another WARNING: Since Walnascar release BB_SHALLOW_GIT will actually
# perform a shallow initial checkout, which makes it impossible to determine
# the correct number of commits in the repository - thus using this class
# is not recommended when shallow cloning is enabled.
#
# use example:
#
# inherit gitpkgv
#
# PV = "1.0+git" # expands to 1.0+git
# PKGV = "1.0+git${GITPKGV}" # expands also to something like 1.0+git31337+4c1c21d7d
#
# or
#
# inherit gitpkgv
#
# PV = "1.0+git" # expands to 1.0+git
# PKGV = "${GITPKGVTAG}" # expands to something like 1.0-31337+g4c1c21d
# if there is tag v1.0 before this revision or
# ver1.0-31337+g4c1c21d if there is tag ver1.0
GITPKGV = "${@get_git_pkgv(d, False)}"
GITPKGVTAG = "${@get_git_pkgv(d, True)}"
# This regexp is used to drop unwanted parts of the found tags. Any matching
# groups will be concatenated to yield the final version.
GITPKGV_TAG_REGEXP ??= "v(\d.*)"
def gitpkgv_drop_tag_prefix(d, version):
import re
m = re.match(d.getVar('GITPKGV_TAG_REGEXP'), version)
if m:
return ''.join(group for group in m.groups() if group)
else:
return version
def get_git_pkgv(d, use_tags):
import os
import bb
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
#
# If SRCREV_FORMAT is set respect it for tags
#
format = d.getVar('SRCREV_FORMAT')
if not format:
names = []
for url in ud.values():
if url.type == 'git' or url.type == 'gitsm':
names.append(url.name)
if len(names) > 0:
format = '_'.join(names)
else:
format = 'default'
found = False
for url in ud.values():
if url.type == 'git' or url.type == 'gitsm':
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
if d.getVar('BB_GIT_SHALLOW') == '1':
bb.warnonce('%s: Shallow cloning enabled - gitpkgv.bbclass will not generate sortable versions' % d.getVar('PN'))
found = True
vars = { 'repodir' : quote(destdir),
'rev' : quote(url.revision) }
rev = bb.fetch2.get_srcrev(d).split('+')[1]
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 -C %(repodir)s rev-list %(rev)s -- 2>/dev/null | wc -l"
% vars, d, quiet=True).strip().lstrip('0')
if commits != "":
oe.path.remove(rev_file, recurse=False)
with open(rev_file, "w") as f:
f.write("%d\n" % int(commits))
else:
commits = "0"
else:
with open(rev_file, "r") as f:
commits = f.readline(128).strip()
if use_tags:
try:
output = bb.fetch2.runfetchcmd(
"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:
ver = "0.0-%s-g%s" % (commits, vars['rev'][:7])
else:
ver = "%s+%s" % (commits, vars['rev'][:7])
format = format.replace(url.name, ver)
if found:
return format
return '0+0'
Morty Proxy This is a proxified and sanitized view of the page, visit original site.