Package zeronet: Specfile

# TODO
#	python3(bitcoinrpc.authproxy)

Name: zeronet
Version: 0.7.1
Release: alt1

Summary: ZeroNet - Decentralized websites using Bitcoin crypto and BitTorrent network

License: GPLv2
Group: Networking/Other
Url: https://github.com/HelloZeroNet/ZeroNet

# Source-url: https://github.com/HelloZeroNet/ZeroNet/archive/refs/tags/v%version.tar.gz
Source: %name-%version.tar

Source1: zeronet.conf
Source2: zeronet.service

BuildArch: noarch

%define zeronetdir %_datadir/%name

BuildRequires(pre): rpm-build-python3
BuildRequires(pre): rpm-build-intro

# generated by 'epm restore --dry-run' from zeronet-0.7.1/requirements.txt
%py3_use gevent >= 1.1.0
%py3_use msgpack >= 0.4.4
%py3_use base58
%py3_use merkletools
%py3_use elliptic >= 2.0.1
%py3_use rsa
%py3_use socks
%py3_use pyasn1
%py3_use websocket-client
%py3_use gevent-websocket
%py3_use bencode.py
%py3_use coincurve
%py3_use bitcoinlib > 0.11
%py3_use MaxMindDB


%add_python3_path %zeronetdir

%description
Decentralized websites using Bitcoin crypto and the BitTorrent network - https://zeronet.io / onion.

%prep
%setup
find -name '*.py' -type f | xargs subst 's|#!/usr/bin/env python.*|#!/usr/bin/env python3|'
find -name '*.py' -type f | xargs subst 's|#!/usr/bin/python|#!/usr/bin/env python3|'

%build

%install
mkdir -p %buildroot%zeronetdir

# There is no setup.py shipped, so brute-force copy
cp -a . %buildroot%zeronetdir/
rm -rv %buildroot%zeronetdir/.github/
rm -rv %buildroot%zeronetdir/src/Test/
rm -v %buildroot%zeronetdir/{.gitlab-ci.yml,.travis.yml}
rm -rv %buildroot%zeronetdir/plugins/disabled-StemPort/
# needs missed bitcoinrpc
rm -rv %buildroot%zeronetdir/plugins/Zeroname/
find %buildroot%zeronetdir -name 'Test' -type d | xargs rm -rv


install -D -m644 %SOURCE1 %buildroot%_sysconfdir/%name/zeronet.conf
install -D -m644 %SOURCE2 %buildroot%_unitdir/zeronet.service
mkdir -p %buildroot/var/lib/%name/
mkdir -p %buildroot/var/log/%name/

%pre
/usr/sbin/groupadd -r -f _zeronet ||:
/usr/sbin/useradd -r -g _zeronet -d /var/lib/%name -s /dev/null -c 'ZeroNet user' _zeronet >/dev/null 2>&1 ||:


%files
%doc README.md README-ru.md LICENSE
%attr(0750,_zeronet,_zeronet) %dir %_sysconfdir/%name/
# This is not usual practice but to editting from web interface
%attr(0640,_zeronet,_zeronet) %config(noreplace) %_sysconfdir/%name/zeronet.conf
%attr(0710,_zeronet,_zeronet) /var/lib/%name/
%attr(0750,_zeronet,_zeronet) /var/log/%name/
%_unitdir/zeronet.service
%zeronetdir/

%changelog
* Sun Sep 12 2021 Vitaly Lipatov <lav@altlinux.ru> 0.7.1-alt1
- initial build for ALT Sisyphus