# Generated by go2rpm
%bcond_without check

Name:           golist
Version:        0.10.1
Release:        6%{?dist}
Summary:        A tool to analyse the properties of a Go (Golang) codebase

%global ipath pagure.io/golist

# golist is BSD-3-Clause, with dependencies go-md2man=MIT, blackfriday=BSD-2-Clause, and cli=MIT.
License:        BSD and MIT
URL:            https://%{ipath}
Source0:        https://%{ipath}/archive/v%{version}/golist-%{version}.tar.gz

%global md2man_version 2.0.1
%global md2man_ipath github.com/cpuguy83/go-md2man
Source1:        https://%{md2man_ipath}/archive/v%{md2man_version}/go-md2man-%{md2man_version}.tar.gz

%global cli_version 1.22.5
%global cli_ipath github.com/urfave/cli
Source2:        https://%{cli_ipath}/archive/v%{cli_version}/cli-%{cli_version}.tar.gz

# This needs to track what golang and go-rpm-macros set:
ExclusiveArch:  aarch64 x86_64

# Before split of /usr/bin/golist.
# Remove in Fedora 34.
Conflicts: go-compilers-golang-compiler < 1-34

BuildRequires:  golang

%description
A tool to analyse the properties of a Go (Golang) codebase.


%prep
%setup
%setup -D -T -b 1
%setup -D -T -b 2


%build

%global golist_src      %{_builddir}/golist-%{version}
%global md2man_src      %{_builddir}/go-md2man-%{md2man_version}
%global cli_src         %{_builddir}/cli-%{cli_version}

# Copy the vendored packages' license files into the build dir:
cp '%{md2man_src}/LICENSE.md' LICENSE_cpuguy83_go-md2man
cp '%{md2man_src}/vendor/github.com/russross/blackfriday/v2/LICENSE.txt' LICENSE_russross_blackfriday
cp '%{cli_src}/LICENSE' LICENSE_urfave_cli

mkdir -p _build/src
cd _build
(
    cd src

    mkdir -p "$(dirname '%{ipath}')"
    ln -s '%{golist_src}' '%{ipath}'

    mkdir -p "$(dirname '%{md2man_ipath}')"
    ln -s "%{md2man_src}" '%{md2man_ipath}'

    mkdir -p "$(dirname '%{cli_ipath}')"
    ln -s "%{cli_src}" '%{cli_ipath}'
)

# Flags derived from go-rpm-macros (not using directly due to circular dependency):
GO111MODULE=off \
GOPATH="$(pwd)" \
go build \
    -buildmode pie \
    -compiler gc \
    -tags="rpm_crashtraceback ${BUILDTAGS:-}" \
    -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -compressdwarf=false -extldflags '%__global_ldflags'" \
    -a -v -x \
    -o bin/golist \
    '%{ipath}/cmd/golist'


%install
install -m 0755 -vd              %{buildroot}%{_bindir}
install -m 0755 -vp _build/bin/* %{buildroot}%{_bindir}/


%files
%doc README.md NEWS.md
%license LICENSE*
%{_bindir}/*


%changelog
* Thu Apr 14 2022 Malcolm Inglis <miinglis@amazon.com> - 0.10.1-6.amzn2.0.1
- Build with dependency sources, without go-rpm-macros

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

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.10.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri Jun 14 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.10.1-1
- Update to latest version
- Rewrite for latest Go macros

* Mon May 27 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.10.0-1
- Initial package

