From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web09.2985.1664522036825620267 for ; Fri, 30 Sep 2022 00:13:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NpOOQ376; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664522035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=/xTH257rUHNM451laM5SzvkJWJpH4dza81AdEc8Cflk=; b=NpOOQ376l2j+rcMHcGOFj3tumqd6NaNY6ShJlCYEV2t/CfVZPadCgpENYYskmgRb419FwZ 3brRhFAJhol25tRxlJDJHNjkq5t042EuZbOkQ+s9zbEzMWhWzWTYoZik3+iEy16McGhsTy uTDyOBgBra9O2tFt5yUBRNLcJ2rBP14= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-3-ydqFUh1tNH2Af71-U2l5bg-1; Fri, 30 Sep 2022 03:13:48 -0400 X-MC-Unique: ydqFUh1tNH2Af71-U2l5bg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CAC11C05152 for ; Fri, 30 Sep 2022 07:13:48 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.194.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4090F40EFB02 for ; Fri, 30 Sep 2022 07:13:48 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E74C4180039F; Fri, 30 Sep 2022 09:13:46 +0200 (CEST) Date: Fri, 30 Sep 2022 09:13:46 +0200 From: "Gerd Hoffmann" To: devel@edk2.groups.io Subject: edk2/ovmf version tracking Message-ID: <20220930071346.wza2ksyxb3igsxim@sirius.home.kraxel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 // 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 <