%global shortcommit e4f5b40

Name:        openGemini
Version:     1.0.0
Release:     3
Summary:     An open source distributed time-series database with high concurrency, high performance, and high scalability
License:     Apache 2.0
Group:	     Applications/Databases
URL:         https://www.openGemini.org/
Source0:     %{name}-%{version}.tar.gz
Patch0:      0001-add-loong64-support.patch

BuildRequires: gcc,make,golang >= 1.16

%description
An open source distributed time-series database with high concurrency, high performance, and high scalability.
%prep
%setup -q -n %{name}
%patch0 -p1

%build
# set up temporary build gopath, and put our directory there
mkdir -p ./_build/src/github.com/openGemini/
ln -s $(pwd) ./_build/src/github.com/openGemini/openGemini

go env -w GO111MODULE=auto
go env
export GOPATH=$(pwd)/_build/:%{gopath}
cd ./_build/src/github.com/openGemini/openGemini
go build -o ./  -gcflags="all=-N -l" -ldflags="-X main.TsVersion=v%{Version} -X main.TsBranch=master -X main.TsCommit=%{shortcommit}" -buildmode=pie  ./app/ts-sql
go build -o ./  -gcflags="all=-N -l" -ldflags="-X main.TsVersion=v%{Version} -X main.TsBranch=master -X main.TsCommit=%{shortcommit}" -buildmode=pie  ./app/ts-meta
go build -o ./  -gcflags="all=-N -l" -ldflags="-X main.TsVersion=v%{Version} -X main.TsBranch=master -X main.TsCommit=%{shortcommit}" -buildmode=pie  ./app/ts-store
go build -o ./  -gcflags="all=-N -l" -ldflags="-X main.TsVersion=v%{Version} -X main.TsBranch=master -X main.TsCommit=%{shortcommit}" -buildmode=pie  ./app/ts-monitor
go build -o ./  -gcflags="all=-N -l" -ldflags="-X main.TsVersion=v%{Version} -X main.TsBranch=master -X main.TsCommit=%{shortcommit}" -buildmode=pie  ./app/ts-server

%install
install -d %{buildroot}%{_bindir}
install -d %{buildroot}/etc/%{name}
install -d %{buildroot}/var/log/%{name}
install -p -m 0755 ./ts-sql %{buildroot}%{_bindir}/ts-sql
install -p -m 0755 ./ts-store %{buildroot}%{_bindir}/ts-store
install -p -m 0755 ./ts-meta %{buildroot}%{_bindir}/ts-meta
install -p -m 0755 ./ts-server %{buildroot}%{_bindir}/ts-server
install -p -m 0755 ./ts-monitor %{buildroot}%{_bindir}/ts-monitor
install -p -m 0644 ./config/* %{buildroot}/etc/%{name}

%files
%defattr(-,root,root,-)
/usr/bin/ts-monitor
/usr/bin/ts-sql
/usr/bin/ts-store
/usr/bin/ts-meta
/usr/bin/ts-server
%dir %attr(750,root,root) %{_sysconfdir}/%{name}
%attr(640,root,root) %{_sysconfdir}/%{name}/openGemini.conf
%attr(640,root,root) %{_sysconfdir}/%{name}/openGemini.singlenode.conf
%attr(640,root,root) %{_sysconfdir}/%{name}/monitor.conf
%attr(640,root,root) %{_sysconfdir}/%{name}/weakpasswd.properties
%dir /var/log/%{name}

%changelog
* Wed Dec 18 2024 FloatX <664712890@qq.com> - 1.0.0-3
- Delete ts-cli

* Tue Jul 02 2024 zhangxianting <zhangxianting@uniontech.com> - 1.0.0-2
- Add loong64 support

* Fri Feb 24 2023 opengemini_admin <xiangyu9@huawei.com> - 1.0.0-1
- Initial version
