## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by go2rpm 1.6.0
%bcond_without check

# https://github.com/mvdan/sh
%global goipath         mvdan.cc/sh/v3
%global forgeurl        https://github.com/mvdan/sh
Version:                3.5.1

%gometa

%global common_description %{expand:
A shell parser, formatter, and interpreter. Supports POSIX Shell, Bash, and
mksh.}

%global golicenses      LICENSE
%global godocs          CHANGELOG.md README.md

Name:           %{goname}
Release:        %autorelease
Summary:        A shell parser, formatter, and interpreter

# Upstream license specification: BSD-3-Clause
License:        BSD
URL:            %{gourl}
Source0:        %{gosource}

BuildRequires:  scdoc
BuildRequires:  golang(github.com/google/renameio/maybe)
BuildRequires:  golang(github.com/pkg/diff)
BuildRequires:  golang(github.com/pkg/diff/write)
BuildRequires:  golang(golang.org/x/sync/errgroup)
BuildRequires:  golang(golang.org/x/sys/unix)
BuildRequires:  golang(golang.org/x/term)
BuildRequires:  golang(mvdan.cc/editorconfig)

%if %{with check}
# Tests
BuildRequires:  golang(github.com/creack/pty)
BuildRequires:  golang(github.com/frankban/quicktest)
BuildRequires:  golang(github.com/kr/pretty)
BuildRequires:  golang(github.com/rogpeppe/go-internal/testscript)
%endif

%description
%{common_description}

%package -n     shfmt
Summary:        Shell formatter

%description -n shfmt
shfmt is a shell formatter. shfmt's default shell formatting was chosen to be
consistent, common, and predictable.

%package -n     gosh
Summary:        Proof of concept shell that uses interp

%description -n gosh
Proof of concept shell that uses interp. Note that it's not meant to replace a
POSIX shell at the moment, and its options are intentionally minimalistic.

%gopkg

%prep
%goprep

%build
for cmd in cmd/* ; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done
mkdir -p %{gobuilddir}/man
scdoc < cmd/shfmt/shfmt.1.scd > %{gobuilddir}/man/shfmt.1

%install
%gopkginstall
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -m 0755 -vd                     %{buildroot}%{_mandir}/man1/
install -m 0644 -vp %{gobuilddir}/man/* %{buildroot}%{_mandir}/man1/

%if %{with check}
%check
%gocheck -t cmd
%endif

%files -n shfmt
%license LICENSE
%doc CHANGELOG.md README.md
%{_bindir}/shfmt
%{_mandir}/man1/shfmt.1*

%files -n gosh
%license LICENSE
%doc CHANGELOG.md README.md
%{_bindir}/gosh

%gopkgfiles

%changelog
* Mon Aug 22 2022 Anthony Rabbito <hello@anthonyrabbito.com> 3.5.1-1
- Update to 3.5.1

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> 3.4.3-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Tue Jul 19 2022 Maxwell G <gotmax@e.email> 3.4.3-5
- Rebuild for
  CVE-2022-{1705,32148,30631,30633,28131,30635,30632,30630,1962} in golang

* Sat Jul 09 2022 Maxwell G <gotmax@e.email> 3.4.3-4
- Rebuild for CVE-2022-{24675,28327,29526 in golang}

* Sat Jul 09 2022 Maxwell G <gotmax@e.email> 3.4.3-3
- Rebuild for CVE-2022-{24675,28327,29526 in golang}

* Wed Feb 23 2022 Robert-André Mauchin <zebob.m@gmail.com> 3.4.3-2
- Add missing BR scdoc

* Wed Feb 23 2022 Robert-André Mauchin <zebob.m@gmail.com> 3.4.3-1
- Update to 3.4.3 (fix FTBFS) Close: rhbz#2045653

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> 3.4.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Mon Oct 25 2021 Davide Cavalca <dcavalca@fedoraproject.org> 3.4.0-1
- Update to 3.4.0

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.2.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Wed Apr 07 2021 Davide Cavalca <dcavalca@fedoraproject.org> - 3.2.4-1
- Initial package