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