| Submitter | Otavio Salvador |
|---|---|
| Date | Dec. 15, 2010, 12:50 p.m. |
| Message ID | <1292417425-1328-1-git-send-email-otavio@ossystems.com.br> |
| Download | mbox | patch |
| Permalink | /patch/72/ |
| State | Superseded |
| Delegated to: | Martin Jansa |
| Headers | show |
Comments
On Wed, Dec 15, 2010 at 10:50:25AM -0200, Otavio Salvador wrote: > Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> > --- > classes/gitpv.bbclass | 41 +++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 41 insertions(+), 0 deletions(-) > create mode 100644 classes/gitpv.bbclass > > diff --git a/classes/gitpv.bbclass b/classes/gitpv.bbclass > new file mode 100644 > index 0000000..c9496f1 > --- /dev/null > +++ b/classes/gitpv.bbclass > @@ -0,0 +1,41 @@ > +# gitpv.bbclass provides a PV variable which is a sortable version > +# with the output of "git describe". > +# > +# It can handle SRCREV = ${AUTOREV}, as well as SRCREV = "<hash>" > + > +PV = "${@get_git_pv(d)}" can you integrate it with classes/gitpkgv.bbclass ? get_git_pkgv() there is quite similar and after improving it with git describe you can use it here as ${GITPKGV} and maybe assign to PV only ?= as IMHO recipe should be able to say different base version than 0.0 or use it only in PKGV.. Regards,
On Wed, Dec 15, 2010 at 11:01, Martin Jansa <martin.jansa@gmail.com> wrote: > On Wed, Dec 15, 2010 at 10:50:25AM -0200, Otavio Salvador wrote: >> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> >> --- >> classes/gitpv.bbclass | 41 +++++++++++++++++++++++++++++++++++++++++ >> 1 files changed, 41 insertions(+), 0 deletions(-) >> create mode 100644 classes/gitpv.bbclass >> >> diff --git a/classes/gitpv.bbclass b/classes/gitpv.bbclass >> new file mode 100644 >> index 0000000..c9496f1 >> --- /dev/null >> +++ b/classes/gitpv.bbclass >> @@ -0,0 +1,41 @@ >> +# gitpv.bbclass provides a PV variable which is a sortable version >> +# with the output of "git describe". >> +# >> +# It can handle SRCREV = ${AUTOREV}, as well as SRCREV = "<hash>" >> + >> +PV = "${@get_git_pv(d)}" > > can you integrate it with > classes/gitpkgv.bbclass ? I can however I think the usage is different. The gitpkgv does not use describe and if there's users of it (there's no in recipes) we'd change it for them. That is wrong in my opinion. So I thought about adding another class and not messing with it. > get_git_pkgv() there is quite similar > and after improving it with git describe you can use it here as ${GITPKGV} > > and maybe assign to PV only ?= as IMHO recipe should be able to say > different base version than 0.0 or use it only in PKGV.. about assign to PV ?= I agree however why someone might want to use it only in PKGV?
On Wed, Dec 15, 2010 at 12:27, Otavio Salvador <otavio@ossystems.com.br> wrote: > about assign to PV ?= I agree however why someone might want to use it > only in PKGV? ?= doesn't seem to work. PV is preset so it won't override it.
On 12/15/2010 05:36 PM, Otavio Salvador wrote: > On Wed, Dec 15, 2010 at 12:27, Otavio Salvador <otavio@ossystems.com.br> wrote: >> about assign to PV ?= I agree however why someone might want to use it >> only in PKGV? > > ?= doesn't seem to work. PV is preset so it won't override it. > How about PV .= "${@get_git_pv(d)}"?
On Wed, Dec 15, 2010 at 15:18, Andreas Oberritter <obi@opendreambox.org> wrote: > On 12/15/2010 05:36 PM, Otavio Salvador wrote: >> On Wed, Dec 15, 2010 at 12:27, Otavio Salvador <otavio@ossystems.com.br> wrote: >>> about assign to PV ?= I agree however why someone might want to use it >>> only in PKGV? >> >> ?= doesn't seem to work. PV is preset so it won't override it. >> > > How about PV .= "${@get_git_pv(d)}"? It ought to use the get_git_pv output _only otherwise you'll get a confusing string.
On Wed, Dec 15, 2010 at 12:27:12PM -0200, Otavio Salvador wrote: > On Wed, Dec 15, 2010 at 11:01, Martin Jansa <martin.jansa@gmail.com> wrote: > > On Wed, Dec 15, 2010 at 10:50:25AM -0200, Otavio Salvador wrote: > >> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> > >> --- > >> classes/gitpv.bbclass | 41 +++++++++++++++++++++++++++++++++++++++++ > >> 1 files changed, 41 insertions(+), 0 deletions(-) > >> create mode 100644 classes/gitpv.bbclass > >> > >> diff --git a/classes/gitpv.bbclass b/classes/gitpv.bbclass > >> new file mode 100644 > >> index 0000000..c9496f1 > >> --- /dev/null > >> +++ b/classes/gitpv.bbclass > >> @@ -0,0 +1,41 @@ > >> +# gitpv.bbclass provides a PV variable which is a sortable version > >> +# with the output of "git describe". > >> +# > >> +# It can handle SRCREV = ${AUTOREV}, as well as SRCREV = "<hash>" > >> + > >> +PV = "${@get_git_pv(d)}" > > > > can you integrate it with > > classes/gitpkgv.bbclass ? > > I can however I think the usage is different. I find 3 similar classes a bit confusing gitpkgv, gitver and now gitpv so I was hoping that all 3 classes could be merged to one (probably gitver is best name) where all usefull variables will be prepared, and then only the right one used in recipe. Like in gitpkgv.bbclass example: # inherit gitpkgv # # PV = "1.0+git${SRCPV}" # PKGV = "1.0+git${GITPKGV}" btw there should be '+gitr' not '+git' AFAIK in your case, you can use something like PV = "${GITVER}" btw your current implementation imho doesn't provide sortable version in case someone makes tag "something-special" between tags "release-2010.12" and "release-2011.03". > The gitpkgv does not use describe and if there's users of it (there's > no in recipes) we'd change it for them. That is wrong in my opinion. agreed but it can still be in same bbclass maybe in new variable ?GITTAGVER? as long as bbclass is not changing variables like PV (and expects recipe to use provided variables itself). > about assign to PV ?= I agree however why someone might want to use it > only in PKGV? Here is a bit longer thread with reasoning and description http://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg06746.html Even after converting many recipes from SRCREV to SRCPV I find this concept nice and if local persistent cache will be still needed in new fetchers implementation, then we should probably convert git recipes using SRCPV to something like GITPKGV (this time hopefully without PE bump). Regards,
Patch
diff --git a/classes/gitpv.bbclass b/classes/gitpv.bbclass new file mode 100644 index 0000000..c9496f1 --- /dev/null +++ b/classes/gitpv.bbclass @@ -0,0 +1,41 @@ +# gitpv.bbclass provides a PV variable which is a sortable version +# with the output of "git describe". +# +# It can handle SRCREV = ${AUTOREV}, as well as SRCREV = "<hash>" + +PV = "${@get_git_pv(d)}" + +def git_drop_tag_prefix(version): + import re + if re.match("v\d", version): + return version[1:] + else: + return version + +def get_git_pv(d): + import os + import bb + + urls = bb.data.getVar('SRC_URI', d, 1).split() + + for url in urls: + (type, host, path, user, pswd, parm) = bb.decodeurl(bb.data.expand(url, d)) + if type in ['git']: + gitsrcname = '%s%s' % (host, path.replace('/', '.')) + repodir = os.path.join(bb.data.expand('${GITDIR}', d), gitsrcname) + rev = bb.fetch.get_srcrev(d).split('+')[1] + + cwd = os.getcwd() + os.chdir(repodir) + + try: + ver = bb.fetch.runfetchcmd("git describe %s 2>/dev/null" % rev, d, quiet=True).strip() + except Exception: + commits = bb.fetch.runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True).strip() + ver = "0.0-%s-g%s" % commits, rev[:7] + + os.chdir(cwd) + + return git_drop_tag_prefix(ver) + + return "0+0"
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> --- classes/gitpv.bbclass | 41 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+), 0 deletions(-) create mode 100644 classes/gitpv.bbclass