public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Subject: edk2/ovmf version tracking
Date: Fri, 30 Sep 2022 09:13:46 +0200	[thread overview]
Message-ID: <20220930071346.wza2ksyxb3igsxim@sirius.home.kraxel.org> (raw)

  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


                 reply	other threads:[~2022-09-30  7:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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-list 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=20220930071346.wza2ksyxb3igsxim@sirius.home.kraxel.org \
    --to=devel@edk2.groups.io \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox