File fossil.spec of Package fossil

%bcond_without tests
Name:          fossil
Version:       2.13
Release:       1%{?dist}
Summary:       A simple, high-reliability, distributed SCM with bug tracking, wiki, and forum

License:       BSD
URL:           https://www.fossil-scm.org/
Source0:       %{URL}index.html/uv/fossil-src-%{version}.tar.gz
Source1:       template.config

BuildRequires: gcc-c++
BuildRequires: zlib-devel
BuildRequires: openssl-devel
BuildRequires: tcl
BuildRequires: make

%description
Fossil is a simple, high-reliability, distributed software configuration
management with distributed bug tracking, distributed wiki, forums, and
built-in web interface.

%package doc
Summary:          Fossil documentation

%description doc
Documentation in repository format for %{name}. Users can run `fossil ui`
in %{_docdir}/%{name}-doc folder to view documents in browser.

%prep
%autosetup

# Update config.guess/sub to fix builds on new architectures (aarch64/ppc64le)
for conf in /usr/lib/rpm/config.*; do [ -z "${f}" ] && break; cp "${f}" autosetup; done

%build
%set_build_flags
# This gives configure-without-libdir-spec, but this is done because this is not generated by autoconf (but by autosetup)
# Because of this, it does not support the --host= argument like expected, and as such %%configure cannot be used
./configure --build=%{_build} \
  --disable-dependency-tracking \
  --prefix=%{_prefix} \
  --exec-prefix=%{_exec_prefix} \
  --bindir=%{_bindir} \
  --sbindir=%{_sbindir} \
  --sysconfdir=%{_sysconfdir} \
  --datadir=%{_datadir} \
  --includedir=%{_includedir} \
  --libdir=%{_libdir} \
  --libexecdir=%{_libexecdir} \
  --localstatedir=%{_localstatedir} \
  --sharedstatedir=%{_sharedstatedir} \
  --mandir=%{_mandir} \
  --infodir=%{_infodir} \
  --with-openssl=auto \
  --json

%make_build
# fix spurious-executable-perm
chmod -x www/collisions.ipynb
# fix env-script-interpreter
sed -i "s:^#\!/usr/bin/env\s\+tclsh\s\?$:#!%_bindir/tclsh:" www/mkindex.tcl

%install
%make_install
install -D -m 0644 -t %{buildroot}%{_mandir}/man1 fossil.1


%check
%if %{with tests}
tclsh test/tester.tcl %{buildroot}%{_bindir}/%name
%endif


# create a fossil repository for documents with default settings
%{buildroot}%{_bindir}/%name init --admin-user %name %name-doc.fossil
%{buildroot}%{_bindir}/%name open --empty --force %name-doc.fossil
%{buildroot}%{_bindir}/%name configuration import %{SOURCE1}
%{buildroot}%{_bindir}/%name add www
%{buildroot}%{_bindir}/%name commit --user %name --force --comment '%name-doc initial commit'


%files
%license COPYRIGHT-BSD2.txt
%{_bindir}/%name
%{_mandir}/man1/%name.1*

%files doc
%doc %name-doc.fossil
%doc .fslckout
%doc www

%changelog
openSUSE Build Service is sponsored by