Commit 422ae854 authored by Guido Günther's avatar Guido Günther

Add gbp buildpackage-rpm

This adds a minimal gbp buildpackage-rpm based on Markus Lehtonens work.
parent 7ce69de2
usr/lib/python2.?/dist-packages/gbp/rpm/
usr/lib/python2.7/dist-packages/gbp/scripts/import_srpm.py
usr/lib/python2.7/dist-packages/gbp/scripts/pq_rpm.py
usr/lib/python2.7/dist-packages/gbp/scripts/buildpackage_rpm.py
......@@ -12,6 +12,7 @@ MAN1S = \
gbp-import-orig \
gbp-pq \
gbp-pull \
gbp-buildpackage-rpm \
$(NULL)
MAN5S = gbp.conf
......
......@@ -4,6 +4,7 @@
<!ENTITY dhconfsection "<manvolnum>5</manvolnum>">
<!ENTITY dhemail "<email>agx@sigxcpu.org</email>">
<!ENTITY dhusername "Guido Guenther">
<!ENTITY gbp-buildpackage "<command>gbp buildpackage</command>">
<!ENTITY gbp-import-orig "<command>gbp import-orig</command>">
<!ENTITY gbp-import-dsc "<command>gbp import-dsc</command>">
......@@ -24,6 +25,17 @@
<!ENTITY debuildcmd "<command>debuild</command>">
<!ENTITY gbp.conf "<filename>gbp.conf</filename>">
<!ENTITY rpm-firstname "<firstname>Markus</firstname>">
<!ENTITY rpm-surname "<surname>Lehtonen</surname>">
<!ENTITY rpm-email "<email>markus.lehtonen@linux.intel.com</email>">
<!ENTITY rpm-username "Markus Lehtonen">
<!ENTITY rpm-mansection "<manvolnum>1</manvolnum>">
<!ENTITY gbp-buildpackage-rpm "<command>gbp buildpackage-rpm</command>">
<!ENTITY gbp-import-srpm "<command>gbp import-srpm</command>">
<!ENTITY gbp-pq-rpm "<command>gbp pq-rpm</command>">
<!ENTITY rpmbuild "<command>rpmbuild</command>">
<!ENTITY wget "<command>wget</command>">
<!ENTITY debian "<productname>Debian</productname>">
<!ENTITY git "<productname>Git</productname>">
<!ENTITY dch "<productname>dch</productname>">
......
<!DOCTYPE reference PUBLIC "-//OASIS//DTD DocBook V4.1//EN"
[
<!ENTITY % COMMON SYSTEM "common.ent">
%COMMON;
<!ENTITY % MANPAGES SYSTEM "manpages/manpages.ent">
%MANPAGES;
]>
<reference>
<title>git-buildpackage Manual</title>
&man.gbp.buildpackage.rpm;
</reference>
This diff is collapsed.
......@@ -12,5 +12,6 @@
<!ENTITY man.gbp.conf SYSTEM "gbp.conf.sgml">
<!ENTITY man.gbp.config-files SYSTEM "man.conffiles.sgml">
<!ENTITY man.seealso.common SYSTEM "man.seealso.sgml">
<!ENTITY man.gbp.buildpackage.rpm SYSTEM "gbp-buildpackage-rpm.sgml">
<!ENTITY % COMMON.OPTIONS SYSTEM "man.common-options.ent">
%COMMON.OPTIONS;
# vim: set fileencoding=utf-8 :
#
# (C) 2006,2007,2010-2012 Guido Guenther <agx@sigxcpu.org>
# (C) 2006,2007,2010-2012,2015 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
......@@ -101,6 +101,7 @@ class GbpOptionParser(OptionParser):
'sign-tags' : 'False',
'force-create' : 'False',
'no-create-orig' : 'False',
'cleaner' : '/bin/true',
'keyid' : '',
'posttag' : '',
'postbuild' : '',
......@@ -577,7 +578,6 @@ class GbpOptionParserDebian(GbpOptionParser):
defaults = dict(GbpOptionParser.defaults)
defaults.update( {
'builder' : 'debuild -i -I',
'cleaner' : '/bin/true',
} )
......@@ -591,7 +591,13 @@ class GbpOptionParserRpm(GbpOptionParser):
'vendor' : 'Downstream',
'packaging-branch' : 'master',
'packaging-dir' : '',
'packaging-tag-msg' : ('%(pkg)s (vendor)s release '
'%(version)s'),
'packaging-tag' : 'packaging/%(version)s',
'export-sourcedir' : 'SOURCES',
'export-specdir' : 'SPECS',
'export-dir' : '../rpmbuild',
'builder' : 'rpmbuild',
'spec-file' : '',
})
......@@ -612,9 +618,19 @@ class GbpOptionParserRpm(GbpOptionParser):
'packaging-tag':
"Format string for packaging tags, RPM counterpart of the "
"'debian-tag' option, default is '%(packaging-tag)s'",
'packaging-tag-msg':
("Format string for packaging tag messages, "
"default is '%(packaging-tag-msg)s'"),
'spec-file':
"Spec file to use, causes the packaging-dir option to be "
"ignored, default is '%(spec-file)s'",
'export-sourcedir':
"Subdir (under EXPORT_DIR) where packaging sources (other than "
"the spec file) are exported, default is "
"'%(export-sourcedir)s'",
'export-specdir':
"Subdir (under EXPORT_DIR) where package spec file is "
"exported default is '%(export-specdir)s'",
})
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
This diff is collapsed.
......@@ -12,8 +12,8 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, please see
# <http://www.gnu.org/licenses/>
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Temporary directory handling"""
import os
......
......@@ -247,6 +247,7 @@ done
%{python_sitelib}/gbp/scripts/*rpm*.py*
%{python_sitelib}/gbp/rpm/*py*
%if %{with docs}
%{_mandir}/man1/gbp-buildpackage-rpm.1*
%endif
......
Subproject commit bae44ddc98ae0ed15ae078cb7c2fc597dee48da5
Subproject commit bea3aa372447b2fca611f187c2daa55edd8cdb3f
# vim: set fileencoding=utf-8 :
#
# (C) 2013-2015 Intel Corporation <markus.lehtonen@linux.intel.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Unit tests for the gbp-buildpackage-rpm tool"""
import glob
import mock
import os
import re
import shutil
import stat
import subprocess
from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611
from gbp.git import GitRepository
from gbp.scripts.buildpackage_rpm import main as gbp_rpm
from tests.component.rpm import RpmRepoTestBase, RPM_TEST_DATA_DIR
from tests.testutils import ls_dir, ls_tar
# Disable "Method could be a function warning"
# pylint: disable=R0201
# Disable "Too many public methods"
# pylint: disable=R0904
DATA_DIR = os.path.join(RPM_TEST_DATA_DIR, 'rpm')
ORIG_DATA_DIR = os.path.join(RPM_TEST_DATA_DIR, 'orig')
MOCK_NOTIFICATIONS = []
def mock_gbp(args):
"""Wrapper for gbp-buildpackage-rpm"""
return gbp_rpm(['arg0', '--git-notify=off','--git-ignore-branch']
+ args
+ ['-ba', '--clean', '--target=noarch', '--nodeps'])
def mock_notify(summary, message, notify_opt):
"""Mock notification system"""
# Auto will succeed
if notify_opt.is_auto():
MOCK_NOTIFICATIONS.append((summary, message))
return True
# Otherwise fail
return False
class TestGbpRpm(RpmRepoTestBase):
"""Basic tests for gbp buildpackage-rpm"""
@staticmethod
def ls_rpm(rpm):
"""List the contents of an rpm package"""
args = ['rpm', '-q', '--qf',
'[%{FILEDIGESTS %{FILEMODES} %{FILENAMES}\n]', '-p']
popen = subprocess.Popen(args + [rpm], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = popen.communicate()
if popen.returncode:
raise Exception("Failed to get file metadata for %s: %s" %
(rpm, stderr))
return sorted([(nam, mod, dig) for dig, mod, nam in
[lin.split(None, 2) for lin in stdout.splitlines()]])
@staticmethod
def check_rpms(directory):
"""Check build results"""
# Only check files, at least for now
files = glob.glob(directory + '/*rpm')
assert files, "No rpms (%s)found in %s" % (files, directory)
for path in files:
ref_file = os.path.join(DATA_DIR, os.path.basename(path))
eq_(TestGbpRpm.ls_rpm(path), TestGbpRpm.ls_rpm(ref_file))
@staticmethod
def check_and_rm_file(filepath, content):
"""Check file content and remove it"""
with open(filepath) as fobj:
eq_(fobj.read(), content)
os.unlink(filepath)
@classmethod
def setup_class(cls, **kwargs):
"""Setup unit tests"""
super(TestGbpRpm, cls).setup_class(**kwargs)
def test_outside_repo(self):
"""Run outside a git repository"""
eq_(mock_gbp([]), 1)
self._check_log(0, 'gbp:error: %s is not a git repository' %
os.path.abspath('.'))
def test_invalid_config_file(self):
"""Test invalid config file"""
# Create and commit dummy invalid config file
repo = GitRepository.create('.')
with open('.gbp.conf', 'w') as conffd:
conffd.write('foobar\n')
repo.add_files('.gbp.conf')
repo.commit_all('Add conf')
eq_(mock_gbp([]), 1)
self._check_log(0, 'gbp:error: File contains no section headers.')
def test_native_build(self):
"""Basic test of native pkg"""
self.init_test_repo('gbp-test-native')
eq_(mock_gbp([]), 0)
c = os.path.abspath(os.path.curdir)
self.check_rpms('../rpmbuild/RPMS/*')
shutil.rmtree('../rpmbuild')
"""Test --git-cleaner option"""
self.init_test_repo('gbp-test-native')
# Make repo dirty
with open('untracked-file', 'w') as fobj:
fobj.write('this file is not tracked\n')
# Build on dirty repo should fail
eq_(mock_gbp([]), 1)
# Build should succeed with cleaner
eq_(mock_gbp(['--git-cleaner=rm untracked-file']), 0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment