samba, samba-ads: Update to 3.5.6 for security fixes
[openembedded.git] / classes / gitpkgv.bbclass
blobbc1dc32561f917cf0584bf741538b8474703e18e
1 # gitpkgv.bbclass provides a GITPKGV variable which is a sortable version
2 # with the format NN+GITHASH, to be used in PKGV, where
4 # NN equals the total number of revs up to SRCREV
5 # GITHASH is SRCREV's (full) hash
7 # gitpkgv.bbclass assumes the git repository has been cloned, and contains
8 # SRCREV. So ${GITPKGV} should never be used in PV, only in PKGV.
9 # It can handle SRCREV = ${AUTOREV}, as well as SRCREV = "<some fixed git hash>"
11 # use example:
13 # inherit gitpkgv
15 # PV = "1.0+git${SRCPV}"
16 # PKGV = "1.0+git${GITPKGV}"
18 GITPKGV = "${@get_git_pkgv(d)}"
20 def get_git_pkgv(d):
21         import os
22         import bb
24         urls = bb.data.getVar('SRC_URI', d, 1).split()
26         for url in urls:
27                 (type, host, path, user, pswd, parm) = bb.decodeurl(bb.data.expand(url, d))
28                 if type in ['git']:
30                         gitsrcname = '%s%s' % (host, path.replace('/', '.'))
31                         repodir = os.path.join(bb.data.expand('${GITDIR}', d), gitsrcname)
32                         rev = bb.fetch.get_srcrev(d).split('+')[1]
34                         cwd = os.getcwd()
35                         os.chdir(repodir)
36                         output = bb.fetch.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True)
37                         os.chdir(cwd)
39                         return "%s+%s" % (output.split()[0], rev)
41         return "0+0"