[edk2-devel] edk2/ovmf version tracking

Gerd Hoffmann posted 1 patch 1 year, 7 months ago
Failed in applying to current master (apply log)
[edk2-devel] edk2/ovmf version tracking
Posted by Gerd Hoffmann 1 year, 7 months ago
  Hi,

OVMF builds carry version '0.0.0'.  I'd like to replace that with
something more useful.  Attached below is a patch doing that by
hooking a script into PREBUILD.  That is probably not the most
elegant way to do it ...

While looking around I have not found any edk2 version information in
the source tree.  So, when building from a edk2 tarball there is no
version information available.  Other projects have a VERSION file in
the toplevel directory, or something language-specific like the version
field in python's setup.cfg.  I think ekd2 should store the name of the
most recent stable tag in some file too.

I think the version information should be automatically generated by
some script to be as precise a possible.  When building from a git
checkout we can get the version information from git.  When building
packages (rpm/deb/...) storing the package version would be useful too,
either by automatically detecting package builds (as the script below
does for rpm builds), or by allowing to override the version information
using build options so package build scrips can handle it that way.

Comments?
Suggestions how to do that best?

take care,
  Gerd

diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index f39d9cd117e6..94029720318f 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -24,6 +24,7 @@ [Defines]
   BUILD_TARGETS                  = NOOPT|DEBUG|RELEASE
   SKUID_IDENTIFIER               = DEFAULT
   FLASH_DEFINITION               = OvmfPkg/OvmfPkgX64.fdf
+  PREBUILD                       = sh OvmfPkg/SmbiosPlatformDxe/Version.sh
 
   #
   # Defines for default states.  These can be changed on the command line.
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 94249d3ff1b0..e3a16196bbdc 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -14,10 +14,11 @@
 #include <Protocol/Smbios.h>                  // EFI_SMBIOS_PROTOCOL
 
 #include "SmbiosPlatformDxe.h"
+#include "Version.h"
 
 #define TYPE0_STRINGS \
   "EFI Development Kit II / OVMF\0"     /* Vendor */ \
-  "0.0.0\0"                             /* BiosVersion */ \
+  EDK2_BUILD_VERSION "\0"               /* BiosVersion */ \
   "02/06/2015\0"                        /* BiosReleaseDate */
 //
 // Type definition and contents of the default Type 0 SMBIOS table.
diff --git a/OvmfPkg/SmbiosPlatformDxe/.gitignore b/OvmfPkg/SmbiosPlatformDxe/.gitignore
new file mode 100644
index 000000000000..a40297ad16db
--- /dev/null
+++ b/OvmfPkg/SmbiosPlatformDxe/.gitignore
@@ -0,0 +1 @@
+Version.h
diff --git a/OvmfPkg/SmbiosPlatformDxe/Version.sh b/OvmfPkg/SmbiosPlatformDxe/Version.sh
new file mode 100755
index 000000000000..31d4f5c0080b
--- /dev/null
+++ b/OvmfPkg/SmbiosPlatformDxe/Version.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+outfile="${0%.sh}.h"
+
+if test "${RPM_PACKAGE_NAME}" != ""; then
+    # building rpm package
+    VERSION="${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}-${RPM_PACKAGE_RELEASE}"
+elif test -d .git -a -x "$(which git)"; then
+    # building from git checkout
+    VERSION="$(git describe --tag --match edk2-stable*)"
+else
+    # fallback
+    VERSION="unknown"
+fi
+
+cat <<EOF | tee "$outfile"
+#define EDK2_BUILD_VERSION "${VERSION}"
+EOF



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#94564): https://edk2.groups.io/g/devel/message/94564
Mute This Topic: https://groups.io/mt/94011765/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-