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.

150 lines
4.7 KiB

%define fullversion 2021-10-23T03-28-24Z
%define realversion %(echo %{fullversion} | sed -e 's/[^0-9]//g' | cut -c -8)
%define clientversion 2021-10-07T04-19-58Z
%define clientshort %(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
%package client
Summary: Web Object Cloud Storage Client
%description client
Minio Client
%prep
%setup -T -q -c %{name}-%{realversion}
export GOPATH=`pwd`
export GO111MODULE=on
mkdir -p go/src/github.com/minio/
cd go/src/github.com/minio/
git clone https://github.com/minio/minio
git clone https://github.com/minio/mc
%build
export GOPATH=`pwd`
export GO111MODULE=on
export CGO_ENABLED=0
export GOPROXY=https://goproxy.io
cd go/src/github.com/minio
pushd 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 generate
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
popd
pushd mc
git checkout tags/RELEASE.%{clientversion}
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-mc
popd
%install
install -p -D -m 0555 go/src/github.com/minio/minio/minio %{buildroot}%{_bindir}/minio
install -p -D -m 0555 go/src/github.com/minio/mc/minio-mc %{buildroot}%{_bindir}/minio-mc
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 go/src/github.com/minio/minio
./minio --version | tee v
v=$(awk '/version/{print $3}' v)
test "$v" = RELEASE.%{fullversion}
%files
%doc
%caps(cap_net_bind_service=+ep) %{_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
%files client
%{_bindir}/minio-mc
%changelog