Skip to content

Commit

Permalink
scripts: ignore unavailable interpreters
Browse files Browse the repository at this point in the history
Skip running and setting environment variables for unavailable
interpreters in the env_use_destdir wrapper script to avoid output
like:

    $ ./scripts/env_use_destdir $DESTDIR/usr/sbin/getenforce
    ./scripts/env_use_destdir: 59: ruby: not found
    ./scripts/env_use_destdir: 59: ruby: not found
    Enforcing

Signed-off-by: Christian Göttsche <[email protected]>
Acked-by: James Carter <[email protected]>
  • Loading branch information
cgzones authored and jwcart2 committed Nov 15, 2023
1 parent eabd8e9 commit 2d2e872
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/env_use_destdir
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,21 @@ if [ -n "${SBINDIR:-}" ] ; then
PATH="$DESTDIR$SBINDIR:$PATH"
fi

NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '/usr', 'base': '/usr'}))"):$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")"
if [ -n "${PYTHONPATH:-}" ] ; then
# Prefix the PYTHONPATH with the new directories
export PYTHONPATH="$NEW_PYTHONPATH:$PYTHONPATH"
else
# Define PYTHONPATH
export PYTHONPATH="$NEW_PYTHONPATH"
if command -v "${PYTHON:-python3}" > /dev/null ; then
NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '/usr', 'base': '/usr'}))"):$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")"
if [ -n "${PYTHONPATH:-}" ] ; then
# Prefix the PYTHONPATH with the new directories
export PYTHONPATH="$NEW_PYTHONPATH:$PYTHONPATH"
else
# Define PYTHONPATH
export PYTHONPATH="$NEW_PYTHONPATH"
fi
fi

# shellcheck disable=SC2155
export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
if command -v "${RUBY:-ruby}" > /dev/null ; then
export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
fi

# Run the command given on the command line
if [ $# -gt 0 ] ; then
Expand Down

0 comments on commit 2d2e872

Please sign in to comment.