From d29584f251af5d0395a9c57596e8bf776b5b56a2 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 5 Nov 2019 12:07:39 +0100 Subject: [slx-addon] simplify addon setup and hopefully make it faster --- .../modules.d/slx-addons/scripts/setup-addons.sh | 45 ++++------------------ 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/builder/modules.d/slx-addons/scripts/setup-addons.sh b/builder/modules.d/slx-addons/scripts/setup-addons.sh index 94c2c444..09ec9885 100644 --- a/builder/modules.d/slx-addons/scripts/setup-addons.sh +++ b/builder/modules.d/slx-addons/scripts/setup-addons.sh @@ -52,52 +52,23 @@ setup_addon() { info "'$ADDONS_DIR/$ADDON/addon-required' missing or returned non-zero, skipping..." return 1 fi + # purge addon-* files + rm -f -- addon-* - for entry in $(find * -not -wholename "addon-*" 2>/dev/null); do - if [ -d "$entry" ]; then - [ -d "/$entry" ] || mkdir -p "/${entry}" - continue - fi - local dir=${entry%/*} - [ -d "$NEWROOT/$dir" ] || mkdir -p "$NEWROOT/$dir" - if [ -f "$entry" -a ! -L "$entry" ]; then - if [ ! -e "$NEWROOT/${entry}" ] || ! diff -q "$entry" "$NEWROOT/${entry}"; then - mv -f -- "$entry" "$NEWROOT/${entry}" - fi - else - # either block dev, char dev or a symlink, just overwrite them "blindly" - mv -f -- "$entry" "$NEWROOT/${entry}" - fi + # move all the files over + for entry in $(find * -not -type d 2>/dev/null); do + mkdir -p "${NEWROOT}/${entry%/*}" + mv -f -- "$entry" "${NEWROOT}/${entry}" done - # post merge: remove whiteouts from filesystem + # post merge: remove files marked as whiteouts + # (e.g. they were removed during the addon installation) for WHITEOUT in "$NEWROOT/opt/openslx/etc/"*.whiteout; do [ -e "$WHITEOUT" ] || continue while read line; do rm -f "${NEWROOT}/${line}" done < "$WHITEOUT" done - - # finally update ld.so.cache expected to be under /opt/openslx/etc/.ld.so.cache - # NOTE: if we have more than one addon in the future, we need to be extra - # careful with prebuilt ld.caches since they need to match *ALL* addons - local ADDON_LD_CACHE="$NEWROOT/opt/openslx/etc/$ADDON.ld.so.cache" - if [ ! -e "$ADDON_LD_CACHE" ] || ! mv -f -- "$ADDON_LD_CACHE" "$NEWROOT/etc/ld.so.cache" ; then - # Using prebuilt ld cache failed, try hard to find a ldconfig... - for LDCONFIG in "$(type -p ldconfig 2>/dev/null)" "${NEWROOT}/sbin/ldconfig.real"; do - if [ -x "$LDCONFIG" ] && "$LDCONFIG" -r "$NEWROOT"; then - return 0 - fi - done - # try with chroot if we have it - local CHROOT_PATH="$(type -p chroot 2>/dev/null)" - if [ -x "$CHROOT_PATH" ] && "$CHROOT_PATH" "$NEWROOT" ldconfig; then - return 0 - fi - # very bad indeed, libraries won't be registered in the cache ... - warn "Failed to find 'ldconfig' to rebuild the addon's missing ld.so.cache..." - return 1 - fi } if ! setup_addons; then -- cgit v1.2.3-55-g7522