From f246719e2fc34a3c36db7506d7a7791d1eb7b6f5 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 10 Jul 2012 16:15:18 +0300 Subject: [PATCH] cmd_export: parse correct spec file Do not parse the working copy of the spec file but the one that was exported. Signed-off-by: Markus Lehtonen --- gitbuildsys/cmd_export.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index 81c25db..d7d189d 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -24,6 +24,7 @@ import glob import urlparse import shutil import errno +import tempfile import msger import utils @@ -77,30 +78,19 @@ def do(opts, args): outdir = "%s/packaging" % workdir if opts.outdir: outdir = opts.outdir + mkdir_p(outdir) + # Only guess spec filename here, parse later when we have the correct + # spec file at hand specfile = utils.guess_spec(workdir, opts.spec) - try: - spec = rpm.parse_spec(specfile) - except GbpError, err: - msger.error('%s' % err) - - if not spec.name or not spec.version: - msger.error('can\'t get correct name or version from spec file.') - else: - outdir = "%s/%s-%s-%s" % (outdir, spec.name, spec.version, spec.release) - mkdir_p(outdir) - - urlres = urlparse.urlparse(spec.orig_file) - tarball = '%s/%s' % (outdir, os.path.basename(urlres.path)) - msger.info('generate tar ball: %s' % tarball) - + export_dir = tempfile.mkdtemp(prefix='gbs_export_', dir=outdir) with utils.Workdir(workdir): commit = opts.commit or 'HEAD' relative_spec = specfile.replace('%s/' % workdir, '') try: if gbp_build(["argv[0] placeholder", "--git-export-only", "--git-ignore-new", "--git-builder=osc", - "--git-export-dir=%s" % outdir, + "--git-export-dir=%s" % export_dir, "--git-packaging-dir=packaging", "--git-specfile=%s" % relative_spec, "--git-export=%s" % commit]): @@ -108,4 +98,16 @@ def do(opts, args): except GitRepositoryError, excobj: msger.error("Repository error: %s" % excobj) + try: + spec = rpm.parse_spec(os.path.join(export_dir, os.path.basename(specfile))) + except GbpError, err: + msger.error('%s' % err) + + if not spec.name or not spec.version: + msger.error('can\'t get correct name or version from spec file.') + else: + outdir = "%s/%s-%s-%s" % (outdir, spec.name, spec.version, spec.release) + shutil.rmtree(outdir, ignore_errors=True) + shutil.move(export_dir, outdir) + msger.info('package files have been exported to:\n %s' % outdir) -- 2.7.4