Skip to content

Commit

Permalink
replace run_cmd with run_shell_cmd in custom easyblock for Rust (…
Browse files Browse the repository at this point in the history
…`rust.py`)
  • Loading branch information
branfosj committed Feb 3, 2024
1 parent dcd646c commit a5a5cdb
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions easybuild/easyblocks/r/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.config import build_option
from easybuild.tools.run import run_cmd
from easybuild.tools.run import run_shell_cmd
from easybuild.tools.systemtools import get_shared_lib_ext


Expand Down Expand Up @@ -91,22 +91,23 @@ def install_step(self):
runpath_regex = re.compile(r"\(RUNPATH\)\s+Library runpath")

for shared_lib in shared_libs:
out, ec = run_cmd("readelf -d %s" % shared_lib, simple=False, trace=False)
if ec:
raise EasyBuildError("Failed to check RPATH section in %s: %s", shared_lib, out)
elif runpath_regex.search(out):
res = run_shell_cmd("readelf -d %s" % shared_lib, hidden=True)
if res.exit_code:
raise EasyBuildError("Failed to check RPATH section in %s: %s", shared_lib, res.output)
elif runpath_regex.search(res.output):
self.log.info("RUNPATH section found in %s - need to change to RPATH", shared_lib)

# first determine current RUNPATH value
out, ec = run_cmd("patchelf --print-rpath %s" % shared_lib)
if ec:
raise EasyBuildError("Failed to determine current RUNPATH value for %s: %s", shared_lib, out)
res = run_shell_cmd("patchelf --print-rpath %s" % shared_lib)
if res.exit_code:
raise EasyBuildError("Failed to determine current RUNPATH value for %s: %s", shared_lib,
res.output)
else:
runpath = out.strip()
runpath = res.output.strip()
# use RUNPATH value to RPATH value
out, ec = run_cmd("patchelf --set-rpath '%s' --force-rpath %s" % (runpath, shared_lib))
if ec:
raise EasyBuildError("Failed to set RPATH for %s: %s", shared_lib, out)
res = run_shell_cmd("patchelf --set-rpath '%s' --force-rpath %s" % (runpath, shared_lib))
if res.exit_code:
raise EasyBuildError("Failed to set RPATH for %s: %s", shared_lib, res.output)
else:
self.log.info("RPATH set for %s", shared_lib)
else:
Expand Down

0 comments on commit a5a5cdb

Please sign in to comment.