From 391a5638bb044b3ba2efe468911ca708a9a75656 Mon Sep 17 00:00:00 2001 From: Ben Woods Date: Fri, 20 Sep 2024 14:51:16 +0800 Subject: [PATCH] add: golang-github-zrepl (#2112) (cherry picked from commit 89d6601cb5b86d4c0090d954e7093e374272bd3a) --- anda/langs/go/zrepl/anda.hcl | 5 ++ anda/langs/go/zrepl/golang-github-zrepl.spec | 88 ++++++++++++++++++++ anda/langs/go/zrepl/update.rhai | 1 + 3 files changed, 94 insertions(+) create mode 100644 anda/langs/go/zrepl/anda.hcl create mode 100644 anda/langs/go/zrepl/golang-github-zrepl.spec create mode 100644 anda/langs/go/zrepl/update.rhai diff --git a/anda/langs/go/zrepl/anda.hcl b/anda/langs/go/zrepl/anda.hcl new file mode 100644 index 0000000000..2e08ece2df --- /dev/null +++ b/anda/langs/go/zrepl/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "golang-github-zrepl.spec" + } +} diff --git a/anda/langs/go/zrepl/golang-github-zrepl.spec b/anda/langs/go/zrepl/golang-github-zrepl.spec new file mode 100644 index 0000000000..f3e8ecb708 --- /dev/null +++ b/anda/langs/go/zrepl/golang-github-zrepl.spec @@ -0,0 +1,88 @@ +# Generated by go2rpm 1.14.0 +%bcond_without check +%define debug_package %nil + +# https://github.com/zrepl/zrepl +%global goipath github.com/zrepl/zrepl +Version: 0.6.1 + +%gometa -f + +%global common_description %{expand: +One-stop ZFS backup & replication solution.} + +%global golicenses LICENSE +%global godocs README.md + +Name: zrepl +Release: 1%?dist +Summary: One-stop ZFS backup & replication solution +Packager: Ben Woods + +License: MIT +URL: https://zrepl.github.io/ +Source: %{gosource} + +BuildRequires: anda-srpm-macros +BuildRequires: git-core +BuildRequires: systemd-rpm-macros +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +%description %{common_description} + +%gopkg + +%prep +%goprep +go mod download + +%build +go build -ldflags "-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -s -w" -buildmode=pie -o %{gobuilddir}/bin/zrepl %{goipath} + +# Correct the path in the systemd unit file +sed 's:/usr/local/bin/:%{_bindir}/:g' dist/systemd/zrepl.service > %{gobuilddir}/zrepl.service + +# Generate the default configuration file +sed 's#USR_SHARE_ZREPL#%{_datadir}/doc/zrepl#' packaging/systemd-default-zrepl.yml > %{gobuilddir}/zrepl.yml + +# Generate shell auto-completion files +%{gobuilddir}/bin/zrepl gencompletion bash %{gobuilddir}/bash_completion +%{gobuilddir}/bin/zrepl gencompletion zsh %{gobuilddir}/zsh_completion + +%install +%gopkginstall +install -m 0755 -vd %{buildroot}%{_bindir} +install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ +install -Dm 0644 %{gobuilddir}/zrepl.service %{buildroot}%{_unitdir}/zrepl.service +install -Dm 0644 %{gobuilddir}/zrepl.yml %{buildroot}%{_sysconfdir}/zrepl/zrepl.yml +install -Dm 0644 %{gobuilddir}/bash_completion %{buildroot}%{_datadir}/bash-completion/completions/zrepl +install -Dm 0644 %{gobuilddir}/zsh_completion %{buildroot}%{_datadir}/zsh/site-functions/_zrepl +install -d %{buildroot}%{_datadir}/doc/zrepl +cp -a config/samples %{buildroot}%{_datadir}/doc/zrepl/examples + +%post +%systemd_post zrepl.service + +%preun +%systemd_preun zrepl.service + +%postun +%systemd_postun_with_restart zrepl.service + +%files +%license LICENSE +%doc README.md +%{_bindir}/* +%config %{_unitdir}/zrepl.service +%dir %{_sysconfdir}/zrepl +%config(noreplace) %{_sysconfdir}/zrepl/zrepl.yml +%{_datadir}/bash-completion/completions/zrepl +%{_datadir}/zsh/site-functions/_zrepl +%{_datadir}/doc/zrepl + +%gopkgfiles + +%changelog +%autochangelog diff --git a/anda/langs/go/zrepl/update.rhai b/anda/langs/go/zrepl/update.rhai new file mode 100644 index 0000000000..b316576ed2 --- /dev/null +++ b/anda/langs/go/zrepl/update.rhai @@ -0,0 +1 @@ +rpm.version(gh("zrepl/zrepl"));