Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 May 2013, 11:41
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
/usr/sbin/bootmanager improvements
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [1 Post]  
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 2675
Location: Kiel,Germany

PostPosted: Fri 15 Jun 2012, 18:32    Post subject:  /usr/sbin/bootmanager improvements
Subject description: slow, ugly, others
 

Here i'll place my adjustments to bootmanager !

Today i decided 50 to 80 seconds had been too long on dual core 2,6GHz to build the addlist/yeslist database for the kernel modules .

Here's my yeslist function untidy, renamed to addlist() :

Code:
addlist_func() {
 #choose extra modules to load at bootup.

 TTY=`tty`
 TMP_DIR=/tmp/bootmanager;mkdir -p $TMP_DIR
 echo "Create db :`date`" 1>>$TTY

 #ALLMODULES="`cat /lib/modules/$KERNVER/modules.dep | cut -f 1 -d ':' | grep -o '[a-zA-Z0-9_-]*\.ko' | tr '\-' '_' | sort -u`"

 ALLMODULES=`modprobe -l |rev|cut -f 1 -d '/'|rev |sed 's|\.ko$||;s|\.ko\..*$||;s|-|_|g'|sort`
 echo "$ALLMODULES" > $TMP_DIR/ALLMODULES.lst
 HOW_MANY=`echo "$ALLMODULES" |wc -l`

 yaf-splash -font "8x16" -outline 0 -margin 4 -bg orange -text "Please wait, processing $HOW_MANY modules ..." &
 X1PID=$!

 . /etc/rc.d/MODULESCONFIG
 MODLIST=""
 #note, lsmod will show all modules with '-' as '_'...
 #LOADEDMODULES=" `lsmod | grep -v '^Module' | cut -f 1 -d ' ' | tr '\n' ' '`"

 LOADEDMODULES="`lsmod | grep -v '^Module' | cut -f 1 -d ' ' |sort`"
 echo "$LOADEDMODULES" > $TMP_DIR/LOADEDMODULES.lst
 grep -v -w -f $TMP_DIR/LOADEDMODULES.lst $TMP_DIR/ALLMODULES.lst > $TMP_DIR/FILTERED_MODULES.1.lst
 echo "$ADDLIST" |tr ' ' '\n ' |sed '/^$/d;s|\:.*||' |sort > $TMP_DIR/ADDLIST.lst
 grep -v -w -f $TMP_DIR/ADDLIST.lst $TMP_DIR/FILTERED_MODULES.1.lst > $TMP_DIR/FILTERED_MODULES.2.lst

 loop_1(){  #creates "off" list
 echo "First loop :`date`" 1>>$TTY
 for ONEMOD in $ALLMODULES
 do
  #NAMEONLY="`basename $ONEMOD .ko`"
  #NAMEONLY=${ONEMOD##*/};
  #NAMEONLY=${NAMEONLY//\.ko*/}
  #NAMEONLY=${ONEMOD//\.ko*/}
  NAMEONLY="$ONEMOD"
  MODPATTERN=" $NAMEONLY "
  #leave off list if already loaded...
  [ "`echo "$LOADEDMODULES" | grep "$MODPATTERN"`" ] && continue
  MODPATTERN=' '"$NAMEONLY"'[ :]'
  #leave off left pane if already on right pane...
  [ "`echo "$ADDLIST" | grep "$MODPATTERN"`" ] && continue
  MODLIST="$MODLIST $NAMEONLY $NAMEONLY off"
 done
 echo "First loop :`date`" 1>>$TTY
}

 cat $TMP_DIR/FILTERED_MODULES.2.lst | sed 's|\(.*\)|\1 \1 off|' > $TMP_DIR/OFFLIST.lst
 cat $TMP_DIR/ADDLIST.lst  | sed 's|\(.*\)|\1 \1 on|' > $TMP_DIR/ONLIST.lst

 loop_2(){  ##creates "on" list
 echo "Second loop :`date`" 1>>$TTY
 #check for parameters
 for ONEMOD in $ADDLIST
 do
  NAMEONLY="$ONEMOD"
  xONEMOD="$ONEMOD"
  if [ `echo -n "$ONEMOD" | tr ':' ' ' | wc -w` -gt 1 ];then
   MPARAMS="`echo -n "$ONEMOD" | cut -f 2-9 -d ':' | tr ':' ' '`"
   NAMEONLY="`echo -n "$ONEMOD" | cut -f 1 -d ':'`"
   xONEMOD="$NAMEONLY $MPARAMS"
  fi
  MODPATTERN=" $NAMEOLY "
  #leave off list if already loaded...
  [ "`echo "$LOADEDMODULES" | grep "$MODPATTERN"`" != "" ] && continue
  MODLIST="$MODLIST $ONEMOD \"$xONEMOD\" on"
 done
 echo "Second loop :`date`" 1>>$TTY
}

 MODLIST="`cat $TMP_DIR/ONLIST.lst |tr '\n' ' '` `cat $TMP_DIR/OFFLIST.lst |tr '\n' ' '`"
 kill $X1PID
 echo "Create db :`date`" 1>>$TTY
 echo "Xdialog: `date`" 1>>$TTY
 #gui
 EXECME="Xdialog --wmclass \"module16\" --title \"BootManager: Module add-list manager\" --left --stdout --separator \" \" --buildlist \"On the left pane is the complete list of modules available to be\nused by Puppy (and not currently loaded).\nOn the right pane are modules that you have explicitly chosen to\nbe loaded at bootup (not auto-loaded by default).\nIf you want to force a module to load, move it to the right pane,\nclick OK button, then reboot Puppy.\nNote, if you want to find out further information about any module,\nrun PupScan (look in the System menu)\" 0 0 8 $MODLIST >$TMP_DIR/yesrettags.txt"
 eval $EXECME
 RETVAL=$?
 echo "Xdialog: `date`" 1>>$TTY
 [ $RETVAL -eq 0 ] || return 1
 cat $TMP_DIR/yesrettags.txt | tr ' ' '\n' | tr ':' ' ' > $TMP_DIR/modules_addlist_edit #v411
 Xdialog --backtitle "If you wish, add any required parameters to these modules\nExample: mmc_block major=179\nIf you don't know what this means, just click 'OK' button"  --wmclass "module16" --title "BootManager: Edit module addlist" --left --stdout --no-cancel --editbox $TMP_DIR/modules_addlist_edit 0 0 > $TMP_DIR/modules_addlist_edit_out
 [ $? -ne 0 ] && return 1
 ADDLIST="`cat $TMP_DIR/modules_addlist_edit_out`"
 ADDLIST=' '"`echo "$ADDLIST" | tr ' ' ':' | tr '\n' ' ' | tr -s ' '`"
 #ADDLIST=" `cat /tmp/yesrettags.txt | tr '\n' ' '`"
 #now update /etc/rc.d/MODULESCONFIG...
 grep -v '^ADDLIST' /etc/rc.d/MODULESCONFIG > /tmp/MODULESCONFIG
 mv -f /tmp/MODULESCONFIG /etc/rc.d/MODULESCONFIG
 echo "ADDLIST='${ADDLIST}'" >> /etc/rc.d/MODULESCONFIG
} #end addlist_func


using basename i had for the loop_1 times :
First loop :Fr 15. Jun 23:08:59 GMT+1 2012
First loop :Fr 15. Jun 23:10:12 GMT+1 2012
1min 13 sec .

using shell substitution for loop_1
First loop :Fr 15. Jun 23:27:25 GMT+1 2012
First loop :Fr 15. Jun 23:28:20 GMT+1 2012
55 sec .

using ^heavy^ grep and sed :
Create db :Sa 16. Jun 00:14:08 GMT+1 2012
Create db :Sa 16. Jun 00:14:09 GMT+1 2012
1 sec.
:SHOCK: Very Happy

:NOTE: it is 4.3.1 bootmanager in this post !

[update 2012-06-20]

added two times -w option to grep

grep -v -f $TMP_DIR/*.lst would accidentally filter all acpi modules for exemple if 'ac' module is currently loaded

[/update 2012-06-20]
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [1 Post]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0448s ][ Queries: 11 (0.0027s) ][ GZIP on ]