Blob Blame History Raw
# If any of the following macros should be set otherwise,
# you can wrap any of them with the following conditions:
# - %%if 0%%{centos} == 7
# - %%if 0%%{?rhel} == 7
# - %%if 0%%{?fedora} == 23
# Or just test for particular distribution:
# - %%if 0%%{centos}
# - %%if 0%%{?rhel}
# - %%if 0%%{?fedora}
#
# Be aware, on centos, both %%rhel and %%centos are set. If you want to test
# rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition.
# (Don't forget to replace double percentage symbol with single one in order to apply a condition)

# Build with debug info rpm
%global with_debug 0


%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package   %{nil}
%endif


%global provider        github
%global provider_tld    com
%global project         exercism
%global repo            cli
# https://github.com/exercism/cli
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path     %{provider_prefix}

Name:           %{project}
Version:        3.0.12
Release:        1%{?dist}
Summary:        Exercism command-line interface
License:        MIT
URL:            https://%{provider_prefix}
Source0:        https://%{provider_prefix}/archive/v%{version}/%{repo}-%{version}.tar.gz

# Remove the github.com/inconshreveable/go-update dependency
Patch0001:      0001-Disable-self-update.patch

# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ExclusiveArch:  %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}}
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}

BuildRequires: golang(github.com/blang/semver)
BuildRequires: golang(github.com/spf13/cobra)
BuildRequires: golang(github.com/spf13/pflag)
BuildRequires: golang(github.com/spf13/viper)
BuildRequires: golang(golang.org/x/net/html/charset)
BuildRequires: golang(golang.org/x/text/transform)
BuildRequires: golang(github.com/stretchr/testify/assert)

%description
Exercism provides a way to do the problems on https://exercism.io.

This CLI ships as a binary with no additional run-time requirements. This means 
that if you're doing the Haskell problems on exercism you don't need a working 
Python or Ruby environment simply to fetch and submit exercises.


%prep
%autosetup -n %{repo}-%{version} -p1

# create a fake GOPATH
mkdir -p ./_build/src/%{provider}.%{provider_tld}/%{project}
ln -s $(pwd) ./_build/src/%{import_path}

# Skip Go modules
rm go.mod go.sum


%build
export GOPATH=$(pwd)/_build:%{gopath}
go build -o out/exercism exercism/main.go


%install
# main exercism binary
install -d -p %{buildroot}%{_bindir}/
install -p out/exercism %{buildroot}%{_bindir}/
# shell completion
install -d %{buildroot}%{_datadir}/bash-completion/completions
install -Dpm0644 shell/exercism_completion.bash %{buildroot}%{_datadir}/bash-completion/completions/exercism
install -d %{buildroot}%{_datadir}/fish/completions
install -Dpm0644 shell/exercism.fish %{buildroot}%{_datadir}/fish/completions/exercism.fish
install -d %{buildroot}%{_datadir}/zsh/site-functions
install -Dpm0644 shell/exercism_completion.zsh %{buildroot}%{_datadir}/zsh/site-functions/_exercism


%check
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/_build:%{gopath}

# TestLoad_InvalidJSON try to hard-link from PWD to TMPDIR
export TMPDIR=$(pwd)/_check_tmp
mkdir -p $TMPDIR

%if ! 0%{?gotest:1}
%global gotest go test
%endif

%gotest %{import_path}/api
%gotest %{import_path}/browser
%gotest %{import_path}/cli
%gotest %{import_path}/cmd
%gotest %{import_path}/config
%gotest %{import_path}/debug
%gotest %{import_path}/exercism
%gotest %{import_path}/workspace


#define license tag if not already defined
%{!?_licensedir:%global license %doc}

%files
%license LICENSE
%doc CHANGELOG.md RELEASE.md README.md
%{_bindir}/exercism
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/exercism
%dir %{_datadir}/fish
%dir %{_datadir}/fish/completions
%{_datadir}/fish/completions/exercism.fish
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_exercism


%changelog
* Wed Jul 10 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 3.0.12-1
- Update to latest version
- Add fish completions

* Sat Feb 09 2019 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 3.0.11-1
- Update to latest version

* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Wed Sep 06 2017 Clément David <c.david86@gmail.com> - 2.4.1-1
- First package for Fedora