File pgweb.spec of Package pgweb

#
# spec file for package pgweb
#
# Copyright (c) 2024 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 __arch_install_post export NO_BRP_STRIP_DEBUG=true
# Project name when using go tooling.
Name:           pgweb
Version:        0.17.0
Release:        0
Summary:        Cross-platform client for PostgreSQL databases
# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses
License:        MIT
URL:            https://github.com/sosedoff/pgweb
Source:         %{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
Source2:        %{name}.service
BuildRequires:  fdupes
BuildRequires:  go >= 1.22
BuildRequires:  go-md2man
BuildRequires:  golang-packaging
BuildRequires:  git
ExcludeArch:    s390
%if 0%{?is_opensuse}
ExcludeArch:    s390x
%endif
%{?systemd_ordering}

%description
Simple web-based and cross platform PostgreSQL database explorer.

%prep
%autosetup -a1 -p1

%build
export VERSION=%{version}
export COMMIT=%{commit}
export CGO_ENABLED=1
go build \
   -mod=vendor \
   -buildmode=pie \
   -ldflags "-s -w -X main.gitCommit=$COMMIT -X main.version=$VERSION" \
   -o %{name} ;

%install
# Install the binary.
install -D -m 0755 %{name} "%{buildroot}/%{_bindir}/%{name}"
# Build the man page.
go-md2man -in README.md -out %{name}.1

# Install the man page.
install -D -m 0644 %{name}.1 "%{buildroot}/%{_mandir}/man1/%{name}.1"
rm %{name}.1
install -D -m 0755 %{SOURCE2} %{buildroot}%{_userunitdir}/%{name}.service

%fdupes %{buildroot}

%pre
%systemd_user_pre %{name}.service

%post
%systemd_user_post %{name}.service

%preun
%systemd_user_preun %{name}.service

%postun
%systemd_user_postun %{name}.service

%files
%license LICENSE
%doc CHANGELOG.md README.md CONTRIBUTING.md SCREENS.md
%{_bindir}/%{name}
%{_userunitdir}/%{name}.service
%{_mandir}/man1/%{name}*.1.gz

%changelog

openSUSE Build Service is sponsored by