A new user interface for you! Read more...

File go-ipfs.spec of Package go-ipfs

#
# spec file for package go-ipfs
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define debug_package %{nil}
%define repo github.com/ipfs/go-ipfs
Name:           go-ipfs
Version:        0.4.20
Release:        0
Summary:        IPFS implementation in Go
License:        MIT
Group:          Productivity/Networking/Other
URL:            https://%{repo}
Source0:        https://%{repo}/archive/v%{version}.tar.gz
Source1:        deps.tar.gz

BuildRequires:  git
BuildRequires:  go >= 1.12
BuildRequires:  systemd-rpm-macros
Requires:       fuse
%systemd_requires

%description
IPFS is a global, versioned, peer-to-peer filesystem. It combines good ideas from Git, BitTorrent, Kademlia, SFS, and the Web. It is like a single bittorrent swarm, exchanging git objects. IPFS provides an interface as simple as the HTTP web, but with permanence built in. You can also mount the world at /ipfs.

%prep
%setup -q
tar xf %{S:1}
mkdir -p src/%{repo}
chmod u+w mod -R
cp -al mod/* src/
rm -rf mod
mv [^s]* src/%{repo}
# map deps to where go1.12 expects them
find src -name \*@v[0-9]* -type d | perl -ne 'chomp;$o=$_; s/@.*//; $o=~s!.*/!!; print "ln -s \"$o\" \"$_\"\n"; symlink($o, $_)'
find src -name "*!*" -type d | perl -ne 'chomp;$o=$_; s/!(.)/\u$1/g; $o=~s!.*/!!; print "ln -s \"$o\" \"$_\"\n"; symlink($o, $_)'

%build
export GOPATH="$(pwd)"
export PATH=$PATH:"$(pwd)"/bin
env
cd src/%{repo}
go build -buildmode=pie -o ./cmd/ipfs/ipfs ./cmd/ipfs

%install
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_userunitdir}
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_datadir}/bash-completion/completions/ipfs

cp src/github.com/ipfs/%{name}/cmd/ipfs/ipfs %{buildroot}%{_bindir}
cat << EOF >>  %{buildroot}%{_userunitdir}/ipfs.service
[Unit]
Description=InterPlanetary File System (IPFS) daemon

[Service]
ExecStart=/usr/bin/ipfs daemon
Restart=on-failure

[Install]
WantedBy=default.target
EOF
cat << EOF >> %{buildroot}%{_unitdir}/ipfs@.service
[Unit]
Description=InterPlanetary File System (IPFS) daemon

[Service]
User=%i
ExecStart=/usr/bin/ipfs daemon
Restart=on-failure

[Install]
WantedBy=default.target
EOF
cp src/github.com/ipfs/%{name}/misc/completion/ipfs-completion.bash %{buildroot}%{_datadir}/bash-completion/completions/ipfs

%pre
%service_add_pre ipfs@.service

%post
%service_add_post ipfs@.service

%preun
%service_del_preun ipfs@.service

%postun
%service_del_postun ipfs@.service

%files
%{_bindir}/ipfs
%{_userunitdir}/ipfs.service
%{_unitdir}/ipfs@.service
%{_datadir}/bash-completion/completions/ipfs
%license src/%{repo}/LICENSE
%doc src/%{repo}/docs/*

%changelog