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>
(cherry picked from commit 3eb77b4fca)
r14.0.x
Slávek Banko 3 years ago
parent b70630a227
commit b62ce69302
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -18,49 +18,84 @@ esac
. /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
# Install directories needed by smartcard reading daemon, command, and
# key-script
for dir in etc/opensc usr/lib/pcsc var/run tmp ; do
if [ ! -d ${DESTDIR}/${dir} ] ; then mkdir -p ${DESTDIR}/${dir} ; fi
for dir in etc/opensc lib usr/lib var/run tmp ; do
if [ ! -d ${DESTDIR}/${dir} ] ;
then
mkdir -p ${DESTDIR}/${dir}
fi
done
# Install pcscd daemon, drivers, conf file, and include libgcc as well since
# pcscd utilizes pthread_cancel
mkdir -p ${DESTDIR}/lib
# Install pcscd daemon, drivers, conf file
copy_exec /usr/sbin/pcscd /sbin
if [ -e /lib/*`uname -i`*/libgcc_s.so.1 ]
then
copy_exec /lib/*`uname -i`*/libgcc_s.so.1 /lib
else
copy_exec /lib/libgcc_s.so.1 /lib
fi
if [ -e /lib/*`uname -i`*/libpcsclite.so.1 ]
then
copy_exec /lib/*`uname -i`*/libpcsclite.so.1 /lib
else
copy_exec /lib/libpcsclite.so.1 /lib
fi
if [ -e /usr/lib/*`uname -i`*/libusb-1.0.so.0 ]
then
copy_exec /usr/lib/*`uname -i`*/libusb-1.0.so.0 /usr/lib
else if [ -e /usr/lib/libusb-1.0.so.0 ]
then
copy_exec /usr/lib/libusb-1.0.so.0 /usr/lib
copy_plugin libpcsclite.so.1
find /usr/lib/pcsc ! -type d |
while read PSCS_FILE; do
if [ ! -x ${PSCS_FILE} ] && [ ${PSCS_FILE} = ${PSCS_FILE%.so} ]; then
[ -d ${DESTDIR}${PSCS_FILE%/*} ] || \
mkdir -p ${DESTDIR}${PSCS_FILE%/*}
cp -pL $PSCS_FILE ${DESTDIR}${PSCS_FILE%/*}
else
copy_exec $PSCS_FILE
fi
done
if [ -d /etc/reader.conf.d ]; then
cp -pLR /etc/reader.conf.d ${DESTDIR}/etc/
fi
cp -r /usr/lib/pcsc ${DESTDIR}/usr/lib
if [ -e /etc/reader.conf.d ]
then
cp -Rp /etc/reader.conf.d ${DESTDIR}/etc/
else
cp /etc/reader.conf ${DESTDIR}/etc
if [ -e /etc/reader.conf ]; then
cp -pL /etc/reader.conf ${DESTDIR}/etc/
fi
# Install opensc commands and conf file
copy_exec /usr/bin/opensc-tool /bin
copy_exec /usr/bin/pkcs15-crypt /bin
cp /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc
copy_exec /usr/bin/opensc-tool /bin/
copy_exec /usr/bin/pkcs15-crypt /bin/
copy_exec /usr/bin/pkcs15-tool /bin/
cp -pL /etc/opensc/opensc.conf ${DESTDIR}/etc/opensc/
# Install other required utilities
copy_exec /bin/grep /bin
@ -82,11 +117,4 @@ copy_exec /usr/bin/scriptor_standalone /bin
copy_exec /usr/bin/smartauth.sh /bin
# Libraries
# cp /usr/lib/libltdl.so* ${DESTDIR}/usr/lib
# cp /lib/libncurses.so.5 ${DESTDIR}/lib
if [ -e /lib/*`uname -i`*/libncursesw.so.5 ]
then
cp /lib/*`uname -i`*/libncursesw.so.5 ${DESTDIR}/lib
else
cp /lib/libncursesw.so.5 ${DESTDIR}/lib
fi
copy_plugin libncursesw.so.[0-9]

Loading…
Cancel
Save