#packaging-dir=rpm
# Spec file to be used
#spec-file = gbp.spec
+# Compress auto-generated patches
+#patch-export-compress=100k
# Export patches with numbering in filenames
#patch-numbers = False
'rpmbuild-srpmdir' : 'SRPMS',
'rpmbuild-buildrootdir' : 'BUILDROOT',
'patch-export' : 'False',
+ 'patch-export-compress' : '0',
'pristine-tarball-name' : 'auto',
} )
"build with untracked files in the source tree, default is '%(ignore-untracked)s'",
'patch-export':
"Create patches between upstream and export-treeish, default is '%(patch-export)s'",
+ 'patch-export-compress':
+ "Compress (auto-generated) patches larger than given number of bytes, 0 never compresses, default is '%(patch-export-compress)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'",
} )
raise NoSpecError, "Searching spec from other branch not implemented yet"
+def string_to_int(val_str):
+ """
+ Convert string of possible unit identifier to int.
+
+ @param val_str: value to be converted
+ @type val_str: C{str}
+ @return: value as integer
+ @rtype: C{int}
+
+ >>> string_to_int("1234")
+ 1234
+ >>> string_to_int("123k")
+ 125952
+ >>> string_to_int("1234K")
+ 1263616
+ >>> string_to_int("1M")
+ 1048576
+ """
+ units = {'k': 1024,
+ 'm': 1024**2,
+ 'g': 1024**3,
+ 't': 1024**4}
+
+ if val_str[-1].lower() in units:
+ return int(val_str[:-1]) * units[val_str[-1].lower()]
+ else:
+ return int(val_str)
+
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
import shutil
import re
import datetime
+import gzip
import gbp.rpm as rpm
from gbp.rpm.policy import RpmPkgPolicy
export_group.add_option("--git-export-only", action="store_true", dest="export_only", default=False,
help="only export packaging files, don't build")
export_group.add_boolean_config_file_option("patch-export", dest="patch_export")
+ export_group.add_config_file_option("patch-export-compress", dest="patch_export_compress")
export_group.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
options, args = parser.parse_args(args)
+ options.patch_export_compress = rpm.string_to_int(options.patch_export_compress)
+
gbp.log.setup(options.color, options.verbose)
if options.retag:
if not options.tag and not options.tag_only:
import tempfile
import re
import gzip
+import subprocess
from gbp.config import (GbpOptionParserRpm, GbpOptionGroup)
from gbp.rpm.git import (GitRepositoryError, RpmGitRepository)
from gbp.git import GitModifier
import gbp.log
from gbp.patch_series import (PatchSeries, Patch)
from gbp.pkg import parse_archive_filename
-from gbp.rpm import (SpecFile, guess_spec)
+from gbp.rpm import (SpecFile, guess_spec, 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)
+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_export_compress)
+
return patches, commands
parser.add_option("--export-rev", action="store", dest="export_rev", default="",
help="Export patches from treeish object TREEISH instead "
"of head of patch-queue branch", metavar="TREEISH")
+ parser.add_config_file_option("patch-export-compress",
+ dest="patch_export_compress")
(options, args) = parser.parse_args(argv)
gbp.log.setup(options.color, options.verbose)
+ options.patch_export_compress = string_to_int(options.patch_export_compress)
if len(args) < 2:
gbp.log.err("No action given.")