diff --git a/etc/config b/etc/config index 70f9bd0d5..fb492ccb8 100755 --- a/etc/config +++ b/etc/config @@ -15,6 +15,8 @@ export DIALOGRC=/etc/lunar/dialogrc DEFAULT_PREFIX=/usr + OBSOLETE_LIB_DIR=/usr/lib/lunar/OBSOLETE + BOOTSTRAP=/var/lib/lunar/bootstrap EXCLUDED=/var/lib/lunar/excluded MOONBASE=/var/lib/lunar/moonbase diff --git a/libs/build.lunar b/libs/build.lunar index ff3a124ad..9f4f02d21 100644 --- a/libs/build.lunar +++ b/libs/build.lunar @@ -24,6 +24,8 @@ # # # Parts Copyrighted Steven Michalske 2004 under GPLv2 # # # +# Parts Copyrighted Stefan Wold 2020 under GPLv2 # +# # ############################################################ @@ -33,23 +35,22 @@ save_libraries() { [ "$MODULE" == "glibc" ] && return 0 - OLD_VERSION=`installed_version $MODULE` + OLD_VERSION=$(installed_version $MODULE) OLD_LOG=$INSTALL_LOGS/$MODULE-$OLD_VERSION [ -e "$OLD_LOG" ] || return 0 OLD_LIBS=$SOURCE_DIRECTORY/old.libraries - mkdir -p $OLD_LIBS + mkdir -p $OLD_LIBS SAVED=$OLD_LIBS/$MODULE.saved.libraries rm -rf $SAVED - grep "/lib/" "$OLD_LOG" | + egrep "/lib(32|64)?/" "$OLD_LOG" | while read LINE; do - if [ -f "$LINE" ] && file -bL $LINE | - grep -E -q "shared object|pie executable" + egrep -q "shared object|pie executable" then verbose_msg "saving library \"$LINE\"" if [ -h $LINE ]; then @@ -58,11 +59,11 @@ save_libraries() { cut -c 2- ) ) - ln -sf $DEST $OLD_LIBS/`basename $LINE` + ln -sf $DEST $OLD_LIBS/$(basename $LINE) else - cp $LINE $OLD_LIBS + cp $LINE $OLD_LIBS fi - echo $OLD_LIBS/`basename $LINE` >> $SAVED + echo $OLD_LIBS/$(basename $LINE) >> $SAVED fi done @@ -75,6 +76,40 @@ save_libraries() { } +save_obsolete_libraries() { + local OLD_LIBS LIB + debug_msg "save_obsolete_libraries($@)" + OLD_LIBS=$SOURCE_DIRECTORY/old.libraries + + if [[ "$KEEP_OBSOLETE_LIBS" != "on" ]]; then + verbose_msg "KEEP_OBSOLETE_LIBS is currently disabled" + return + fi + + if [ ! -d "$OBSOLETE_LIB_DIR" ]; then + mkdir -p "$OBSOLETE_LIB_DIR" + fi + + for f in $(ls -1 $OLD_LIBS/*.so* 2> /dev/null); do + LIB=$(basename $f) + if ! parse_iw | grep -q $LIB; then + verbose_msg "saving obsolete library ($LIB)" + cp -P $f "$OBSOLETE_LIB_DIR"/ + fi + done + + ldconfig $OBSOLETE_LIB_DIR +} + + +remove_obsolete_libraries() { + debug_msg "remove_obsolete_libraries($@)" + verbose_msg "Removing OBSOLETE libraries" + rm -rf "$OBSOLETE_LIB_DIR" + ldconfig +} + + release_saved_libraries() { local OLD_LIBS SAVED FILE debug_msg "release_saved_libraries ($@)" @@ -400,6 +435,7 @@ default_post_build() { fi ldconfig + save_obsolete_libraries release_saved_libraries cd / } diff --git a/libs/check.lunar b/libs/check.lunar index e4398c5a0..db562353b 100644 --- a/libs/check.lunar +++ b/libs/check.lunar @@ -100,12 +100,14 @@ fix_depends () { run_fix() { - local MODULES MODULE + local MODULES MODULE KEEP_OBSOLETE debug_msg "run_fix ($@)" + KEEP_OBSOLETE=1 MODULES=$* if [ -z "$MODULES" ] ; then MODULES=$(list_installed | fgrep -v -x moonbase) + unset KEEP_OBSOLETE fi if [[ -n "$FIXDEPENDS" ]] ; then @@ -136,7 +138,7 @@ run_fix() { export TMP_LIN_SUCCESS=$(temp_create "successful") export TMP_LIN_FAIL=$(temp_create "failed") - if [[ ! -n "$NOFIX" ]] ; then + if [[ ! -n "$NOFIX" ]] ; then for MODULE in $(sort_by_dependency ${BROKEN_MODULES[@]}) ; do if module_installed $MODULE && ! module_held $MODULE ; then if ! run_checks $MODULE ; then @@ -150,13 +152,20 @@ run_fix() { continue elif ! run_checks $MODULE ; then verbose_msg "Attempt to recompile \"$MODULE\" succeeded but \"$MODULE\" still is broken!" + KEEP_OBSOLETE=1 continue fi fi fi fi done - + + # Only remove OBSOLETE if `lunar fix` pass all checks + # not perfect but it will have to do for now + if [ ! -n "$KEEP_OBSOLETE" ]; then + remove_obsolete_libraries + fi + display_update_log fix else display_update_log nofix diff --git a/misc/unset.sh b/misc/unset.sh index 52394873e..4df22e505 100644 --- a/misc/unset.sh +++ b/misc/unset.sh @@ -63,6 +63,7 @@ unset MODULE_STATUS unset MODULE_STATUS_BACKUP unset MOONBASE unset MOONBASE_URL +unset OBSOLETE_LIB_DIR unset PATCH_URL unset PLATFORM unset PRESERVE diff --git a/plugins/check-ldd.plugin b/plugins/check-ldd.plugin index f7d817961..28b8765a7 100644 --- a/plugins/check-ldd.plugin +++ b/plugins/check-ldd.plugin @@ -7,6 +7,8 @@ # # # Copyright 2005 by Auke Kok under GPLv2 # # # +# Copyright 2020 by Stefan Wold under GPLv2 # +# # ############################################################# @@ -31,11 +33,11 @@ plugin_module_check_ldd() { LOG=$(egrep "/(bin|games|lib(32|64)?|sbin|libexec)/" $I_LOG | egrep -v "/(doc|fonts|include|locale|man|modules|var|share|pkgconfig)/") for FILE in $LOG; do - if [ -f "$FILE" ] && [ ! -h "$FILE" ] && file -b "$FILE" | grep -q "ELF" && LD_LIBRARY_PATH=$NEW_LD ldd "$FILE" 2>&1 | grep -q "not found" ; then + if [ -f "$FILE" ] && [ ! -h "$FILE" ] && file -b "$FILE" | grep -q "ELF" && LD_LIBRARY_PATH=$NEW_LD ldd "$FILE" 2>&1 | egrep -q "(not found|lunar/OBSOLETE/)" ; then ( export IFS="$IFS_OLD" message "${FILE_COLOR}${FILE}${DEFAULT_COLOR} of ${MODULE_COLOR}${MODULE} ${PROBLEM_COLOR}is broken. ${DEFAULT_COLOR}" - LD_LIBRARY_PATH=$NEW_LD ldd "$FILE" 2>&1 | grep "not found" + LD_LIBRARY_PATH=$NEW_LD ldd "$FILE" 2>&1 | egrep "(not found|lunar/OBSOLETE/)" ) LDD_STATUS=1 fi diff --git a/prog/lunar b/prog/lunar index 395723c9c..7e1cb9ab1 100755 --- a/prog/lunar +++ b/prog/lunar @@ -514,6 +514,7 @@ feature_menu() { I_HELP="Create archives of installed software?" K_HELP="Keep source code in /usr/src on good compiles? (gcc profiling needs it)" M_HELP="Email reports?" + O_HELP="Preserve old libaries on module upgrade until lunar fix has completed?" P_HELP="Preserve modified files or backup them up and overwrite with defaults?" R_HELP="Prompt to view reports?" S_HELP="Play audio with prompts?" @@ -526,21 +527,22 @@ feature_menu() { Z_HELP="Custom modules in zlocal override equally named ones (NOT RECOMMENDED) ?" L_HELP="Use xz compression for logs and caches?" - ARCHIVE=${ARCHIVE:-on} - AUTORESURRECT=${AUTORESURRECT:-on} - AUTOFIX=${AUTOFIX:-on} - AUTOPRUNE=${AUTOPRUNE:-off} - COLOR=${COLOR:-on} - KEEP_SOURCE=${KEEP_SOURCE:-off} - MAIL_REPORTS=${MAIL_REPORTS:-off} - VIEW_REPORTS=${VIEW_REPORTS:-off} - PRESERVE=${PRESERVE:-on} - SOUND=${SOUND:-off} - SUSTAIN=${SUSTAIN:-on} - VOYEUR=${VOYEUR:-on} - REAP=${REAP:-on} - GARBAGE=${GARBAGE:-on} - VERBOSE=${VERBOSE:-off} + ARCHIVE=${ARCHIVE:-on} + AUTORESURRECT=${AUTORESURRECT:-on} + AUTOFIX=${AUTOFIX:-on} + AUTOPRUNE=${AUTOPRUNE:-off} + COLOR=${COLOR:-on} + KEEP_SOURCE=${KEEP_SOURCE:-off} +KEEP_OBSOLETE_LIBS=${KEEP_OBSOLETE_LIBS:-on} + MAIL_REPORTS=${MAIL_REPORTS:-off} + VIEW_REPORTS=${VIEW_REPORTS:-off} + PRESERVE=${PRESERVE:-on} + SOUND=${SOUND:-off} + SUSTAIN=${SUSTAIN:-on} + VOYEUR=${VOYEUR:-on} + REAP=${REAP:-on} + GARBAGE=${GARBAGE:-on} + VERBOSE=${VERBOSE:-off} case $VOYEUR in off) VOYEUR=off ; VOYEUR_progress=off ;; @@ -561,46 +563,48 @@ feature_menu() { --checklist \ "" \ 0 40 14 \ - "ARCHIVE" "Toggle" "$ARCHIVE" "$I_HELP" \ - "AUTORESURRECT" "Toggle" "$AUTORESURRECT" "$H_HELP" \ - "AUTOFIX" "Toggle" "$AUTOFIX" "$F_HELP" \ - "AUTOPRUNE" "Toggle" "$AUTOPRUNE" "$U_HELP" \ - "COLOR" "Toggle" "$COLOR" "$C_HELP" \ - "KEEP_SOURCE" "Toggle" "$KEEP_SOURCE" "$K_HELP" \ - "GARBAGE" "Toggle" "$GARBAGE" "$G_HELP" \ - "MAIL_REPORTS" "Toggle" "$MAIL_REPORTS" "$M_HELP" \ - "PRESERVE" "Toggle" "$PRESERVE" "$P_HELP" \ - "SOUND" "Toggle" "$SOUND" "$S_HELP" \ - "SUSTAIN" "Toggle" "$SUSTAIN" "$T_HELP" \ - "VIEW_REPORTS" "Toggle" "$VIEW_REPORTS" "$R_HELP" \ - "VOYEUR" "Choice" "$VOYEUR" "$V_HELP" \ - "VOYEUR_progress" "Choice" "$VOYEUR_progress" "$VP_HELP" \ - "REAP" "Toggle" "$REAP" "$E_HELP" \ - "VERBOSE" "Toggle" "$VERBOSE" "$W_HELP" \ - "ZLOCAL_OVERRIDES" "Toggle" "$ZLOCAL_OVERRIDES" "$Z_HELP" \ - "PROBE_EXPIRED" "Toggle" "$PROBE_EXPIRED" "$X_HELP" \ - "COMPRESS_XZ" "Toggle" "$COMPRESS_XZ" "$L_HELP"` + "ARCHIVE" "Toggle" "$ARCHIVE" "$I_HELP" \ + "AUTORESURRECT" "Toggle" "$AUTORESURRECT" "$H_HELP" \ + "AUTOFIX" "Toggle" "$AUTOFIX" "$F_HELP" \ + "AUTOPRUNE" "Toggle" "$AUTOPRUNE" "$U_HELP" \ + "COLOR" "Toggle" "$COLOR" "$C_HELP" \ + "KEEP_SOURCE" "Toggle" "$KEEP_SOURCE" "$K_HELP" \ + "KEEP_OBSOLETE_LIBS" "Toggle" "$KEEP_OBSOLETE_LIBS" "$O_HELP" \ + "GARBAGE" "Toggle" "$GARBAGE" "$G_HELP" \ + "MAIL_REPORTS" "Toggle" "$MAIL_REPORTS" "$M_HELP" \ + "PRESERVE" "Toggle" "$PRESERVE" "$P_HELP" \ + "SOUND" "Toggle" "$SOUND" "$S_HELP" \ + "SUSTAIN" "Toggle" "$SUSTAIN" "$T_HELP" \ + "VIEW_REPORTS" "Toggle" "$VIEW_REPORTS" "$R_HELP" \ + "VOYEUR" "Choice" "$VOYEUR" "$V_HELP" \ + "VOYEUR_progress" "Choice" "$VOYEUR_progress" "$VP_HELP" \ + "REAP" "Toggle" "$REAP" "$E_HELP" \ + "VERBOSE" "Toggle" "$VERBOSE" "$W_HELP" \ + "ZLOCAL_OVERRIDES" "Toggle" "$ZLOCAL_OVERRIDES" "$Z_HELP" \ + "PROBE_EXPIRED" "Toggle" "$PROBE_EXPIRED" "$X_HELP" \ + "COMPRESS_XZ" "Toggle" "$COMPRESS_XZ" "$L_HELP"` then - ARCHIVE=off - AUTORESURRECT=off - AUTOFIX=off - AUTOPRUNE=off - COLOR=off - KEEP_SOURCE=off - MAIL_REPORTS=off - PRESERVE=off - SOUND=off - SUSTAIN=off - VIEW_REPORTS=off - VOYEUR=off - REAP=off - GARBAGE=off - VERBOSE=off -ZLOCAL_OVERRIDES=off - PROBE_EXPIRED=off - COMPRESS_METHOD=bz2 + ARCHIVE=off + AUTORESURRECT=off + AUTOFIX=off + AUTOPRUNE=off + COLOR=off + KEEP_SOURCE=off +KEEP_OBSOLETE_LIBS=off + MAIL_REPORTS=off + PRESERVE=off + SOUND=off + SUSTAIN=off + VIEW_REPORTS=off + VOYEUR=off + REAP=off + GARBAGE=off + VERBOSE=off + ZLOCAL_OVERRIDES=off + PROBE_EXPIRED=off + COMPRESS_METHOD=xz for TOGGLE in $TOGGLES; do case $TOGGLE in @@ -610,6 +614,7 @@ ZLOCAL_OVERRIDES=off AUTOPRUNE) AUTOPRUNE=on ;; COLOR) COLOR=on ;; KEEP_SOURCE) KEEP_SOURCE=on ;; + KEEP_OBSOLETE_LIBS) KEEP_OBSOLETE_LIBS=on ;; MAIL_REPORTS) MAIL_REPORTS=on ;; PRESERVE) PRESERVE=on ;; SOUND) SOUND=on ;; @@ -638,6 +643,7 @@ ZLOCAL_OVERRIDES=off set_local_config "AUTOFIX" "$AUTOFIX" set_local_config "AUTOPRUNE" "$AUTOPRUNE" set_local_config "KEEP_SOURCE" "$KEEP_SOURCE" + set_local_config "KEEP_OBSOLETE_LIBS" "$KEEP_OBSOLETE_LIBS" set_local_config "MAIL_REPORTS" "$MAIL_REPORTS" set_local_config "PRESERVE" "$PRESERVE" set_local_config "SOUND" "$SOUND"