if not specs:
msger.error('no spec file found under /packaging sub-directory')
- specfile = specs[0] #TODO:
- if len(specs) > 1:
- msger.warning('multiple specfiles found.')
-
-
+ specfile = utils.guess_spec(workdir, opts.spec)
distconf = configmgr.get('distconf', 'build')
if opts.dist:
distconf = opts.dist
import errno
import msger
+import utils
from gbp.scripts.buildpackage_rpm import git_archive, guess_comp_type
from gbp.rpm.git import GitRepositoryError, RpmGitRepository
if opts.outdir:
outdir = opts.outdir
- git_project = os.path.basename(workdir)
- specfile = '%s/packaging/%s.spec' % (workdir, git_project)
- if not os.path.exists(specfile):
- specs = glob.glob('%s/packaging/*.spec' % workdir)
- if not specs:
- msger.error('no spec file found under',
- '/packaging sub-directory of %s' % workdir)
-
- if len(specs) > 1:
- msger.error("Can't decide which spec file to use.")
- else:
- specfile = specs[0]
-
+ specfile = utils.guess_spec(workdir, opts.spec)
spec = rpm.parse_spec(specfile)
if not spec.name or not spec.version:
msger.error('can\'t get correct name or version from spec file.')
from conf import configmgr
import obspkg
import errors
-from utils import Workdir
+import utils
import gbp.rpm
from gbp.scripts.buildpackage_rpm import main as gbp_build
if not specs:
msger.error('no spec file found under /packaging sub-directory')
- specfile = specs[0] #TODO:
- if len(specs) > 1:
- msger.warning('multiple specfiles found.')
-
+ specfile = utils.guess_spec(workdir, opts.spec)
# get 'name' and 'version' from spec file
spec = gbp.rpm.parse_spec(specfile)
if not spec.name or not spec.version:
oscworkdir = localpkg.get_workdir()
localpkg.remove_all()
- with Workdir(workdir):
+ with utils.Workdir(workdir):
if gbp_build(["argv[0] placeholder", "--git-export-only",
"--git-ignore-new", "--git-builder=osc",
"--git-export-dir=%s" % oscworkdir,
fd.close()
return qemu_emulator
+
+def guess_spec(workdir, default_spec):
+ if default_spec:
+ if not os.path.exists(default_spec):
+ msger.error('%s does not exit' % default_spec)
+ return default_spec
+ git_project = os.path.basename(workdir)
+ specfile = '%s/packaging/%s.spec' % (workdir, git_project)
+ if not os.path.exists(specfile):
+ specs = glob.glob('%s/packaging/*.spec' % workdir)
+ if not specs:
+ msger.error('no spec file found under',
+ '/packaging sub-directory of %s' % workdir)
+
+ if len(specs) > 1:
+ msger.error("Can't decide which spec file to use.")
+ else:
+ specfile = specs[0]
+ return specfile
default=None,
dest='outdir',
help='Output directory')
+ @cmdln.option('--spec',
+ default=None,
+ dest='spec',
+ help='Specify a spec file to use')
def do_export(self, _subcmd, opts, *args):
"""${cmd_name}: export files and prepare for build
help='Do incremental build, which need support of spec file,'
' and tar ball unpack stage should be enabled with the '
'condition of RPM macro RSYNCDONE')
+ @cmdln.option('--spec',
+ default=None,
+ dest='spec',
+ help='Specify a spec file to use')
@cmdln.option('--debuginfo',
action='store_true',
default=False,
callback=handle_project,
help='Base OBS project being used to branch from, ' \
'use "Trunk" if not specified')
+ @cmdln.option('--spec',
+ default=None,
+ dest='spec',
+ help='Specify a spec file to use')
def do_remotebuild(self, subcmd, opts, *args):
"""${cmd_name}: remote build package