[PATCH 4/4] fedora: Update buildsrpm.sh for dynamic versioning

Prarit Bhargava prarit at redhat.com
Thu Jan 19 20:16:01 UTC 2017


fwts.spec requires a manual update for the major, minor and subminor
versions every release.  This can be avoided by dynamically updating the
spec file every build.

I have modified buildsrpm.sh to determine the current version of fwts from the
value of FWTS_VERSION in src/lib/include/fwts_version.h.  This value is used to
substitute values for major, minor, and subminor values in fwts.spec.in.
The buildsrpm.sh script creates fwts.spec which is then used to build rpms.

Also update the global .gitignore file to ignore the dynamically created
fwts.spec file.

Signed-off-by: Prarit Bhargava <prarit at redhat.com>
---
 .gitignore         |    1 +
 fedora/buildrpm.sh |   22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 7ae1561839d5..add5f0b4b4fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,5 +35,6 @@ src/lib/src/libfwts.la
 src/utilities/kernelscan
 fwts-test/*/*.sh.trs
 fwts-test/*/*.sh.log
+fedora/fwts.spec
 fedora/rpm
 src/acpica/source/compiler/aslcompiler.y
diff --git a/fedora/buildrpm.sh b/fedora/buildrpm.sh
index 1400b6ca7fc1..a3225a19cca5 100755
--- a/fedora/buildrpm.sh
+++ b/fedora/buildrpm.sh
@@ -12,13 +12,23 @@ RPMBUILD=$(if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
 RPM="$(pwd)/rpm"
 mkdir -p $RPM/SOURCES $RPM/BUILD $RPM/SRPMS $RPM/SPECS
 
-# get the tarball
-major=$(cat fwts.spec | grep -m 1 major | awk -F " " ' { print $3 }')
-minor=$(cat fwts.spec | grep -m 1 minor | awk -F " " ' { print $3 }')
-subminor=$(cat fwts.spec | grep -m 1 subminor | awk -F " " ' { print $3 }')
-tarversion="V$major.$minor.$subminor"
+# find the version in src/lib/include/fwts_version.h
+_fwts_version=$(git grep FWTS_VERSION ../src/lib/include/fwts_version.h | awk -F "\"" ' { print $2 } ')
+# strip off leading "V" from FWTS_VERSION
+fwts_version=${_fwts_version#"V"}
+
+# change __VERSION, __MAJOR, and __MINOR_SUBMINOR in fwts.spec.in
+major=$(echo $fwts_version | awk -F "." ' { print $1 }')
+minor_subminor=$(echo $fwts_version | awk -F "." ' { print $2"."$3 }')
+sed -i 's/{__VERSION}/'${fwts_version}'/g' fwts.spec.in
+sed -i 's/{__MAJOR}/'${major}'/g' fwts.spec.in
+sed -i 's/{__MINOR_SUBMINOR}/'${minor_subminor}'/g' fwts.spec.in
 
-(cd $RPM/SOURCES && curl -O http://fwts.ubuntu.com/release/fwts-${tarversion}.tar.gz)
+# create fwts.spec from fwts.spec.in
+cp -f fwts.spec.in fwts.spec
+
+# get the tarball
+(cd $RPM/SOURCES && curl -O http://fwts.ubuntu.com/release/fwts-V${fwts_version}.tar.gz)
 
 # copy the specfile over
 rm -f $RPM/SPECS/fwts.spec
-- 
1.7.9.3




More information about the fwts-devel mailing list