Skip to content

Commit

Permalink
Alias readlink command
Browse files Browse the repository at this point in the history
See the previous commit on `getopt`

Signed-off-by: Cristian Le <[email protected]>
  • Loading branch information
LecrisUT committed Mar 25, 2024
1 parent 74339d4 commit fdbbd79
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/beakerlib.sh
Expand Up @@ -34,6 +34,7 @@

# Command aliases for compatibilities. Set them by replacing this string through the Makefile interface
declare -r __INTERNAL_GETOPT_CMD="getopt"
declare -r __INTERNAL_READLINK_CMD="readlink"

__INTERNAL_SOURCED=${__INTERNAL_SOURCED-}
echo "${__INTERNAL_SOURCED}" | grep -qF -- " ${BASH_SOURCE} " && return || __INTERNAL_SOURCED+=" ${BASH_SOURCE} "
Expand Down Expand Up @@ -479,7 +480,7 @@ TESTID=${TESTID-}
JOBID=${JOBID-}
RECIPEID=${RECIPEID-}
BEAKERLIB_JOURNAL=${BEAKERLIB_JOURNAL-}
export BEAKERLIB=${BEAKERLIB:-$(dirname "$(readlink -e ${BASH_SOURCE})")}
export BEAKERLIB=${BEAKERLIB:-$(dirname "$($__INTERNAL_READLINK_CMD -e ${BASH_SOURCE})")}
. $BEAKERLIB/storage.sh
. $BEAKERLIB/infrastructure.sh
. $BEAKERLIB/journal.sh
Expand Down
2 changes: 1 addition & 1 deletion src/infrastructure.sh
Expand Up @@ -713,7 +713,7 @@ rlFileBackup() {
file="$(echo "$file" | sed "s|^\([^/]\)|$PWD/\1|" | sed 's|/$||')"
# follow symlinks in parent dir
path="$(dirname "$file")"
path="$(readlink -n -m "$path")"
path="$($__INTERNAL_READLINK_CMD -n -m "$path")"
file="$path/$(basename "$file")"

# bail out if the file does not exist
Expand Down
6 changes: 3 additions & 3 deletions src/libraries.sh
Expand Up @@ -114,15 +114,15 @@ __INTERNAL_extractOrigin(){

if [ ! -e "$0" ]
then
SOURCE="$( readlink -f . )"
SOURCE="$( $__INTERNAL_READLINK_CMD -f . )"
else
SOURCE="$( readlink -f $0 )"
SOURCE="$( $__INTERNAL_READLINK_CMD -f $0 )"
fi

local DIR="$( dirname "$SOURCE" )"
while [ -h "$SOURCE" ]
do
SOURCE="$(readlink -f "$SOURCE")"
SOURCE="$($__INTERNAL_READLINK_CMD -f "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
done
Expand Down
2 changes: 1 addition & 1 deletion src/logging.sh
Expand Up @@ -551,7 +551,7 @@ rlFileSubmit() {
ALIAS=$(echo $ALIAS | tr '/' "$SEPARATOR" | sed "s/^${SEPARATOR}*//")
fi
rlLogInfo "Sending $FILE as $ALIAS"
ln -s "$(readlink -f $FILE)" "$TMPDIR/$ALIAS"
ln -s "$($__INTERNAL_READLINK_CMD -f $FILE)" "$TMPDIR/$ALIAS"

if [ -z "$BEAKERLIB_COMMAND_SUBMIT_LOG" ]
then
Expand Down
2 changes: 1 addition & 1 deletion src/rpms.sh
Expand Up @@ -340,7 +340,7 @@ rlAssertBinaryOrigin() {
{
status=1
# expand symlinks (if any)
local BINARY=$(readlink -f $FULL_CMD)
local BINARY=$($__INTERNAL_READLINK_CMD -f $FULL_CMD)

# get the rpm owning the binary
local BINARY_RPM=$(rpm -qf --qf="%{name}\n" $BINARY | uniq)
Expand Down

0 comments on commit fdbbd79

Please sign in to comment.