commit c308e728fc39319b2df18175d78b4a3abdede449
Author: Elan Ruusamäe <g...@delfi.ee>
Date:   Thu Sep 22 16:19:02 2016 +0300

    setup version to binary like upstream does
    
    $ docker run --rm --entrypoint minio minio/minio version

 minio.spec | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/minio.spec b/minio.spec
index 7fc3f63..126d6c4 100644
--- a/minio.spec
+++ b/minio.spec
@@ -1,10 +1,12 @@
 %define                tag     RELEASE.2016-09-11T17-42-18Z
 %define                subver  %(echo %{tag} | sed -e 's/[^0-9]//g')
-%define                rel     0.1
+# git fetch https://github.com/minio/minio.git 
refs/tags/RELEASE.2016-09-11T17-42-18Z
+# git rev-list -n 1 FETCH_HEAD
+%define                commitid        85e2d886bcb005d49f3876d6849a2b5a55e03cd3
 Summary:       Cloud Storage Server
 Name:          minio
-Version:       1.1.0
-Release:       0.%{subver}.%{rel}
+Version:       0.%{subver}
+Release:       1
 License:       Apache v2.0
 Group:         Development/Building
 Source0:       https://github.com/minio/minio/archive/%{tag}.tar.gz
@@ -15,8 +17,8 @@ ExclusiveArch:        %{ix86} %{x8664} %{arm}
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
 # go stuff
-%define _enable_debug_packages 0
-%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 
/dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
+%define                _enable_debug_packages 0
+%define                gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head 
-c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
 %define                gopath          %{_libdir}/golang
 %define                import_path     github.com/minio/minio
 
@@ -27,7 +29,6 @@ service.
 
 %prep
 %setup -qc
-
 mv %{name}-*/* .
 
 install -d src/$(dirname %{import_path})
@@ -36,8 +37,36 @@ ln -s ../../.. src/%{import_path}
 %build
 export GOPATH=$(pwd)
 export GOROOT=%{_libdir}/golang
+
+# setup flags like 'go run buildscripts/gen-ldflags.go' would do
+tag=%{tag}
+version=${tag#RELEASE.}
+commitid=%{commitid}
+scommitid=$(echo $commitid | cut -c1-12)
+prefix=%{import_path}/cmd
+
+LDFLAGS="
+-X $prefix.Version=$version
+-X $prefix.ReleaseTag=$tag
+-X $prefix.CommitID=$commitid
+-X $prefix.ShortCommitID=$scommitid
+"
+
 %gobuild -o %{name}
 
+# check that version set properly
+./%{name} version | tee v
+
+#Version: 2016-09-11T17-42-18Z
+#Release-Tag: RELEASE.2016-09-11T17-42-18Z
+#Commit-ID: 85e2d886bcb005d49f3876d6849a2b5a55e03cd3
+v=$(awk '/Version:/{print $2}' v)
+test "$v" = $version
+v=$(awk '/Release-Tag:/{print $2}' v)
+test "$v" = $tag
+v=$(awk '/Commit-ID:/{print $2}' v)
+test "$v" = $commitid
+
 %install
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{_sbindir}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/minio.git/commitdiff/c308e728fc39319b2df18175d78b4a3abdede449

_______________________________________________
pld-cvs-commit mailing list
pld-cvs-commit@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to