diff mbox series

[PULL,1/4] edk2: get version + date from git submodule

Message ID 20240409162942.454419-2-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,1/4] edk2: get version + date from git submodule | expand

Commit Message

Gerd Hoffmann April 9, 2024, 4:29 p.m. UTC
Turned out hard-coding version and date in the Makefile wasn't a bright
idea.  Updating it on edk2 updates is easily forgotten.  Fetch the info
from git instead.  Store in edk2-version, so this can be committed to
the repo and is present in tarballs too.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-ID: <20240327102448.61877-2-kraxel@redhat.com>
---
 roms/Makefile | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Comments

Michael Tokarev April 9, 2024, 6:02 p.m. UTC | #1
09.04.2024 19:29, Gerd Hoffmann:
> Turned out hard-coding version and date in the Makefile wasn't a bright
> idea.  Updating it on edk2 updates is easily forgotten.  Fetch the info
> from git instead.  Store in edk2-version, so this can be committed to
> the repo and is present in tarballs too.

This too,
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2233


> +-include edk2-version

> +edk2-version: edk2
> +	if test -e edk2/.git; then \
> +		echo "EDK2_STABLE = $$(cd edk2; git describe --tags --match 'edk2-stable*')" > $@; \
> +		echo "EDK2_DATE = $$(cd edk2; git log -1 --pretty='format:%cd' --date='format:%m/%d/%Y')" >> $@; \
> +	else \
> +		touch $@; \
> +	fi

edk2-version will become a stray file in the source dir, not cleaned up.
But since this code path is only evaluated once, it is trivial to inline
it, in a way similar to the first version.

BTW, git has -C option instead of using `cd'.

So it goes like this:

EDK2_STABLE = $(shell [ ! -d edk2/.git ] || git -C edk2 describe --tags --match 'edk2-stable*')

ditto for EDK2_DATE.

> +efi: edk2-version
>   	$(PYTHON) edk2-build.py --config edk2-build.config \
> -		--version-override "edk2-stable202302-for-qemu" \
> -		--release-date "03/01/2023"
> +		--version-override "$(EDK2_STABLE)-for-qemu" \
> +		--release-date "$(EDK2_DATE)" \

How it will look like if there's no edk2/.git, for example, when run in
extracted release tarball, with empty EDK2_STABLE and EKD2_DATE?

Should these values be a part of release tarball maybe?
Or maybe it's better to base EKD2_{DATE|VERSION} on qemu date/version in
this case?

Thanks,

/mjt
Peter Maydell April 9, 2024, 6:39 p.m. UTC | #2
On Tue, 9 Apr 2024 at 19:02, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> 09.04.2024 19:29, Gerd Hoffmann:
> > +efi: edk2-version
> >       $(PYTHON) edk2-build.py --config edk2-build.config \
> > -             --version-override "edk2-stable202302-for-qemu" \
> > -             --release-date "03/01/2023"
> > +             --version-override "$(EDK2_STABLE)-for-qemu" \
> > +             --release-date "$(EDK2_DATE)" \
>
> How it will look like if there's no edk2/.git, for example, when run in
> extracted release tarball, with empty EDK2_STABLE and EKD2_DATE?
>
> Should these values be a part of release tarball maybe?
> Or maybe it's better to base EKD2_{DATE|VERSION} on qemu date/version in
> this case?

Patch 2 commits the edk2-version file, so it should end up
in the release tarball that way. (Effectively it becomes an
output of the "build the roms" process, same as the edk2 blobs
themselves.)

thanks
-- PMM
diff mbox series

Patch

diff --git a/roms/Makefile b/roms/Makefile
index edc234a0e886..783a5cab4f4c 100644
--- a/roms/Makefile
+++ b/roms/Makefile
@@ -52,6 +52,8 @@  SEABIOS_EXTRAVERSION="-prebuilt.qemu.org"
 #
 EDK2_EFIROM = edk2/BaseTools/Source/C/bin/EfiRom
 
+-include edk2-version
+
 default help:
 	@echo "nothing is build by default"
 	@echo "available build targets:"
@@ -147,10 +149,19 @@  skiboot:
 	$(MAKE) -C skiboot CROSS=$(powerpc64_cross_prefix)
 	cp skiboot/skiboot.lid ../pc-bios/skiboot.lid
 
-efi:
+edk2-version: edk2
+	if test -e edk2/.git; then \
+		echo "EDK2_STABLE = $$(cd edk2; git describe --tags --match 'edk2-stable*')" > $@; \
+		echo "EDK2_DATE = $$(cd edk2; git log -1 --pretty='format:%cd' --date='format:%m/%d/%Y')" >> $@; \
+	else \
+		touch $@; \
+	fi
+
+efi: edk2-version
 	$(PYTHON) edk2-build.py --config edk2-build.config \
-		--version-override "edk2-stable202302-for-qemu" \
-		--release-date "03/01/2023"
+		--version-override "$(EDK2_STABLE)-for-qemu" \
+		--release-date "$(EDK2_DATE)" \
+		--silent --no-logs
 	rm -f ../pc-bios/edk2-*.fd.bz2
 	bzip2 --verbose ../pc-bios/edk2-*.fd