未验证 提交 c1823f4a 编写于 作者: A Amador Pahim

Merge branch 'ldoktor-utils-soft2'

Signed-off-by: NAmador Pahim <apahim@redhat.com>
......@@ -36,6 +36,7 @@ implement the given backend class.
"""
import os
import re
import shutil
import logging
import optparse
import tempfile
......@@ -584,35 +585,43 @@ class YumBackend(RpmBackend):
:return final_dir: path of ready-to-build directory
"""
path = tempfile.mkdtemp(prefix='avocado_software_manager')
if dest_path is None:
log.error("Please provide a valid path")
return ""
for pkg in ["rpm-build", "yum-utils"]:
if not self.check_installed(pkg):
if not self.install(pkg):
log.error("SoftwareManager (YumBackend) can't get packages"
"with dependency resolution: Package '%s'"
"could not be installed", pkg)
return ""
try:
src_rpm = process.system_output('yumdownloader --urls --source'
' %s' % name).splitlines()[-1]
src_rpm = src_rpm.split("/")[-1]
process.system_output('yumdownloader --source %s --destdir %s' % (name, path))
src_rpm = os.path.join(path, src_rpm)
if self.rpm_install(src_rpm):
if self.build_dep(name):
return self.prepare_source(
"%s/rpmbuild/SPECS/%s.spec" % (os.environ['HOME'], name), dest_path)
if dest_path is None:
log.error("Please provide a valid path")
return ""
for pkg in ["rpm-build", "yum-utils"]:
if not self.check_installed(pkg):
if not self.install(pkg):
log.error("SoftwareManager (YumBackend) can't get "
"packageswith dependency resolution: Package"
" '%s' could not be installed", pkg)
return ""
try:
process.run('yumdownloader --assumeyes --verbose --source %s '
'--destdir %s' % (name, path))
src_rpms = [_ for _ in os.walk(path).next()[2]
if _.endswith(".src.rpm")]
if len(src_rpms) != 1:
log.error("Failed to get downloaded src.rpm from %s:\n%s",
path, os.walk(path).next()[2])
return ""
if self.rpm_install(os.path.join(path, src_rpms[-1])):
if self.build_dep(name):
spec_path = os.path.join(os.environ['HOME'],
"rpmbuild", "SPECS",
"%s.spec" % name)
return self.prepare_source(spec_path, dest_path)
else:
log.error("Installing build dependencies failed")
return ""
else:
log.error("Installing build dependencies failed")
log.error("Installing source rpm failed")
return ""
else:
log.error("Installing source rpm failed")
except process.CmdError as details:
log.error(details)
return ""
except process.CmdError as details:
log.error(details)
return ""
finally:
shutil.rmtree(path)
class DnfBackend(YumBackend):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册