From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Sander Eikelenboom <linux@eikelenboom.it>,
"Keir (Xen.org)" <keir@xen.org>,
Marek Marczykowski <marmarek@invisiblethingslab.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2] Use {git, hg, svn} commit id if available for xen_changeset
Date: Wed, 8 May 2013 12:17:55 +0100 [thread overview]
Message-ID: <518A3463.2080602@citrix.com> (raw)
In-Reply-To: <1368011157.26321.233.camel@zakaz.uk.xensource.com>
On 08/05/13 12:05, Ian Campbell wrote:
> On Wed, 2013-05-08 at 06:42 +0100, Marek Marczykowski wrote:
>> As Xen uses git as primary repository, get git commit id for
>> xen_changeset info.
> I applied this to an hg repo and:
> $ chmod +x xen/tools/scmversion
> $ rm xen/include/xen/compile.h
> $ make -C xen include/xen/compile.h
> make: Entering directory `/local/scratch/ianc/devel/xen-unstable.hg/xen'
> __ __ _ _ _____ _ _ _
> \ \/ /___ _ __ | || | |___ / _ _ _ __ ___| |_ __ _| |__ | | ___
> \ // _ \ '_ \ | || |_ |_ \ __| | | | '_ \/ __| __/ _` | '_ \| |/ _ \
> / \ __/ | | | |__ _| ___) |__| |_| | | | \__ \ || (_| | |_) | | __/
> /_/\_\___|_| |_| |_|(_)____/ \__,_|_| |_|___/\__\__,_|_.__/|_|\___|
>
> make: Leaving directory `/local/scratch/ianc/devel/xen-unstable.hg/xen'
> $ grep CHANGESET xen/include/xen/compile.h
> #define XEN_CHANGESET " 2>/dev/null | tr -d n)"
>
> Same seems to happen for a git repo too so its not VCS specific.
>
> It also happens if I do an actual build rather than forcing things as
> above.
>
> Running scmversion by hand appears to produce good output.
>
> Indentation in svmversion seems a bit off though, e.g.
> + printf '%s %s%s' "$date" git: $head
> +
> + # Is this git on svn?
> + if git config --get svn-remote.svn.url >/dev/null; then
> + printf -- 'svn:%s' "`git svn find-rev $head`"
> + fi
>
> Seems to be tab vs space related, the printf is space indented and the
> rest is tab indented.
>
> Ian.
Can I please re-request a merge of this change (which in itself is good
and fine) with
http://lists.xen.org/archives/html/xen-devel/2012-07/msg01886.html
The reason is that the changeset information is *still broken* for an
out-of-scm builds such as RPMs and DEBs.
I will happily rebase the above path on top of this one, if it is accepted.
~Andrew
>
>> Changes in v2:
>> - split scm calls into separate script - based on Linux kernel one,
>> with tags handling removed
>> - update title
>>
>> Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com>
>> ---
>> xen/Makefile | 2 +-
>> xen/tools/scmversion | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 100 insertions(+), 1 deletion(-)
>> create mode 100755 xen/tools/scmversion
>>
>> diff --git a/xen/Makefile b/xen/Makefile
>> index 0fb3db7..6f1f13d 100644
>> --- a/xen/Makefile
>> +++ b/xen/Makefile
>> @@ -126,7 +126,7 @@ include/xen/compile.h: include/xen/compile.h.in .banner
>> -e 's/@@version@@/$(XEN_VERSION)/g' \
>> -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
>> -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
>> - -e 's!@@changeset@@!$(shell ((hg parents --template "{date|date} {rev}:{node|short}" >/dev/null && hg parents --template "{date|date} {rev}:{node|short}") || echo "unavailable") 2>/dev/null)!g' \
>> + -e 's!@@changeset@@!$(shell tools/scmversion || echo "unavailable") 2>/dev/null | tr -d '\n')!g' \
>> < include/xen/compile.h.in > $@.new
>> @grep \" .banner >> $@.new
>> @grep -v \" .banner
>> diff --git a/xen/tools/scmversion b/xen/tools/scmversion
>> new file mode 100755
>> index 0000000..19d4137
>> --- /dev/null
>> +++ b/xen/tools/scmversion
>> @@ -0,0 +1,99 @@
>> +#!/bin/sh
>> +#
>> +# This scripts adds local version information from the version
>> +# control systems git, mercurial (hg) and subversion (svn).
>> +#
>> +# If something goes wrong, send a mail the kernel build mailinglist
>> +# (see MAINTAINERS) and CC Nico Schottelius
>> +# <nico-linuxsetlocalversion -at- schottelius.org>.
>> +#
>> +# Based on setlocalversion from Linux kernel
>> +#
>> +#
>> +
>> +usage() {
>> + echo "Usage: $0 [--save-scmversion] [srctree]" >&2
>> + exit 1
>> +}
>> +
>> +scm_only=false
>> +srctree=.
>> +if test "$1" = "--save-scmversion"; then
>> + scm_only=true
>> + shift
>> +fi
>> +if test $# -gt 0; then
>> + srctree=$1
>> + shift
>> +fi
>> +if test $# -gt 0 -o ! -d "$srctree"; then
>> + usage
>> +fi
>> +
>> +scm_version()
>> +{
>> + local short
>> + short=false
>> +
>> + cd "$srctree"
>> + if test -e .scmversion; then
>> + cat .scmversion
>> + return
>> + fi
>> + if test "$1" = "--short"; then
>> + short=true
>> + fi
>> +
>> + # Check for git and a git repo.
>> + if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
>> + date=`git show -s --pretty="%ad" HEAD`
>> +
>> + printf '%s %s%s' "$date" git: $head
>> +
>> + # Is this git on svn?
>> + if git config --get svn-remote.svn.url >/dev/null; then
>> + printf -- 'svn:%s' "`git svn find-rev $head`"
>> + fi
>> +
>> + # Update index only on r/w media
>> + [ -w . ] && git update-index --refresh --unmerged > /dev/null
>> +
>> + # Check for uncommitted changes
>> + if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then
>> + printf '%s' -dirty
>> + fi
>> +
>> + # All done with git
>> + return
>> + fi
>> +
>> + # Check for mercurial and a mercurial repo.
>> + if test -d .hg && hgid=`hg id 2>/dev/null`; then
>> + id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
>> + date=`hg parents --template "{date|date}"`
>> + printf '%s %s%s' "$date" hg: "$id"
>> +
>> + # Are there uncommitted changes?
>> + # These are represented by + after the changeset id.
>> + case "$hgid" in
>> + *+|*+\ *) printf '%s' -dirty ;;
>> + esac
>> +
>> + # All done with mercurial
>> + return
>> + fi
>> +
>> + # Check for svn and a svn repo.
>> + if rev=`LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then
>> + rev=`echo $rev | awk '{print $NF}'`
>> + printf -- 'svn:%s' "$rev"
>> +
>> + # All done with svn
>> + return
>> + fi
>> +}
>> +
>> +# full scm version string
>> +res="$(scm_version)"
>> +
>> +echo "$res"
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-05-08 11:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-08 5:42 [PATCH v2] Use {git, hg, svn} commit id if available for xen_changeset Marek Marczykowski
2013-05-08 11:05 ` Ian Campbell
2013-05-08 11:17 ` Andrew Cooper [this message]
2013-05-08 11:26 ` Ian Campbell
2013-05-08 11:59 ` Andrew Cooper
2013-05-08 12:05 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=518A3463.2080602@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=keir@xen.org \
--cc=linux@eikelenboom.it \
--cc=marmarek@invisiblethingslab.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.