Blob Blame History Raw
%bcond_without check

%global goipath
Version:                3.1.2


%global common_description %{expand:
Git extension for versioning large files.}

%global golicenses
%global godocs          docs\\\

Name:           git-lfs
Release:        %autorelease
Summary:        Git extension for versioning large files

License:        MIT
Source3:        README.Fedora

BuildRequires:  gnupg2

BuildRequires:  golang(
BuildRequires:  golang( >= 2.1.0
BuildRequires:  golang( >= 2.1.0
BuildRequires:  golang( >= 0-0.13.20220318gitf0c862d
BuildRequires:  golang(
BuildRequires:  golang( >= 2.0.1
BuildRequires:  golang( >= 1.5.0
BuildRequires:  golang( >= 0.0.4
BuildRequires:  golang(
BuildRequires:  golang(
BuildRequires:  golang(
BuildRequires:  golang( >= 0.0.3
BuildRequires:  golang( >= 1.0.1
BuildRequires:  golang(
BuildRequires:  golang(

# Generate man pages
BuildRequires:  /usr/bin/ronn

%if %{with check}
# Tests
BuildRequires:  golang( >= 1.6.1
BuildRequires:  golang( >= 1.6.1
BuildRequires:  golang(
BuildRequires:  perl-Digest-SHA
BuildRequires:  perl-Test-Harness
# Tests require full git suite, but not generally needed.
BuildRequires:  git >= 1.8.5

Requires:       git-core >= 1.8.5

Git Large File Storage (LFS) replaces large files such as audio samples,
videos, datasets, and graphics with text pointers inside Git, while
storing the file contents on a remote server.


tar xf %{SOURCE2}
keyring="$(ls git-lfs-git-lfs-*/keys.asc)"

# Replicate gpgverify, because it requires detached signatures.

fatal_error() {
    message="$1"  # an error message
    status=$2     # a number to use as the exit code
    echo "gpgverify: $message" >&2
    exit $status

check_status() {
    action="$1"  # a string that describes the action that was attempted
    status=$2    # the exit code of the command
    if test $status -ne 0 ; then
        fatal_error "$action failed." $status

# Make a temporary working directory.
workdir="$(mktemp --directory)"
check_status 'Making a temporary directory' $?

# Decode any ASCII armor on the keyring. This is harmless if the keyring isn't
# ASCII-armored.
gpg2 --homedir="${workdir}" --yes --output="${workring}" --dearmor "${keyring}"
check_status 'Decoding the keyring' $?

# Verify the signature using the decoded keyring.
gpgv2 --homedir="${workdir}" --keyring="${workring}" "%{SOURCE1}"
check_status 'Signature verification' $?

# Clean up. (This is not done in case of an error that may need inspection.)
rm --recursive --force ${workdir}

# END gpgverify.

cd %{_sourcedir}
sha256sum --check --ignore-missing %{SOURCE1}

cp -p %SOURCE3 .

# Modify Makefile so that it expects binaries where we build them.
sed -i -e 's!\.\./bin/!/%{gobuilddir}/bin/!g' t/Makefile

# Build manpages first (some embedding in the executable is done.)
pushd docs
ronn --roff man/*.ronn
%gobuild -o %{gobuilddir}/bin/mangen man/mangen.go

LDFLAGS="-X ' %{fedora}' " \
%gobuild -o %{gobuilddir}/bin/git-lfs %{goipath}

# Build test executables
for cmd in t/cmd/*.go; do
    %gobuild -o "%{gobuilddir}/bin/$(basename $cmd .go)" "$cmd"
%gobuild -o "%{gobuilddir}/bin/git-lfs-test-server-api" t/git-lfs-test-server-api/*.go

# Move man pages out of docs so they don't get installed twice.
mv docs/man .

install -Dpm0755 %{gobuilddir}/bin/git-lfs %{buildroot}%{_bindir}/%{name}
install -d -p %{buildroot}%{_mandir}/man1/
install -Dpm0644 man/*.1 %{buildroot}%{_mandir}/man1/
install -d -p %{buildroot}%{_mandir}/man5/
install -Dpm0644 man/*.5 %{buildroot}%{_mandir}/man5/

if [ "x$(git config --type=bool --get '')" != "xtrue" ]; then
%{_bindir}/%{name} install --system --skip-repo

if [ $1 -eq 0 ] && \
   [ "x$(git config --type=bool --get '')" != "xtrue" ]; then
    %{_bindir}/%{name} uninstall --system --skip-repo
exit 0

%if %{with check}
PATH=%{buildroot}%{_bindir}:%{gobuilddir}/bin:$PATH \
    make -C t PROVE_EXTRA_ARGS="-j$(getconf _NPROCESSORS_ONLN)"

%doc README.Fedora docs