From e360a62f67aaf616bb55ebd56dae8cce6803e91e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 30 2017 11:31:06 +0000 Subject: [PATCH 1/4] Let simple-koji-ci use a custom mock config using nspawn with networking Signed-off-by: Pierre-Yves Chibon --- diff --git a/MANIFEST.in b/MANIFEST.in index b3b0353..ddbdc31 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,5 @@ graft fedmsg.d include *.rst include LICENSE requirements.txt dev-requirements.txt +include simple_koji_ci.spec +include simple_koji_ci.cfg diff --git a/README.rst b/README.rst index 5b78d9b..70d7f52 100644 --- a/README.rst +++ b/README.rst @@ -11,6 +11,10 @@ Set up your environment with:: $ python setup.py develop $ python setup.py build +Install the custom mock configuration:: + + $ cp simple_koji_ci.cfg /etc/mock/ + And then run it with:: $ fedmsg-hub diff --git a/simple-koji-ci.spec b/simple-koji-ci.spec index eb74260..c9df402 100644 --- a/simple-koji-ci.spec +++ b/simple-koji-ci.spec @@ -20,12 +20,14 @@ Source0: https://releases.pagure.org/simple-koji-ci BuildArch: noarch BuildRequires: fedmsg +BuildRequires: mock BuildRequires: python2-devel BuildRequires: python-setuptools BuildRequires: python2-dogpile-cache BuildRequires: python2-six Requires: fedmsg +Requires: mock Requires: python2-requests Requires: python2-dogpile-cache Requires: python2-six @@ -46,12 +48,18 @@ rm -rf %{modname}.egg-info %install %{__python2} setup.py install -O1 --skip-build --root=%{buildroot} +# Install the custom mock config +install -p -m 644 simple_koji_ci.cfg \ + $RPM_BUILD_ROOT/%{_sysconfdir}/mock/simple_koji_ci.cfg + + # setuptools installs these, but we don't want them. rm -rf %{buildroot}%{python2_sitelib}/tests/ %files %doc README.rst %license LICENSE +%{_sysconfdir}/mock/simple_koji_ci.cfg %{python2_sitelib}/simple_koji_ci/ %{python2_sitelib}/simple_koji_ci-%{version}* diff --git a/simple_koji_ci.cfg b/simple_koji_ci.cfg new file mode 100644 index 0000000..cf0bd67 --- /dev/null +++ b/simple_koji_ci.cfg @@ -0,0 +1,10 @@ +# mock configuration for simple_koji_ci +# vim:tw=0:ts=4:sw=4:et: + +# Include the default mock configuration +include('/etc/mock/default.cfg') + +# Mock uses systemd-nspawn(1) by default. but let's be explicit and allow +# nspawn to have network access. +config_opts['use_nspawn'] = True +config_opts['rpmbuild_networking'] = True diff --git a/simple_koji_ci/buildsys.py b/simple_koji_ci/buildsys.py index 6818d79..74d551f 100644 --- a/simple_koji_ci/buildsys.py +++ b/simple_koji_ci/buildsys.py @@ -159,10 +159,11 @@ class Koji(object): # Create the SRPM cmd = [ - 'mock', '--buildsrpm', '--define', - '%_disable_source_fetch 0', '--spec', specfile, - '--sources', tmp, '--resultdir', tmp, - '--old-chroot', + 'mock', '-r', 'simple_koji_ci.cfg', '--buildsrpm', + '--define', '%_disable_source_fetch 0', + '--spec', specfile, + '--sources', tmp, + '--resultdir', tmp, ] _log.info("Calling %r" % ' '.join(cmd)) output = sp.check_output( From 45ef8fb2124dec9712eaf3661b8285a2474a767c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 30 2017 14:37:49 +0000 Subject: [PATCH 2/4] Small style fix Signed-off-by: Pierre-Yves Chibon --- diff --git a/setup.py b/setup.py index 55ad2d3..c9ee5af 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,8 @@ setup( url='https://pagure.io/simple-koji-ci', install_requires=get_requirements(), tests_require=get_requirements('dev-requirements.txt'), - packages=find_packages(exclude=('simple_koji_ci.tests', 'simple_koji_ci.tests.*')), + packages=find_packages( + exclude=('simple_koji_ci.tests', 'simple_koji_ci.tests.*')), test_suite='simple_koji_ci.tests', entry_points=""" [moksha.consumer] From 0d556ab44b725961007c70b8d89bd111d2104b5b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 31 2017 12:10:54 +0000 Subject: [PATCH 3/4] Drop the call to mock --init, --buildsrpm does it by default Signed-off-by: Pierre-Yves Chibon --- diff --git a/simple_koji_ci/buildsys.py b/simple_koji_ci/buildsys.py index 74d551f..3de6b8b 100644 --- a/simple_koji_ci/buildsys.py +++ b/simple_koji_ci/buildsys.py @@ -147,16 +147,6 @@ class Koji(object): specfile = tmp + '/' + package + '.spec' - # Initialize the mock env - cmd = ['mock', '--init'] - _log.info("Calling %r" % ' '.join(cmd)) - output = sp.check_output( - cmd, - cwd=tmp, - stderr=sp.STDOUT, - ) - _log.debug(output) - # Create the SRPM cmd = [ 'mock', '-r', 'simple_koji_ci.cfg', '--buildsrpm', From bc50e1ad8c737b271313a90616cc063b81c4b09a Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 31 2017 12:11:49 +0000 Subject: [PATCH 4/4] Pass the full path to the custom mock config when building the srpm Signed-off-by: Pierre-Yves Chibon --- diff --git a/simple_koji_ci/buildsys.py b/simple_koji_ci/buildsys.py index 3de6b8b..f0a1e15 100644 --- a/simple_koji_ci/buildsys.py +++ b/simple_koji_ci/buildsys.py @@ -149,7 +149,8 @@ class Koji(object): # Create the SRPM cmd = [ - 'mock', '-r', 'simple_koji_ci.cfg', '--buildsrpm', + 'mock', '-r', '/etc/mock/simple_koji_ci.cfg', + '--buildsrpm', '--define', '%_disable_source_fetch 0', '--spec', specfile, '--sources', tmp,