3c53fac
%bcond check 1
cfc5088
cfc5088
# https://github.com/git-lfs/git-lfs
c169408
%global goipath         github.com/git-lfs/git-lfs/v3
d0ffcc6
Version:                3.4.1
6612d3e
6612d3e
%gometa
31425e0
cfc5088
%global common_description %{expand:
cfc5088
Git extension for versioning large files.}
cfc5088
cfc5088
%global golicenses      LICENSE.md
cfc5088
%global godocs          docs CHANGELOG.md CODE-OF-CONDUCT.md\\\
cfc5088
                        CONTRIBUTING.md README.md
cfc5088
31425e0
Name:           git-lfs
1f52ea7
Release:        %autorelease
31425e0
Summary:        Git extension for versioning large files
31425e0
d5bb8f6
# See LICENSE.md for details.
d5bb8f6
License:        MIT AND BSD-3-Clause
31425e0
URL:            https://git-lfs.github.io/
abe1a4f
Source0:        https://github.com/%{name}/%{name}/releases/download/v%{version}/%{name}-v%{version}.tar.gz
ce1bd2f
Source1:        https://github.com/git-lfs/git-lfs/releases/download/v%{version}/sha256sums.asc#/sha256sums-%{version}.asc
ce1bd2f
Source2:        https://api.github.com/repos/git-lfs/git-lfs/tarball/core-gpg-keys#/core-gpg-keys.tar.gz
ce1bd2f
Source3:        README.Fedora
ce1bd2f
c5dca52
# Backport fix for flaky tests.
c5dca52
Patch:          https://github.com/git-lfs/git-lfs/pull/5616.patch
c5dca52
5de897f
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
5de897f
ExcludeArch: %{ix86}
5de897f
ce1bd2f
BuildRequires:  gnupg2
6612d3e
2582c6e
BuildRequires:  golang(github.com/dpotapov/go-spnego)
fbb3078
BuildRequires:  golang(github.com/git-lfs/gitobj/v2) >= 2.1.1
fbb3078
BuildRequires:  golang(github.com/git-lfs/gitobj/v2/errors) >= 2.1.1
de7997a
BuildRequires:  golang(github.com/git-lfs/go-netrc/netrc) >= 0-0.13.20220318gitf0c862d
c169408
BuildRequires:  golang(github.com/git-lfs/pktline)
c169408
BuildRequires:  golang(github.com/git-lfs/wildmatch/v2) >= 2.0.1
de7997a
BuildRequires:  golang(github.com/leonelquinteros/gotext) >= 1.5.0
1d521ec
BuildRequires:  golang(github.com/mattn/go-isatty) >= 0.0.4
31425e0
BuildRequires:  golang(github.com/olekukonko/ts)
452c2a3
BuildRequires:  golang(github.com/pkg/errors)
31425e0
BuildRequires:  golang(github.com/rubyist/tracerx)
3c53fac
BuildRequires:  golang(github.com/spf13/cobra) >= 1.6.0
be8ae68
BuildRequires:  golang(github.com/ssgelm/cookiejarparser) >= 1.0.1
3c53fac
BuildRequires:  golang(golang.org/x/net/http2) >= 0.7.0
3c53fac
BuildRequires:  golang(golang.org/x/sync/semaphore) >= 0.1.0
3c53fac
BuildRequires:  golang(golang.org/x/sys/unix) >= 0.5.0
cfc5088
cfc5088
# Generate man pages
fbb3078
BuildRequires:  /usr/bin/asciidoctor
cfc5088
cfc5088
%if %{with check}
cfc5088
# Tests
c169408
BuildRequires:  golang(github.com/stretchr/testify/assert) >= 1.6.1
c169408
BuildRequires:  golang(github.com/stretchr/testify/require) >= 1.6.1
6612d3e
BuildRequires:  golang(github.com/xeipuuv/gojsonschema)
4b82caf
BuildRequires:  perl-Digest-SHA
452c2a3
BuildRequires:  perl-Test-Harness
414546a
# Tests require full git suite, but not generally needed.
6612d3e
BuildRequires:  git >= 1.8.5
cfc5088
%endif
31425e0
6612d3e
Requires:       git-core >= 1.8.5
31425e0
31425e0
%description
31425e0
Git Large File Storage (LFS) replaces large files such as audio samples,
31425e0
videos, datasets, and graphics with text pointers inside Git, while
31425e0
storing the file contents on a remote server.
31425e0
31425e0
cfc5088
%gopkg
31425e0
31425e0
31425e0
%prep
ce1bd2f
tar xf %{SOURCE2}
ce1bd2f
keyring="$(ls git-lfs-git-lfs-*/keys.asc)"
ce1bd2f
ce1bd2f
#
ce1bd2f
# Replicate gpgverify, because it requires detached signatures.
ce1bd2f
#
ce1bd2f
ce1bd2f
fatal_error() {
ce1bd2f
    message="$1"  # an error message
ce1bd2f
    status=$2     # a number to use as the exit code
ce1bd2f
    echo "gpgverify: $message" >&2
ce1bd2f
    exit $status
ce1bd2f
}
ce1bd2f
ce1bd2f
check_status() {
ce1bd2f
    action="$1"  # a string that describes the action that was attempted
ce1bd2f
    status=$2    # the exit code of the command
ce1bd2f
    if test $status -ne 0 ; then
ce1bd2f
        fatal_error "$action failed." $status
ce1bd2f
    fi
ce1bd2f
}
ce1bd2f
ce1bd2f
# Make a temporary working directory.
ce1bd2f
workdir="$(mktemp --directory)"
ce1bd2f
check_status 'Making a temporary directory' $?
ce1bd2f
workring="${workdir}/keyring.gpg"
ce1bd2f
ce1bd2f
# Decode any ASCII armor on the keyring. This is harmless if the keyring isn't
ce1bd2f
# ASCII-armored.
ce1bd2f
gpg2 --homedir="${workdir}" --yes --output="${workring}" --dearmor "${keyring}"
ce1bd2f
check_status 'Decoding the keyring' $?
ce1bd2f
ce1bd2f
# Verify the signature using the decoded keyring.
ce1bd2f
gpgv2 --homedir="${workdir}" --keyring="${workring}" "%{SOURCE1}"
ce1bd2f
check_status 'Signature verification' $?
ce1bd2f
ce1bd2f
# Clean up. (This is not done in case of an error that may need inspection.)
ce1bd2f
rm --recursive --force ${workdir}
ce1bd2f
ce1bd2f
#
ce1bd2f
# END gpgverify.
ce1bd2f
#
ce1bd2f
ce1bd2f
cd %{_sourcedir}
ce1bd2f
sha256sum --check --ignore-missing %{SOURCE1}
ce1bd2f
cfc5088
%goprep
ce1bd2f
cp -p %SOURCE3 .
e247c69
%autopatch -p1
31425e0
e247c69
# Modify tests so that they expect binaries where we build them.
cfc5088
sed -i -e 's!\.\./bin/!/%{gobuilddir}/bin/!g' t/Makefile
e247c69
sed -i -e 's!^BINPATH=.\+!BINPATH="%{gobuilddir}/bin"!g' t/testenv.sh
4b5133c
3c53fac
# cobra 1.7 changed some output.
3c53fac
%if %{fedora} >= 39
3c53fac
sed -i '/cmp/s/$/ || true/' t/t-completion.sh
3c53fac
%endif
3c53fac
31425e0
31425e0
%build
1df9caa
# Build manpages first (some embedding in the executable is done.)
fbb3078
# Note that the variables are set here simply to prevent the Makefile from
fbb3078
# shelling out to git, but the actual value is unused.
fbb3078
make man GIT_LFS_SHA=unused VERSION=unused PREFIX=unused
1df9caa
pushd docs
cfc5088
%gobuild -o %{gobuilddir}/bin/mangen man/mangen.go
cfc5088
%{gobuilddir}/bin/mangen
1df9caa
popd
31425e0
ff1a7b1
LDFLAGS="-X 'github.com/git-lfs/git-lfs/config.Vendor=Fedora %{fedora}' " \
cfc5088
%gobuild -o %{gobuilddir}/bin/git-lfs %{goipath}
31425e0
3c53fac
# Generate completion files.
3c53fac
for shell in bash fish zsh; do
3c53fac
    %{gobuilddir}/bin/git-lfs completion ${shell} > %{name}.${shell}
3c53fac
done
3c53fac
3c53fac
# Build test executables.
cfc5088
for cmd in t/cmd/*.go; do
cfc5088
    %gobuild -o "%{gobuilddir}/bin/$(basename $cmd .go)" "$cmd"
4b82caf
done
cfc5088
%gobuild -o "%{gobuilddir}/bin/git-lfs-test-server-api" t/git-lfs-test-server-api/*.go
4b82caf
fbb3078
# Remove man pages from docs so they don't get installed twice.
fbb3078
rm -r docs/man
65a97aa
31425e0
31425e0
%install
cfc5088
%gopkginstall
cfc5088
install -Dpm0755 %{gobuilddir}/bin/git-lfs %{buildroot}%{_bindir}/%{name}
fbb3078
for section in 1 5 7; do
fbb3078
    install -d -p %{buildroot}%{_mandir}/man${section}/
fbb3078
    install -Dpm0644 man/man${section}/*.${section} %{buildroot}%{_mandir}/man${section}/
fbb3078
done
3c53fac
install -Dpm 0644 %{name}.bash %{buildroot}%{bash_completions_dir}/%{name}
3c53fac
install -Dpm 0644 %{name}.fish %{buildroot}%{fish_completions_dir}/%{name}.fish
3c53fac
install -Dpm 0644 %{name}.zsh  %{buildroot}%{zsh_completions_dir}/_%{name}
31425e0
31425e0
31425e0
%post
6588063
if [ "x$(git config --type=bool --get 'fedora.git-lfs.no-modify-config')" != "xtrue" ]; then
b212096
%{_bindir}/%{name} install --system --skip-repo
6588063
fi
31425e0
31425e0
%preun
6588063
if [ $1 -eq 0 ] && \
6588063
   [ "x$(git config --type=bool --get 'fedora.git-lfs.no-modify-config')" != "xtrue" ]; then
b212096
    %{_bindir}/%{name} uninstall --system --skip-repo
31425e0
fi
31425e0
exit 0
31425e0
31425e0
cfc5088
%if %{with check}
31425e0
%check
cfc5088
%gocheck
cfc5088
PATH=%{buildroot}%{_bindir}:%{gobuilddir}/bin:$PATH \
4b5133c
    make -C t PROVE_EXTRA_ARGS="-j$(getconf _NPROCESSORS_ONLN)"
cfc5088
%endif
31425e0
31425e0
31425e0
%files
6588063
%doc README.md README.Fedora CHANGELOG.md docs
31425e0
%license LICENSE.md
31425e0
%{_bindir}/%{name}
31425e0
%{_mandir}/man1/%{name}*.1*
31425e0
%{_mandir}/man5/%{name}*.5*
fbb3078
%{_mandir}/man7/%{name}*.7*
3c53fac
%{bash_completions_dir}/%{name}
3c53fac
%{fish_completions_dir}/%{name}.fish
3c53fac
%{zsh_completions_dir}/_%{name}
31425e0
cfc5088
%gopkgfiles
31425e0
31425e0
31425e0
%changelog
1f52ea7
%autochangelog