'packaging-tag' : 'packaging/%(version)s',
'upstream-tag' : 'upstream/%(upstreamversion)s',
'pq-branch' : 'development/%(branch)s',
+ 'import-files' : ['.gbp.conf',
+ 'debian/gbp.conf'],
'spec-file' : 'auto',
'builder' : 'rpmbuild',
'cleaner' : '/bin/true',
'pq-branch':
"format string for the patch-queue branch name, default is "
"'%(pq-branch)s'",
+ 'import-files':
+ "Comma-separated list of additional file(s) to import from "
+ "packaging branch. These will appear as one monolithic patch "
+ "in the pq/development branch. Default is %(import-files)s",
'spec-file':
"Spec file to use, 'auto' makes gbp to guess, other values "
"make the packaging-dir option to be ignored, default is "
return GitModifier(match.group('name'), match.group('email'))
return GitModifier()
+def import_extra_files(repo, commitish, files):
+ """Import branch-specific gbp.conf files to current branch"""
+ found = {}
+ for fname in files:
+ if fname:
+ try:
+ found[fname] = repo.show('%s:%s' % (commitish, fname))
+ except GitRepositoryError:
+ pass
+ if found:
+ gbp.log.info("Importing additional file(s) from branch '%s' into '%s'" %
+ (commitish, repo.get_branch()))
+ for fname, content in found.iteritems():
+ dirname = os.path.dirname(fname)
+ if dirname and not os.path.exists(dirname):
+ os.makedirs(dirname)
+ with open(fname, 'w') as fobj:
+ fobj.write(content)
+
+ files = found.keys()
+ gbp.log.debug('Adding/commiting %s' % files)
+ repo.add_files(files, force=True)
+ commit_msg = ('Auto-import packaging file(s) from branch %s:\n'
+ ' %s\n\nGbp: Ignore\nGbp-Rpm: Ignore' % (commitish,
+ ' '.join(files)))
+ repo.commit_files(files, msg=commit_msg)
def import_spec_patches(repo, options):
"""
try:
gbp.log.info("Switching to branch '%s'" % pq_branch)
repo.set_branch(pq_branch)
+ import_extra_files(repo, base, options.import_files)
if not queue:
return
apply_and_commit_patch(repo, patch, fallback_author=None)
+def opt_split_cb(option, opt_str, value, parser):
+ """Split option string into a list"""
+ setattr(parser.values, option.dest, value.split(','))
+
+
def main(argv):
"""Main function for the gbp pq-rpm command"""
retval = 0
"this is used as the 'base' branch. Default is "
"'%(packaging-branch)s'")
parser.add_config_file_option(option_name="pq-branch", dest="pq_branch")
+ parser.add_config_file_option(option_name="import-files",
+ dest="import_files", type="string", action="callback",
+ callback=opt_split_cb)
parser.add_option("--export-rev", action="store", dest="export_rev",
default="",
help="Export patches from treeish object TREEISH instead of head "