File pigeon.spec of Package pigeon
#
# spec file for package golang
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#
Name: pigeon
Version: 1.3.0
Release: 0
Summary: Generates parsers in Go from a PEG grammar
License: BSD-3-Clause
Url: https://github.com/mna/pigeon
Source0: %{name}-%{version}.tar.gz
Source1: vendor.tar.gz
BuildRequires: golang(API) >= 1.22
%description
The pigeon command generates parsers based on a parsing expression grammar
(PEG). Its grammar and syntax is inspired by the PEG.js project, while the
implementation is loosely based on the parsing expression grammar for C# 3.0
article.
%prep
%autosetup -a 1
%build
COMMIT_HASH="$(sed -n 's/commit: \(.*\)/\1/p' %_sourcedir/%{name}.obsinfo)"
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}")
go build \
-mod=vendor \
-buildmode=pie \
-ldflags=" \
-X main.version=v%{version} \
-X main.commit=${COMMIT_HASH} \
-X main.date=${BUILD_DATE}" \
-o bin/%{name}
%install
# Install the binary.
install -D -m 0755 bin/%{name} %{buildroot}/%{_bindir}/%{name}
%check
# make sure the binary is pristine and at least runs,
# there are no checks to run...
%{buildroot}/%{_bindir}/%{name} --help
%files
%{_bindir}/%{name}
%doc README.md CONTRIBUTING.md
%license LICENSE
%changelog