#packaging-dir=rpm
# Spec file to be used
#spec-file = gbp.spec
+# Compress auto-generated patches
+#patch-compress=100k
# Export patches with numbering in filenames
#patch-numbers = False
'export-specdir' : 'SPECS',
'export-sourcedir' : 'SOURCES',
'spec-vcs-tag' : '',
+ 'patch-export' : 'False',
+ 'patch-compress' : '0',
'patch-import' : 'True',
'import-files' : ['.gbp.conf',
'debian/gbp.conf'],
'spec-vcs-tag':
"Set/update the 'VCS:' tag in the spec file, empty value "
"removes the tag entirely, default is '%(spec-vcs-tag)s'",
+ 'patch-export':
+ "Create patches between upstream and export-treeish, default "
+ "is '%(patch-export)s'",
+ 'patch-compress':
+ "Compress (auto-generated) patches larger than given number of "
+ "bytes, 0 never compresses, default is "
+ "'%(patch-compress)s'",
'patch-import':
"Import patches to the packaging branch, default is "
"'%(patch-import)s'",
"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",
- 'patch-export':
- "Create patches between upstream and export-treeish, default "
- "is '%(patch-export)s'",
'pristine-tarball-name':
"Filename to record to pristine-tar, set to 'auto' to not "
"mangle the file name, default is '%(pristine-tarball-name)s'",
git_archive_submodules,
git_archive_single, dump_tree,
write_wc, drop_index)
-from gbp.scripts.pq_rpm import parse_spec
+from gbp.scripts.pq_rpm import parse_spec, update_patch_series
def makedir(path):
return upstream_tree
+def export_patches(repo, spec, export_treeish, options):
+ """Generate patches and update spec file"""
+ upstream_tree = get_upstream_tree(repo, spec, options)
+ update_patch_series(repo, spec, upstream_tree, export_treeish, options)
+
+
def is_native(repo, options):
"""Determine whether a package is native or non-native"""
if options.native.is_auto():
export_group.add_config_file_option(option_name="spec-file",
dest="spec_file")
export_group.add_config_file_option("spec-vcs-tag", dest="spec_vcs_tag")
+ export_group.add_boolean_config_file_option("patch-export",
+ dest="patch_export")
+ export_group.add_option("--git-patch-export-rev", dest="patch_export_rev",
+ metavar="TREEISH",
+ help="Export patches from TREEISH")
+ export_group.add_boolean_config_file_option(option_name="patch-numbers",
+ dest="patch_numbers")
+ export_group.add_config_file_option("patch-compress", dest="patch_compress")
return parser
(prefix, prefix, prefix))
return None, None, None
+ options.patch_compress = rpm.string_to_int(options.patch_compress)
+
return options, args, builder_args
# Setup builder opts
setup_builder(options, builder_args)
+ # Generate patches, if requested
+ if options.patch_export and not is_native(repo, options):
+ if options.patch_export_rev:
+ patch_tree = get_tree(repo, options.patch_export_rev)
+ else:
+ patch_tree = tree
+ export_patches(repo, spec, patch_tree, options)
+
# Prepare final export dirs
export_dir = makedir(options.export_dir)
source_dir = makedir(os.path.join(export_dir,
import os
import re
import shutil
+import subprocess
import sys
import gbp.log
from gbp.patch_series import PatchSeries, Patch
from gbp.pkg import parse_archive_filename
from gbp.rpm import (SpecFile, NoSpecError, guess_spec, guess_spec_repo,
- spec_from_repo)
+ spec_from_repo, string_to_int)
from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base,
parse_gbp_commands, format_patch, format_diff,
apply_and_commit_patch, drop_pq)
merge_base = None
return merge_base == parent_sha1
+
+def compress_patches(patches, compress_size=0):
+ """
+ Rename and/or compress patches
+ """
+ ret_patches = []
+ for patch in patches:
+ # Compress if patch file is larger than "threshold" value
+ suffix = ''
+ if compress_size and os.path.getsize(patch) > compress_size:
+ gbp.log.debug("Compressing %s" % os.path.basename(patch))
+ subprocess.Popen(['gzip', '-n', patch]).communicate()
+ suffix = '.gz'
+
+ ret_patches.append(os.path.basename(patch) + suffix)
+ return ret_patches
+
+
def generate_patches(repo, start, end, outdir, options):
"""
Generate patch files from git
if patch_fn:
patches.append(patch_fn)
+ # Compress
+ patches = compress_patches(patches, options.patch_compress)
+
return patches, commands
parser.add_config_file_option(option_name="import-files",
dest="import_files", type="string", action="callback",
callback=optparse_split_cb)
+ parser.add_config_file_option("patch-compress",
+ dest="patch_compress")
return parser
parser = build_parser(argv[0])
if not parser:
return None, None
- return parser.parse_args(argv)
+
+ options, args = parser.parse_args(argv)
+ options.patch_compress = string_to_int(options.patch_compress)
+ return options, args
def main(argv):