]> git.pld-linux.org Git - packages/minio.git/commitdiff
setup version to binary like upstream does
authorElan Ruusamäe <glen@delfi.ee>
Thu, 22 Sep 2016 13:19:02 +0000 (16:19 +0300)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 22 Sep 2016 13:35:41 +0000 (16:35 +0300)
$ docker run --rm --entrypoint minio minio/minio version

minio.spec

index 7fc3f631e65bf18be146effddcf0e17ad8723cc2..126d6c4e01863fd9c312fdbf64978e0253fc994a 100644 (file)
@@ -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}
This page took 0.063636 seconds and 4 git commands to generate.