1#!/bin/bash 2set -e 3 4# Find the --sysroot argument 5sysroot= 6next_arg=false 7for arg; do 8 if ${next_arg}; then 9 next_arg=false 10 sysroot="${arg}" 11 continue # not break, in case there are more than one 12 fi 13 case "${arg}" in 14 (--sysroot|-r) 15 next_arg=true 16 continue 17 ;; 18 (--sysroot=*) 19 sysroot="${arg#*=}" 20 continue # not break, in case there are more than one 21 ;; 22 (-r?*) 23 sysroot="${arg#-r}" 24 continue # not break, in case there are more than one 25 ;; 26 esac 27done 28if [ -z "${sysroot}" ]; then 29 echo "${0}: --sysroot argument must be given." 1>&2 30 exit 1 31fi 32 33topdir="$(dirname "$(realpath "$(dirname "${0}")")")" 34DRACUT_LDD="$(mktemp /tmp/dracut-ldd.XXXXXX)" 35cat >"${DRACUT_LDD}" <<EOL 36#!/bin/bash 37${topdir}/sbin/prelink-rtld --root='${sysroot}' \${1} 38EOL 39chmod +x "${DRACUT_LDD}" 40export DRACUT_LDD 41export DRACUT_INSTALL="${topdir}/lib/dracut/dracut-install" 42export DRACUT_LDCONFIG=/bin/true 43export dracutbasedir="${topdir}/lib/dracut" 44(exec "${topdir}/bin/dracut.real" "${@}") 45 46if [ -n "${DRACUT_LDD}" ]; then 47 rm -f "${DRACUT_LDD}" 48fi 49