Spdk/scripts/ar-xnvme-fixer
Michal Berger c8f62d792a test: Enable xnvme in autotest builds
Signed-off-by: Michal Berger <michal.berger@intel.com>
Change-Id: I32594d94eb397dfe1fcec867fd0caf67a07b208c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14118
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
2022-08-29 11:40:08 +00:00

31 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# The xnvme build executes library_bundler.py which wraps itself around ar
# to create libxnvme.a. It builds a set of MRI commands which then is
# passed to ar via stdin. The set of members is declared via ADDLIB
# followed by an absolute path to the file. On the physical nodes this
# path may look as the following:
#
# /workspace/foo-job@tmp/...
#
# The '@' has a special meaning for ar when spotted on the cmdline.
# It ends up splitting the path into /workspace/foo-job treating it
# as a member path which doesn't exist. This causes the entire build
# to fail. To workaround this, we inject ourselves via AR_TOOL and
# modify the MRI commands such that the absolute paths to members are
# replaced with relative ones (relative to xnvme/builddir from where
# the library_bundler.py is executed).
curdir=$(readlink -f "$(dirname "$0")")
rootdir=$(readlink -f "$curdir/../")
[[ ! -t 0 ]] || exit 1
while read -r cmd arg; do
if [[ $cmd == ADDLIB && $arg == /* ]]; then
arg=${arg/"$rootdir/xnvme/"/"../"}
fi
mri+=("$cmd${arg:+ $arg}")
done
ar "$@" < <(printf '%s\n' "${mri[@]}")