home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / remasterpup2 < prev    next >
Encoding:
Text File  |  2006-06-27  |  22.0 KB  |  549 lines

  1. #!/bin/sh
  2. #simple script to remaster the puppy2 live-cd.
  3. #(c) Copyright 2006 Barry Kauler, www.puppyos.com
  4.  
  5. PUPPYVERSION="`cat /etc/puppyversion`"
  6.  
  7. if [ "`mount | grep '/initrd/pup_ro2'`" = "" ];then
  8.  #no pup_xxx.sfs file mounted on pup_ro2, probably h.d. install...
  9.  Xdialog --left --title "Puppy simple remaster CD: ERROR" --msgbox "This program requires a pup_$PUPPYVERSION.sfs file mounted on /initrd/pup_ro2.
  10. Which is not the case here, probably because this is a full hard drive
  11. installation? Whatever, boot Puppy from live-CD and then you will be able to
  12. use this script.
  13.  
  14. Note, I have not tried it, but if you setup the situation of pup_$PUPPYVERSION.sfs
  15. mounted on directory /initrd/pup_ro2, that will be acceptable for this program.
  16. You will also need a current live-CD, as the program gets files off it.
  17. Anyone want to try it?
  18.  
  19. Click 'Ok' button to quit..." 0 0
  20.  exit
  21. fi
  22.  
  23.  
  24. #these are created at bootup by /initrd/usr/sbin/init...
  25. PUPMODE=`cat /etc/rc.d/PUPMODE` #a number, see /initrd/usr/sbin/init.
  26. PDEV1="`cat /etc/rc.d/PDEV1`"     #the partition have booted off.
  27. DEV1FS="`cat /etc/rc.d/DEV1FS`"   #f.s. of PDEV1.
  28. PUPSFS="`cat /etc/rc.d/PUPSFS`"   #=pup_001.sfs versioned name, stored on PDEV1
  29. PUPSAVE="`cat /etc/rc.d/PUPSAVE`" #=vfat,sda1,/pup_save.3fs location & name of persistent storage file.
  30. PMEDIA="`cat /etc/rc.d/PMEDIA`"
  31.  
  32. SAVEPART="$PDEV1"
  33. CDR="/dev/$SAVEPART"
  34.  
  35. #choose where to create isolinux-builds/ directory...
  36. Xdialog --left --title "Puppy2 simple CD remaster" --msgbox "Welcome! This little program takes a snapshot of your current system and burns
  37. it to CD.
  38.  
  39. A Puppy2 live-CD has 4 main files: vmlinuz, isolinux.cfg, initrd.gz, and
  40. pup_$PUPPYVERSION.sfs, where $PUPPYVERSION is the current version number (without dots).
  41.  
  42. It is the last file that mainly interests us here: it has the entire Puppy
  43. filesystem, everything from '/' down. What this script does is rebuild this
  44. file pup_$PUPPYVERSION.sfs, with everything currently under '/' -- that is, all
  45. installed packages (DotPups and PupGets), all mounted .sfs extension files,
  46. everything, gets combined into one file, pup_$PUPPYVERSION.sfs and burnt to CD.
  47. Note, if you have an 'underdog Linux' mounted, that too will get combined
  48. into the pup_$PUPPYVERSION.sfs file, so beware, it could get big!
  49.  
  50. Click OK button to continue..." 0 0
  51.  
  52. [ ! $? -eq 0 ] && exit
  53.  
  54. #calc size needed...
  55. Xdialog --title "Puppy2 simple CD remaster" --msgbox "Calculating needed working space.\nPlease wait, this may take awhile..." 0 0 &
  56. XPID=$!
  57. SIZEOPT=0
  58. SIZEBIN=`du -sk /bin | cut -f 1`
  59. SIZESBIN=`du -sk /sbin | cut -f 1`
  60. SIZELIB=`du -sk /lib | cut -f 1`
  61. SIZEUSR=`du -sk /usr | cut -f 1`
  62. [ -d /opt ] && SIZEOPT=`du -sk /opt | cut -f 1`
  63. sync
  64. kill $XPID
  65. SIZETOTALK=`expr $SIZEBIN + $SIZESBIN + $SIZELIB + $SIZEUSR + $SIZEOPT`
  66. SIZETOTALM=`expr $SIZETOTALK \/ 1024`
  67. echo "SIZETOTALM=$SIZETOTALM"
  68. #estimate a compressed size...
  69. SIZENEEDEDM=`expr $SIZETOTALM \/ 3`
  70. SIZESLACKM=`expr $SIZENEEDEDM \/ 4` #guess
  71. SIZENEEDEDM=`expr $SIZENEEDEDM + $SIZESLACKM`
  72. SIZENEEDEDM=`expr $SIZENEEDEDM + 5` #space for vmlinuz, initrd.gz, etc
  73.  
  74. #now choose working partition...
  75. PARTSLIST="`probepart -m 2> /dev/null | grep '^/dev/' | grep --extended-regexp 'ext2|ext3|reiserfs|msdos|vfat' | cut -f 1-3 -d '|'`"
  76.  
  77.  echo -n "" > /tmp/schoices.txt
  78.  echo "$PARTSLIST" |
  79.  while read APART
  80.  do
  81.   ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
  82.   ASIZE="`echo -n "$APART" | cut -f 3 -d '|'`"
  83.   AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
  84.   AFREE="`df -m | grep "/dev/$ATAG" | tr -s " " | cut -f 4 -d " "`"
  85.   if [ ! "$AFREE" ];then
  86.    mount -t $AFS /dev/$ATAG /mnt/data > /dev/null 2>&1
  87.    if [ $? -eq 0 ];then
  88.     if [ "$ATAG" = "fd0" ];then
  89.      FFREE=`df -k | grep "/dev/$ATAG" | tr -s " " | cut -f 4 -d " "`
  90.      AFREE="`dc $FFREE 1000 \/ p`"
  91.     else
  92.      AFREE="`df -m | grep "/dev/$ATAG" | tr -s " " | cut -f 4 -d " "`"
  93.     fi
  94.     umount /dev/$ATAG
  95.    fi
  96.   fi
  97.   #AVALUE="off"
  98.   #[ "$ATAG" = "$PDEV1" ] && AVALUE="on"
  99.   #echo "${ATAG} \"Filesystem: $AFS  Size: ${ASIZE}M  Free: ${AFREE}M\" ${AVALUE} \\" >> /tmp/schoices.txt
  100.   echo "${ATAG} \"Filesystem: $AFS  Size: ${ASIZE}M  Free: ${AFREE}M\" \\" >> /tmp/schoices.txt
  101.  done
  102.  SCHOICES="`cat /tmp/schoices.txt`"
  103.  
  104. #add tmpfs ramdisk choice...
  105. SIZETMPFSM="`df -m | grep '^tmpfs' | grep '/initrd/pup_rw' | tr -s " " | cut -f 4 -d " "`"
  106. if [ ! "$SIZETMPFSM" = "" ];then
  107.  SCHOICES="$SCHOICES
  108. ramdisk \"Filesystem: tmpfs  Size: nnn  Free: ${SIZETMPFSM}M\" \\"
  109. fi
  110.  
  111.  
  112.  echo '#!/bin/sh' > /tmp/savedlg
  113.  echo -n "Xdialog --stdout --left --title \"Puppy2 simple CD remaster\" --menubox \"A working area is required in which to create the new live-CD iso file.
  114. Here are the available partitions. You must choose one that has at least
  115. ${SIZENEEDEDM}M free space on it.
  116.  
  117. If the partition that you would like to use has less than ${SIZENEEDEDM}M free space
  118. on it, you will need to quit this script and delete some files.
  119. Note 1: you can use the tmpfs ramdisk, which is in RAM, if it has enough space.
  120. Note 2: you can use a usb drive, but it needs to have been plugged in before
  121.         running this script, so that it will get detected.
  122.  
  123. Highlight desired choice then click OK button...\" 0 0 5 " >> /tmp/savedlg
  124.  echo "$SCHOICES"  >> /tmp/savedlg
  125.  echo ' > /tmp/tag.txt' >> /tmp/savedlg
  126.  chmod 755 /tmp/savedlg
  127.  
  128. /tmp/savedlg
  129. WKGPART="`cat /tmp/tag.txt`"
  130. echo "WKGPART=$WKGPART"
  131. [ "$WKGPART" = "" ] && exit
  132.  
  133.  
  134. #copy files off live-cd....
  135. DRIVESFND="`probedisk 2>&1`"
  136. IDEDRVSFND="`test-eide 2>&1 | grep "cdrom"`"
  137. SELECTIONS="`echo "$DRIVESFND" | grep '^/dev/' | grep -i "cd" | grep -i "rom" | cut -f 1,3 -d "|" | tr " " "_" | tr "|" " " | tr '$' "_"`"
  138. BURNERDRV="`Xdialog --left --title "Puppy2 simple CD remaster" --stdout --menubox "This remaster program needs to read some files off the current live-CD.
  139. So, you need to choose a CD/DVD drive, and it must also be a burner drive
  140. so that the files created by this program can be burnt to a new CD/DVD.
  141. Choose the CD/DVD drive..." 0 48 4 $SELECTIONS 2> /dev/null `"
  142. [ ! $? -eq 0 ] && exit
  143. [ "$BURNERDRV" = "" ] && exit
  144. BURNERDRV="`echo -n "$BURNERDRV" | cut -f 3 -d '/'`"
  145. echo "BURNERDRV=$BURNERDRV"
  146.  
  147.  
  148. CDMNTPT="`mount | grep "/dev/$BURNERDRV" | tr -s " " | cut -f 3 -d " "`"
  149. if [ ! "$CDMNTPT" = "" ];then
  150.  if [ ! -f $CDMNTPT/initrd.gz ];then
  151.   fuser -k -m /dev/$BURNERDRV
  152.   sync
  153.   umount /dev/$BURNERDRV 2> /dev/null
  154.   if [ ! $? -eq 0 ];then
  155.    Xdialog --title "ERROR" --msgbox "Mounted CD, get rid of it before running this program!" 0 0
  156.    exit
  157.   fi
  158.   CDMNTPT=""
  159.  fi
  160. fi
  161.  
  162. if [ "$CDMNTPT" = "" ];then
  163.  while [ 1 ];do
  164.  Xdialog --title "Puppy2 simple CD remaster" --msgbox "Please insert the current Puppy live-CD into drive $BURNERDRV.
  165. Then click OK..." 0 0
  166.  #now mount it...
  167.  CDMNTPT="/mnt/$BURNERDRV"
  168.  mkdir /mnt/$BURNERDRV 2> /dev/null
  169.  mount -t iso9660 /dev/$BURNERDRV /mnt/$BURNERDRV
  170.  [ $? -eq 0 ] && break
  171.  done
  172. fi
  173.  
  174. #now get the files off it...
  175. #firstly need working place to write to...
  176. WKGMNTPT="`mount | grep "/dev/$WKGPART" | tr -s " " | cut -f 3 -d " "`"
  177. [ "$WKGMNTPT" = "/initrd/pup_rw" ] && WKGMNTPT="/"
  178. if [ "$WKGMNTPT" = "" ];then
  179.  WKGFS="`echo "$SCHOICES" | grep "^$WKGPART" | cut -f 2 -d ':' | cut -f 2 -d " "`"
  180.  [ "$WKGFS" = "msdos" ] && WKGFS="vfat"
  181.  mkdir /mnt/$WKGPART 2> /dev/null
  182.  mount -t $WKGFS /dev/$WKGPART /mnt/$WKGPART
  183. fi
  184.  
  185. Xdialog --title "Puppy2 simple CD remaster" --msgbox "Copying files from CD to /mnt/$WKGPART/puppylivecdbuild/, please wait..." 0 0 &
  186. XPID=$!
  187. rm -rf /mnt/$WKGPART/puppylivecdbuild #precaution
  188. mkdir /mnt/$WKGPART/puppylivecdbuild
  189. #now copy the files...
  190.    sync
  191.    cp $CDMNTPT/isolinux.bin /mnt/$WKGPART/puppylivecdbuild/
  192.    sync
  193.    cp $CDMNTPT/isolinux.cfg /mnt/$WKGPART/puppylivecdbuild/
  194.    sync
  195.    cp $CDMNTPT/boot.msg /mnt/$WKGPART/puppylivecdbuild/ 2> /dev/null
  196.    sync
  197.    cp $CDMNTPT/goofy.16 /mnt/$WKGPART/puppylivecdbuild/ 2> /dev/null
  198.    sync
  199.    cp $CDMNTPT/vmlinuz /mnt/$WKGPART/puppylivecdbuild/
  200.    sync
  201.    cp $CDMNTPT/initrd.gz /mnt/$WKGPART/puppylivecdbuild/
  202.    sync
  203.  
  204. umount /dev/$BURNERDRV 2> /dev/null
  205.  
  206. kill $XPID
  207. Xdialog --left --title "Puppy2 simple CD remaster" --msgbox "Creating the pup_$PUPPYVERSION.sfs file in /mnt/$WKGPART/puppylivecdbuild/.
  208. This can take quite a long time, so please wait.... and wait...
  209. Note, no need to click the OK button, as this window will disappear
  210. when pup_$PUPPYVERSION.sfs is finally created.
  211. Please wait..." 0 0 &
  212. XPID=$!
  213.  
  214. #create new pup_xxx.sfs file...
  215. #problem, as want everything under /, but not /initrd, nor anything mounted in /mnt
  216. mkdir /puppylivecdbuild 2> /dev/null #dummy, only used if wkg partition is the tmpfs.
  217. DIRHOME=""
  218. [ -d /home ] && DIRHOME="/home"
  219. [ -d /sys ] && DIRSYS="/sys"
  220. rm -f /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs 2> /dev/null
  221. sync
  222. #note, /pup_$PUPPYVERSION.sfs is not normally there, i relocated it to a separate tmpfs,
  223. #however have not yet done that for multisession-cd/dvd (PUPMODE=77)...
  224. #note, /home could be in underdog linux...
  225. mksquashfs / /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs -e /etc /proc /initrd /var /tmp /archive /mnt /root /puppylivecdbuild $DIRHOME $DIRSYS /pup_$PUPPYVERSION.sfs
  226. sync
  227.  
  228. #add pristine folders (out of current pup_xxx.sfs)...
  229. mksquashfs /initrd/pup_ro2/proc /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs -keep-as-directory
  230. sync
  231. mksquashfs /initrd/pup_ro2/tmp /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs -keep-as-directory
  232. sync
  233. mksquashfs /initrd/pup_ro2/mnt /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs -keep-as-directory
  234. sync
  235.  
  236. kill $XPID
  237.  
  238. #######START WORKING ON /root#######
  239. rm -rf /tmp/root 2> /dev/null
  240. #do some work on /root before add it to the squashfs...
  241. cp -a /initrd/pup_ro2/root /tmp/root #pristine /root
  242. #copy all of my-applications/
  243. cp -af /root/my-applications/* /tmp/root/my-applications/
  244. #some dotpups get installed here...
  245. cp -af /root/my-roxapps /tmp/root/
  246. #window manager config files...
  247. cp -af /root/.jwmrc /tmp/root/
  248. cp -af /root/.fvwm95rc /tmp/root/
  249. cp -af /root/.icewm/menu /tmp/root/.icewm/
  250. #rox desktop settings...
  251. cp -af /root/Choices/ROX-Filer/PuppyPin /tmp/root/Choices/ROX-Filer/
  252. cp -af /root/Choices/ROX-Filer/globicons /tmp/root/Choices/ROX-Filer/
  253. #this may have been modified for a different w.m...
  254. cp -af /root/.xinitrc /tmp/root/
  255. #also this...
  256. [ -f /root/.xset.sh ] cp -af /root/.xset.sh /tmp/root/
  257.  
  258. #TODO think need to do this for /var also...
  259.  
  260. #.packages/ .files, copy any files installed to /root...
  261. echo -n "" > /tmp/allpkgs.files
  262. for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  263. do
  264.  for ONEFILE in `cat $ONEPKG | grep '^/root/' | tr "\n" " "`
  265.  do
  266.   DIRNAME="`dirname $ONEFILE`"
  267.   mkdir -p $DIRNAME
  268.   cp -f $ONEFILE /tmp$DIRNAME/
  269.  done
  270. done
  271.  
  272. #modify /root/.packages/ files, as all installed packages are now part of the new cd...
  273.  #integrity check of /root/.packages/alienpackages.txt...
  274.  if [ -s /root/.packages/alienpackages.txt ];then
  275.   ERRLINE="`cat /root/.packages/alienpackages.txt | grep -v '^".\+" ".\+" .\+ ".\+" \\'`"
  276.   if [ ! "$ERRLINE" = "" ];then
  277.    xmessage -bg '#ff8080' -title "ERROR ERROR" "The following line(s) in /root/.packages/alienpackages.txt
  278. has incorrect syntax and has been removed:
  279. $ERRLINE
  280.  
  281. Please advise the package author that he/she has stuffed up!
  282. Note, this remaster-CD program can still continue, click button..."
  283.   fi
  284.   cat /root/.packages/alienpackages.txt | grep '^".\+" ".\+" .\+ ".\+" \\' > /tmp/alienpackagesxxx
  285.   sync
  286.   cp -f /tmp/alienpackagesxxx /root/.packages/alienpackages.txt
  287.  fi
  288. #any entries in livepackages.txt now "on", transferred to packages.txt...
  289. rm -rf /tmp/root/.packages/*
  290. echo -n "" > /tmp/root/.packages/packages.txt
  291. cp /root/.packages/buildvariables /tmp/root/.packages/
  292. #tricky, packages.txt lines have "\" on ends, which stuffs up the read...
  293. cat /root/.packages/packages.txt | tr "\\" "|" |
  294. while read ONELINE
  295. do
  296.  [ "$ONELINE" = "" ] && continue #precaution, blank line.
  297.  ONEPKG="^\"`echo -n "$ONELINE" | cut -f 2 -d '"'`\""
  298.   #if alien package with same name, let it override...
  299.   if [ -s /root/.packages/alienpackages.txt ];then
  300.    [ ! "`cat /root/.packages/alienpackages.txt | grep "$ONEPKG"`" = "" ] && continue
  301.   fi
  302.  NEWLINE="`cat /root/.packages/livepackages.txt 2> /dev/null | grep "$ONEPKG" | grep '" on "'`"
  303.  if [ "$NEWLINE" = "" ];then
  304.   echo "$ONELINE" | tr "|" "\\" >> /tmp/root/.packages/packages.txt
  305.  else
  306.   echo "$NEWLINE" >> /tmp/root/.packages/packages.txt
  307.  fi
  308. done
  309. #also handle any alien packages (dotpups will be)...
  310. if [ -s /root/.packages/alienpackages.txt ];then
  311.  cat /root/.packages/alienpackages.txt >> /tmp/root/.packages/packages.txt
  312.  sort -u /tmp/root/.packages/packages.txt > /tmp/packagesxxx
  313.  cp -f /tmp/packagesxxx /tmp/root/.packages/packages.txt
  314. fi
  315.  
  316. Xdialog --left --title "Puppy simple remaster CD" --msgbox "This program has created folder /tmp/root, which has everything that is now
  317. going to be added as /root in the pup_$PUPPYVERSION.sfs file.
  318. This is mostly 'pristine', as obviously you do not want all your cache files,
  319. temp files, email files, and other working/temporary files to be burnt onto
  320. the CD. However, if you are familiar with the workings of Puppy, you might
  321. like to take a look at /tmp/root right now, and possibly add anything that
  322. you want from /root (or remove something!)
  323. (if you think that this program has missed out something important that
  324.  should be burnt into /root on the CD, please let me know -- Barry Kauler)
  325.  
  326. After examining /tmp/root,
  327. click 'Ok' to add /root in pup_$PUPPYVERSION.sfs file..." 0 0
  328. sync
  329. mksquashfs /tmp/root /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs -keep-as-directory
  330. sync
  331. rm -rf /tmp/root
  332. #######END WORKING ON /root#######
  333.  
  334. #######START WORKING ON /etc#######
  335. rm -rf /tmp/etc 2> /dev/null
  336. #do some work on /etc before add it to the .sfs...
  337. cp -a /initrd/pup_ro2/etc /tmp/etc #pristine /etc.
  338. #maybe this has been modified...
  339. cp -af /etc/ld.so.conf /tmp/etc/
  340.  
  341. #.packages/ .files, copy any files installed to /etc...
  342. echo -n "" > /tmp/allpkgs.files
  343. for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  344. do
  345.  for ONEFILE in `cat $ONEPKG | grep '^/etc/' | tr "\n" " "`
  346.  do
  347.   DIRNAME="`dirname $ONEFILE`"
  348.   mkdir -p $DIRNAME
  349.   cp -f $ONEFILE /tmp$DIRNAME/
  350.  done
  351. done
  352. sync
  353.  
  354. #what about settings for a particular pc?...
  355. MSG1="Hardware customisation was not chosen."
  356. Xdialog --left --title "Puppy simple remaster CD" --yesno "Have created the /etc directory for the new pup_$PUPPYVERSION.sfs file.
  357. It is in a 'pristine' state, but you can choose to customise it.
  358. Do you want to add customisations for your hardware? Examples are
  359. mouse, keyboard, video. But, if you answer 'Yes' here, the live-CD
  360. will be preconfigured for your PC only. Therefore, it is best to
  361. answer 'No' if you want to boot the new live-CD on different PCs.
  362.  
  363. Click 'Yes' button to customise /etc...
  364. Click 'No' button not to customise (recommended)..." 0 0
  365. if [ $? -eq 0 ];then
  366.  cp -af /etc/codepage /tmp/etc/
  367.  cp -af /etc/fontmap /tmp/etc/
  368.  cp -af /etc/keyboardtype /tmp/etc/
  369.  cp -af /etc/keymap /tmp/etc/
  370.  cp -af /etc/mousebuttons /tmp/etc/
  371.  cp -af /etc/mousedevice /tmp/etc/
  372.  cp -af /etc/videomode /tmp/etc/
  373.  cp -af /etc/eth0mode /tmp/etc/
  374.  cp -af /etc/eth1mode /tmp/etc/
  375.  cp -af /etc/resolv.conf /tmp/etc/
  376.  rm -f /tmp/etc/localtime #a symlink
  377.  cp -af /etc/localtime /tmp/etc/
  378.  cp -af /etc/TZ /tmp/etc/
  379.  cp -af /etc/cdburnerdevice /tmp/etc/
  380.  cp -af /etc/dvddevice /tmp/etc/
  381.  cp -af /etc/modemdevice /tmp/etc/
  382.  cp -af /etc/securetelnetrc /tmp/etc/
  383.  cp -af /etc/modules.conf /tmp/etc/
  384.  cp -af /etc/modprobe.conf /tmp/etc/
  385.  cp -af /etc/rdesktoprc /tmp/etc/
  386.  cp -af /etc/windowmanager /tmp/etc/
  387.  cp -af /etc/xextraoptions /tmp/etc/
  388.  cp -af /etc/X11/xorg.conf /tmp/etc/X11
  389.  MSG1="These files were customised in /etc:
  390. codepage fontmap keyboardtype keymap mousebuttons mousedevice videomode
  391. eth0mode eth1mode resolv.conf localtime TZ cdburnerdevice dvddevice modemdevice
  392. securetelnetrc modprobe.conf rdesktoprc windowmanager xextraoptions X11/xorg.conf"
  393. fi
  394.  
  395. #some files to always copy...
  396. cp -af /etc/Puppybackgroundcolor /tmp/etc/
  397. cp -af /etc/Puppybackgroundpicture /tmp/etc/
  398. #TODO: other gtk and jwm customisations.
  399.  
  400. Xdialog --left --title "Puppy simple remaster CD" --msgbox "$MSG1
  401.  
  402. If you know what you are doing, you can now modify any files in /tmp/etc
  403. folder. This is just about to be added to /etc in the .sfs file.
  404. Do anything you want before clicking 'Ok'.
  405. (If this program has missed something important, let me know -- Barry Kauler)
  406.  
  407. Click 'Ok' to add /etc in pup_$PUPPYVERSION.sfs file..." 0 0
  408.  
  409. sync
  410. mksquashfs /tmp/etc /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs -keep-as-directory
  411. sync
  412. rm -rf /tmp/etc
  413. #######END WORKING ON /etc#######
  414.  
  415. #######START WORKING ON /var#######
  416. rm -rf /tmp/var 2> /dev/null
  417. cp -a /initrd/pup_ro2/var /tmp/var #pristine var
  418.  
  419. #.packages/ .files, copy any files installed to /var...
  420. echo -n "" > /tmp/allpkgs.files
  421. for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  422. do
  423.  for ONEFILE in `cat $ONEPKG | grep '^/var/' | tr "\n" " "`
  424.  do
  425.   DIRNAME="`dirname $ONEFILE`"
  426.   mkdir -p $DIRNAME
  427.   cp -f $ONEFILE /tmp$DIRNAME/
  428.  done
  429. done
  430. sync
  431.  
  432. sync
  433. mksquashfs /tmp/var /mnt/$WKGPART/puppylivecdbuild/pup_$PUPPYVERSION.sfs -keep-as-directory
  434. sync
  435. rm -rf /tmp/var
  436. #######END WORKING ON /var#######
  437.  
  438.  
  439. #edit isolinux.cfg...
  440. ISOLINUXCFG="`cat /mnt/$WKGPART/puppylivecdbuild/isolinux.cfg`"
  441. #small tweaks, like acpi=on, ide=nodma...
  442. Xdialog --left --title "Puppy simple remaster CD" --yesno "Almost ready to burn the CD!
  443. All the files that will be burnt to CD are in /mnt/$WKGPART/puppylivecdbuild/.
  444.  
  445. The final thing that you may want to do is edit isolinux.cfg. It has this:
  446. $ISOLINUXCFG
  447.  
  448. PMEDIA parameter is a hint to Puppy what media you are booting the live-CD from.
  449. 'idecd' is the normal internal CD/DVD drive. Other options are:
  450.  usbflash usbhd usbcd ideflash idehd idecd idezip satahd scsihd scsicd
  451. but, since this program is remastering the CD, restrict choices to one of the
  452. 'cd' options.
  453.  
  454. PKEYS is the default keyboard layout. Example: 'PKEYS=us'  Choices are:
  455.  be br cf de dk es fi fr gr hu it jp no pl ru se uk us
  456. If you need more choices, the Keyboard Wizard has more, after bootup.
  457.  
  458. You may also add any kernel parameters. Some PCs require 'acpi=off' to boot
  459. properly (also gives fan, temperature monitoring).
  460.  
  461. (If answer 'Yes', an editor will appear, must exit
  462.  editor before this program will continue)
  463. Click 'Yes' button to edit isolinux.cfg..." 0 0
  464. if [ $? -eq 0 ];then
  465.  #leafpad /mnt/$WKGPART/puppylivecdbuild/isolinux.cfg
  466.  gtk-shell -t "/mnt/$WKGPART/puppylivecdbuild/isolinux.cfg" -ef "/mnt/$WKGPART/puppylivecdbuild/isolinux.cfg"
  467.  sync
  468. fi
  469.  
  470. #build new iso file, or direct burn to cd...
  471. #to save space, burn direct from /mnt/$WKGPART/puppylivecdbuild/ to cd...
  472. Xdialog --left --title "Puppy simple remaster CD" --msgbox "All the files that will be burnt to CD/DVD are in /mnt/$WKGPART/puppylivecdbuild/.
  473.  
  474. As the working partition may have limited space (for example, you are using a
  475. USB pen drive), these files are burnt direct to CD/DVD, rather than create an
  476. intermediary iso file. If you do need an iso file, you can copy it from the CD
  477. afterward (dd if=/dev/$BURNERDRV of=puppy.iso seek=0 bs=32k).
  478.  
  479. Click close-box on window to quit program at this point (leaving
  480.  /mnt/$WKGPART/puppylivecdbuild/ files in existence, and /dev/$WKGPART
  481.  mounted on /mnt/$WKGPART)
  482. Click 'Ok' button to burn to CD/DVD..." 0 0
  483. [ ! $? -eq 0 ] && exit
  484.  
  485.  
  486. #now for the actual burn...
  487. CDCHOICE="`Xdialog --left --stdout --title "Puppy simple remaster CD" --menubox "Please choose the media to burn to.
  488. The burner drive is /dev/$BURNERDRV, and obviously it must be able to burn
  489. a DVD if you want to burn a DVD!
  490.  
  491. Note: a shortcoming of current version of this program is may fail to
  492. burn to a real (not emulated) SCSI CD burner drive.
  493.  
  494. Note, if you want to create an iso file that can be used for multisession
  495. CD or DVD, I recommend that you burn to DVD now, then later use the 'dd'
  496. program to create an iso file:
  497.  # dd if=/dev/$BURNERDRV of=puppy.iso seek=0 bs=32k
  498.  
  499. PLEASE INSERT THE NEW CD OR DVD RIGHT NOW, THEN CHOOSE FROM MENU..." 0 0 4 CD-R "New blank recordable CD" DVD-R "New blank DVD-R (not +R, -RW, +RW)"`"
  500.  
  501. echo '#!/bin/sh' > /tmp/new2cd.sh
  502. if [ "`echo "$CDCHOICE" | grep 'DVD'`" = "" ];then
  503.  #burn to CD...
  504.  echo "mkisofs -D -R -quiet -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /mnt/$WKGPART/puppylivecdbuild/ | cdrecord -multi -tao -pad -data -v speed=4 gracetime=2 dev=ATAPI:/dev/$BURNERDRV  -" >> /tmp/new2cd.sh
  505. else
  506.  echo "growisofs -speed=4 -Z $CDR -R -D -quiet -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /mnt/$WKGPART/puppylivecdbuild/" >> /tmp/new2cd.sh
  507. fi
  508. echo 'echo -n "Finished. Press ENTER key to continue: "' >> /tmp/new2cd.sh
  509. echo 'read nippi'  >> /tmp/new2cd.sh
  510. chmod 755 /tmp/new2cd.sh
  511. rxvt -bg orange -title "Puppy simple remaster CD" -e /tmp/new2cd.sh
  512.  
  513. sync
  514. rm -rf /puppylivecdbuild
  515. rm -rf /mnt/$WKGPART/puppylivecdbuild
  516. sync
  517. umount /dev/$WKGPART
  518.  
  519. eject /dev/$BURNERDRV
  520.  
  521. Xdialog --left --title "Puppy simple remaster CD" --msgbox "You should now have a new custom Puppy live-CD!
  522.  
  523. WARNING:
  524. There is a tricky situation here, as all the installed packages (DotPups and
  525. PupGets, plus anything else that you may have installed, have all been burnt to
  526. CD/DVD (plus .sfs extension files).
  527. But, they are still installed in the current pup_save.3fs, the Puppy persistent
  528. storage file (where all your stuff gets saved, so it is there next time Puppy
  529. is booted). All those files are duplicated, but will that do any harm if you
  530. boot the new CD? ...should be okay, but I recommend that you uninstall as much
  531. as possible right now, before booting the new CD. Note, do not uninstall them
  532. after booting the new CD as that will also 'delete' the packages burnt onto the
  533. CD.
  534. But, you do not even know if your new CD works, perhaps it is best if you boot
  535. it to confirm it works. Then, boot the old CD again, and delete all the packages,
  536. get rid of .sfs extension files also.
  537. Or, easiest and cleanest option, boot another operating system, or an older
  538. Puppy multisession CD, and rename the pup_save.3fs file (you should not do this
  539. while it is in use, hence the advice to boot some other OS that does not use it)
  540. -- then boot your new live-CD.
  541. I do not want this warning to get to confusing, but if you had used a multi-
  542. session CD when running this program, or run Puppy totally in RAM, then a
  543. pup_save.3fs file is not used. If it exists on the hard drive, you could rename
  544. it. Then when boot the new live-CD, no existing pup_save.3fs to mess things up.
  545. " 0 0
  546.  
  547.  
  548. ####THE END######
  549.