Improve processing of multiarch libraries location in scripts.

Initramfs hook instead of a fixed list of libraries, it processes dependent
libraries by using copy_exec function. This also ensure the copy of the
symlinks and maintaining the original paths by multiarch location.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/6/head
Slávek Banko 3 years ago
parent 64a75f83cd
commit 3eb77b4fca
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -43,8 +43,34 @@ fi
# Find plymouth # Find plymouth
PLYDIR=/bin/plymouth PLYDIR=/bin/plymouth
# Determine multiarch directory
ARCHDIR=$(ldd $SHELL | grep libc\.so |\
sed -e "s|^.*=> \(.*\)/[^/]*$|\1|" -e "s|^/usr||" -e "s|^/||")
if [ -z "$ARCHDIR" ] && [ -n "$HOSTTYPE" ] && [ -n "$OSTYPE" ]; then
ARCHDIR=$HOSTTYPE-$OSTYPE
fi
if [ -z "$ARCHDIR" ]; then
ARCHDIR=$(uname -i)
if [ "$ARCHDIR" = "unknown" ]; then
ARCHDIR=$(uname -m)
fi
if [ "$ARCHDIR" = "ppc64le" ]; then
ARCHDIR="powerpc64"
fi
if [ "$ARCHDIR" = "ppc64el" ]; then
ARCHDIR="powerpc64"
fi
ARCHDIR="*${ARCHDIR}*"
fi
# Set system PKCS library path # Set system PKCS library path
SYSTEM_PKCS_LIBRARY=/usr/lib/opensc-pkcs11.so SYSTEM_PKCS_LIBRARY=opensc-pkcs11.so
for x in /${ARCHDIR} /lib /usr/${ARCHDIR} /usr/lib; do
if [ -e $x/$SYSTEM_PKCS_LIBRARY ]; then
SYSTEM_PKCS_LIBRARY=$(echo $x/$SYSTEM_PKCS_LIBRARY)
break
fi
done
# print message to usplash or stderr # print message to usplash or stderr
# usage: msg <command> "message" [switch] # usage: msg <command> "message" [switch]

@ -18,97 +18,87 @@ esac
. /usr/share/initramfs-tools/hook-functions . /usr/share/initramfs-tools/hook-functions
# Additional function for copying plugin (library) from multiarch directory.
# Based on copy_exec.
copy_plugin() {
local src target x
src="${1}"
if [ ${src} = "${src#/}" ]; then
for x in /${ARCHDIR} /lib /usr/${ARCHDIR} /usr/lib; do
if [ -e $x/$src ]; then
src=$(echo $x/$src)
break
fi
done
fi
target="${2:-$src}"
copy_exec "${src}" "${target}" || return $(($? - 1))
}
# Determine multiarch directory
ARCHDIR=$(ldd $SHELL | grep libc\.so |\
sed -e "s|^.*=> \(.*\)/[^/]*$|\1|" -e "s|^/usr||" -e "s|^/||")
if [ -z "$ARCHDIR" ] && [ -n "$HOSTTYPE" ] && [ -n "$OSTYPE" ]; then
ARCHDIR=$HOSTTYPE-$OSTYPE
fi
if [ -z "$ARCHDIR" ]; then
ARCHDIR=$(uname -i)
if [ "$ARCHDIR" = "unknown" ]; then
ARCHDIR=$(uname -m)
fi
if [ "$ARCHDIR" = "ppc64le" ]; then
ARCHDIR="powerpc64"
fi
if [ "$ARCHDIR" = "ppc64el" ]; then
ARCHDIR="powerpc64"
fi
ARCHDIR="*${ARCHDIR}*"
fi
# Hooks for loading smartcard reading software into the initramfs # Hooks for loading smartcard reading software into the initramfs
# Install directories needed by smartcard reading daemon, command, and # Install directories needed by smartcard reading daemon, command, and
# key-script # key-script
for dir in etc/opensc usr/lib var/run tmp ; do for dir in etc/opensc lib usr/lib var/run tmp ; do
if [ ! -d ${DESTDIR}/${dir} ] ; if [ ! -d ${DESTDIR}/${dir} ] ;
then then
mkdir -p ${DESTDIR}/${dir} mkdir -p ${DESTDIR}/${dir}
fi fi
done done
# Install pcscd daemon, drivers, conf file, and include libgcc as well since # Install pcscd daemon, drivers, conf file
# pcscd utilizes pthread_cancel
mkdir -p ${DESTDIR}/lib
copy_exec /usr/sbin/pcscd /sbin copy_exec /usr/sbin/pcscd /sbin
ARCHDIR=$(uname -i) copy_plugin libpcsclite.so.1
if [ "$ARCHDIR" = "unknown" ]; then
ARCHDIR=$(uname -m) find /usr/lib/pcsc ! -type d |
fi while read PSCS_FILE; do
if [ "$ARCHDIR" = "ppc64le" ]; then if [ ! -x ${PSCS_FILE} ] && [ ${PSCS_FILE} = ${PSCS_FILE%.so} ]; then
ARCHDIR="powerpc64" [ -d ${DESTDIR}${PSCS_FILE%/*} ] || \
fi mkdir -p ${DESTDIR}${PSCS_FILE%/*}
if [ "$ARCHDIR" = "ppc64el" ]; then cp -pL $PSCS_FILE ${DESTDIR}${PSCS_FILE%/*}
ARCHDIR="powerpc64" else
fi copy_exec $PSCS_FILE
fi
if [ -e /lib/*${ARCHDIR}*/libgcc_s.so.1 ] done
then
cp -L /lib/*${ARCHDIR}*/libgcc_s.so.1 ${DESTDIR}/lib
else
cp -L /lib/libgcc_s.so.1 ${DESTDIR}/lib
fi
if [ -e /lib/*${ARCHDIR}*/libpcsclite.so.1 ]
then
cp -L /lib/*${ARCHDIR}*/libpcsclite.so.1 ${DESTDIR}/lib
elif [ -e /usr/lib/*${ARCHDIR}*/libpcsclite.so.1 ]
then
cp -L /usr/lib/*${ARCHDIR}*/libpcsclite.so.1 ${DESTDIR}/lib
else
cp -L /lib/libpcsclite.so.1 ${DESTDIR}/lib
fi
if [ -e /lib/*${ARCHDIR}*/libudev.so.1 ]
then
cp -L /lib/*${ARCHDIR}*/libudev.so.1 ${DESTDIR}/lib
elif [ -e /usr/lib/*${ARCHDIR}*/libudev.so.1 ]
then
cp -L /usr/lib/*${ARCHDIR}*/libudev.so.1 ${DESTDIR}/lib
else
cp -L /lib/libudev.so.1 ${DESTDIR}/lib
fi
if [ -e /usr/lib/*${ARCHDIR}*/libusb-1.0.so.0 ] if [ -d /etc/reader.conf.d ]; then
then cp -pLR /etc/reader.conf.d ${DESTDIR}/etc/
cp -L /usr/lib/*${ARCHDIR}*/libusb-1.0.so.0 ${DESTDIR}/usr/lib
elif [ -e /lib/*${ARCHDIR}*/libusb-1.0.so.0 ]
then
cp -L /lib/*${ARCHDIR}*/libusb-1.0.so.0 ${DESTDIR}/usr/lib
elif [ -e /usr/lib/libusb-1.0.so.0 ]
then
cp -L /usr/lib/libusb-1.0.so.0 ${DESTDIR}/usr/lib
else
echo "Unable to locate libusb-1.0"
exit 1
fi fi
if [ -e /etc/reader.conf ]; then
cp -LRp /usr/lib/pcsc ${DESTDIR}/usr/lib/ cp -pL /etc/reader.conf ${DESTDIR}/etc/
if [ -e /etc/reader.conf.d ]
then
cp -L -Rp /etc/reader.conf.d ${DESTDIR}/etc/
else
cp -L /etc/reader.conf ${DESTDIR}/etc/
fi fi
# Install opensc commands and conf file # Install opensc commands and conf file
copy_exec /usr/bin/opensc-tool /bin/ copy_exec /usr/bin/opensc-tool /bin/
copy_exec /usr/bin/pkcs15-crypt /bin/ copy_exec /usr/bin/pkcs15-crypt /bin/
copy_exec /usr/bin/pkcs15-tool /bin/ copy_exec /usr/bin/pkcs15-tool /bin/
cp -L /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc/ cp -pL /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc/
# Install opensc interface library # Install opensc interface library
if [ -e /usr/lib/*${ARCHDIR}*/opensc-pkcs11.so ] copy_plugin opensc-pkcs11.so
then
cp -L /usr/lib/*${ARCHDIR}*/opensc-pkcs11.so ${DESTDIR}/usr/lib
elif [ -e /usr/lib/opensc-pkcs11.so ]
then
cp -L /usr/lib/opensc-pkcs11.so ${DESTDIR}/usr/lib
fi
# Install other required utilities # Install other required utilities
copy_exec /bin/grep /bin copy_exec /bin/grep /bin
@ -130,14 +120,7 @@ copy_exec /usr/bin/cryptosmartcard.sh /bin
copy_exec /usr/bin/cardpincheck /bin copy_exec /usr/bin/cardpincheck /bin
# Libraries # Libraries
# cp -L /usr/lib/libltdl.so* ${DESTDIR}/usr/lib copy_plugin libncursesw.so.[0-9]
# cp -L /lib/libncurses.so.5 ${DESTDIR}/lib
if [ -e /lib/*${ARCHDIR}*/libncursesw.so.[0-9] ]
then
cp -L /lib/*${ARCHDIR}*/libncursesw.so.[0-9] ${DESTDIR}/lib
else
cp -L /lib/libncursesw.so.[0-9] ${DESTDIR}/lib
fi
# LUKS keys # LUKS keys
if [ -e /etc/trinity/luks/card ] if [ -e /etc/trinity/luks/card ]

Loading…
Cancel
Save