CHANGE_PERSONALITY = {
- 'ia32': 'linux32',
- 'i686': 'linux32',
- 'i586': 'linux32',
- 'i386': 'linux32',
- 'ppc': 'powerpc32',
- 's390': 's390',
- 'sparc': 'linux32',
- 'sparcv8': 'linux32',
- }
+ 'ia32': 'linux32',
+ 'i686': 'linux32',
+ 'i586': 'linux32',
+ 'i386': 'linux32',
+ 'ppc': 'powerpc32',
+ 's390': 's390',
+ 'sparc': 'linux32',
+ 'sparcv8': 'linux32',
+ }
SUPPORTEDARCHS = [
- 'x86_64',
- 'i586',
- 'armv6l',
- 'armv7hl',
- 'armv7l',
- 'aarch64',
- 'mips',
- 'mipsel',
- ]
+ 'x86_64',
+ 'i586',
+ 'armv6l',
+ 'armv7hl',
+ 'armv7l',
+ 'aarch64',
+ 'mips',
+ 'mipsel',
+ ]
USERID = pwd.getpwuid(os.getuid())[0]
TMPDIR = None
for package_dir in package_dirs:
main_spec, rest_specs = guess_spec(package_dir, packaging_dir,
- None, commit)
+ None, commit)
rest_specs.append(main_spec)
for spec in rest_specs:
if args.include_all:
content = show_file_from_rev(package_dir, spec, commit)
if content is None:
raise GbsError('failed to checkout %s from commit: %s' %
- (spec, commit))
+ (spec, commit))
tmp_spec = Temp(content=content)
spec_to_parse = tmp_spec.path
cmd_opts = []
cache = Temp(prefix=os.path.join(TMPDIR, 'gbscache'),
- directory=True)
+ directory=True)
cachedir = cache.path
if not os.path.exists(cachedir):
os.makedirs(cachedir)
profile = configmgr.get_current_profile()
return profile
-
def main(args):
"""gbs build entry point."""
fn_changes = changes_file_list[0]
if len(changes_file_list) > 1:
log.warning("Found more than one changes files, %s is taken "
- % (changes_file_list[0]))
+ % (changes_file_list[0]))
else:
fn_changes = 'CHANGES'
'--spec-file=%s' % specfile,
'--changelog-file=%s' % fn_changes,
'--editor-cmd=%s' % get_editor_cmd(),
- ]
+ ]
if args.since:
gbp_args.append('--since=%s' % args.since)
if args.all:
raise GbsError(str(err))
tmp = Temp(prefix='gbp_', dirn=configmgr.get('tmpdir', 'general'),
- directory=True)
+ directory=True)
packaging_dir = get_packaging_dir(args)
# Guess spec from correct branch
ret = gbp_pq_rpm(gbp_args + ['convert'])
if not ret:
log.info("You can now create the development branch with "
- "'gbs devel start'")
+ "'gbs devel start'")
if ret:
raise GbsError('Action failed!')
argv.extend(["--git-patch-export",
"--git-patch-export-compress=100k",
"--git-patch-export-squash-until=%s" %
- squash_patches_until,
+ squash_patches_until,
"--git-patch-export-ignore-path=^(%s/.*|.gbs.conf)" %
- packaging_dir,
+ packaging_dir,
])
if orphan_packaging:
'--git-rpmbuild-srpmdir=.',
'--git-rpmbuild-buildrootdir=.',
'--short-circuit', '-bs',
- ])
+ ])
else:
argv.extend(["--git-builder=osc", "--git-export-only"])
Export packaging files using git-buildpackage
"""
tmp = utils.Temp(prefix='gbp_', dirn=configmgr.get('tmpdir', 'general'),
- directory=True)
+ directory=True)
gbp_args = create_gbp_export_args(repo, commit, export_dir, tmp.path,
spec, args, force_native=False,
mkdir_p(outdir)
tmpdir = configmgr.get('tmpdir', 'general')
- tempd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'), \
+ tempd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'),
directory=True)
export_dir = tempd.path
if rest_specs:
# backup updated spec file
specbakd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_export_'),
- directory=True)
- shutil.copy(os.path.join(export_dir,
- os.path.basename(main_spec)), specbakd.path)
+ directory=True)
+ shutil.copy(os.path.join(export_dir, os.path.basename(main_spec)),
+ specbakd.path)
for spec in rest_specs:
export_sources(repo, commit, export_dir, spec, args,
create_tarball=False)
- shutil.copy(os.path.join(export_dir,
- os.path.basename(spec)), specbakd.path)
+ shutil.copy(os.path.join(export_dir, os.path.basename(spec)),
+ specbakd.path)
# restore updated spec files
for spec in glob.glob(os.path.join(specbakd.path, "*.spec")):
shutil.copy(spec, export_dir)
shutil.move(export_dir, outdir)
if args.source_rpm:
- log.info('source rpm generated to:\n %s/%s.src.rpm' % \
- (outdir, os.path.basename(outdir)))
+ log.info('source rpm generated to:\n %s/%s.src.rpm' %
+ (outdir, os.path.basename(outdir)))
log.info('package files have been exported to:\n %s' % outdir)
"--upstream-branch=%s" % upstream_branch, path,
"--upstream-tag=%s" % upstream_tag,
"--tmp-dir=%s" % tmp.path,
- ]
+ ]
if args.debug:
params.append("--verbose")
if not args.no_pristine_tar and os.path.exists("/usr/bin/pristine-tar"):
apiurl = obsconf.url
if not apiurl.user:
- raise GbsError('empty user is not allowed for remotebuild, please '\
+ raise GbsError('empty user is not allowed for remotebuild, please '
'add user/passwd to gbs conf, and try again')
if args.commit and args.include_all:
raise Usage('--commit can\'t be specified together with '
- '--include-all')
+ '--include-all')
obs_repo = args.repository
obs_arch = args.arch
content = utils.show_file_from_rev(workdir, relative_spec, commit)
if content is None:
raise GbsError('failed to checkout %s from commit: %s' %
- (relative_spec, commit))
+ (relative_spec, commit))
tmp_spec = utils.Temp(content=content)
spec_to_parse = tmp_spec.path
api_passwd = apiurl.passwd if apiurl.passwd else ''
# Create temporary oscrc
- oscrc = OSCRC_TEMPLATE % {
- "http_debug": 1 if log.level == DEBUG else 0,
- "debug": 1 if log.level == DEBUG else 0,
- "apiurl": apiurl,
- "user": apiurl.user,
- "passwdx": encode_passwd(api_passwd),
- }
+ oscrc = OSCRC_TEMPLATE % {"http_debug": 1 if log.level == DEBUG else 0,
+ "debug": 1 if log.level == DEBUG else 0,
+ "apiurl": apiurl,
+ "user": apiurl.user,
+ "passwdx": encode_passwd(api_passwd),
+ }
tmpdir = configmgr.get('tmpdir', 'general')
tmpd = utils.Temp(prefix=os.path.join(tmpdir, '.gbs_remotebuild_'),
'no build log.' % (package, obs_repo, obs_arch,
status[obs_repo][obs_arch]))
log.info('build log for %s/%s/%s/%s' % (target_prj, package,
- obs_repo, obs_arch))
+ obs_repo, obs_arch))
print api.get_buildlog(target_prj, package, obs_repo, obs_arch)
return 0
api.rebuild(target_prj, package, obs_arch)
else:
log.warning("no local changes found. can't trigger rebuild "
- "as no available build repos found")
+ "as no available build repos found")
return 0
else:
log.info('commit packaging files to build server ...')
api.commit_files(target_prj, package, commit_files, commit_msg)
except ObsError as exc:
raise GbsError('commit packages fail: %s, please check the '
- 'permission of target project:%s' % (exc, target_prj))
+ 'permission of target project:%s' %
+ (exc, target_prj))
log.info('local changes submitted to build server successfully')
log.info('follow the link to monitor the build progress:\n'
- ' %s/package/show?package=%s&project=%s' \
- % (apiurl.replace('api', 'build'), package, target_prj))
+ '%s/package/show?package=%s&project=%s'
+ % (apiurl.replace('api', 'build'), package, target_prj))
user and system settings location
"""
- lookup_paths = (
- '.gbs/templates/submit_message',
- '~/.gbs/templates/submit_message',
- '/etc/gbs/templates/submit_message')
-
+ lookup_paths = ('.gbs/templates/submit_message',
+ '~/.gbs/templates/submit_message',
+ '/etc/gbs/templates/submit_message',
+ )
for path in lookup_paths:
abs_path = os.path.abspath(os.path.expanduser(path))
orphan_packaging = configmgr.get('packaging_branch', 'orphan-devel')
if orphan_packaging and args.commit == 'HEAD':
log.error("You seem to be submitting a development branch of an "
- "(orphan) packaging branch. Please export your changes to the "
- "packaging branch with 'gbs devel export' and submit from there.")
+ "(orphan) packaging branch. Please export your changes to"
+ "the packaging branch with 'gbs devel export' and submit"
+ "from there.")
raise GbsError("Refusing to submit from devel branch")
message = args.msg
args.remote = upstream.split('/')[0]
else:
log.info("no upstream set for the current branch, using "
- "'origin' as the remote server")
+ "'origin' as the remote server")
args.remote = 'origin'
return
with open(self._fpname, 'w') as fptr:
- buf = ''.join([line for line in self._flines if line is not None ])
+ buf = ''.join([line for line in self._flines if line is not None])
fptr.write(buf)
'''Support multi-levels of gbs.conf. Use this class to get and set
item value without caring about concrete ini format'''
- DEFAULTS = {
- 'general': {
- 'tmpdir': '/var/tmp',
- 'editor': '',
- 'packaging_branch': 'master',
- 'upstream_branch': 'upstream',
- 'upstream_tag': 'upstream/${upstreamversion}',
- 'squash_patches_until': '',
- 'buildroot': '~/GBS-ROOT/',
- 'packaging_dir': 'packaging',
- 'work_dir': '.',
- 'fallback_to_native': '',
- },
- 'orphan-devel': {
- 'packaging_branch': '',
- },
- }
+ DEFAULTS = {'general': {'tmpdir': '/var/tmp',
+ 'editor': '',
+ 'packaging_branch': 'master',
+ 'upstream_branch': 'upstream',
+ 'upstream_tag': 'upstream/${upstreamversion}',
+ 'squash_patches_until': '',
+ 'buildroot': '~/GBS-ROOT/',
+ 'packaging_dir': 'packaging',
+ 'work_dir': '.',
+ 'fallback_to_native': '',
+ },
+ 'orphan-devel': {'packaging_branch': '',
+ },
+ }
DEFAULT_CONF_TEMPLATE = '''[general]
#Current profile name which should match a profile section name
# empty string password is acceptable here
continue
cfgparser.set_into_file(sec,
- key + 'x',
- encode_passwd(plainpass),
- key)
+ key + 'x',
+ encode_passwd(plainpass),
+ key)
dirty.add(cfgparser)
if dirty:
raise errors.ConfigError(err)
log.warning('subcommand oriented style of config is deprecated. '
- 'Please check %s, a new profile oriented style of config which'
- ' was converted from your current settings.' % fname)
+ 'Please check %s, a new profile oriented style of config '
+ ' which was converted from your current settings.' % fname)
def get_optional_item(self, section, option, default=None):
'''return default if section.option does not exist'''
def build_profile_by_name(self, name):
'''return profile object by a given section'''
if not name.startswith('profile.'):
- raise errors.ConfigError('section name specified by general.profile'
- ' must start with string "profile.": %s' % name)
+ raise errors.ConfigError('section name specified by '
+ ' general.profile must start with string'
+ ' "profile.": %s' % name)
if not self.has_section(name):
raise errors.ConfigError('no such section: %s' % name)
profile.buildroot = self.get_optional_item(name, 'buildroot')
if self.get_optional_item(name, 'buildconf'):
profile.buildconf = os.path.expanduser(self._interpolate(
- self.get_optional_item(name,
- 'buildconf')))
+ self.get_optional_item(name, 'buildconf')))
if self.get_optional_item(name, 'exclude_packages'):
exclude_val = self.get_optional_item(name, 'exclude_packages')
for pkg in exclude_val.split(','):
if pkg.strip():
- profile.exclude_packages.append(pkg.strip());
+ profile.exclude_packages.append(pkg.strip())
return profile
password = self.get_optional_item(sec, 'passwd')
url = URL(addr, user, password)
- obsconf = SectionConf(profile, 'obs.%s' % sec, url,
- self.get_optional_item('remotebuild', 'base_prj'),
- self.get_optional_item('remotebuild', 'target_prj'))
+ obsconf = SectionConf(profile,
+ 'obs.%s' % sec, url,
+ self.get_optional_item('remotebuild',
+ 'base_prj'),
+ self.get_optional_item('remotebuild',
+ 'target_prj'))
profile.set_obs(obsconf)
repos = self._parse_build_repos()
# Change logging level names to lower case
for level in (DEBUG, INFO, WARNING, ERROR):
- gbp.log.logging.addLevelName(level,
- gbp.log.logging.getLevelName(level).lower())
+ gbp.log.logging.addLevelName(level, \
+ gbp.log.logging.getLevelName(level).lower())
# Set verbosity
verbose = verbose or debug
if verbose:
meta += "</repository>\n"
else:
logger.warning('no project repos in target project, please add '
- 'repos from OBS webUI manually, or specify base project '
- 'with -B <base_prj>, then gbs can help to set repos '
- 'using the settings of the specified base project.')
+ 'repos from OBS webUI manually, or specify base '
+ 'project with -B <base_prj>, then gbs can help to '
+ 'set repos using the settings of the specified '
+ 'base project.')
meta += "</project>\n"
try:
# This regular expression is created for parsing the
# results of of core.get_results()
stat_re = re.compile(r'^(?P<repo>\S+)\s+(?P<arch>\S+)\s+'
- '(?P<status>\S*)$')
+ '(?P<status>\S*)$')
for res in build_status:
match = stat_re.match(res)
if match:
if os.path.islink(packaging_dir):
packaging_dir = os.readlink(packaging_dir)
check = lambda fname, dir_only=False: os.path.exists(os.path.join(
- git_path, fname))
- glob_ = lambda pattern: [name.replace(git_path+'/', '')
+ git_path, fname))
+ glob_ = lambda pattern: [name.replace(git_path+'/', '') \
for name in reversed(glob.glob(os.path.join(git_path, pattern)))]
msg = 'No such spec file %s'
else:
if not output.startswith('tree %s' % git_object):
# packaging_dir is a symlink
packaging_dir = output
- check = lambda fname, dir_only=False : file_exists_in_rev(git_path,
- fname, commit_id, dir_only=dir_only)
+ check = lambda fname, dir_only=False: file_exists_in_rev(git_path,
+ fname,
+ commit_id, \
+ dir_only=dir_only)
glob_ = lambda pattern: glob_in_rev(git_path, pattern, commit_id)
msg = "No such spec file %%s in %s" % commit_id
'NO_PROXY', 'no_proxy']:
proxies.append('%s=%s' % (key, env.get(key, '')))
raise UrlError("connect timeout to %s, maybe it's caused by "
- "proxy settings, please check. %s" % (curl.url,
+ "proxy settings, please check. %s" % (curl.url, \
'\n '.join(proxies)))
elif errcode == pycurl.E_ABORTED_BY_CALLBACK:
raise KeyboardInterrupt(err)
'buildconf' not in meta or \
not meta['buildconf']:
log.warning("No build.conf in build.xml "
- "of repo: %s" % latest_repo_url)
+ "of repo: %s" % latest_repo_url)
return
buildconf_url = latest_repo_url.pathjoin('builddata/%s' %
if not is_clean and opts.include_all:
if untracked_files:
log.info('the following untracked files would be included'
- ':\n %s' % '\n '.join(untracked_files))
+ ':\n %s' % '\n '.join(untracked_files))
if uncommitted_files:
log.info('the following uncommitted changes would be included'
- ':\n %s' % '\n '.join(uncommitted_files))
+ ':\n %s' % '\n '.join(uncommitted_files))
def hexdigest(fhandle, block_size=4096):
"""Calculate hexdigest of file content."""
GBS = imp.load_source("gbs", "./tools/gbs").main
ENV = {}
-TEST_SPEC_CONTENT="""
+TEST_SPEC_CONTENT = """
Name: test
Version: 1.0
Release: 0
self.fake_files = {self.ETC: etc,
self.HOME: home,
self.PROJECT: project,
- }
+ }
self.real_exists = os.path.exists
self.real_abspath = os.path.abspath
def test_subcommand_help():
"""Test running gbs help with all possible subcommands."""
for sub in ["build", "lb", "remotebuild", "rb", "changelog", "ch",
- "submit", "sr", "export", "ex", "import", "im",
- "chroot", "chr"]:
+ "submit", "sr", "export", "ex", "import", "im",
+ "chroot", "chr"]:
try:
print '>>>sub', sub
if __name__ == '__main__':
- unittest.main()
\ No newline at end of file
+ unittest.main()