From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7lmg-0002uo-02 for qemu-devel@nongnu.org; Tue, 31 May 2016 11:40:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7lmb-0006ho-KS for qemu-devel@nongnu.org; Tue, 31 May 2016 11:40:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7lmb-0006hi-8R for qemu-devel@nongnu.org; Tue, 31 May 2016 11:40:41 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 826C18E74B for ; Tue, 31 May 2016 15:40:40 +0000 (UTC) References: <1464707044-10447-1-git-send-email-lersek@redhat.com> <20160531151418.GZ21628@redhat.com> From: Laszlo Ersek Message-ID: Date: Tue, 31 May 2016 17:40:38 +0200 MIME-Version: 1.0 In-Reply-To: <20160531151418.GZ21628@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] configure: save git working tree information in "pkgversion" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Kashyap Chamarthy On 05/31/16 17:14, Daniel P. Berrange wrote: > On Tue, May 31, 2016 at 05:04:04PM +0200, Laszlo Ersek wrote: >> When building QEMU from a git working tree (either in-tree or >> out-of-tree), it is useful to capture the working tree status in the QEMU >> binary, for the "-version" option to report. >> >> Daniel suggested using the "pkgversion" variable (tied to the >> "--with-pkgversion" option) of the configure script for this. Downstream >> packagers of QEMU already use this option for customizing their builds, >> plus libvirtd captures "pkgversion" (with the "-version" option) in >> "/var/log/libvirt/qemu/$GUEST.log", whenever a guest is started. >> >> The information we include in "pkgversion" is the output of git-describe, >> with a plus sign (+) appended if there are staged or unstaged changes to >> tracked files, at the time of "configure" being executed. >> >> The content of "pkgversion" is not changed when "--with-pkgversion" is >> used on the command line. >> >> Cc: "Daniel P. Berrange" >> Cc: Kashyap Chamarthy >> Signed-off-by: Laszlo Ersek >> --- >> configure | 38 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 38 insertions(+) >> >> diff --git a/configure b/configure >> index b5aab7257b33..20a7ec5cc0fd 100755 >> --- a/configure >> +++ b/configure >> @@ -4255,6 +4255,44 @@ if have_backend "dtrace"; then >> fi >> >> ########################################## >> +# save git working tree information in pkgversion >> + >> +# If pkgversion has not been set to a non-empty string, fetch the output of >> +# "git describe" into it. If the working tree is unclean (there are staged or >> +# unstaged changes in tracked files), then append a plus sign. >> +# >> +# If we're not building from a git working tree, then pkgversion is not >> +# changed. Otherwise, git errors are fatal. >> + >> +if test -z "$pkgversion" && test -d "$source_path/.git"; then >> + pkgversion=$( >> + export GIT_DIR=$source_path/.git >> + export GIT_WORK_TREE=$source_path >> + >> + git_desc=$(git describe) >> + git_exit=$? >> + if test $git_exit -ne 0; then >> + exit $git_exit >> + fi >> + >> + git_changes= >> + for git_diff_option in "" --staged; do >> + git diff $git_diff_option --quiet >> + git_exit=$? >> + case $git_exit in >> + (0) ;; >> + (1) git_changes=+ >> + ;; >> + (*) exit $git_exit >> + ;; >> + esac >> + done > > An alternative to this would be to jus use > > "git describe --dirty" > > which appends "--dirty" to its output if working tre has uncommitted > changes. Good idea! > Not sure if the --dirty flag is a recent option or whether we can just > assume it always exists. Grepping git's Documentation/RelNotes/ directory, I find: - in "1.6.6.txt": the introduction of --dirty - in "1.7.6.4.txt": an apparently important bugfix for --dirty Version 1.7.6.4 of git was tagged on Sep 23 2011. Does this information help in deciding if we can use --dirty? For example, Debian oldstable ("wheezy"), which I tend to use as one reference point for "ancient but still supported", has 1.7.10.4: https://packages.debian.org/wheezy/git Another example: the latest git package in EPEL-5 is 1.8.2.3: http://koji.fedoraproject.org/koji/buildinfo?buildID=757915 Thanks Laszlo