File mock.spec of Package mock
#
# spec file for package mock
#
# Copyright (c) 2023 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/
#
# mock group id allocate for Fedora
%global mockgid 135
%global __python python3
%global python_sitelib %{python3_sitelib}
%if 0%{?suse_version}
%define python3_pkgversion 3
%endif
%bcond_with lint
%if 0%{?suse_version}
%bcond_with tests
%else
%bcond_without tests
%endif
%if !0%{defined _distconfdir}
%define _distconfdir /etc
%endif
Name: mock
Version: 6.5
Release: 1%{?dist}
Summary: Builds packages inside chroots
License: GPL-2.0-or-later
URL: https://github.com/rpm-software-management/mock/
# Source is created by
# git clone https://github.com/rpm-software-management/mock.git
# cd mock
# git reset --hard %%{name}-%%{version}
# tito build --tgz
Source: https://github.com/rpm-software-management/mock/releases/download/%{name}-%{version}-1/%{name}-%{version}.tar.gz
Patch0: add-templated-directory.patch
BuildRequires: bash-completion
BuildRequires: python%{python3_pkgversion}-devel
Requires: python3
Requires: %{name}-filesystem = %{version}-%{release}
Requires: coreutils
Requires: createrepo_c
# Requires 'mock-core-configs', or replacement (GitHub PR#544).
Requires: mock-configs
Requires: pigz
Requires: python%{python3_pkgversion}-backoff
Requires: python%{python3_pkgversion}-distro
Requires: python%{python3_pkgversion}-jinja2
Requires: python%{python3_pkgversion}-pyroute2
Requires: python%{python3_pkgversion}-requests
Requires: python%{python3_pkgversion}-rpm
Requires: systemd
Requires: tar
# hwinfo plugin
Requires: util-linux
Recommends: btrfs-progs
Recommends: dnf-utils
Recommends: podman
Suggests: dnf-plugins-core
Suggests: procenv
# DNF4 stack
Suggests: python3-dnf
Suggests: qemu-user-static
Suggests: yum
# We know that the current version of mock isn't compatible with older variants,
# and we want to enforce automatic upgrades.
Conflicts: mock-core-configs < 33
BuildArch: noarch
%if !0%{?suse_version}
%if 0%{?mageia}
Requires: usermode-consoleonly
%else
Requires: usermode
%endif
%endif
%if 0%{?fedora} || 0%{?rhel} >= 8
# This is still preferred package providing 'mock-configs'
Suggests: mock-core-configs
%endif
%if 0%{?fedora} || 0%{?rhel} >= 8
Requires: systemd-container
%endif
%if 0%{?fedora}
Suggests: iproute
%endif
%if 0%{?mageia}
Suggests: iproute2
%endif
# Suse currently patches the templated dictionary
%if !0%{?suse_version}
Requires: python%{python3_pkgversion}-templated-dictionary
%endif
%if %{with lint}
BuildRequires: python%{python3_pkgversion}-pylint
%endif
%if 0%{?fedora} >= 38
# DNF5 stack
Suggests: dnf5
Suggests: dnf5-plugins
%endif
%if %{with tests}
BuildRequires: python%{python3_pkgversion}-distro
BuildRequires: python%{python3_pkgversion}-jinja2
BuildRequires: python%{python3_pkgversion}-pyroute2
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-requests
# Suse currently patches the templated dictionary
%if !0%{?suse_version}
Requires: python%{python3_pkgversion}-templated-dictionary
%endif
%endif
%if 0%{?fedora} || 0%{?rhel} >= 8
BuildRequires: perl-interpreter
%else
BuildRequires: perl
%endif
%if 0%{?suse_version}
Requires: procps
Requires: shadow
%else
Requires: procps-ng
Requires: shadow-utils
%endif
%description
Mock takes an SRPM and builds it in a chroot.
%package scm
Summary: Mock SCM integration module
Requires: %{name} = %{version}-%{release}
Recommends: cvs
Recommends: git
# We could migrate to 'copr-distgit-client'
Recommends: rpkg
Recommends: subversion
Recommends: tar
%description scm
Mock SCM integration module.
%package lvm
Summary: LVM plugin for mock
Requires: %{name} = %{version}-%{release}
Requires: lvm2
%description lvm
Mock plugin that enables using LVM as a backend and support creating snapshots
of the buildroot.
%package filesystem
Summary: Mock filesystem layout
Requires(pre): shadow
Provides: group(mock)
%description filesystem
Filesystem layout and group for Mock.
%prep
%setup -q
%patch -p1 -P0
%if !0%{?suse_version}
for file in py/mock.py py/mock-parse-buildlog.py; do
sed -i 1"s|#!%{_bindir}/python3 |#!python |" $file
done
%endif
%build
for i in py/mockbuild/constants.py py/mock-parse-buildlog.py; do
perl -p -i -e 's|^VERSION\s*=.*|VERSION="%{version}"|' $i
perl -p -i -e 's|^SYSCONFDIR\s*=.*|SYSCONFDIR="%{_sysconfdir}"|' $i
perl -p -i -e 's|^PYTHONDIR\s*=.*|PYTHONDIR="%{python_sitelib}"|' $i
perl -p -i -e 's|^PKGPYTHONDIR\s*=.*|PKGPYTHONDIR="%{python_sitelib}/mockbuild"|' $i
done
for i in docs/mock.1 docs/mock-parse-buildlog.1; do
perl -p -i -e 's|\@VERSION\@|%{version}"|' $i
done
%install
#base filesystem
mkdir -p %{buildroot}%{_sysconfdir}/mock/eol/templates
mkdir -p %{buildroot}%{_sysconfdir}/mock/templates
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_libexecdir}/mock
install mockchain %{buildroot}%{_bindir}/mockchain
install py/mock-parse-buildlog.py %{buildroot}%{_bindir}/mock-parse-buildlog
install py/mock.py %{buildroot}%{_libexecdir}/mock/mock
%if 0%{?suse_version}
ln -s %{_libexecdir}/mock/mock %{buildroot}%{_bindir}/mock
%else
ln -s consolehelper %{buildroot}%{_bindir}/mock
%endif
install -d %{buildroot}%{_distconfdir}/pam.d
cp -a etc/pam/* %{buildroot}%{_distconfdir}/pam.d/
install -d %{buildroot}%{_sysconfdir}/mock
cp -a etc/mock/* %{buildroot}%{_sysconfdir}/mock/
%if !0%{?suse_version}
install -d %{buildroot}%{_sysconfdir}/security/console.apps/
cp -a etc/consolehelper/mock %{buildroot}%{_sysconfdir}/security/console.apps/%{name}
%endif
install -d %{buildroot}%{_datadir}/bash-completion/completions/
cp -a etc/bash_completion.d/* %{buildroot}%{_datadir}/bash-completion/completions/
ln -s mock %{buildroot}%{_datadir}/bash-completion/completions/mock-parse-buildlog
install -d %{buildroot}%{_sysconfdir}/pki/mock
cp -a etc/pki/* %{buildroot}%{_sysconfdir}/pki/mock/
install -d %{buildroot}%{python_sitelib}/
cp -a py/mockbuild %{buildroot}%{python_sitelib}/
install -d %{buildroot}%{_mandir}/man1
cp -a docs/mock.1 docs/mock-parse-buildlog.1 %{buildroot}%{_mandir}/man1/
install -d %{buildroot}%{_datadir}/cheat
cp -a docs/mock.cheat %{buildroot}%{_datadir}/cheat/mock
install -d %{buildroot}%{_localstatedir}/lib/mock
install -d %{buildroot}%{_localstatedir}/cache/mock
%if 0%{?suse_version}
mkdir -p %{buildroot}%{_docdir}/mock
install -p -m 0644 docs/site-defaults.cfg %{buildroot}%{_docdir}/mock
%else
mkdir -p %{buildroot}%{_pkgdocdir}
install -p -m 0644 docs/site-defaults.cfg %{buildroot}%{_pkgdocdir}
%endif
sed -i 's/^_MOCK_NVR = None$/_MOCK_NVR = "%{name}-%{version}-%{release}"/' \
%{buildroot}%{_libexecdir}/mock/mock
%pre filesystem
# check for existence of mock group, create it if not found
getent group mock > /dev/null || groupadd -f -g %{mockgid} -r mock
exit 0
%check
%if %{with lint}
# ignore the errors for now, just print them and hopefully somebody will fix it one day
pylint-3 py/mockbuild/ py/*.py py/mockbuild/plugins/* || :
%endif
%if %{with tests}
./run-tests.sh --no-cov
%endif
%files
%dir %{_sysconfdir}/pki/
%defattr(0644, root, mock)
%dir %{_docdir}/mock/
%dir %{_sysconfdir}/pki/mock
%doc %{_docdir}/mock/site-defaults.cfg
%{_datadir}/bash-completion/completions/mock
%{_datadir}/bash-completion/completions/mock-parse-buildlog
%if !0%{?suse_version}
# executables
%{_bindir}/mock
%{_bindir}/mockchain
%{_bindir}/mock-parse-buildlog
%{_libexecdir}/mock
%endif
# python stuff
%defattr(0644, root, mock)
%{python_sitelib}/mockbuild/
%exclude %{python_sitelib}/mockbuild/scm.*
%exclude %{python_sitelib}/mockbuild/__pycache__/scm.*
%exclude %{python_sitelib}/mockbuild/plugins/lvm_root.*
%exclude %{python_sitelib}/mockbuild/plugins/__pycache__/lvm_root.*
# config files
%config(noreplace) %{_sysconfdir}/%{name}/*.ini
%config(noreplace) %{_sysconfdir}/%{name}/*.cfg
%if 0%{?suse_version}
%dir /%{_distconfdir}/pam.d
%{_distconfdir}/pam.d/%{name}
%else
%config(noreplace) %{_sysconfdir}/pam.d/%{name}
%config(noreplace) %{_sysconfdir}/security/console.apps/%{name}
%endif
# directory for personal gpg keys
%dir %{_sysconfdir}/pki/mock
%config(noreplace) %{_sysconfdir}/pki/mock/*
# docs
%{_mandir}/man1/mock.1%{?ext_man}
%{_mandir}/man1/mock-parse-buildlog.1%{?ext_man}
%{_datadir}/cheat/mock
# cache & build dirs
%defattr(0775, root, mock, 0775)
%dir %{_localstatedir}/cache/mock
%dir %{_localstatedir}/lib/mock
%if 0%{?suse_version}
# executables
%{_bindir}/mock
%{_bindir}/mockchain
%{_bindir}/mock-parse-buildlog
%{_libexecdir}/mock
%endif
%if !0%{?suse_version}
%files scm
%{python_sitelib}/mockbuild/scm.py*
%{python3_sitelib}/mockbuild/__pycache__/scm.*.py*
%files lvm
%{python_sitelib}/mockbuild/plugins/lvm_root.*
%{python3_sitelib}/mockbuild/plugins/__pycache__/lvm_root.*.py*
%endif
%files filesystem
%license COPYING
%dir %{_sysconfdir}/mock
%dir %{_sysconfdir}/mock/eol
%dir %{_sysconfdir}/mock/eol/templates
%dir %{_sysconfdir}/mock/templates
%dir %{_datadir}/cheat
%changelog