From f8c593c4b745971fd4ce8887c9e02717dba5e536 Mon Sep 17 00:00:00 2001 From: chubtub <43381989+chubtub@users.noreply.github.com> Date: Tue, 8 Feb 2022 17:31:22 -0500 Subject: [PATCH] Add git timestamp and hash to the rpm name. Also centralize version number to package.sh. --- tools/tcg_rim_tool/build.gradle | 1 - tools/tcg_rim_tool/package.sh | 13 ++++++++----- tools/tcg_rim_tool/tcg_rim_tool.spec | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/tcg_rim_tool/build.gradle b/tools/tcg_rim_tool/build.gradle index 375d1b3c..6b65459a 100644 --- a/tools/tcg_rim_tool/build.gradle +++ b/tools/tcg_rim_tool/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'java' -version = '2.1.0' repositories { mavenCentral() diff --git a/tools/tcg_rim_tool/package.sh b/tools/tcg_rim_tool/package.sh index d4636949..c8885c49 100755 --- a/tools/tcg_rim_tool/package.sh +++ b/tools/tcg_rim_tool/package.sh @@ -1,17 +1,20 @@ #!/bin/bash +VERSION=2.1.0 +GIT_HASH=`git rev-parse HEAD | head -c6` +GIT_COMMIT_UNIX_TIMESTAMP=`git show -s --format=%ct | xargs echo -n` +RELEASE="$((GIT_COMMIT_UNIX_TIMESTAMP)).$GIT_HASH" +name="tcg_rim_tool" # Enter package directory SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd $SCRIPT_DIR -name="tcg_rim_tool" - -tar -cf $name.tar build.gradle gradle* src/ docs/ rim_fields.json keystore.jks scripts/ -gzip -f $name.tar +tar -cf "$name-$VERSION.$RELEASE".tar build.gradle gradle* src/ docs/ rim_fields.json keystore.jks scripts/ +gzip -f "$name-$VERSION.$RELEASE".tar if [ -d rpmbuild ]; then rm -rf rpmbuild fi mkdir -p rpmbuild/BUILD rpmbuild/BUILDROOT rpmbuild/SOURCES rpmbuild/RPMS rpmbuild/SPECS rpmbuild/SRPMS -rpmbuild -bb $name.spec --define "_sourcedir $PWD" --define "_topdir $PWD/rpmbuild" +rpmbuild -bb $name.spec --define "_sourcedir $PWD" --define "_topdir $PWD/rpmbuild" --define 'RELEASE '$RELEASE --define 'VERSION '$VERSION popd diff --git a/tools/tcg_rim_tool/tcg_rim_tool.spec b/tools/tcg_rim_tool/tcg_rim_tool.spec index c7ab4843..12e27791 100644 --- a/tools/tcg_rim_tool/tcg_rim_tool.spec +++ b/tools/tcg_rim_tool/tcg_rim_tool.spec @@ -1,11 +1,11 @@ Name: tcg_rim_tool -Version: 2.1.0 -Release: 1%{?dist} +Version: %{?VERSION} +Release: %{?RELEASE} Summary: A java command-line tool to create PC client root RIM License: ASL 2.0 URL: https://github.com/nsacyber/HIRS -Source0: %{name}.tar.gz +Source0: %{name}-%{version}.%{release}.tar.gz BuildRequires: java-headless >= 1:1.8.0 @@ -19,7 +19,7 @@ This tool will generate a base RIM file for PC clients in accordance with the sc rm -f /opt/hirs/rimtool/%{name}*.jar %build -./gradlew build +./gradlew -Pversion=%{version} build %install mkdir -p %{buildroot}/opt/hirs/rimtool/ %{buildroot}/usr/local/bin