summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben.brown@codethink.co.uk>2017-08-30 14:06:42 +0000
committerBen Brown <ben.brown@codethink.co.uk>2017-08-30 14:06:42 +0000
commita4864c6b99181883411b6191315af5fbf431c426 (patch)
tree6485ae6dd3574cef8b819ad1ca48b28f27a2f2aa
parentefc37b2ceb243af733b5c6500cab0e6ddaa34769 (diff)
parent5e833c9cb0b623bf7b5ac176bf578ff11f4fd756 (diff)
downloadybd-a4864c6b99181883411b6191315af5fbf431c426.tar.gz
Merge branch 'benbrown/rpm-deploy-no-sandbox' into 'master'
Stop using the sandbox to query rpm metadata See merge request !387
-rw-r--r--ybd/rpm.py41
1 files changed, 13 insertions, 28 deletions
diff --git a/ybd/rpm.py b/ybd/rpm.py
index 0278ff5..86d123f 100644
--- a/ybd/rpm.py
+++ b/ybd/rpm.py
@@ -15,6 +15,7 @@ import repos
import requests
import tempfile
import utils
+import subprocess
# Because rpm is otherwise totally broken
@@ -498,34 +499,19 @@ def package_one_rpm(dn, userdata):
return True
-def rpm_deployment_filename(system, dn, rpmpath):
+def rpm_deployment_filename(dn, rpmpath):
# Reads rpm's headers to construct its filename.
- # It copies the rpm into the sandbox, because the artifact is
- # outside the sandbox.
- filename = os.path.basename(rpmpath)
- sandbox_dstdir = os.path.join(system['sandbox'], 'tmp')
- sandbox_dstfile = os.path.join(sandbox_dstdir, filename)
- sandbox_real_rpmpath = os.path.join(sandbox_dstdir, filename)
- sandbox_rpmpath = os.path.join('/tmp', filename)
- if not os.path.exists(sandbox_dstdir):
- os.makedirs(sandbox_dstdir)
- shutil.copyfile(rpmpath, sandbox_dstfile)
-
- env_vars = sandbox.env_vars_for_build(system)
- command = (
- 'rpm {} {} -q -p {} '
- '--queryformat="%{{name}}-%{{version}}-%{{release}}.%{{arch}}.rpm"'
- .format(common_rpm_args, extract_defines(dn), sandbox_rpmpath))
- ret, out, err = sandbox.run_sandboxed(system, command,
- env_vars, exit_on_error=False,
- run_logged=False,
- print_command=False)
- os.remove(sandbox_real_rpmpath)
- if not ret:
- app.log("ERROR: Failed to generate rpm name, {}".format(err))
+ out = ""
+ qf = '--queryformat="%{name}-%{version}-%{release}.%{arch}.rpm'
+ try:
+ with open(os.devnull, 'w') as fnull:
+ out = subprocess.check_output(['rpm', '-q', '-p', rpmpath, qf],
+ stderr=fnull)
+ except subprocess.CalledProcessError:
+ app.log(dn, "ERROR: Failed to generate rpm name")
sys.exit(1)
- if out is None:
- app.log(dn, "ERROR: getting rpm deployment filename returned None")
+ if not out:
+ app.log(dn, "ERROR: getting rpm deployment filename returned empty")
sys.exit(1)
return out
@@ -543,8 +529,7 @@ def deploy_rpm(dn, userdata):
return False
dstdir = os.path.join(app.config['deployment'],
'RPMs', cache_key(userdata['system']))
- dstfilename = rpm_deployment_filename(userdata['system'],
- dn, cached_path)
+ dstfilename = rpm_deployment_filename(dn, cached_path)
dstpath = os.path.join(dstdir, dstfilename)
if not os.path.exists(dstdir):
os.makedirs(dstdir)