File moor.spec of Package moor

#
# spec file for package moor
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# 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/
#

Name:           moor
Version:        2.9.3
Release:        0
Summary:        Pager designed to just do the right thing without any configuration
License:        BSD-2-Clause-Views
Group:          Productivity/Text/Utilities
URL:            https://github.com/walles/moor
Source0:        %{name}-%{version}.tar.gz
Source1:        vendor.tar.zst
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.23
BuildRequires:  zstd

%description
Moor is a pager. It reads and displays UTF-8 encoded text from files or pipelines.

Moor is designed to just do the right thing without any configuration.

The intention is that Moor should be trivial to get into if you have previously

been using Less. If you come from Less and find Moor confusing or hard to migrate 

to, please report it to https://github.com/walles/moor/issues

%prep
%autosetup -a1

%build
COMMIT_HASH="$(sed -n 's/commit: \(.*\)/\1/p' %_sourcedir/%{name}.obsinfo)"
VERSION=%{version}
DATE_FMT="+%%Y-%%m-%%dT%%H:%%M:%%SZ"
BUILD_DATE=$(date -u -d "@${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u "${DATE_FMT}")

export LDFLAGS="-X github.com/walles/moor/version.version=v%{version} \
    -X main.commit=${COMMIT_HASH:0:8} \
    -X main.date=${BUILD_DATE} -X main.builtBy=openSUSE \
    -X main.versionString=%{version}"

go build \
   -mod=vendor \
   -buildmode=pie \
   -ldflags "$LDFLAGS" \
   ./cmd/moor

%install
install -D -m0755 %{name} %{buildroot}%{_bindir}/%{name}
install -D -m0644 %{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1

%check
%gotest ./...

%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1%{?ext_man}

%changelog
openSUSE Build Service is sponsored by