Creatiing a new iso: new pinstall.sh scripts

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
papaschtroumpf
Posts: 250
Joined: Fri 17 Jun 2005, 04:23

Creatiing a new iso: new pinstall.sh scripts

#1 Post by papaschtroumpf »

the "configuring fvwm95 menu" step of creating a new iso takes forever(over an hour), and several other steps that loop on every keyword also take a long time.
Maybe it's because I'm running under Virtual PC rather than a real machine but everything else seems to run at decent speed (the host machine is an Athlon XP3200+ with 1G of RAM, although the virtual machine only gets 256M).
Procesor usage is at close to 100% during that time.

I'm trying to understand what the psinstall.sh for fvwm95 does.

it looks like given a list of keywords it searches for the pattern :#+ "KEYWORD and removes the #

I don't understand why it is processed one line at a time by creating a new process for each line, etc...

unless the version of sed in puppy has limitations that one wouldn't expect, you should be able to process the entire file in one command. For example for the keyword Mozilla:

sed -e 's/^#+ "Mozilla/+ "Mozilla/' fvwm95rc >txt
mv -f txt fvwm95rc

this would uncomment the 4 instances of Mozilla (browser, address book, ...)

You would still need to run the command for every keyword but there are at most 300 of them so it shouldn't take an hour:

#!/bin/sh
for ONEKEY in $KEYWORDS
do
sed -e "s/^#+ \"$ONEKEY /+ \"$ONEKEY /" .fwvm95rc >txt
cp -f txt .fwvm95rc
done

you might be able to use the -in-place option of sed rather than do a copy if puppy supports it but I'm not sure it would be faster.
Mandriva LE 2005 user and puppy newbie

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#2 Post by BarryK »

yes, the "createpuppy" script does that awfully slowly.
At the time I was learning how to filter through a text file line-by-line using only Bash/Ash script. The method chosen is inefficient.

Well, you could rewrite it, if you can think of some better way.
I did come up with something better later on, but the thing is, when something is working, it gets placed lower on the priority list.

User avatar
papaschtroumpf
Posts: 250
Joined: Fri 17 Jun 2005, 04:23

#3 Post by papaschtroumpf »

I'll give it a shot.I'm taking a "snpahot" of what the relevant files look like at the end of the process so I can compare it to the output of the one I intend to write.
I'll let you know if I come up with something good and you can decide if you want to incorporate it in future versions or not.
Mandriva LE 2005 user and puppy newbie

User avatar
papaschtroumpf
Posts: 250
Joined: Fri 17 Jun 2005, 04:23

#4 Post by papaschtroumpf »

What does the similar loop in 0rootfs_skeletton.... (starting around line 62) do exactly? I haven't fully "unwrapped" the script yet.

EDIT: looks like it builds the documentation index.html file but not sure what its input is yet.
EDIT AGAIN: OK I get it now, all it does is uncomment the right lines in index.html. I assume PupGet does something similar when you add a package, otherwise it waste less space to simply remove the line.

I'll see if I can speed up that one too.
Mandriva LE 2005 user and puppy newbie

User avatar
papaschtroumpf
Posts: 250
Joined: Fri 17 Jun 2005, 04:23

#5 Post by papaschtroumpf »

Barry, why don't you give this a try:

replace the pinstall.sh in 0root-skeleton-1.0.3 with the following and let me know if the resulting files are OK (It doesn't remove the spaces after "<!--")

I only changed the part that took a long time (rebuilding index.html) why touch the rest if it ain't broke?

Takes seconds instead of many minutes.

Code: Select all

#!/bin/sh
#post-install script.
#Puppy Linux
#assume current directory is rootfs-complete, which has the final filesystem.
#this script is similar to the post-install scripts of the window managers.
#Keywords are located in the Help page and the lines uncommented.

WKGDIR="`pwd`"

CONFIGFILE="usr/share/doc/index.html"
CONFIGBASE="index.html"
echo "Configuring Puppy skeleton..."

#cleanup...
rm -f /tmp/fbvideomode.txt


#/tmp/keywords.txt has all the keywords read from file "keyword" in each package.
KEYWORDS="`cat /tmp/keywords.txt`"
NUMKEYS="`wc -w /tmp/keywords.txt | tr -s " " | cut -f 2 -d " "`"

#number lines in the config file...
NUMLINES="`wc -l $CONFIGFILE | tr -s " " | cut -f 2 -d " "`"

#update Puppy version number...
PUPPYVERSION="`cat root0/.etc/puppyversion`"
#echo
echo "Have read rootfs-complete/etc/puppyversion."
echo "The current version of Puppy is $PUPPYVERSION (3 digits, no dots)."
echo -n "Type a new value now, or only press ENTER to keep current: "
read nnnn
if [ ! "$nnnn" = "" ];then
 echo "Puppy version is now $nnnn"
 PUPPYVERSION="$nnnn"
fi
rm -f root0/.etc/puppyversion
echo -n "$PUPPYVERSION" > root0/.etc/puppyversion
DIGIT1="`echo "$PUPPYVERSION" | cut -b 1`"
DIGIT2="`echo "$PUPPYVERSION" | cut -b 2`"
DIGIT3="`echo "$PUPPYVERSION" | cut -b 3`"
RIGHTVER="${DIGIT1}.${DIGIT2}.${DIGIT3}"

echo "Configuring Puppy Help page..."

echo "Writing version number to Help page..."
#insert the version number into file...
EDITTEXT="s/PUPPYVERSION/$RIGHTVER/g"
cat $CONFIGFILE | sed -e "$EDITTEXT" > /tmp/puphelppage.htm
sync
cp -f /tmp/puphelppage.htm $CONFIGFILE
sync

#insert date into file...
echo "Writing the date to Help page..."
PUPPYDATE="`date | tr -s " " | cut -f 2,6 -d " "`"
EDITTEXT="s/PUPPYDATE/$PUPPYDATE/g"
cat $CONFIGFILE | sed -e "$EDITTEXT" > /tmp/puphelppage.htm
sync
cp -f /tmp/puphelppage.htm $CONFIGFILE
sync


REBUILDMENU="yes"
if [ -f /tmp/bypassmenurebuild ];then
 #bypassmenurebuild will only exist if previous execution of createpuppy had the
 #identical chosen packages.
 if [ -f ../$CONFIGBASE.bak ];then
  cp -f ../$CONFIGBASE.bak $CONFIGFILE
  REBUILDMENU="no"
 fi
fi

if [ "$REBUILDMENU" = "yes" ];then
 echo "The number of keywords to process is $NUMKEYS."
 echo "Processing keywords..."
 for ONEKEY in $KEYWORDS
 do
  echo -n " $ONEKEY"
  sync
  #remove the <!-- and --> markers if the line contains the keyword
  EDITTEXT="s/^<!--\(.\+$ONEKEY.\+\)-->/\1/"
  sed -e "$EDITTEXT" $CONFIGFILE > /tmp/0rootfs_skeleton.pinstall.temp
  sync
  mv -f /tmp/0rootfs_skeleton.pinstall.temp $CONFIGFILE
 done
 cp -f $CONFIGFILE ../$CONFIGBASE.bak
fi
rm -f /tmp/0rootfs_skeleton.pinstall.temp

echo
echo "...rootfs-complete/$CONFIGFILE file has been processed."

#echo "The default kernel for Puppy is vmlinuz."
echo -n "vmlinuz" > /tmp/vmlinuzforpup.txt
#note, createpuppy will read this.

#end#


I'm working on changing the pinstall.sh for fvm95 to make it faster too and I'll post it when I'm done.
Mandriva LE 2005 user and puppy newbie

User avatar
papaschtroumpf
Posts: 250
Joined: Fri 17 Jun 2005, 04:23

#6 Post by papaschtroumpf »

Here's the fast version of the pinstall.sh for fvwm95
(only changed the menu building which was taking forever)

Code: Select all

#!/bin/sh
#post-install script.
#Puppy Linux
#assume current directory is rootfs-complete, which has the final filesystem.
WKGDIR="`pwd`"

####CHANGE THESE THREE LINES FOR ANOTHER W.M.#####
echo "Configuring menu for Fvwm95 window manager..."
CONFIGFILE="root0/.fvwm95rc"
CONFIGBASE="DOTfvwm95rc"

#...for example above line actually finds string:  #+ "Gcombust
#   replaces it with + "Gcombust, in case of keyword being Gcombust.
#   The above code is somewhat obfuscated. What we end up with below is:
#    sed -e 'g/#+ "Gcombust/+ "Gcombust/s'

#...well, this is simply removing a # in column 1 to uncomment the line.
#   an xml config file may have <!-- stuff in here --> so you will have to
#   do it a bit differently -- see JWM post-install script for an example.

#/tmp/keywords.txt has all the keywords read from file "keyword" in each package.
KEYWORDS="`cat /tmp/keywords.txt`"
NUMKEYS="`wc -w /tmp/keywords.txt | tr -s " " | cut -f 2 -d " "`"

REBUILDMENU="yes"
if [ -f /tmp/bypassmenurebuild ];then
 #bypassmenurebuild will only exist if previous execution of createpuppy had the
 #identical chosen packages.
 if [ -f ../$CONFIGBASE.bak ];then
  cp -f ../$CONFIGBASE.bak $CONFIGFILE
  REBUILDMENU="no"
 fi
fi

if [ "$REBUILDMENU" = "yes" ];then
 echo "The number of keywords to process is $NUMKEYS."
 echo "Processing keywords (this may take awhile!)..."

 for ONEKEY in $KEYWORDS
 do
  echo -n " $ONEKEY"
  #remove the # at the start of the line if it is #+ "ONEKEY
  EDITTEXT="s/^#+ \"$ONEKEY /+ \"$ONEKEY /"
  sync
  sed -e "$EDITTEXT" $CONFIGFILE > /tmp/fvwm95.pinstall.temp
  sync
  mv -f /tmp/fvwm95.pinstall.temp $CONFIGFILE
 done
 cp -f $CONFIGFILE ../$CONFIGBASE.bak
fi
rm /tmp/fvwm95.pinstall.temp
echo
echo "...rootfs-complete/$CONFIGFILE file has been processed."

#NOTE:
#This script is not complete. Unfortunately there is an inconsistency in the format
#of menu syntax in Fvwm config file, and curently have left the first item in each
#menu group permanently enabled. It is probably possible to rectify that, but will
#need some crafty code here. Basically, first item has a space or tab in column one,
#following items have a + character.
echo
echo "WARNING: Unfortunately there is an inconsistency in the /root/.fvwm95rc config"
echo "file such that the first item in each sub-menu cannot be commented-out."
echo "The items are:"
echo " Find menu: Gtkcat, Run menu: Xrun, Games menu: Bubbles, Multimedia: Xtmix,"
echo " Internet menu: Gftp, Graphics: Xpaint, Wordprocessing: Abiword, Calc: Xcalc,"
echo " Information menu: Xcalendar, File menu: ROX-Filer."
echo "This means that you MUST choose these packages, otherwise you need to manually"
echo "edit /root0/.fvwm95rc."
echo
echo -n "Press ENTER key to continue script: "
read mmnn

#end#
jwm script coming up soon
Mandriva LE 2005 user and puppy newbie

User avatar
papaschtroumpf
Posts: 250
Joined: Fri 17 Jun 2005, 04:23

#7 Post by papaschtroumpf »

as promised this is the pinstall.sh script for the jwm unleashed, rebuilds the menus in a fraction of the time.

I'll do more testing later to make sure it's all fine. Let me know if you find any issues.

Code: Select all

#!/bin/sh
#post-install script.
#Puppy Linux
#assume current directory is rootfs-complete, which has the final filesystem.
WKGDIR="`pwd`"

####CHANGE THESE LINES FOR ANOTHER W.M.#####
CONFIGFILE="root0/.jwmrc"
CONFIGBASE="DOTjwmrc"
echo "Configuring menu for JWM window manager..."
####ALSO CHANGE CODE BELOW THAT UNCOMMENTS LINE####

#...JWM config file is in xml format, all menu items commented out:
#   <!--   <Program label="Gcombust" icon="gcombust.xpm">gcombust</Program> -->

#/tmp/keywords.txt has all the keywords read from file "keyword" in each package.
KEYWORDS="`cat /tmp/keywords.txt`"
NUMKEYS="`wc -w /tmp/keywords.txt | tr -s " " | cut -f 2 -d " "`"


REBUILDMENU="yes"
if [ -f /tmp/bypassmenurebuild ];then
 #bypassmenurebuild will only exist if previous execution of createpuppy had the
 #identical chosen packages.
 if [ -f ../$CONFIGBASE.bak ];then
  cp -f ../$CONFIGBASE.bak $CONFIGFILE
  REBUILDMENU="no"
 fi
fi

if [ "$REBUILDMENU" = "yes" ];then
 echo "The number of keywords to process is $NUMKEYS."
 echo "Processing keywords (this may take awhile!)..."
 for ONEKEY in $KEYWORDS
 do

  echo -n " $ONEKEY"
  sync
  #remove the <!-- and --> markers if the line contains the keyword
  EDITTEXT="s/^<!-- \+\(<Program label=\"$ONEKEY.\+\)-->/\1/"
  sed -e "$EDITTEXT" $CONFIGFILE > /tmp/jwm.pinstall.temp
  sync
  mv -f /tmp/jwm.pinstall.temp $CONFIGFILE
  sync
 done
 cp -f $CONFIGFILE ../$CONFIGBASE.bak
fi
  rm -f /tmp/jwm.pinstall.temp
echo
echo "...rootfs-complete/$CONFIGFILE file has been processed."

#v1.0.3
#case of fvwm95 not there...
if [ ! -f /usr/X11R6/bin/fvwm95 ];then
 echo -n "jwm" > ./etc/windowmanager
fi
sync

#end#

Mandriva LE 2005 user and puppy newbie

User avatar
papaschtroumpf
Posts: 250
Joined: Fri 17 Jun 2005, 04:23

#8 Post by papaschtroumpf »

I made the scripts available in one easy to apply path, see this thread: http://www.murga.org/~puppy/viewtopic.php?p=4123#4123
Mandriva LE 2005 user and puppy newbie

Post Reply