[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 07/11] Makefile: Derive "PKGVERSION" from "git de
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PULL 07/11] Makefile: Derive "PKGVERSION" from "git describe" by default |
Date: |
Fri, 7 Oct 2016 13:58:05 +0100 |
On 6 June 2016 at 18:35, Paolo Bonzini <address@hidden> wrote:
> From: Fam Zheng <address@hidden>
>
> Currently, if not specified in "./configure", QEMU_PKGVERSION will be
> empty. Write a rule in Makefile to generate a value from "git describe"
> combined with a possible git tree cleanness suffix, and write into a new
> header.
>
> $ cat qemu-version.h
> #define QEMU_PKGVERSION "-v2.6.0-557-gd6550e9-dirty"
>
> Include the header in .c files where the macro is referenced. It's not
> necessary to include it in all files, otherwise each time the content of
> the file changes, all sources have to be recompiled.
>
> +qemu-version.h: FORCE
> + $(call quiet-command, \
> + (cd $(SRC_PATH); \
> + printf '#define QEMU_PKGVERSION '; \
> + if test -n "$(PKGVERSION)"; then \
> + printf '"$(PKGVERSION)"\n'; \
> + else \
> + if test -d .git; then \
> + printf '" ('; \
> + git describe --match 'v*' 2>/dev/null | tr -d
> '\n'; \
> + if ! git diff-index --quiet HEAD &>/dev/null;
> then \
> + printf -- '-dirty'; \
> + fi; \
> + printf ')"\n'; \
> + else \
> + printf '""\n'; \
> + fi; \
> + fi) > address@hidden)
> + $(call quiet-command, cmp --quiet $@ address@hidden || mv
> address@hidden $@)
I've just discovered that this rune incorrectly always
adds "-dirty" to the version string if /bin/sh is dash.
This is because "&>/dev/null" is not POSIX shell syntax, it is a
bash extension, and if you run this with dash then the command
always fails.
I'm not sure why we are redirecting anything here, since we
are using git diff-index's --quiet option which suppresses
all output. The simplest fix would seem to be to just delete
the redirect option entirely.
The fix for this should probably be cc:stable since it's
annoying that you can't out of the box build QEMU and have
the version number say '2.7.0' rather than '2.7.0-dirty'...
thanks
-- PMM
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PULL 07/11] Makefile: Derive "PKGVERSION" from "git describe" by default,
Peter Maydell <=