File wal-g.spec of Package wal-g

#
# spec file for package wal-g
#
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define backends pg mysql mongo redis fdb sqlserver gp

%global provider        github
%global provider_tld    com
%global project         wal-g
%global _project        wal-g
%global repo            wal-g
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     %{provider_prefix}

Name:           wal-g
Version:        3.0.7
Release:        0
%define revision v%{version}
Summary:        Archival and Restoration for Postgres
License:        Apache-2.0
Group:          Productivity/Databases/Tools
URL:            https://github.com/wal-g/wal-g
Source:         %{name}-%{version}.tar.gz
Source1:        vendor.tar.xz
BuildRequires:  golang(API) >= 1.22
BuildRequires:  golang-packaging
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libbrotlicommon)
BuildRequires:  pkgconfig(libsodium)
BuildRequires:  pkgconfig(lzo2)
ExcludeArch:    %{ix86}

%description
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

%package mysql
#
Summary:        WAL-G (mysql backend)
Group:          Productivity/Databases/Tools
Requires(post): update-alternatives
Requires(postun): update-alternatives

%description mysql
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

This package holds the mysql version of the toolset.

%package redis
Group:          Productivity/Databases/Tools
Requires(post): update-alternatives
Requires(postun): update-alternatives
#
Summary:        WAL-G (redis backend)
%description redis
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

This package holds the redis version of the toolset.

%package pg
Group:          Productivity/Databases/Tools
Requires(post): update-alternatives
Requires(postun): update-alternatives
Provides:       %{name} = %{version}-%{release}
Obsoletes:      %{name} < %{version}-%{release}
#
Summary:        WAL-G (pg backend)
%description pg
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

This package holds the pg version of the toolset.

%package gp
Group:          Productivity/Databases/Tools
Requires(post): update-alternatives
Requires(postun): update-alternatives
Provides:       %{name} = %{version}-%{release}
Obsoletes:      %{name} < %{version}-%{release}
#
Summary:        WAL-G (gp backend)
%description gp
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

This package holds the gp version of the toolset.

%package mongo
Group:          Productivity/Databases/Tools
Requires(post): update-alternatives
Requires(postun): update-alternatives
#
Summary:        WAL-G (mongo backend)
%description mongo
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

This package holds the mongo version of the toolset.

%package fdb
Group:          Productivity/Databases/Tools
Requires(post): update-alternatives
Requires(postun): update-alternatives
#
Summary:        WAL-G (fdb backend)
%description fdb
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

This package holds the fdb version of the toolset.

%package sqlserver
Group:          Productivity/Databases/Tools
Requires(post): update-alternatives
Requires(postun): update-alternatives
#
Summary:        WAL-G (sqlserver backend)
%description sqlserver
WAL-G is the successor of WAL-E with a number of key differences. WAL-G uses
LZ4 compression, multiple processors and non-exclusive base backups for
Postgres.

This package holds the sqlserver version of the toolset.


%prep
%autosetup -a1

%build
cd main
for i in %{backends} ; do
pushd $i
go build \
  -mod=vendor \
  -buildmode=pie \
  -tags "brotli lzo libsodium" \
  -o ../../wal-g-$i \
  -ldflags "-X github.com/wal-g/wal-g/cmd/pg.BuildDate=$(date -r ${RPM_SOURCE_DIR}/%{name}.changes -u +%%Y-%%m-%%dT%%H:%%M:%%S%%z ) -X github.com/wal-g/wal-g/cmd/pg.GitRevision=%{revision} -X github.com/wal-g/wal-g/cmd/pg.WalgVersion=%{version}"
popd
done

%install
install -m 0755 -D -d      %{buildroot}%{_bindir}
install -m 0755 -D wal-g-* %{buildroot}%{_bindir}/

install -m 0755 -D -d                      %{buildroot}%{_sysconfdir}/alternatives
ln -s -f %{_bindir}/wal-g                  %{buildroot}%{_sysconfdir}/alternatives/wal-g
ln -s -f %{_sysconfdir}/alternatives/wal-g %{buildroot}%{_bindir}/wal-g

%post pg
update-alternatives --install \
   %{_bindir}/wal-g wal-g %{_bindir}/wal-g-pg 4

%postun pg
if [ ! -f %{_bindir}/wal-g-pg ] ; then
   update-alternatives --remove wal-g %{_bindir}/wal-g-pg
fi

%files pg
%{_bindir}/wal-g
%ghost %{_sysconfdir}/alternatives/wal-g
%{_bindir}/wal-g-pg
%license LICENSE.md
%doc docs/CONTRIBUTORS.md docs/PostgreSQL.md docs/README.md docs/STORAGES.md

%post gp
update-alternatives --install \
   %{_bindir}/wal-g wal-g %{_bindir}/wal-g-pg 4

%postun gp
if [ ! -f %{_bindir}/wal-g-pg ] ; then
   update-alternatives --remove wal-g %{_bindir}/wal-g-gp
fi

%files gp
%{_bindir}/wal-g
%ghost %{_sysconfdir}/alternatives/wal-g
%{_bindir}/wal-g-gp
%license LICENSE.md
%doc docs/CONTRIBUTORS.md docs/PostgreSQL.md docs/README.md docs/STORAGES.md

%post mysql
update-alternatives --install \
   %{_bindir}/wal-g wal-g %{_bindir}/wal-g-mysql 3

%postun mysql
if [ ! -f %{_bindir}/wal-g-mysql ] ; then
   update-alternatives --remove wal-g %{_bindir}/wal-g-mysql
fi

%files mysql
%{_bindir}/wal-g
%ghost %{_sysconfdir}/alternatives/wal-g
%{_bindir}/wal-g-mysql
%license LICENSE.md
%doc docs/CONTRIBUTORS.md docs/MySQL.md docs/README.md docs/STORAGES.md

%post mongo
update-alternatives --install \
   %{_bindir}/wal-g wal-g %{_bindir}/wal-g-mongo 2

%postun mongo
if [ ! -f %{_bindir}/wal-g-mongo ] ; then
   update-alternatives --remove wal-g %{_bindir}/wal-g-mongo
fi

%files mongo
%{_bindir}/wal-g
%ghost %{_sysconfdir}/alternatives/wal-g
%{_bindir}/wal-g-mongo
%license LICENSE.md
%doc docs/CONTRIBUTORS.md docs/MongoDB.md docs/README.md docs/STORAGES.md

%post redis
update-alternatives --install \
   %{_bindir}/wal-g wal-g %{_bindir}/wal-g-redis 1

%postun redis
if [ ! -f %{_bindir}/wal-g-redis ] ; then
   update-alternatives --remove wal-g %{_bindir}/wal-g-redis
fi

%files redis
%{_bindir}/wal-g
%ghost %{_sysconfdir}/alternatives/wal-g
%{_bindir}/wal-g-redis
%license LICENSE.md
%doc docs/CONTRIBUTORS.md docs/README.md docs/STORAGES.md docs/Redis.md

%post fdb
update-alternatives --install \
   %{_bindir}/wal-g wal-g %{_bindir}/wal-g-fdb 1

%postun fdb
if [ ! -f %{_bindir}/wal-g-fdb ] ; then
   update-alternatives --remove wal-g %{_bindir}/wal-g-fdb
fi

%files fdb
%{_bindir}/wal-g
%ghost %{_sysconfdir}/alternatives/wal-g
%{_bindir}/wal-g-fdb
%license LICENSE.md
%doc docs/CONTRIBUTORS.md docs/README.md docs/STORAGES.md docs/FoundationDB.md

%post sqlserver
update-alternatives --install \
   %{_bindir}/wal-g wal-g %{_bindir}/wal-g-sqlserver 1

%postun sqlserver
if [ ! -f %{_bindir}/wal-g-sqlserver ] ; then
   update-alternatives --remove wal-g %{_bindir}/wal-g-sqlserver
fi

%files sqlserver
%{_bindir}/wal-g
%ghost %{_sysconfdir}/alternatives/wal-g
%{_bindir}/wal-g-sqlserver
%license LICENSE.md
%doc docs/CONTRIBUTORS.md docs/README.md docs/STORAGES.md docs/SQLServer.md 



%changelog
openSUSE Build Service is sponsored by