%global _hardened_build 1
%define debug_package %{nil}

Name:		soju
Version:	0.1.1
Release:	1%{?dist}
Summary:	A user-friendly IRC bouncer
Group:		System/Library
License:	MIT
URL:		https://github.com/42wim/matterircd
Source0:	soju.service
BuildRequires:	golang


%description
A user-friendly IRC bouncer :
  - Multi-user
  - Support multiple clients for a single user, with proper backlog synchronization
  - Support connecting to multiple upstream servers via a single IRC connection to the bouncer


%prep
%setup -q -T -c %{name}-%{version}
export GOPATH=`pwd`
mkdir -p src/git.sr.ht/~emersion/
cd src/git.sr.ht/~emersion/
git clone https://git.sr.ht/~emersion/soju


%build
export GOPATH=`pwd`
cd src/git.sr.ht/~emersion/soju
git checkout tags/v%{version}
go build -v -trimpath --ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid %{version}" -o sojud ./cmd/soju
go build -v -trimpath --ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid %{version}" -o soju-ctl ./cmd/sojuctl


%install
install -p -D -m 0644 %{SOURCE0} %{buildroot}%{_unitdir}/soju.service
install -p -D -m 0555 src/git.sr.ht/~emersion/soju/sojud %{buildroot}%{_bindir}/sojud
install -p -D -m 0555 src/git.sr.ht/~emersion/soju/soju-ctl %{buildroot}%{_bindir}/soju-ctl
install -p -D -m 0644 src/git.sr.ht/~emersion/soju/config.in %{buildroot}%{_sysconfdir}/soju/soju.conf


%post
%systemd_post soju.service


%preun
%systemd_preun soju.service


%postun
%systemd_postun soju.service


%files
%doc
%config(noreplace) %{_sysconfdir}/soju/soju.conf
%{_unitdir}/soju.service
%{_bindir}/sojud
%{_bindir}/soju-ctl


%changelog
