'rpmbuild-srpmdir' : 'SRPMS',
'rpmbuild-buildrootdir' : 'BUILDROOT',
'patch-export' : 'False',
+ 'patch-export-compress' : '0',
'merge' : 'False',
'pristine-tarball-name' : 'auto',
})
'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'",
import shutil
import re
from datetime 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.")