Patch for lvu search|links|service

ratler at lunar-linux.org ratler at lunar-linux.org
Thu Feb 19 19:48:54 GMT 2004


I forwarding this patch from a friend named Linus Swälas, he isn't
currently subscribed but will be soon.

This will speed up search A LOT, from 3 min28sec to 3.4 sec on my laptop.

Sincerely
Ratler
-------------- next part --------------
--- lvu	2004-02-19 20:29:37.000000000 +0100
+++ lvu.new	2004-02-19 20:09:19.000000000 +0100
@@ -861,10 +861,9 @@
     search)
-      for SECTION in $(list_sections) ; do
-        for MODULE in $(list_modules $SECTION) ; do
-        (
-          run_module_file $MODULE DETAILS | grep -q -i "$2" &&
-          echo "$SECTION/$MODULE"
-        )
+      for SECTION in $(list_sections)
+      do
+        for MODULE in $(list_modules $SECTION)
+	do
+          echo "$MOONBASE/$SECTION/$MODULE/DETAILS"
 	done
-      done
+      done | xargs egrep -l -i "$2" | sed "s;${MOONBASE}/\(.*\)/DETAILS;\1;"
       ;;
@@ -872,10 +871,10 @@
     service)
-      for SECTION in $(list_sections) ; do
-        for MODULE in $(list_modules $SECTION) ; do
-          if [ -f $MOONBASE/$SECTION/$MODULE/services ] && 
-              grep -q -i "$2" $MOONBASE/$SECTION/$MODULE/services ; then
-            echo "$SECTION/$MODULE"
-          fi
+      for SECTION in $(list_sections)
+      do
+        for MODULE in $(list_modules $SECTION)
+	do
+          [[ -f $MOONBASE/$SECTION/$MODULE/services ]] && \
+	  	echo "$MOONBASE/$SECTION/$MODULE/services"
 	done
-      done
+      done | xargs egrep -l -i "$2" | sed "s;${MOONBASE}/\(.*\)/services;\1;"
       ;;
@@ -999,19 +998,18 @@
    links)
-     if [ -z "$2" ] ; then
-       return 1
-     else
-       for FILE in $(lvu install $2) ; do
-         TYPE=$(file $FILE | cut -d' ' -f2)
-         if [[ "$TYPE" == "ELF" ]] ; then
-           BINARIES="$BINARIES $FILE"
-           verbose_msg "found binary: \"$FILE\""
-         fi
-       done
-       for BINARY in $BINARIES ; do
-         LINKSTO=$(ldd $BINARY | cut -d' ' -f3)
-       done
-       for LINK in $LINKSTO ; do
-         lvu from $LINK | cut -d: -f1
-       done | sort | uniq
-     fi
+     [[ -z "$2" ]] && return 1
+
+     REGEX=""
+     for LINK in `lvu install $2 | xargs file | awk -F: '/ELF/ { print $1 }' | xargs ldd | egrep -v ':$' | cut -d' ' -f3 | sort | uniq`
+     do
+	 if [[ -z $REGEX ]]
+	 then
+	 	REGEX="($LINK)"
+	 else
+	 	REGEX="${REGEX}|($LINK)"
+	 fi
+     done
+
+     pushd $INSTALL_LOGS >/dev/null
+     egrep -l "$REGEX" *
+     popd >/dev/null
      ;;


More information about the Lunar mailing list