File twopence.spec of Package twopence

#
# spec file for package twopence
#
# Copyright (c) 2014-2021 SUSE LLC
#
# 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/
#


%if 0%{?suse_version} >= 1210
%define pyversion 2.7
%else
%define pyversion 2.6
%endif
%define rbversion %{rb_ver}
%define rbdir %{_libdir}/ruby/gems/%{rbversion}
%define extdir %{rbdir}/extensions/%{gem_platform}/%{rbversion}/twopence-%{version}
%define mod_name twopence
%define mod_full_name %{mod_name}-%{version}

Name:           twopence

Summary:        A generic testing engine
License:        GPL-2.0
Group:          Development/Tools/Other
Url:            https://github.com/openSUSE/twopence/
Version:        0.4.2
Release:        0
Source0:        %{name}-%{version}.tar.bz2
Source1:        %{name}-test-server.service
Source2:        %{name}-tmpfiles.conf
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} >= 1210
Requires(post): shadow
Requires(post): systemd
Requires(post): udev
%endif

%description
A test executor that can run tests in a KVM virtual machine without using
the network, or that can run more traditional tests in a remote machine
through SSH or serial lines.


%package -n     libtwopence0
Summary:        A generic testing engine - library
Group:          Development/Tools/Other
BuildRequires:  libssh-devel
Requires:       twopence

%description -n libtwopence0
A test executor that can run tests in a KVM virtual machine without using
the network, or that can run more traditional tests in a remote machine
through SSH or serial lines.

This is the client side library.


%package -n     twopence-devel
Summary:        A generic testing engine - development files
Group:          Development/Tools/Other
Requires:       libtwopence0
%if 0%{?suse_version} >= 1210
BuildArch:      noarch
%endif

%description -n twopence-devel
A test executor that can run tests in a KVM virtual machine without using
the network, or that can run more traditional tests in a remote machine
through SSH or serial lines.

These are the development files for using directly the library.


%package -n     twopence-shell-client
Summary:        A generic testing engine - shell commands
Group:          Development/Tools/Other

%description -n twopence-shell-client
A test executor that can run tests in a KVM virtual machine without using
the network, or that can run more traditional tests in a remote machine
through SSH or serial lines.

These are the shell commands to call twopence directly from command line.


%package -n     rubygem-twopence
Summary:        A generic testing engine - Ruby wrappers
Group:          Development/Tools/Other
BuildRequires:  ruby-devel
BuildRequires:  ruby-macros

%description -n rubygem-twopence
A test executor that can run tests in a KVM virtual machine without using
the network, or that can run more traditional tests in a remote machine
through SSH or serial lines.

These are the Ruby wrappers.


%package -n     python-twopence
Summary:        A generic testing engine - Python wrappers
Group:          Development/Tools/Other
Buildrequires:  python-devel

%description -n python-twopence
A test executor that can run tests in a KVM virtual machine without using
the network, or that can run more traditional tests in a remote machine
through SSH or serial lines.

These are the Python wrappers.


%package -n     twopence-test-server
Summary:        A generic testing engine - server for system under tests
Group:          Development/Tools/Other

%description -n twopence-test-server
A test executor that can run tests in a KVM virtual machine without using
the network, or that can run more traditional tests in a remote machine
through SSH or serial lines.

This server must be installed on the system under tests when using the
virtio or serial plugins. It is not needed when using the ssh plugin.


%prep
%setup -q -n %name-%version

%build
export RBVERSION="%rbversion"
make all

%install
export DESTDIR="%buildroot"
export LIBDIR="%_libdir"
export INCDIR="%_includedir"
export BINDIR="%_bindir"
export MANDIR="%_mandir"
export RBVERSION="%rbversion"
export ARCH="%arch"
make install
%gem_cleanup
%if 0%{?suse_version} >= 1210
  install -m0755 -d %buildroot/%{_unitdir} %buildroot/%{_sbindir}
  install -m0644 %{_sourcedir}/%{name}-test-server.service \
                 %buildroot/%{_unitdir}/twopence-test-server.service
  ln -svf service %buildroot/%{_sbindir}/rctwopence-test-server
  install -m0755 -d %buildroot/usr/lib/tmpfiles.d
  install -m0644 %{_sourcedir}/%{name}-tmpfiles.conf \
                 %buildroot/usr/lib/tmpfiles.d/twopence.conf
%endif
ln -sf libtwopence.so.%{version} %buildroot/%{_libdir}/libtwopence.so

%post
%if 0%{?suse_version} >= 1210
  getent group qemu >/dev/null || /usr/sbin/groupadd -r qemu
  getent passwd qemu >/dev/null || /usr/sbin/useradd -r -g qemu -d / -s /sbin/nologin -c "qemu user" qemu
  /usr/bin/systemd-machine-id-setup
  /usr/bin/systemd-tmpfiles --create
%endif

%files
%defattr(-,root,root)
%doc TODO COPYING library/protocol.txt
%dir /usr/lib/twopence-0
/usr/lib/twopence-0/add_virtio_channel.sh
%if 0%{?suse_version} >= 1210
  %dir /usr/lib/tmpfiles.d
  /usr/lib/tmpfiles.d/twopence.conf
%endif

##############################################################################

%post -n libtwopence0
/sbin/ldconfig

%postun -n libtwopence0
/sbin/ldconfig

%files -n libtwopence0
%defattr(-,root,root)
%{_libdir}/libtwopence.so.%{version}
%{_libdir}/libtwopence.so
%doc %{_mandir}/man3/twopence.3.gz

##############################################################################

%files -n twopence-devel
%defattr(-,root,root)
%dir %{_includedir}/twopence
%{_includedir}/twopence/twopence.h
%{_includedir}/twopence/buffer.h
%{_includedir}/twopence/version.h

##############################################################################

%files -n twopence-shell-client
%defattr(-,root,root)
%doc %{_mandir}/man1/twopence_command.1.gz
%doc %{_mandir}/man1/twopence_inject.1.gz
%doc %{_mandir}/man1/twopence_extract.1.gz
%doc %{_mandir}/man1/twopence_exit.1.gz
%{_bindir}/twopence_command
%{_bindir}/twopence_inject
%{_bindir}/twopence_extract
%{_bindir}/twopence_exit
/usr/lib/twopence-0/example.sh

##############################################################################

%files -n rubygem-twopence
%defattr(-,root,root)
%if 0%{?suse_version} > 1500
%doc %{rbdir}/doc/twopence-%{version}
%endif
%dir %{rbdir}/gems/twopence-%{version}
%dir %{rbdir}/gems/twopence-%{version}/ext
%dir %{rbdir}/gems/twopence-%{version}/ext/twopence
%dir %{rbdir}/gems/twopence-%{version}/lib
%if 0%{?sle_version} <= 120500
%dir %{rbdir}/doc/twopence-%{version}
%dir %{rbdir}/doc/twopence-%{version}/ri
%{rbdir}/doc/twopence-%{version}/ri/cache.ri
%endif
%{rbdir}/cache/twopence-%{version}.gem
%if 0%{?suse_version} >= 1315
  %dir %{extdir}
  %{extdir}/twopence.so
  %{extdir}/gem.build_complete
%endif

%if 0%{?suse_version} > 1320
%{rbdir}/gems/twopence-%{version}/ext/twopence/.sitearchdir.time
%else
%if 0%{?suse_version} >= 1210
%{rbdir}/gems/twopence-%{version}/ext/twopence/.RUBYARCHDIR.time
%endif
%endif

%{rbdir}/gems/twopence-%{version}/ext/twopence/twopence.so
%{rbdir}/gems/twopence-%{version}/ext/twopence/extconf.rb
%{rbdir}/gems/twopence-%{version}/ext/twopence/glue.c
%{rbdir}/gems/twopence-%{version}/ext/twopence/target.c
%{rbdir}/gems/twopence-%{version}/ext/twopence/target.h
%{rbdir}/gems/twopence-%{version}/lib/twopence.so
%{rbdir}/specifications/twopence-%{version}.gemspec
%{_prefix}/lib/twopence-0/example.rb

##############################################################################

%files -n python-twopence
%defattr(-,root,root)
%doc %{_mandir}/man3/*.3py*
%{_libdir}/python%{pyversion}/site-packages/twopence.so
%{_prefix}/lib/twopence-0/example.py

##############################################################################

%if 0%{?suse_version} >= 1210
%pre -n twopence-test-server
%{service_add_pre twopence-test-server.service}

%post -n twopence-test-server
%{service_add_post twopence-test-server.service}

%preun -n twopence-test-server
%{service_del_preun twopence-test-server.service}

%postun -n twopence-test-server
%{service_del_postun twopence-test-server.service}
%endif

%files -n twopence-test-server
%defattr(-,root,root)
%doc %{_mandir}/man1/twopence_test_server.1.gz
%{_bindir}/twopence_test_server
%if 0%{?suse_version} >= 1210
  %{_unitdir}/twopence-test-server.service
  %{_sbindir}/rctwopence-test-server
%endif

%changelog
openSUSE Build Service is sponsored by