提交 cc3f2717 编写于 作者: L Lukáš Doktor

utils.software_manager: Remove the temporary dir on get_source

Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 6ac5f939
......@@ -36,6 +36,7 @@ implement the given backend class.
"""
import os
import re
import shutil
import logging
import optparse
import tempfile
......@@ -584,39 +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:
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])
if dest_path is None:
log.error("Please provide a valid path")
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)
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.
先完成此消息的编辑!
想要评论请 注册