You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.8 KiB

%define fullversion 2020-12-12T08-39-07Z
%define realversion %(echo %{fullversion} | sed -e 's/[^0-9]//g' | cut -c -8)
%global _hardened_build 1
%define minio_user minio
%define minio_group minio
%define minio_home /var/lib/minio/
Name : minio
Version : %{realversion}
Release : 1%{?dist}
Summary : Web Object Cloud Storage Server
Group : System/Web
License : Apache License
URL : https://min.io
#Source0 : https://github.com/minio/minio/archive/RELEASE.2020-05-08T02-40-49Z.tar.gz
Source1 : minio-server.config
Source2 : minio-gateway.config
Source3 : minio-server.service
Source4 : minio-gateway.service
BuildRequires : golang
BuildRequires : git
%description
MinIO is an object storage server.
It is compatible with Amazon S3 cloud storage service.
It is best suited for storing unstructured data such as photos, videos, log
files, backups and container / VM images.
Size of an object can range from a few KBs to a maximum of 5TiB.
%package server
Summary: Web Object Cloud Storage Server
Requires: minio
%description server
Minio Server Package
%package gateway
Summary: Web Object Cloud Storage Server
Requires: minio
%description gateway
Minio Gateway Package
%prep
%setup -T -q -c %{name}-%{realversion}
export GOPATH=`pwd`
export GO111MODULE=on
mkdir -p src/github.com/minio/
cd src/github.com/minio/
git clone https://github.com/minio/minio
%build
export GOPATH=`pwd`
export GO111MODULE=on
export CGO_ENABLED=0
cd src/github.com/minio/minio
git checkout tags/RELEASE.%{fullversion}
export COMMIT=$(git rev-parse HEAD)
export SHORTCOMMIT=$(git rev-parse --short HEAD)
export BUILDDATE=$(date +%Y%m%d)
sed 's/goGetTag = "DEVELOPMENT.GOGET"/goGetTag = "RELEASE.%{fullversion}"/' -i cmd/build-constants.go
sed 's/Version = goGetTag/Version = "%{fullversion}"/' -i cmd/build-constants.go
sed 's/ReleaseTag = goGetTag/ReleaseTag = "RELEASE.%{fullversion}"/' -i cmd/build-constants.go
sed 's/CommitID = goGetTag/CommitID = "'$COMMIT'"/' -i cmd/build-constants.go
sed 's/ShortCommitID = CommitID\[:12\]/ShortCommitID = "'$SHORTCOMMIT'"/' -i cmd/build-constants.go
go build -v -tags kqueue -trimpath --ldflags "
-X github.com/minio/minio/cmd.ReleaseTag=RELEASE.%{fullversion}
-X github.com/minio/minio/cmd.CommitID=$COMMIT
-X github.com/minio/minio/cmd.ShortCommitID=$SHORTCOMMIT
-X github.com/minio/minio/cmd.Version=%{version}
-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')
-buildid %{version}" -o minio
%install
install -p -D -m 0555 src/github.com/minio/minio/minio %{buildroot}%{_bindir}/minio
install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/minio/server
install -p -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/minio/gateway
install -p -D -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}/minio-server.service
install -p -D -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/minio-gateway.service
install -p -d -m 0700 %{buildroot}%{minio_home}
%pre
getent group %{minio_group} > /dev/null || groupadd -r %{minio_group}
getent passwd %{minio_user} > /dev/null || useradd -r -d %{minio_home} -g %{minio_group} -s /bin/bash -c "minio user" %{minio_user}
exit 0
%post server
%systemd_post minio-server.service
%preun server
%systemd_preun minio-server.service
%postun server
%systemd_postun minio-server.service
%post gateway
%systemd_post minio-gateway.service
%preun gateway
%systemd_preun minio-gateway.service
%postun gateway
%systemd_postun minio-gateway.service
%check
cd src/github.com/minio/minio
./minio --version | tee v
v=$(awk '/version/{print $3}' v)
test "$v" = RELEASE.%{fullversion}
%files
%doc
%{_bindir}/minio
%attr(700,%{minio_user},%{minio_group}) %dir %{minio_home}
%files server
%config(noreplace) %{_sysconfdir}/%{name}/server
%{_unitdir}/minio-server.service
%files gateway
%config(noreplace) %{_sysconfdir}/%{name}/gateway
%{_unitdir}/minio-gateway.service
%changelog