import gbp.rpm as rpm
from gbp.errors import GbpError
-change_personality = {
+CHANGE_PERSONALITY = {
'i686': 'linux32',
'i586': 'linux32',
'i386': 'linux32',
'sparcv8': 'linux32',
}
-obsarchmap = {
- 'i686': 'i586',
- 'i586': 'i586',
- }
-
-buildarchmap = {
+BUILDARCHMAP = {
'ia32': 'i686',
'i686': 'i686',
'i586': 'i686',
'i386': 'i686',
}
-supportedarchs = [
+SUPPORTEDARCHS = [
'ia32',
'i686',
'i586',
# register qemu emulator for interpreting other arch executable file
if not os.path.exists(node):
- qemu_arm_string = ":arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfa\\xff\\xff\\xff:%s:" % qemu_emulator
+ qemu_arm_string = ":arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00"\
+ "\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff"\
+ "\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff"\
+ "\\xff\\xff\\xff\\xff\\xff\\xfa\\xff\\xff\\xff:%s:" \
+ % qemu_emulator
try:
(tmpfd, tmppth) = tempfile.mkstemp()
os.write(tmpfd, "echo '%s' > /proc/sys/fs/binfmt_misc/register" \
msger.error(str(err))
if not opts.incremental:
- utils.gitStatusChecker(repo, opts)
+ utils.git_status_checker(repo, opts)
workdir = repo.path
hostarch = get_hostarch()
else:
buildarch = hostarch
msger.info('No arch specified, using system arch: %s' % hostarch)
- if buildarch in buildarchmap:
- buildarch = buildarchmap[buildarch]
+ if buildarch in BUILDARCHMAP:
+ buildarch = BUILDARCHMAP[buildarch]
- if not buildarch in supportedarchs:
+ if not buildarch in SUPPORTEDARCHS:
msger.error('arch %s not supported, supported archs are: %s ' % \
- (buildarch, ','.join(supportedarchs)))
+ (buildarch, ','.join(SUPPORTEDARCHS)))
build_cmd = configmgr.get('build_cmd', 'build')
userid = configmgr.get('user', 'remotebuild')
extrapkgs = opts.extra_packs.split(',')
cmd += ['--extra-packs=%s' % ' '.join(extrapkgs)]
- if hostarch != buildarch and buildarch in change_personality:
- cmd = [ change_personality[buildarch] ] + cmd
+ if hostarch != buildarch and buildarch in CHANGE_PERSONALITY:
+ cmd = [ CHANGE_PERSONALITY[buildarch] ] + cmd
proxies = get_env_proxies()
# Parse spec file
try:
- spec = rpm.parse_spec(os.path.join(export_dir, os.path.basename(specfile)))
+ spec = rpm.parse_spec(os.path.join(export_dir,
+ os.path.basename(specfile)))
except GbpError, err:
msger.error('%s' % err)
def make_log_entries(commits, git_repo):
"""Make changelog entries from the set of git commits."""
entries = []
- prevauthor = None
# Add header
author = git_repo.get_author_info()
entries.append("* %s %s <%s> %s" % \
for commit in commits:
commit_info = git_repo.get_commit_info(commit)
entries.append("- %s" % commit_info["subject"])
- prevauthor = commit_info["author"].name
return entries
from gitbuildsys import msger
from gitbuildsys.conf import configmgr
-def do(opts, args):
+def do(opts, _args):
if opts.arch in ['ia32', 'i686', 'i586', 'i386']:
arch = 'i686'
try:
subprocess.call(['sudo', 'cp', '/etc/resolv.conf', build_root + \
'/etc/resolv.conf'])
- except:
+ except OSError:
msger.warning('failed to setup /etc/resolv.conf')
try:
build_env = os.environ
- build_env['PS1']="(tizen-build-env)@\h \W]\$ "
+ build_env['PS1'] = "(tizen-build-env)@\h \W]\$ "
subprocess.call(cmd, env=build_env)
except OSError, err:
msger.error('failed to chroot to %s: %s' % (build_root, err))
except GitRepositoryError, err:
msger.error(str(err))
- utils.gitStatusChecker(repo, opts)
+ utils.git_status_checker(repo, opts)
workdir = repo.path
if not os.path.exists("%s/packaging" % workdir):
msger.error("Repository error: %s" % excobj)
try:
- spec = rpm.parse_spec(os.path.join(export_dir, os.path.basename(specfile)))
+ spec = rpm.parse_spec(os.path.join(export_dir,
+ os.path.basename(specfile)))
except GbpError, err:
msger.error('%s' % err)
import os
import glob
-import shutil
-
from gitbuildsys import msger, errors, utils
msger.error(str(err))
if not (opts.buildlog or opts.status):
- utils.gitStatusChecker(repo, opts)
+ utils.git_status_checker(repo, opts)
workdir = repo.path
# TODO: check ./packaging dir at first
}
tmpdir = configmgr.get('tmpdir', 'general')
- tmpd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_remotebuild_'), directory=True)
+ tmpd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_remotebuild_'),
+ directory=True)
exportdir = tmpd.path
tmpf = utils.Temp(dirn=exportdir, prefix='.oscrc', content=oscrc)
oscrcpath = tmpf.path
the sections and keys
"""
- def _get_savekey(sec, opt):
- return "%s.%s" % (sec, opt)
-
# save the original filepath and contents
self._fpname = fname
self._flines = fptr.readlines()
value = line.strip()
if value:
cursect[optname] = "%s\n%s" % (cursect[optname], value)
- savekey = _get_savekey(cursect['__name__'], optname)
+ savekey = "%s.%s" % (cursect['__name__'], optname)
self._opt_linenos[savekey].append(lineno)
# a section header or option header?
else:
optval = ''
optname = self.optionxform(optname.rstrip())
cursect[optname] = optval
- savekey = _get_savekey(cursect['__name__'], optname)
+ savekey = "%s.%s" % (cursect['__name__'], optname)
self._opt_linenos[savekey] = [lineno]
else:
def __init__(self, fpath=None):
self.cfgparser = BrainConfigParser()
self.reset_from_conf(fpath)
+ self.replaced_keys = defaultdict(list)
def reset_from_conf(self, fpath):
if fpath:
if not os.path.exists(fpath):
- raise errors.ConfigError('Configuration file %s does not exist' % fpath)
+ raise errors.ConfigError('Configuration file %s does not '\
+ 'exist' % fpath)
fpaths = [fpath]
else:
# use the default path
raise errors.ConfigError('config file error:%s' % err)
self._check_passwd()
- def _lookfor_confs(self):
+ @staticmethod
+ def _lookfor_confs():
"""Look for available config files following the order:
> Global
> User
cmd = cmdln_or_args
msg = 'running command: "%s"' % cmd
- if out: out = out.strip()
+ if out:
+ out = out.strip()
if out:
msg += ', with output::'
msg += '\n +----------------'
try:
curl.perform()
- except pycurl.error, e:
- errcode = e.args[0]
+ except pycurl.error, err:
+ errcode = err.args[0]
if errcode == pycurl.E_OPERATION_TIMEOUTED:
- raise errors.UrlError('timeout on %s: %s' % (url, e))
+ raise errors.UrlError('timeout on %s: %s' % (url, err))
elif errcode == pycurl.E_FILESIZE_EXCEEDED:
raise errors.UrlError('max download size exceeded on %s'\
% url)
else:
- errmsg = 'pycurl error %s - "%s"' % (errcode, str(e.args[1]))
+ errmsg = 'pycurl error %s - "%s"' % (errcode, str(err.args[1]))
raise errors.UrlError(errmsg)
finally:
outfile.close()
self.parse()
def get_buildconf(self):
- elementTree = ET.parse(self.buildmeta)
- root = elementTree.getroot()
- buildElem = root.find('buildconf')
- if buildElem is None:
+ etree = ET.parse(self.buildmeta)
+ buildelem = etree.getroot().find('buildconf')
+ if buildelem is None:
return None
- buildconf = buildElem.text.strip()
-
- return buildconf
+ return buildelem.text.strip()
def build_repos_from_buildmeta(self, baseurl):
if not (self.buildmeta and os.path.exists(self.buildmeta)):
return
- elementTree = ET.parse(self.buildmeta)
- root = elementTree.getroot()
+ etree = ET.parse(self.buildmeta)
+ root = etree.getroot()
archs = []
repos = []
repo_items = root.find('repos')
if self.buildmeta:
self.buildconf = None
break
- pass
# Check if it's repo with builddata/build.xml exist
buildxml_url = os.path.join(repo, 'builddata/build.xml')
return None
-def gitStatusChecker(git, opts):
+def git_status_checker(git, opts):
try:
if opts.commit:
git.rev_parse(opts.commit)
- is_clean, out = git.is_clean()
+ is_clean = git.is_clean()[0]
status = git.status()
except (GbpError, GitRepositoryError), err:
msger.error(str(err))
import re
from distutils.core import setup
+
try:
import setuptools
# enable "setup.py develop", optional
if len(sys.argv) > 1 and 'install' in sys.argv:
try:
import platform
- (dist, ver, rid) = platform.linux_distribution()
-
# for debian-like distros, mods will be installed to
# ${PYTHONLIB}/dist-packages
- if dist in ('debian', 'Ubuntu'):
+ if platform.linux_distribution()[0] in ('debian', 'Ubuntu'):
sys.argv.append('--install-layout=deb')
- except:
+ except Exception:
pass
setup(name='gbs',