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:
import os
import re
import shutil
+import glob
import errno
from urlparse import urlparse
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)" %
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
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:
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:
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):