siosm / rpms / mock

Forked from rpms/mock 2 years ago
Clone
Blob Blame History Raw
# next four lines substituted by autoconf
%define major 1
%define minor 2
%define sub 1
%define extralevel %{nil}
%define release_version %{major}.%{minor}.%{sub}%{extralevel}

%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

%if 0%{?fedora} > 21
%global use_python3 1
%global use_python2 0
%else
%global use_python3 0
%global use_python2 1
%endif

%if %{use_python3}
%global python_sitelib %{python3_sitelib}
%else
%global python_sitelib %{python_sitelib}
%endif

# mock group id allocate for Fedora
%global mockgid  135

Summary: Builds packages inside chroots
Name: mock
Version: %{release_version}
Release: 1%{?dist}
License: GPLv2+
Source: https://git.fedorahosted.org/cgit/mock.git/snapshot/%{name}-%{version}.tar.xz
URL: http://fedoraproject.org/wiki/Projects/Mock
BuildArch: noarch
Requires: yum >= 2.4
Requires: tar
Requires: pigz
Requires: usermode
Requires: yum-utils
Requires: createrepo_c
Requires: pyliblzma
%if 0%{?rhel} != 6
Requires: systemd
%endif
Requires(pre): shadow-utils
Requires(post): coreutils
BuildRequires: autoconf, automake
%if 0%{?fedora} || 0%{?rhel} > 6
BuildRequires: bash-completion
%endif
%if %{use_python3}
Requires: python3
Requires: python3-six
Requires: python3-requests
Requires: rpm-python3
BuildRequires: python3-devel
%else
Requires: python-ctypes
Requires: python-six
Requires: python-requests
Requires: python >= 2.6
BuildRequires: python-devel
%endif


%description
Mock takes an SRPM and builds it in a chroot.

%package scm
Summary: Mock SCM integration module
Requires: %{name} = %{version}-%{release}
Requires: cvs
Requires: git
Requires: subversion
Requires: tar

%description scm
Mock SCM integration module.

%if 0%{?rhel} != 6 && %{use_python2}
# lvm plugin requires lvm2-python-libs, kernel >= 3.0 and glibc >= 2.14, which
# are not available on el6
%package lvm
Summary: LVM plugin for mock
Requires: %{name} = %{version}-%{release}
Requires: lvm2
Requires: lvm2-python-libs
Requires: glibc >= 2.14

%description lvm
Mock plugin that enables using LVM as a backend and support creating snapshots
of the buildroot.
%endif

%prep
%setup -q
%if 0%{?rhel} == 6
sed -i "s|^USE_NSPAWN = True|USE_NSPAWN = False|" py/mockbuild/util.py 
%endif
%if %{use_python3}
sed -i 's/AM_PATH_PYTHON/AM_PATH_PYTHON([3])/' configure.ac
for file in py/mock.py py/mockchain.py; do
  sed -i 1"s|#!/usr/bin/python |#!/usr/bin/python3 |" $file
done
%endif

%build
autoreconf -vif
%configure
make

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
mkdir -p $RPM_BUILD_ROOT/var/lib/mock
mkdir -p $RPM_BUILD_ROOT/var/cache/mock
ln -s consolehelper $RPM_BUILD_ROOT/usr/bin/mock

echo "%defattr(0644, root, mock)" > %{name}.cfgs
find $RPM_BUILD_ROOT%{_sysconfdir}/mock -name "*.cfg" \
    | sed -e "s|^$RPM_BUILD_ROOT|%%config(noreplace) |" >> %{name}.cfgs

# just for %%ghosting purposes
ln -s fedora-rawhide-x86_64.cfg $RPM_BUILD_ROOT%{_sysconfdir}/mock/default.cfg

if [ -d $RPM_BUILD_ROOT%{_datadir}/bash-completion ]; then
    echo %{_datadir}/bash-completion/completions/mock >> %{name}.cfgs
    echo %{_datadir}/bash-completion/completions/mockchain >> %{name}.cfgs
elif [ -d $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d ]; then
    echo %{_sysconfdir}/bash_completion.d/mock >> %{name}.cfgs
fi

%if 0%{?rhel} == 6
    # can be removed when yum-utils >= 1.1.31 lands in el6
    echo "config_opts['plugin_conf']['package_state_enable'] = False" >> $RPM_BUILD_ROOT%{_sysconfdir}/mock/site-defaults.cfg
%endif

%pre

# check for existence of mock group, create it if not found
getent group mock > /dev/null || groupadd -f -g %mockgid -r mock
exit 0

%post

# fix cache permissions from old installs
chmod 2775 %{_localstatedir}/cache/%{name}

if [ -e /etc/os-release ]; then
    # fedora and rhel7
    if grep -Fq Rawhide /etc/os-release; then
        ver=rawhide
    else
        ver=$(source /etc/os-release && echo $VERSION_ID | cut -d. -f1 | grep -o '[0-9]\+')
    fi
else
    # rhel6 or something obsure, use buildtime version
    ver=%{?rhel}%{?fedora}
fi
mock_arch=$(python -c "import rpmUtils.arch; baseArch = rpmUtils.arch.getBaseArch(); print baseArch")
cfg=%{?fedora:fedora}%{?rhel:epel}-$ver-${mock_arch}.cfg
[ -e %{_sysconfdir}/%{name}/$cfg ] || exit -2
if [ "$(readlink %{_sysconfdir}/%{name}/default.cfg)" != "$cfg" ]; then
  ln -s $cfg %{_sysconfdir}/%{name}/default.cfg 2>/dev/null || ln -s -f $cfg %{_sysconfdir}/%{name}/default.cfg.rpmnew
fi
:

%files -f %{name}.cfgs
%defattr(-, root, root)

# executables
%{_bindir}/mock
%{_bindir}/mockchain
%attr(0755, root, root) %{_sbindir}/mock

# python stuff
%{python_sitelib}/*
%exclude %{python_sitelib}/mockbuild/scm.*
%exclude %{python_sitelib}/mockbuild/plugins/lvm_root.*

# config files
%dir  %{_sysconfdir}/%{name}
%ghost %config(noreplace,missingok) %{_sysconfdir}/%{name}/default.cfg
%config(noreplace) %{_sysconfdir}/%{name}/*.ini
%config(noreplace) %{_sysconfdir}/pam.d/%{name}
%config(noreplace) %{_sysconfdir}/security/console.apps/%{name}

# gpg keys
%dir %{_sysconfdir}/pki/mock
%config(noreplace) %{_sysconfdir}/pki/mock/*

# docs
%{_mandir}/man1/mock.1*
%{_mandir}/man1/mockchain.1*
%doc ChangeLog

# cache & build dirs
%defattr(0775, root, mock, 02775)
%dir %{_localstatedir}/cache/mock
%dir %{_localstatedir}/lib/mock

%files scm
%{python_sitelib}/mockbuild/scm.py*

%if 0%{?rhel} != 6 && %{use_python2}
%files lvm
%{python_sitelib}/mockbuild/plugins/lvm_root.*
%endif

%changelog
* Sat Nov 15 2014 Miroslav Suchý <msuchy@redhat.com> - 1.2.1-1
- allow mockchain to accept path as config
- end yum's installroot path with a slash [RHBZ#1160428]
- add --mount option [RHBZ#1162637]
- add some missing bash completation strings
- run --shell as root with --new-chroot
- Don't fail scrub when there's no pool [RHBZ#1162631]
- Globbing and tilde expansion
- move restoring priviledges to finally [RHBZ#1162720]
- Remove "Buildroot must be already initialized" note
- Add missing --print-root-path to manpage
- Do not print ANSI escape characters into log [RHBZ#1163037]
- in site-defaults.cfg initialize dictionary of plugins [RHBZ#1162595]
- Disable empty names and values in config_opts[macros] [RHBZ#1160765]
- Disable single macros in -D cmd option [RHBZ#1160765]
- rpmbuild is in /usr/bin [RHBZ#1161112]
- man page for --macro-file [RHBZ#1160326]
- Added option [--macro-file] to support external rpm macros file [RHBZ#1160326]
- Don't output installation/build output when redirected
- Better log message for intial buildroot installation
- Be more specific when installing configs
- Install into correct sitelib when using Python 3
- Fix nosync on aarch64
- wrap all remaining getcwd() [RHBZ#1159300]
- do not use rpm in %post scriptlet [RHBZ#1131279]
- Fix unclear legal host output [RHBZ#1159794]
- allow running from directory, which is deleted [RHBZ#1159300]
- create compress_logs plugin [RHBZ#1100923]
- when default.cfg exists create default.cfg.rpmnew [RHBZ#1085308]
- accept paths to target definition files [RHBZ#1126117]
- set title bar in xterm [RHBZ#1126235]
- pass --enablerepo/--disablerepo to yum in the same order as provided to mock [RHBZ#1154604]
- Fix incorrect printing of binary strings on py3
- Add missing Requires rpm-python3
- Don't print Yum and build output when quiet
- Prevent output being printed twice with --verbose (rhbz#1152971)
- Fix printing non-ascii characters with output redirected (rhbz#1152952)
- replace urlgrabber by python-requests
- use python3 for Fedora22+
- Don't print we're doing rpmbuild -bb, when it may not be true
- 'prep' choice missing in short-circuit option parser
- Don't execute prebuild in short-circuit mode

* Thu Oct  9 2014 Miroslav Suchý <msuchy@redhat.com> - 1.2.0-1
- update configs for secondary architecture (Dan Horák)
- caching of buildroots using LVM (Michael Simacek)
- add support for DNF (Michael Simacek)
- initial porting to python3 (Michael Simacek)
- new config option nosync (Michael Simacek)
- add CentOS extra repository [BZ# 1108402]
- correctly create default.cfg on arm [BZ# 1033786]
- postpone loading of rpm after chroot is set [BZ# 1111147]
- use systemd-nspawn instead of chroot [RHBZ# 1132762]
- in --copyout do not fail on symlinks [BZ# 971474]
- allow to short circuit to prep phase [BZ# 966985]

* Fri Jul 18 2014 Clark Williams <williams@redhat.com> - 1.1.41-1
- fix python 2.7 feature so we can run on rhel6

* Thu Jul 17 2014 Clark Williams <williams@redhat.com> - 1.1.40-1
- from Miroslav Suchý <msuchy@redhat.com>:
  - mock: Revert "revert 7ec6a1e9d202ab56fb31c914dbf7516c045e56ab" [BZ# 1103239]
  - configs: use final Centos 7 path in configs [BZ# 1108402]
  - configs: fix typo in fedora-rawhide-armhfp config [BZ# 1108847]
  - mockchain: use getuid() instead of getgid() [BZ# 1108265]
  - configs: check gpg key of packages from Fedora, Centos, Epel
  - plugins: disable package_state by default on el6
  - make /etc/mtab symlink to /proc/self/mounts [BZ# 1116158]
  - do not list pki files twice
  - deploy etc/pki to buildroot
- from Michael Simacek <msimacek@redhat.com>:
  - mock: do not allow config scripts to regain root priviledges
- from Igor Gnatenko <i.gnatenko.brain@gmail.com>:
  - Add F21 configs
  - Change releasever to 22 for rawhide

* Wed May 21 2014 Clark Williams <williams@redhat.com> - 1.1.39-1
- configs: update epel-7 koji repo to use correct URL
- from Ken Dreyer <ktdryer@ktdryder.com>
  - Use RHEL 7 RC mirrorlist URLs
from Miroslav Suchý <msuchy@redhat.com>
  - add support for subscription-manager (RHSM)
  - expand tabs for better readablity
  - cut of everything after decimal point, if there is some [BZ# 1098477]
  - better code readablity
  - clarify the log messages
  - use metalink instead of mirrorlist in yum config
  - set LC_MESSAGE to C before executing command [BZ# 519258]
  - use ctypes.get_errno() instead of ctypes.c_int.in_dll(_libc, "errno")
  - revert 7ec6a1e9d202ab56fb31c914dbf7516c045e56ab (python 2.4 workarounds)
  - buildroot and %clean is not needed for el6 and fedoras
  - description should always end with dot
  - remove shebang from mockbuild/mounts.py
  - %defattr is not needed since rpm 4.4
  - remove el5 conditional
  - use createrepo_c which is much faster
  - whitespace fixes
  - remove unused variables: 'username' and 'hdr'
  - better logging of kernel version [BZ# 1048826]
  - partially revert 9db6edb33cc34a450e762eb5d2bedf9067ebc419 [BZ# 1034805]
  - teach mockchain about ftp [BZ# 1061776]
from Jerry James <loganjerry@gmail.com>
  - fix post scriptlet to deal with rawhide [BZ# 1083689]

* Mon Mar 31 2014 Clark Williams <williams@redhat.com> - 1.1.38-1
- revert commit 34d0b1d815e4 for quoting (breaks fedora-review)

* Thu Mar 27 2014 Clark Williams <williams@redhat.com> - 1.1.37-2
- fix el6 requires for yum-utils

* Mon Mar 24 2014 Clark Williams <williams@redhat.com> - 1.1.37-1
- fix thinko in test script for running configs
- plugins: turn off package_state plugin by default
- fix automake to use 'xz' compression
- additional commits needed by scm commit
- elevate privs when accessing the chroot rpmdb [BZ# 1051474]
- quote --shell args like a shell [BZ# 966144]
- from Tuomo Soini <tis@foobar.fi>
  - Fix for race in directory creation [BZ# 1052045]
- from Peter Jönsson <peter.jonsson@klarna.com>
  - Add support for creating tarballs with scm data still inside
- from Tomas Kopecek <tkopecek@redhat.com>
  - internal_dev_setup option used consistently
- from Dennis Gilmore <dennis@ausil.us>
  - add rawhide aarch64 config
  - remove sparc rawhide configs, she be dead
- from Ville Skyttä <ville.skytta@iki.fi>
  - Use $(mocketcdir) in install-data-hook instead of duplicating its value
  - Use xz tarball to save a bit of space
  - Clean up unused imports
  - Install bash completion to proper dir with bash-completion 2
  - Remove Fedora 18 configs
  - Use install @foo instead of groupinstall foo in chroot_setup_cmd
- from Rodrigo Dias Cruz <rodrigodc+redhatbugzilla@gmail.com>
  -  fix scm problem with specfiles using rpm macros [BZ# 1056271]
- from Tomas Kopecek <tkopecek@redhat.com>
  - avoid undefined variable error in try/finally block [BZ# 1063275]

* Wed Feb  5 2014 Clark Williams <williams@redhat.com> - 1.1.36-1
- configs: first cut at epel-7 configs for x86_64 and ppc64
- Add 'extra_chroot_dirs' config option
- use repoquery --installroot to avoid yum cache corruption [BZ# 1029352 and 985681]
- mockchain: avoid special characters in repoid [BZ# 1034805]
- from Jon Disnard <jdisnard@gmail.com>:
  - implement autoreconf call in build phase of mock rpm [BZ# 926154]
  - fix --copyout by temporary drop and restore of privs [BZ# 1002142]
- from Dennis Gilmore <dennis@ausil.us>:
  - rawhide and f19/f18 is hardware floating point only for arm, drop the unneeded configs
- from Yann Droneaud <yann@droneaud.fr>:
  - pass root environment to repoquery calls for proxy config [BZ# 974499]
- from Miroslav Suchý <msuchy@redhat.com>:
  - add releasever config option to configs [BZ# 1056039]

* Tue Nov  5 2013 Clark Williams <williams@redhat.com> - 1.1.35-1
- modified %%post logic to set default config correctly

* Tue Oct 29 2013 Clark Williams <williams@redhat.com> - 1.1.34-1
- fixed specfile to include mass rebuild changelog entry
- package_state: drop privs when writing available_packages data [BZ# 916685]
- unconditionally update default.cfg on install [BZ# 858822]
- attempt to make mock more EL5 friendly [BZ# 949616]
- do not ignore missing dependencies [BZ# 955478]
- set the group defined in chrootgid [BZ# 953519]
- add the --nocheck option to mock [BZ# 1015790]
- raise privs before deleting rpm db files in chroot [BZ# 973617]
- clean up orphan processes even if chroot not cleaned [BZ# 972868]
- do not remove the chroot builddir if not cleaning the chroot [BZ# 483486]
- use root object environment in package_state plugin [BZ# 921221]
- Pass values of --plugin-option through literal_eval [BZ# 1018359]
- add default mode to mount in tmpfs plugin [BZ# 598257]
- exit mockbuild.util.logOutput() when child process dies [BZ# 885405]

* Wed Aug 21 2013 Clark Williams <williams@redhat.com> - 1.1.33-1
- removed f17 configs
- added f20 configs
- fixed mockchain to use mock config default setup [BZ# 962573]
- remove bogus lockfile dir in _setupDirs() [BZ# 894305]

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.32-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Thu Apr 18 2013 Clark Williams <williams@redhat.com> - 1.1.32-1
- fixed post scriptlet to use correct keyword to getent

* Fri Apr 12 2013 Clark Williams <williams@redhat.com> - 1.1.31-1
- removed f16 configurations files
- selinux plugin: modify to catch yum-builddep in callback [BZ# 923927]
- fix logging assumption in main mock file [BZ# 912624]
- initial cut at chroot_scan plugin [BZ# 441090]
- updated specfile to use static mock gid 135
- from Marko Myllynen <myllynen@redhat.com>:
  - separate scm module into separate package [BZ# 798367]
  - scm plugin: Handle filenames w/ spaces in SCM/git  [BZ# 915264]
  - scm plugin: if tar supports --exlcude-vcs use it [BZ#  824848]
- from Shad L. Lords <slords@lordsfam.net>:
  - mounts plugin: removed redundant '-t' specified for vfstype [BZ# 910857]
- from Justin Lewis Salmon <jsalmon@cern.ch>:
  - root cache plugin: add the --cache-alternations option [BZ# 905363]

* Thu Mar 28 2013 Clark Williams <williams@redhat.com> - 1.1.30-1
- beef up the logic to remove RPM lock files inside the chroot
- add backup-before-clean configuration options [BZ# 799639]
- added fedora-19 config files [BZ# 922268]
- package_state plugin: don't run repoquery when offline [BZ# 927496]

* Fri Feb 22 2013 Clark Williams <williams@redhat.com> - 1.1.29-1
- move CLONE_NEWUTS to extended unshare options [BZ# 890695]
- make epel-5-* config files safe to eval [BZ# 903686]
- remove CLONE_NEWPID (for now) from unshare(2) call [BZ# 894623]
- initialize package_state_opts so that package_state plugin will work
- change default tests environment to be -i386
- From Tim Woods <timw.fedora@gmail.com>
  - Fix mockchain repo id calculation [BZ# 880849]
- From Tzafrir Cohen <tzafrir.cohen@xorcom.com>
  - Fix most bashism in test scripts
- From Seth Vidal <skvidal@fedoraproject.org>:
  - mockchain: allow for a non-username tmpdir prefix
  - mockchain: comma is a protected character make it _ instead

* Mon Sep 24 2012 Clark Williams <williams@redhat.com> - 1.1.28-1
- add updates-testing stanza to fedora-1x-*.cfg [BZ# 610826]
- modify scrub to handle non-existant chroots [BZ# 860368]

* Fri Sep  7 2012 Clark Williams <williams@redhat.com> - 1.1.27-1
- fixed configs test report to indicate configuration failure total
- remove dead code, unused array 'legal_arches'
- add an 'age_check' parameter to root_cache
- deal with NFS home directories and root_cache issues [BZ# 649192]
- from Mike Miller <mtmiller@ieee.org>:
  - Fix mock kernel version comparison [BZ# 847473]
- from Mathieu Bridon <bochecha@fedoraproject.org>:
  - fix various start/finish state problems [BZ# 835633]
- from Colin Walters <walters@redhat.com>:
  - add CLONE_NEWPID and CLONE_NEWIPC to unshare call [BZ# 851340]

* Fri Aug 10 2012 Dennis Gilmore <dennis@ausil.us> - 1.1.26-2
- add f18 configs
- add rawhide s390 config

* Mon Aug  6 2012 Clark Williams <williams@redhat.com> - 1.1.26-1
- move the fedora-17-ppc* configs into the configs directory

* Tue Jul 31 2012 Clark Williams <williams@redhat.com> - 1.1.25-1
- From Karsten Hopp <karsten@redhat.com>:
  - added ppc and ppc64 configs for fedora 17

* Fri Jul 27 2012 Clark Williams <williams@redhat.com> - 1.1.24-1
- Fixed error when calling os.getlogin() [BZ# 843434]
- removed fedora-15 config files
- from Matt McCutchen <matt@mattmccutchen.net>:
  - allowed common options to be added to yum commands [BZ# 734576]
- from Ville Skyttä <ville.skytta@iki.fi>:
  - added mockchain completion
- from Seth Vidal <skvidal@fedoraproject.org>:
  - added package_state_plugin

* Thu Jun  7 2012 Clark Williams <williams@redhat.com> - 1.1.23-1
  - modified startup code to only set mock group [BZ# 809676]
  - add CLONE_NEWUTS to unshare(2) call [BZ# 818445]
  - from Seth Vidal <skvidal at fedoraproject.org>:
    - add mockchain to mock [BZ# 812477]
  - from Marko Myllynen <myllynen@redhat.com>:
    - fix write_tar check in scm.py [BZ# 828677]
  - from Masatake YAMATO <yamato@redhat.com>:
    - added option to set a plugin parameter value [BZ# 754321]

* Thu Mar 29 2012 Clark Williams <williams@redhat.com> - 1.1.22-1
- fix SCM problem with SSH_AUTH_SOCK [BZ# 803217]
- From Chris St Pierre <chris.a.st.pierre@gmail.com>:
  - allow chroot group to be configure option

* Wed Feb  8 2012 Clark Williams <williams@redhat.com> - 1.1.21-1
- from Dennis Gilmore <dennis@ausil.us>
  - add Fedora 17 mock configs
  - have configs reflect the dropping of dist- for koji repos
  - add configs for arm hardware floating point

* Mon Jan 30 2012 Clark Williams <williams@redhat.com> - 1.1.20-1
- changed createrepo invocation to not be done inside the chroot [BZ# 783926]
- changed [local] repo definitions in f16+ configs [BZ# 753735]
- from Ville Skyttä <ville.skytta@iki.fi>
  - Allow setting https, ftp, and no proxy in addition to http.

* Mon Jan  2 2012 Clark Williams <williams@redhat.com> - 1.1.19-2
- fix missing files from Makefile.am

* Mon Jan  2 2012 Clark Williams <williams@redhat.com> - 1.1.19-1
- fix dangling symlink when using SCM [BZ# 758781]
- remove setting TMPDIR in chroot environment [BZ# 769728]
- add code to allow global proxy in chroot [BZ# 766199]
- explicitly set unprivileged umask in --shell [BZ# 747119]
- add bind-mount config to create sourcedirs [BZ# 706174]
- move mount management into classes
- update environment management code