if obs_pkg:
specfile = '%s/%s/%s.spec' % (prjdir, packagingdir, obs_pkg)
else:
- specfile = utils.find_spec('%s/%s' % (prjdir, packagingdir))
- if not specfile:
- msg = "[ERROR]: Packaging directory contains multiply spec files, backend service can not decide which spec file to use. Please use OBS_PACKAGE parameter in scm/git-obs-mapping project to specify the target spec file or contact system administrator for more details."
- mygerrit.review(commit = GERRIT_PATCHSET_REVISION, message = msg)
- continue
+ specs = utils.find_spec('%s/%s' % (prjdir, packagingdir))
+ if not specs:
+ # no spec exist under packaging, use default name
+ print 'Cannot find spec file under packaging directory!'
+ specfile = '%s/%s/%s.spec' % (prjdir, packagingdir, prj)
+ elif len(specs) == 1:
+ # only one spec exist under packaging
+ specfile = specs[0]
+ else:
+ # multiple specs exist under packaging, use default name
+ specfile = '%s/%s/%s.spec' % (prjdir, packagingdir, prj)
+ if not os.path.isfile(specfile):
+ msg = "[ERROR]: Packaging directory contains multiply spec files, backend service can not decide which spec file to use. Please use OBS_PACKAGE parameter in scm/git-obs-mapping project to specify the target spec file or contact system administrator for more details."
+ mygerrit.review(commit = GERRIT_PATCHSET_REVISION, message = msg)
+ continue
+
print('specfile %s' % specfile)
# build the package under home project of backend service user
if obs_pkg:
specfile = '%s/%s/%s.spec' % (prjdir, packagingdir, obs_pkg)
+ if not os.path.isfile(specfile):
+ msg = "The tag %s pushed, but backend service can not find %s under packaging directory, which is caused by mistake OBS_PACKAGE parameter in scm/git-obs-mapping project. Please correct it or contact system administrator for more details." % (tag, os.path.basename(specfile))
+ feedback(msg, tag, tagger, mygerrit)
+ end('failure')
else:
- specfile = utils.find_spec('%s/%s' % (prjdir, packagingdir))
- if not specfile:
+ specs = utils.find_spec('%s/%s' % (prjdir, packagingdir))
+ if not specs:
+ # no spec exist under packaging, use default name
+ msg = "The tag %s pushed, but packaging directory doesn't contain any spec file. Please create one and re-submit it." % tag
+ feedback(msg, tag, tagger, mygerrit)
+ end('failure')
+ elif len(specs) == 1:
+ # only one spec exist under packaging
+ specfile = specs[0]
+ else:
+ # multiple specs exist under packaging, use default name
specfile = '%s/%s/%s.spec' % (prjdir, packagingdir, prj)
if not os.path.isfile(specfile):
msg = "The tag %s pushed, but packaging directory contains multiply spec files, backend service can not decide which spec file to use. Please use OBS_PACKAGE parameter in scm/git-obs-mapping project to specify the target spec file or contact system administrator for more details." % tag
print('specfile %s' % specfile)
- # check whether spec file exists
- if not os.path.isfile(specfile):
- msg = "The tag %s pushed, but backend service can not find %s under packaging directory, which maybe caused by OBS_PACKAGE parameter in scm/git-obs-mapping project. Please correct it or contact system administrator for more details." % (tag, os.path.basename(specfile))
- feedback(msg, tag, tagger, mygerrit)
- end('failure')
-
try:
# use gbp to parse specfile
spec = gbp.rpm.parse_spec(specfile)
runner.show('gbs export --spec %s --packaging-dir %s -o %s' % (os.path.basename(specfile), packagingdir, outdir))
except Exception, exc:
print('gbp parse spec failed. %s' % exc)
- msg = "The tag %s pushed, but backend service parsed %s failed. Please make sure (gbs export) can work in this project." % (tag, os.path.basename(specfile))
+ msg = "The tag %s pushed, but backend service faile to parse %s. Please make sure (gbs export) can work in this project." % (tag, os.path.basename(specfile))
feedback(msg, tag, tagger, mygerrit)
end('failure')