From 586921572d7b88900739a288f697db097f7b55f8 Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Mon, 1 Apr 2013 16:41:34 +0800 Subject: [PATCH] support updating multiple spec files If --spec specified, only updated specified spec file, othewise update all spec files, including: - Add VCS tag - Add patches Change-Id: I32a469a0140d90ca2d2bceb110d4e4f9ab0301e6 --- gitbuildsys/cmd_changelog.py | 2 +- gitbuildsys/cmd_export.py | 25 ++++++++++++++++++++----- gitbuildsys/cmd_remotebuild.py | 2 +- gitbuildsys/utils.py | 6 ++++-- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/gitbuildsys/cmd_changelog.py b/gitbuildsys/cmd_changelog.py index 4e72ad6..bb28de3 100644 --- a/gitbuildsys/cmd_changelog.py +++ b/gitbuildsys/cmd_changelog.py @@ -114,7 +114,7 @@ def main(args): if args.spec or not changes_file_list: # Create .changes file with the same name as a spec specfile = os.path.basename(guess_spec(repo.path, - packaging_dir, args.spec)) + packaging_dir, args.spec)[0]) fn_changes = os.path.splitext(specfile)[0] + ".changes" fn_changes = os.path.join(repo.path, packaging_dir, fn_changes) else: diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index dc3bf12..15f9e2b 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -22,6 +22,7 @@ import os import re import shutil +import glob import errno from urlparse import urlparse @@ -158,7 +159,6 @@ def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, args, else: argv.extend(["--git-patch-export", "--git-patch-export-compress=100k", - "--git-force-create", "--git-patch-export-squash-until=%s" % squash_patches_until, "--git-patch-export-ignore-path=^(%s/.*|.gbs.conf)" % @@ -241,7 +241,7 @@ def main(args): else: commit = 'HEAD' packaging_dir = get_packaging_dir(args) - relative_spec = utils.guess_spec(workdir, packaging_dir, args.spec, commit) + main_spec, rest_specs = utils.guess_spec(workdir, packaging_dir, args.spec, commit) if args.outdir: outdir = args.outdir @@ -262,9 +262,24 @@ def main(args): check_export_branches(repo, args) with utils.Workdir(workdir): - export_sources(repo, commit, export_dir, relative_spec, args) - - specfile = os.path.basename(relative_spec) + export_sources(repo, commit, export_dir, main_spec, args) + + # also update other spec files if no --spec option specified + if not args.spec and 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) + for spec in rest_specs: + export_sources(repo, commit, export_dir, spec, args) + 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) + + specfile = os.path.basename(main_spec) try: spec = rpm.parse_spec(os.path.join(export_dir, specfile)) except GbpError, err: diff --git a/gitbuildsys/cmd_remotebuild.py b/gitbuildsys/cmd_remotebuild.py index 397355f..9dc7fca 100644 --- a/gitbuildsys/cmd_remotebuild.py +++ b/gitbuildsys/cmd_remotebuild.py @@ -93,7 +93,7 @@ def main(args): else: commit = 'HEAD' - relative_spec = utils.guess_spec(workdir, packaging_dir, args.spec, commit) + relative_spec = utils.guess_spec(workdir, packaging_dir, args.spec, commit)[0] if args.include_all: # include_all means to use work copy, diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index 0a9ae33..b838f13 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -76,7 +76,7 @@ def guess_spec(git_path, packaging_dir, given_spec, commit_id='WC.UNTRACKED'): spec = os.path.join(packaging_dir, given_spec) if not check(spec): raise GbsError(msg % spec) - return spec + return [spec, []] specs = glob_(os.path.join(packaging_dir, '*.spec')) if not specs: @@ -85,7 +85,9 @@ def guess_spec(git_path, packaging_dir, given_spec, commit_id='WC.UNTRACKED'): project_name = os.path.basename(git_path) spec = os.path.join(packaging_dir, '%s.spec' % project_name) - return spec if spec in specs else specs[0] + spec = spec if spec in specs else specs[0] + specs.remove(spec) + return [spec, specs] class Temp(object): -- 2.7.4