[Lunar-commits] CVS: theedge/var/lib/lunar/plugins check-find.plugin, NONE, 1.1 check-ldd.plugin, NONE, 1.1 check-md5sum.plugin, NONE, 1.1 check-symlinks.plugin, NONE, 1.1

Auke Kok sofar at lunar-linux.org
Fri Mar 25 17:56:16 UTC 2005


Update of /var/cvs/lunar/theedge/var/lib/lunar/plugins
In directory espresso.foo-projects.org:/tmp/cvs-serv11404/var/lib/lunar/plugins

Added Files:
	check-find.plugin check-ldd.plugin check-md5sum.plugin 
	check-symlinks.plugin 
Log Message:
Rewriting fix code:
- now plugins instead of one large file
- lunar fix/nofix now runs better per-module
- global lunar fix/nofix doesn't perform expensive ld_export overhead


--- NEW FILE: check-find.plugin ---
#!/bin/bash
#############################################################
#                                                           #
# check-find.plugin - plugin that performs file presence    #
#                       checking of installed modules       #
#                                                           #
#############################################################
#                                                           #
# Copyright 2005 by Auke Kok under GPLv2                    #
#                                                           #
#############################################################


plugin_module_check_find() {
  if [ "$FIND_CHECK" == "off" ] ; then
    return 2
  fi
  debug_msg "plugin_module_check_find ($@)"
  
  MODULE=$1
  VERSION=$(installed_version $MODULE)
  I_LOG=$INSTALL_LOGS/$MODULE-$VERSION
  FIND_STATUS=2

  if [ -e "$I_LOG" ]; then
    IFS_OLD="$IFS"
    export IFS="
"

    LOG=$(cat $I_LOG | grep "/bin/\|/games/\|/include/\|/lib/\|/sbin/" | grep -v  "/doc/\|/etc/\|/fonts/\|/man/\|/var/")

    for ITEM in $LOG ; do
      if [ ! -e "$ITEM" ]; then
        (
          export IFS="$IFS_OLD"
          message "${FILE_COLOR}${ITEM}${DEFAULT_COLOR} of ${MODULE_COLOR}${MODULE}${PROBLEM_COLOR} is missing.${DEFAULT_COLOR}"
        )
        FIND_STATUS=1
      fi
    done
  else
    (
      export IFS="$IFS_OLD"
      message "${MODULE_COLOR}${MODULE}${PROBLEM_COLOR} is missing an install log.${DEFAULT_COLOR}"
    )
    FIND_STATUS=1
  fi
  return $FIND_STATUS
}


plugin_register MODULE_CHECK plugin_module_check_find



--- NEW FILE: check-ldd.plugin ---
#!/bin/bash
#############################################################
#                                                           #
# check-ldd.plugin - plugin that performs ldd checking      #
#                                                           #
#############################################################
#                                                           #
# Copyright 2005 by Auke Kok under GPLv2                    #
#                                                           #
#############################################################


plugin_module_check_ldd() {
  if [ "$LDD_CHECK" == "off" ]; then
    return 2
  fi
  debug_msg "plugin_module_check_ldd ($@)"

  MODULE=$1
  VERSION=$(installed_version $MODULE)
  I_LOG=$INSTALL_LOGS/$MODULE-$VERSION
  LDD_STATUS=2

  if [ -e "$I_LOG" ]; then
    IFS_OLD="$IFS"
    export IFS="
"

    # fast-construct per-module LD path including all /lib/ like directories
    NEW_LD=$(cat $I_LOG | grep "/lib/" | files | sed 's/\(.*\)\/\([^\/]*\)$/\1/g' | uniq | tr '\n' ':')
    LOG=$(cat $I_LOG | grep "/bin/\|/games/\|/lib/\|/sbin/\|/libexec/" | grep -v "/doc/\|/fonts/\|/include/\|/locale/\|/man/\|/modules/\|/var/")

    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
        (
          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"
        )
        LDD_STATUS=1
      fi
    done
  fi
  return $LDD_STATUS
}


plugin_register MODULE_CHECK plugin_module_check_ldd



--- NEW FILE: check-md5sum.plugin ---
#!/bin/bash
#############################################################
#                                                           #
# check-md5sum.plugin - plugin that performs integrity      #
#                       checking of installed modules       #
#                                                           #
#############################################################
#                                                           #
# Copyright 2005 by Auke Kok under GPLv2                    #
#                                                           #
#############################################################


plugin_module_check_md5sum()  {
  # return CONTINUE if we're disabled
  if [ "$MD5SUM_CHECK" == "off" ]; then
    return 2
  fi
  debug_msg "plugin_module_check_md5sum ($@)"

  MODULE=$1
  VERSION=$(installed_version $MODULE)
  MD5_LOG="$MD5SUM_LOGS/$MODULE-$VERSION"
  # by default, do not return OK but CONTINUE
  MD5SUM_STATUS=2

  if [ -e "$MD5_LOG" ]; then
    IFS_OLD="$IFS"
    export IFS="	
"

    OUTPUT=$(cat $MD5_LOG                                         |
            grep "/bin/\|/games/\|/include/\|/lib/\|/sbin/"       |
            grep -v "/doc/\|/etc/\|/fonts/\|/man/\|/var/"         |
            md5sum --check 2>/dev/null | grep -v ": OK" | cut -d: -f1)

    if [ -n "$OUTPUT" ]; then
      for FILE in $OUTPUT; do
        if [ -f "$FILE" ] && [ ! -h "$FILE" ] && file -b "$FILE" |
		    egrep -q "executable|shared object|current ar archive" ; then
          MD5SUM=$(md5sum "$FILE")
          if ! grep -q "$MD5SUM" $MD5SUM_LOGS/*; then
            message "${FILE_COLOR}$FILE${DEFAULT_COLOR} of ${MODULE_COLOR}$MODULE${PROBLEM_COLOR} has wrong md5sum.${DEFAULT_COLOR}"
            MD5SUM_STATUS=1
          fi
        fi
      done
    fi
  else
    message "${MODULE_COLOR}$MODULE${PROBLEM_COLOR}is missing a md5sum log.${DEFAULT_COLOR}"
  fi
  return $MD5SUM_STATUS
}


plugin_register MODULE_CHECK plugin_module_check_md5sum



--- NEW FILE: check-symlinks.plugin ---
#!/bin/bash
#############################################################
#                                                           #
# check-symlinks.plugin - plugin that performs symlink      #
#                         checking of installed modules     #
#                                                           #
#############################################################
#                                                           #
# Copyright 2005 by Auke Kok under GPLv2                    #
#                                                           #
#############################################################


plugin_module_check_symlinks()  {
  # return CONTINUE if we're disabled
  if [ "$SYM_CHECK" == "off" ]; then
    return 2
  fi
  debug_msg "plugin_module_check_symlinks ($@)"

  MODULE=$1
  VERSION=$(installed_version $MODULE)
  I_LOG=$INSTALL_LOGS/$MODULE-$VERSION

  if [ -e "$I_LOG" ]; then
    IFS_OLD="$IFS"
    export IFS="
"

    cat $I_LOG | while read ITEM ; do
      if [ -h "$ITEM" ] && [ -f "$ITEM" ] ; then
      TARGET=$( basename $( ls -la "$ITEM" | cut -d '>' -f2 | cut -c 2- ) )
        if ! grep -q "$TARGET" $I_LOG ; then
         (
          export IFS="$IFS_OLD"
          F_TMP=$(temp_create "$MODULE.remove-line")
          cp $I_LOG $F_TMP
          grep -v $ITEM $F_TMP > $I_LOG
          temp_destroy $F_TMP
          message  "Symbolic link: ${SYMLINK_COLOR}${ITEM}${DEFAULT_COLOR} is owned by ${MODULE_COLOR}${MODULE}${DEFAULT_COLOR}"
          message  "Target of symbolic link is ${FILE_COLOR}${TARGET}${DEFAULT_COLOR}"
          message  "${FILE_COLOR}${TARGET}${DEFAULT_COLOR} is owned by $(grep "^$TARGET$" $INSTALL_LOGS/* | cut -d: -f1)"
          message  "Removed: ${SYMLINK_COLOR}${ITEM}${DEFAULT_COLOR} from ${I_LOG}"
         )
        fi
      fi
    done
  fi
  # always return CONTINUE
  return 2
}


plugin_register MODULE_CHECK plugin_module_check_symlinks





More information about the Lunar-commits mailing list