Advertisement
s243a

/usr/sbin/remasterpup2

Aug 6th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 37.12 KB | None | 0 0
  1. #!/bin/bash
  2. #simple script to remaster the puppy live-cd.
  3. #(c) Copyright 2006 Barry Kauler, www.puppyos.com
  4. #2007 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  5. #v411 update what gets copied from /root and /etc.
  6. #v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
  7. # 22jun09 by Masaki Shinomiya <shino@pos.to> bugfix in cd drive selection
  8. # 01jul09 needed space calculation
  9. # 08jul09 loop mounted iso file usable
  10. # 7aug09 grub4dos support
  11. #w482 shinobar: exclude /lib/modules/${KERNELVER}/initrd.
  12. #v431JP mkisofs with Joliet option, volume id, what copied from cd, remove slmodems
  13. #091212 weird bug, no processes but when run this, x restarts...
  14. # 28dec09 remove /modules/${KERNELVER}/modules.*
  15. #110505 support sudo for non-root user.
  16. #110808 PANZERKOPF: bug fix. 110822 reverted.
  17. #120605 rerwin: omit /dev/snd content, /dev/.udev subdirectory and modem daemons from new master (because daemons reinstalled from firmware if needed).
  18. #120606 rerwin: support users' replacement of stripped /root & /etc with complete directories (for "boot disk").
  19. #120607 rerwin: Remove indicators/files for integrated user-installed packages.
  20. #120721 revert 'wildcards' option (from 120605); improve /dev/snd file exclusion; exclude /usr/share/icons/hicolor/icon-theme.cache (shinobar).
  21. #121021 rerwin: revert 120605 modem daemon removals (because daemons no longer copied from firmware directory).
  22. #130222 convert internationalization from "technosaurus method" to gettext method.
  23. #130222 virtual-CD detection was broken.
  24. #130223 various fixes. note, also fixed /usr/sbin/filemnt. now can retain files between remasters.
  25. #130301 o/p of "losetup" (BB), shows all in use, but "losetup-FULL -a" needs param, also o/p format different.
  26. #130302 L18L: moved m_09 m_10 m_11 top and made another use of it.
  27. #130306 gettext translation fixed, line 354. 130307 again.
  28. #130308 npierce: filter out wrong CDs from choices offered to user; remove CD drive from VIRTUALCD list.
  29. #130527 /etc/.XLOADED has been moved to /root, refer /usr/bin/xwin.
  30.  
  31. [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
  32.  
  33. #NOTE: rename to avoid clash with 'remasterpup2.mo' used by previous i18n method.
  34. export TEXTDOMAIN=remasterpup2x
  35. export OUTPUT_CHARSET=UTF-8
  36. . gettext.sh
  37.  
  38. Yes_lbl="$(gettext 'Yes')"
  39. No_lbl="$(gettext 'No')"
  40. m_01="$(gettext 'Puppy simple CD remaster')" #window title.
  41. m_02="$(gettext 'ERROR')"
  42. m_07="$(gettext 'currently mounted')"
  43. m_08="$(gettext 'not mounted')"
  44. m_09="$(gettext 'Filesystem')" #130302
  45. m_10="$(gettext 'Size')" #130302
  46. m_11="$(gettext 'Free')" #130302
  47.  
  48. choice_cdd () {
  49.     #copy files off live-cd.... w018 use probedisk2...
  50.     SELECTIONS="`probedisk 2>&1 | grep '^/dev/' | grep "|optical|" | cut -f 1,3 -d "|" | tr " " "_" | tr "|" " " | tr '$' "_"`"
  51.     SELECTIONS="$SELECTIONS $VIRTUALCD"
  52.     if [ "$(echo "$SELECTIONS"|tr -d ' ')" = "" ]; then
  53.         m_14_2="$(gettext 'NO CD/DVD drives found.')"
  54.         Xdialog --wrap --left --title "$m_01: $m_02" --msgbox "$m_14_2
  55. $MSG" 0 80
  56.         exit 1
  57.     fi
  58.     if [ "$1" = "filter" ];then #130308 Filter out devices with a missing file.
  59.         FILT_SELECTIONS=""
  60.         i="0"
  61.         for ASELECTION in $SELECTIONS
  62.         do
  63.             if [ "$((i++&1))" -eq "0"  ];then
  64.                 BLKDEV="$ASELECTION"
  65.             else
  66.                 DEVNAME="$ASELECTION"
  67.                 MNTPNT="`mount | grep "$BLKDEV" | tr -s " " | cut -f 3 -d " "`"
  68.                 [ -z "$MNTPNT" -o -f "$MNTPNT/initrd.gz" -a -f "$MNTPNT/$PUPPYSFS" ] && FILT_SELECTIONS="$FILT_SELECTIONS $BLKDEV $DEVNAME"
  69.             fi
  70.         done
  71.         SELECTIONS="$FILT_SELECTIONS"
  72.         if [ -z "$SELECTIONS" ];then
  73.             m_14_3="$(gettext 'Puppy live-CD or virtual CD was not found.')
  74. $(eval_gettext "(No CD or .iso file has both 'initrd.gz' and '${PUPPYSFS}'.)")"
  75.             Xdialog --wrap --left  --title "$m_01: $m_02" --msgbox "$m_14_3" 0 0
  76.             exit
  77.         fi
  78.     fi #130308 end of filter
  79.     m_14_1="$(gettext 'Choose the CD/DVD drive...')"
  80.     DIALOG="Xdialog --wrap --left --title \"$m_01\" --stdout --menubox \"$MSG\n\n$m_14_1\" 0 56 4 $SELECTIONS 2> /dev/null"
  81.     BURNERDRV=""
  82.     RESULT=$(eval $DIALOG) #w018    # 22jun09
  83.     [ $? -ne 0 ] && exit
  84.     BURNERDRV=$RESULT
  85.     [ "$BURNERDRV" = "" ] && exit
  86.     BURNERDRV="`echo -n "$BURNERDRV" | cut -f 3 -d '/'`"
  87. }
  88.  
  89. #LANG=C #faster, plus Xdialog happier.
  90. KERNELVER="`uname -r`"
  91.  
  92. #variables created at bootup by /initrd/usr/sbin/init...
  93. . /etc/rc.d/PUPSTATE
  94. [ "$PUP_LAYER" = "" ] && PUP_LAYER="/pup_ro2"
  95.  
  96. . /etc/DISTRO_SPECS
  97. PUPPYSFS="$DISTRO_PUPPYSFS" #ex: puppy.sfs
  98. PUPSFS_ROOT="${PUPPYSFS%.sfs}"
  99. ZDRVSFS="$DISTRO_ZDRVSFS"   #ex: zdrv.sfs
  100. SFSBASE="`basename $PUPPYSFS .sfs`" #ex: puppy
  101.  
  102.  
  103. PPATTERN="/initrd${PUP_LAYER}"
  104. if [ "`mount | grep "$PPATTERN"`" = "" ];then
  105.     #no puppy.sfs file mounted on pup_ro2, probably h.d. install...
  106.     m_03="$(eval_gettext 'This program requires a ${PUPPYSFS} file mounted on /initrd${PUP_LAYER}.')
  107. $(gettext 'Which is not the case here, probably because this is a full hard drive installation?')
  108. $(gettext 'Whatever, boot Puppy from live-CD and then you will be able to use this script.')
  109.  
  110. $(eval_gettext 'Note, I have not tried it, but if you setup the situation of ${PUPPYSFS} mounted on directory /initrd${PUP_LAYER}, that will be acceptable for this program.')
  111. $(gettext 'You will also need a current live-CD, as the program gets files off it.')
  112. $(gettext 'Anyone want to try it?')
  113.  
  114. $(gettext "Click 'Ok' button to quit...")"
  115.     Xdialog --wrap --left --title "m_01: m_02"  --msgbox "$m_03" 0 80
  116.     exit
  117. fi
  118.  
  119. SAVEPART="$PDEV1" #from PUPSTATE.
  120. CDR="/dev/$SAVEPART"
  121.  
  122. #choose where to create isolinux-builds/ directory...
  123. m_05="$(gettext 'Welcome! This little program takes a snapshot of your current system and create a ISO file.')
  124.  
  125. $(eval_gettext 'A Puppy live-CD has 4 main files: vmlinuz, isolinux.cfg, initrd.gz and ${PUPPYSFS}. Note, in some builds of Puppy there may also be a 5th file, ${ZDRVSFS}.')
  126.  
  127. $(eval_gettext "It is \${PUPPYSFS} that mainly interests us here: it has the entire Puppy filesystem, everything from '/' down. What this script does is rebuild this file \${PUPPYSFS}, with everything currently under '/' -- that is, all user-installed packages, all mounted .sfs extension files, everything, gets combined into one file, \${PUPPYSFS}.")
  128. $(eval_gettext "Note, if you have an 'underdog Linux' mounted, that too will get combined into the \${PUPPYSFS} file, so beware, it could get big!")
  129.  
  130. $(gettext 'Click OK button to continue (or close window to quit)...')"
  131. Xdialog --wrap --left --title "$m_01" --msgbox "$m_05" 0 80
  132.  
  133. [ $? -ne 0 ] && exit
  134.  
  135. #calc size needed...
  136. m_06="$(gettext 'Calculating needed working space.')
  137. $(gettext 'Please wait, this may take awhile...')"
  138. Xdialog --wrap --left  --title "$m_01" --no-buttons --ignore-eof  --infobox "$m_06" 0 0 0 &
  139. XPID=$!
  140. SIZEOPT=0
  141. SIZEBIN=`du -sk /bin | cut -f 1`
  142. SIZESBIN=`du -sk /sbin | cut -f 1`
  143. SIZELIB=`du -sk /lib | cut -f 1`
  144. SIZEUSR=`du -sk /usr | cut -f 1`
  145. SIZEOPT=0   # 01jul09
  146. [ -d /opt ] && SIZEOPT=`du -sk /opt | cut -f 1`
  147. sync
  148. SIZETOTALK=`LANG=C dc $SIZEBIN $SIZESBIN + $SIZELIB + $SIZEUSR + $SIZEOPT + p`
  149. SIZETOTALM=`LANG=C dc $SIZETOTALK 1024 \/ p| cut -d'.' -f1` # 01jul09
  150. [ "$SIZETOTALM" ] || SIZETOTALM=1
  151. #estimate a compressed size...
  152. SIZENEEDEDM=`expr $SIZETOTALM \/ 3`
  153. SIZESLACKM=`expr $SIZENEEDEDM \/ 3` #guess
  154. SIZENEEDEDM=`expr $SIZENEEDEDM + $SIZESLACKM`
  155. SIZENEEDEDM=`expr $SIZENEEDEDM + 25` #space for vmlinuz, initrd.gz, zdrv, etc
  156. #now choose working partition... v431 add ext4...  130216 add f2fs...
  157. PARTSLIST="`probepart -m 2> /dev/null | grep '^/dev/' | grep -E 'f2fs|ext2|ext3|ext4|reiserfs|btrfs|minix|msdos|vfat|exfat|ntfs' | cut -f 1-3 -d '|'`"
  158.  
  159. echo -n "" > /tmp/schoices.txt
  160. echo "$PARTSLIST" |
  161. while read APART
  162. do
  163.     [ "$APART" = "" ] && continue #v3.01 preaution
  164.     MNTSTATUS="($m_07)" #"currently mounted"
  165.     ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
  166.     ASIZE="`echo -n "$APART" | cut -f 3 -d '|'`"
  167.     AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
  168.     AFPATTERN="^/dev/$ATAG " #v3.01
  169.     AFREE="`df -m | grep -m 1 "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`"
  170.     FLAG_RO='no' #v431
  171.     if [ ! "$AFREE" ];then
  172.         MNTSTATUS="($m_08)" #"not mounted"
  173.         mkdir -p /mnt/$ATAG
  174.         mount -t $AFS /dev/$ATAG /mnt/$ATAG > /dev/null 2>&1
  175.         if [ $? -eq 0 ];then
  176.             if [ "$ATAG" = "fd0" ];then
  177.                 FFREE=`df -k | grep -m 1 "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`
  178.                 AFREE="`LANG=C dc $FFREE 1024 \/ p`"
  179.             else
  180.                 AFREE="`df -m | grep -m 1 "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`"
  181.             fi
  182.             [ "`mount | grep -m 1 "$AFPATTERN" | grep ' (rw'`" = "" ] && FLAG_RO='yes' #v431 make sure writable.
  183.             umount /dev/$ATAG
  184.         else #v431
  185.             continue
  186.         fi
  187.     else
  188.         [ "`mount | grep -m 1 "$AFPATTERN" | grep ' (rw'`" = "" ] && FLAG_RO='yes' #v431 make sure writable.
  189.     fi
  190.     [ "$FLAG_RO" = "yes" ] && continue #v431
  191.     [ "$AFS" ] && echo "${ATAG} \"${m_09}: $AFS  ${m_10}: ${ASIZE}M  ${m_11}: ${AFREE}M ${MNTSTATUS}\" \\" >> /tmp/schoices.txt #v3.01 added precaution. #130302 L18L
  192. done
  193. SCHOICES="`cat /tmp/schoices.txt`"
  194.  
  195. #add tmpfs ramdisk choice...
  196. SIZETMPFSM=`df -m | grep '^tmpfs' | grep -E "/initrd/pup_rw|/initrd/mnt/tmpfs" | tr -s " " | cut -f 4 -d " "`
  197. TMPFSMSG=''
  198.  
  199. if [ "$SIZETMPFSM" != "" ];then
  200.     TOTALTMPFSM=`df -m | grep '^tmpfs' | grep -E '/initrd/pup_rw|/initrd/mnt/tmpfs' | tr -s " " | cut -f 2 -d " "`
  201.     if [ "$SCHOICES" = "" ];then #v3.01
  202.         SCHOICES="ramdisk \"$m_09: tmpfs  $m_10: ${TOTALTMPFSM}M  $m_11: ${SIZETMPFSM}M ($m_07)\" \\"
  203.     else
  204.         SCHOICES="$SCHOICES
  205. ramdisk \"$m_09: tmpfs  $m_10: ${TOTALTMPFSM}M  $m_11: ${SIZETMPFSM}M ($m_07)\" \\"
  206.     fi
  207.     m_12="$(gettext 'Note 2: you can use the tmpfs ramdisk, which is in RAM, if it has enough space.')"
  208.     TMPFSMSG="$m_12
  209. "
  210. fi
  211.  
  212. [ "$SCHOICES" = "" ] && exit #precaution.
  213.  
  214. m_13="$(gettext 'A working area is required in which to create the new live-CD iso file.')
  215. $(eval_gettext 'Here are the available partitions. You must choose one that has at least ${SIZENEEDEDM}M free space on it.') $(gettext 'You will need an extra 100 - 300MB space (whatever the size of ISO file is going to be).')
  216.  
  217. $(eval_gettext 'If the partition that you would like to use has less than ${SIZENEEDEDM}M free space on it, you will need to quit this script and delete some files.')
  218.  
  219. $(gettext 'Note 1: you can use a usb drive, but it needs to have been plugged in before running this script, so that it will get detected.')
  220. ${TMPFSMSG}
  221. $(gettext 'Highlight desired choice then click OK button...')"
  222. echo '#!/bin/sh' > /tmp/savedlg
  223. echo -n "Xdialog --wrap --left --stdout --title \"$m_01\" --menubox \"$m_13\" 0 80 5 " >> /tmp/savedlg
  224. echo "$SCHOICES"  >> /tmp/savedlg
  225. echo ' > /tmp/tag.txt' >> /tmp/savedlg
  226. chmod 755 /tmp/savedlg
  227.  
  228. kill $XPID
  229. /tmp/savedlg
  230. [ $? -ne 0 ] && exit #130223
  231. WKGPART="`cat /tmp/tag.txt`"
  232. echo "WKGPART=$WKGPART"
  233. [ "$WKGPART" = "" ] && exit
  234.  
  235. #now get the files off it...
  236. #firstly need working place to write to...
  237. [ "$WKGPART" = "ramdisk" ] && WKGMNTPT="/"
  238. WPATTERN="/dev/$WKGPART "
  239. if [ "$WKGMNTPT" = "" ] ; then
  240.     WKGMNTPT="`mount | grep "$WPATTERN" | head -n 1 | tr -s " " | cut -f 3 -d " "`"
  241. fi
  242. if [ "$WKGMNTPT" = "" ];then
  243.     PPATTERN="^$WKGPART "
  244.     WKGFS="`echo "$SCHOICES" | grep "$PPATTERN" | cut -f 2 -d ':' | cut -f 2 -d " "`"
  245.     [ "$WKGFS" = "msdos" ] && WKGFS="vfat"
  246.     mkdir -p /mnt/$WKGPART
  247.     mount -t $WKGFS /dev/$WKGPART /mnt/$WKGPART
  248.     [ $? -ne 0 ] && exit #precaution.
  249.     WKGMNTPT="/mnt/$WKGPART"
  250. fi
  251. [ "$WKGMNTPT" = "/" ] && WKGMNTPT=""
  252.  
  253. # reuse if sfs file already exists
  254. NEW="yes"
  255. SFSPATH=$(ls -1 $WKGMNTPT/puppylivecdbuild/$PUPPYSFS 2>/dev/null)
  256. if [ "$SFSPATH" != "" -a $(echo "$SFSPATH" | wc -l) -eq 1 ]; then
  257.     m_35="$(eval_gettext '${SFSPATH} found.')
  258. $(gettext 'Do you want to reuse it without any change?')
  259. $(gettext "If uncertain, click the 'No' button")"
  260.     Xdialog --wrap --left --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_35" 0 0 && NEW="no"
  261. fi
  262. SFSPATH=""
  263.  
  264. #=================================================================
  265.  
  266. if [ "$NEW" = "yes" ]; then  ###### long skip if, cleating new sfs
  267.     #130223 i think should wipe contents of $WKGMNTPT/puppylivecdbuild?
  268.     if [ -d $WKGMNTPT/puppylivecdbuild ];then
  269.         [ -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ] && rm -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS
  270.         [ -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS ] && rm -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS
  271.         m_41="$(eval_gettext 'Directory ${WKGMNTPT}/puppylivecdbuild already exists.')
  272.  
  273. $(gettext "Normally, this would be created fresh, empty. However, it exists from a previous execution of 'remasterpup2' script (this program), with files in it. You may choose to leave these files in-place, for the current remaster. If uncertain, click the 'Erase' button.")
  274.  
  275. $(gettext 'Note, if you choose to retain the files: The next operation is this script will will read files from a CD, however they will not over-write existing files. Therefore, any customised files will be retained.')
  276.  
  277. $(gettext "WARNING: If the files in 'puppylivecdbuild' are for a different version of Puppy, click the 'Erase' button.")
  278. $(gettext "Again, warning, if at all uncertain, click the 'Erase' button.")
  279.  
  280. $(gettext "Click 'Keep' button to retain the files...")
  281. $(gettext "Click 'Erase' button to delete the files...")"
  282.         lbl_41="$(gettext 'Keep')"
  283.         lbl_42="$(gettext 'Erase')"
  284.         Xdialog --wrap --left --title "$m_01" --ok-label "$lbl_41" --cancel-label "$lbl_42" --yesno "$m_41" 0 80
  285.         [ $? -ne 0 ] && rm -rf $WKGMNTPT/puppylivecdbuild
  286.     fi
  287.  
  288.     #130222
  289.     #130307 notice, line 356 "WARNING:....", the $ is not backslashed, which is confusing...
  290.     m_42=""
  291.     if [ -d $WKGMNTPT/puppylivecdbuild ];then
  292.         m_42="
  293.  
  294. $(gettext 'NOTICE:')
  295. $(eval_gettext 'Directory ${WKGMNTPT}/puppylivecdbuild already exists.')
  296. $(gettext 'If you want to re-use the files in it, and not re-read files from the CD (or virtual-CD), just click the window close-box to bypass this operation.')
  297. $(gettext '(You may view the directory contents with a file-manager to satisfy yourself whether these files should be re-used)')"
  298.     fi
  299.     m_40="$(gettext 'This remaster program needs to read some files off the current live-CD.')
  300.  
  301. $(gettext "However, if a CD-image file (which has filename extension .iso) is mounted, the files may be read from that. We refer to this as a 'virtual CD'. To mount a virtual CD, just click on a .iso file.")
  302.  
  303. $(eval_gettext "WARNING: Be sure that the live-CD or .iso file is the correct one for the currently running Puppy, which is '\${DISTRO_NAME}', version \${DISTRO_VERSION}. As a check, it must have in it the file '\${DISTRO_PUPPYSFS}'")
  304.  
  305. $(gettext "If you want to read the files off a .iso file rather than a CD/DVD, please click on the .iso file right now (before clicking the 'OK' button below)")
  306. $(gettext "Alternatively, if you want to read the files off a Puppy live-CD, insert it in drive, then click 'OK' button.")${m_42}"
  307.     Xdialog --wrap --left  --title "$m_01" --msgbox "$m_40" 0 80
  308.  
  309.     if [ $? -eq 0 ];then #130223 big if "BIGIF2"
  310.         #130222 fix this...
  311.         VIRTUALCD=""
  312.         #130301 crap, earlier was using losetup-FULL from util-linux git, now using older 2.21.1, it needs -a param,
  313.         #but also truncates long lines (same as bb losetup) -- what a nuisance...
  314.         for ONELOOP in `cat /proc/mounts | grep -E '(^/dev/loop.*)( udf | iso9660 )' | cut -f 1 -d ' ' | tr '\n' ' '` #130308 /dev/loop only
  315.         do
  316.             oPTN="^${ONELOOP} "
  317.             ONEISO="$(cat /proc/mounts | grep "$oPTN" | cut -f 2 -d ' ' | rev | cut -f 1 -d '+' | cut -f 1 -d '/' | rev)" #130301
  318.             [ "$ONEISO" = "" ] && continue #130301 precaution.
  319.             ONELOOP=$(echo "$ONELOOP" | sed 's|/loop/|/loop|')
  320.             VIRTUALCD="${VIRTUALCD} ${ONELOOP} ${ONEISO}"
  321.         done
  322.         m_14="$(gettext 'This remaster program needs to read some files off the current live-CD.')
  323. $(gettext 'You can also use a .iso file if it is already mounted as a virtual CD (you would need to have previously clicked on a .iso file to mount it).')"
  324.         MSG="$m_14"
  325.         choice_cdd filter #130308 Use filtering.
  326.  
  327.         CDPATTERN="/dev/$BURNERDRV "
  328.         CDMNTPT="`mount | grep "$CDPATTERN" | tr -s " " | cut -f 3 -d " "`"
  329.         if [ "$CDMNTPT" != "" ];then
  330.             if [ ! -f $CDMNTPT/initrd.gz ];then #130308 In theory, this will now never be true.
  331.                 #091212 weird bug, no processes but when run this, x restarts...
  332.                 xFUSER="`fuser -m /dev/$BURNERDRV 2>/dev/null`" #do this first, seems to fix it.
  333.                 [ "$xFUSER" != "" ] && fuser -k -m /dev/$BURNERDRV
  334.                 sync
  335.                 umount /dev/$BURNERDRV 2> /dev/null
  336.                 if [ $? -ne 0 ];then
  337.                     m_15="$(gettext 'Mounted CD, get rid of it before running this program!')"
  338.                     Xdialog --wrap --left  --title "$m_02" --msgbox "$m_15" 0 0
  339.                     exit
  340.                 fi
  341.                 CDMNTPT=""
  342.             fi
  343.         fi
  344.  
  345.         if [ "$CDMNTPT" = "" ];then
  346.             m_16="$(eval_gettext 'Please insert the current Puppy live-CD into drive ${BURNERDRV}.')
  347. $(gettext 'Then click OK...')"
  348.             while [ 1 ];do
  349.                 Xdialog --wrap --left  --title "$m_01" --msgbox "$m_16" 0 0
  350.                 [ $? -eq 0  ] || exit   # 22jun09
  351.                 case $BURNERDRV in
  352.                     loop*) #ISO.. already mounted
  353.                         CDMNTPT=$(mount | grep "^/dev/$BURNERDRV " | cut -f 3 -d ' ')
  354.                         ;;
  355.                     *) #CD
  356.                         #now mount it...
  357.                         CDMNTPT="/mnt/$BURNERDRV"
  358.                         mkdir -p /mnt/$BURNERDRV
  359.                         mount -t iso9660 /dev/$BURNERDRV /mnt/$BURNERDRV
  360.                         [ $? -eq 0 ] && break
  361.                         ;;
  362.                 esac
  363.             done
  364.         fi
  365.  
  366.         #now get the files off it...
  367.         m_17="$(eval_gettext 'Copying files from CD to ${WKGMNTPT}/puppylivecdbuild/, please wait...')"
  368.         Xdialog --wrap --left  --title "$m_01" --no-buttons --ignore-eof   --infobox "$m_17" 0 0 0 &
  369.         XPID=$!
  370.         mkdir -p $WKGMNTPT/puppylivecdbuild
  371.         #now copy the files... # v431JP HTM, ICO, INF
  372.         sync
  373.         (
  374.         cd $CDMNTPT
  375.         for F in ${ZDRVSFS} vmlinuz initrd.gz  grldr *efi* *EFI* *.c32 *.sh *.lst *.xpm *.jpg *.png *.bin *.cfg *.msg *.16 *.HTM* *.ICO *.INF help
  376.         do
  377.             #130223 -n means do not override an existing file... 130304 hmmm, -n not supported, use -u ...
  378.             [ -e "$F" ] && cp -a -u $F $WKGMNTPT/puppylivecdbuild/
  379.             sync
  380.         done
  381.         )
  382.         umount /dev/$BURNERDRV 2> /dev/null
  383.         kill $XPID
  384.  
  385.     fi #end "BIGIF2"
  386.  
  387.     m_16_1="$(eval_gettext 'Do you like to make ${ZDRVSFS}, the separate driver file?')"
  388.     Xdialog --wrap --left  --title "$m_01" --default-no --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_16_1" 0 0
  389.     [ $? -eq 0 ] && MKZDRV="yes" || MKZDRV=""
  390.     [ $? -eq 255 ] && exit #130223
  391.  
  392.     # set compression
  393.     /usr/lib/gtkdialog/box_yesno --yes-label "xz (default)" --no-label "gzip" --yes-first --info \
  394.     --yes-icon "execute.svg" --no-icon "execute.svg" \
  395. "$m_01" "$(gettext 'You can use xz or gzip compression. Choose one...')"
  396.     case $? in
  397.         1) COMP="-comp gzip" ;;
  398.         *) COMP="-comp xz -Xbcj x86" ;;
  399.     esac
  400.     #COMP="-noI -noD -noF -noX" #fast tests zzzzzz
  401.     echo "COMP=${COMP}"
  402.     # -
  403.  
  404.     m_18="$(eval_gettext 'Creating the ${PUPPYSFS} file in ${WKGMNTPT}/puppylivecdbuild/.')
  405. $(gettext 'This can take quite a long time, so please wait.... and wait...')
  406. $(eval_gettext 'This window will disappear when ${PUPPYSFS} is finally created.')
  407. $(gettext 'Please wait...')"
  408.     Xdialog --wrap --left  --title "$m_01" --no-buttons --ignore-eof   --infobox "$m_18" 0 0 0 &
  409.     XPID=$!
  410.  
  411.     #create new puppy.sfs file...
  412.     squash() {
  413.         echo $0 $@
  414.         rxvt -bg orange -fg black -title "$m_01" -geometry 80x6 -e mksquashfs $@ 2> /dev/null
  415.     }
  416.    fk_squash() {
  417.         echo $0 $@
  418.         #s243a: use set -x to echo cpio commands in fk_mksquashfs and pass to rxvt
  419.         #rxvt -bg orange -fg black -title "$m_01" -geometry 80x6 -e mksquashfs $@ 2> /dev/null
  420.         fk_mksquashfs $@ #Short term hack
  421.     }
  422.     do_squash(){
  423.       if [ "$mode" = dir ]; then
  424.         fk_squash $@    
  425.       else
  426.         squash $@
  427.       fi
  428.     }  
  429.     fk_mksquashfs(){
  430.       #source_dir=$1; shift
  431.       #target_dir=$2; shift
  432.      option=""
  433.      out=() #Currently not used
  434.      args=()
  435.      declare -A exludes
  436.       for arg in "$@";do
  437.         if [[ "$arg" == -* ]]; then
  438.           case "$arg" in
  439.           -*)
  440.           option="$arg" ;;
  441.           esac  
  442.         else
  443.           case option in
  444.           -e)
  445.             exludes+=( ["$arg"]=1 ) ;;
  446.           '')
  447.             args+=( "$arg" ) ;;
  448.           *)
  449.             out+=( "$arg" ) ;;
  450.           esac
  451.         fi
  452.       done
  453.       n_args=${#args}
  454.       target_dir=$args[$n_args]
  455.       target_dir="${target_dir%.sfs}"
  456.      
  457.       mkdir -p "$target_dir"
  458.       unset 'args[$n_args-1]' #https://stackoverflow.com/questions/8247433/remove-the-last-element-from-an-array
  459.       #while read aDir; do
  460.       if [ realpath "$target_dir" != "/" ]; then
  461.        for aDir in "$args[@]"; do
  462.           excluded="${excludes[$aDir]}"
  463.           [ -z "$excluded" ] && excluded=0
  464.           if [ ! $excluded -eq 1 ]; then
  465.             cd $aDir
  466.             cpio -pd "$target_dir"
  467.           fi
  468.         done
  469.       fi
  470.       #done < <(ls -a -1)
  471.      
  472.     }  
  473.     do_mksquashfs(){
  474.       if [ "$mode" = dir ]; then
  475.         fk_mksquashfs $@    
  476.       else
  477.         mksquashfs $@
  478.       fi
  479.     }          
  480.    
  481.     DIRHOME=""
  482.     [ -d /home ] && DIRHOME="/home"
  483.     [ -d /sys ] && DIRSYS="/sys"
  484.     [ -d /lost+found ] && DIRLOST="/lost+found"
  485.     rm -f ${WKGMNTPT}/puppylivecdbuild/$PUPPYSFS 2> /dev/null
  486.     sync
  487.     #note, /puppy.sfs is not normally there, i relocated it to a separate tmpfs,
  488.     #however have not yet done that for multisession-cd/dvd (PUPMODE=77).
  489.     #note, /home could be in underdog linux...
  490.  
  491.     # modules copied from initrd
  492.     ANOTHER_REMOVE="/lib/modules/$KERNELVER/initrd /lib/modules/*/modules.*"    # 28dec09 modules.*
  493.     if [ "$MKZDRV" = "yes" ]; then
  494.         rm -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS 2> /dev/null
  495.         do_mksquashfs /lib $WKGMNTPT/puppylivecdbuild/$ZDRVSFS -keep-as-directory -e /lib/[^m]* $ANOTHER_REMOVE
  496.         ANOTHER_REMOVE="/lib/modules"
  497.     fi
  498.     #120605 Omit certain /dev subdir content and modem components loaded from firmware tarballs...
  499.     [ -d /dev/snd ] && [ "`ls /dev/snd`" != "" ] && DIRDEVSNDFILES="/dev/snd/*" #120721
  500.     [ -d /dev/.udev ] && DIRDEVUDEV="/dev/.udev"
  501.     #121021 modem daemons now left in place.
  502.     [ -f /usr/share/icons/hicolor/icon-theme.cache ] && ICONCACHE=/usr/share/icons/hicolor/icon-theme.cache #120721
  503.     TOPPLCDB=''
  504.     [ -e /puppylivecdbuild ] && TOPPLCDB='/puppylivecdbuild'
  505.     TOPPUPSFS=''
  506.     [ -e /${PUPPYSFS} ] && TOPPUPSFS="/${PUPPYSFS}"
  507.    
  508.  
  509.  
  510.     # display terminal only for the first stage because it takes the most of time. 'squash' is a function, see above. 120512 $COMP added...
  511.     do_squash / $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ${COMP} -e /media /etc /proc /initrd /var /tmp /archive /mnt /root $TOPPLCDB $ANOTHER_REMOVE $DIRHOME $DIRSYS $DIRLOST $TOPPUPSFS $DIRDEVSNDFILES $DIRDEVUDEV $ICONCACHE  #120605 end #120721 avoid wildecards option, icon-theme.cache 121021
  512.     sync
  513.  
  514.     #add pristine folders (out of current puppy.sfs)...
  515.     do_mksquashfs /initrd${PUP_LAYER}/home $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  516.     sync
  517.     do_mksquashfs /initrd${PUP_LAYER}/proc $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  518.     sync
  519.     do_mksquashfs /initrd${PUP_LAYER}/tmp $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  520.     sync
  521.     do_mksquashfs /initrd${PUP_LAYER}/mnt $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  522.     sync
  523.     do_mksquashfs /initrd${PUP_LAYER}/media $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  524.     sync
  525.  
  526.     kill $XPID
  527.  
  528.     #######START WORKING ON /root#######
  529.     rm -rf /tmp/root 2> /dev/null
  530.     #do some work on /root before add it to the squashfs...
  531.     cp -a /initrd${PUP_LAYER}/root /tmp/root #pristine /root
  532.     #copy all of my-applications/
  533.     cp -af /root/my-applications/* /tmp/root/my-applications/
  534.     #some dotpups get installed here...
  535.     cp -af /root/my-roxapps /tmp/root/ 2>/dev/null
  536.     #window manager config files...
  537.     cp -af /root/.jwmrc /tmp/root/
  538.     cp -af /root/.jwmrc-tray /tmp/root/ #v411
  539.     cp -af /root/.fvwm95rc /tmp/root/
  540.     cp -af /root/.icewm/menu /tmp/root/.icewm/
  541.     #rox desktop settings...
  542.     cp -af /root/Choices/ROX-Filer/PuppyPin /tmp/root/Choices/ROX-Filer/
  543.     cp -af /root/Choices/ROX-Filer/globicons /tmp/root/Choices/ROX-Filer/
  544.     #100117 user changes get saved here, which overrides original...
  545.     if [ -f /root/.config/rox.sourceforge.net/ROX-Filer/globicons ];then
  546.         mkdir -p /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  547.         cp -af /root/.config/rox.sourceforge.net/ROX-Filer/globicons /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  548.     fi
  549.     #100117 i think also save user settings...
  550.     if [ -f /root/.config/rox.sourceforge.net/ROX-Filer/Options ];then
  551.         mkdir -p /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  552.         cp -af /root/.config/rox.sourceforge.net/ROX-Filer/Options /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  553.     fi
  554.     #v411 tidy up, remove desktop drive icons...
  555.     grep -v '/tmp/pup_event_frontend/drive_' /tmp/root/Choices/ROX-Filer/PuppyPin > /tmp/remaster-PuppyPin
  556.     mv -f /tmp/remaster-PuppyPin /tmp/root/Choices/ROX-Filer/PuppyPin
  557.     #this may have been modified for a different w.m...
  558.     cp -af /root/.xinitrc /tmp/root/
  559.     #also this...
  560.     [ -f /root/.xset.sh ] && cp -af /root/.xset.sh /tmp/root/
  561.  
  562.     #v411 gtk theme may have been changed...
  563.     cp -af /root/.gtkrc-2.0 /tmp/root/
  564.  
  565.     #v411 jwm theme may have changed...
  566.     cp -af /root/.jwm/jwmrc-personal /tmp/root/.jwm/
  567.     cp -af /root/.jwm/jwmrc-personal2 /tmp/root/.jwm/
  568.     cp -af /root/.jwm/jwmrc-theme /tmp/root/.jwm/
  569.  
  570.     #v411 pmount preferences...
  571.     cp -af /root/.pmountauto /tmp/root/
  572.     cp -af /root/.pmountengine /tmp/root/
  573.     cp -af /root/.pmountquit /tmp/root/
  574.     cp -af /root/.pmountsingle /tmp/root/
  575.  
  576.     #TODO think need to do this for /var also...
  577.    PKG_FILES_DIR="$(realpath /root/.pacakges)"
  578.    if [ -d "$PKG_FILES_DIR/package-files" ]; then
  579.      PKG_FILES_DIR="$PKG_FILES_DIR/package-files"
  580.    fi
  581.     #.packages/ .files, copy any files installed to /root...
  582.     echo -n "" > /tmp/allpkgs.files
  583.     #for ONEPKG in `ls -1 "$PKG_FILES_DIR/*.files" 2>/dev/null | tr "\n" " "`
  584.     #do
  585.     #   grep '^'"$PKG_FILES_DIR" $ONEPKG | \
  586.     #
  587.         while read -r ONEFILE
  588.         do
  589.             if [ -d "$ONEFILE" ] && [ ! -L "$ONEFILE" ];then #w018
  590.                 mkdir -p "/tmp${ONEFILE}"
  591.             fi
  592.             if [ -f "$ONEFILE" ] || [ -L "$ONEFILE" ];then #w018
  593.                 DIRNAME="`dirname "$ONEFILE"`"
  594.                 mkdir -p "/tmp${DIRNAME}"
  595.                 rm -f "/tmp${ONEFILE}" # if ONEFILE already exists and it's a link, needs to be removed
  596.                 cp -a -f "$ONEFILE" "/tmp${DIRNAME}/"
  597.             fi
  598.         done < <(ls -1 "$PKG_FILES_DIR/*.files" 2>/dev/null)
  599.     #done
  600.  
  601.     #w018...
  602.     #modify /root/.packages/ files, as all installed packages are now part of the new cd...
  603.     cp -a -f /root/.packages /tmp/root/
  604.     if [ -d /var/packages ]; then
  605.       mkdir  -p /tmp/var #This is probably already done
  606.       cp -a -f /var/packages /tmp/var/
  607.     fi
  608.     touch /root/.packages/user-installed-packages
  609.     # 141008: move *.files to ~/.packages/builtin_files/
  610.     cat /root/.packages/user-installed-packages | \
  611.     while read -r ONEPKG
  612.     do
  613.         ONEFILE="/tmp$PKG_FILES_DIR/`echo "$ONEPKG" | cut -f1 -d '|'`.files"
  614.         ONENAME="/tmp/root/.packages/builtin_files/`echo "$ONEPKG" | cut -f2 -d '|'`"
  615.         mv -f "$ONEFILE" "$ONENAME"
  616.     done
  617.     cat /root/.packages/user-installed-packages >> /tmp/root/.packages/woof-installed-packages
  618.     sort -u --key=1 --field-separator="|" /tmp/root/.packages/woof-installed-packages > /tmp/woof-installed-packages-tmp #110722
  619.     mv -f /tmp/woof-installed-packages-tmp /tmp/root/.packages/woof-installed-packages
  620.     echo -n "" > /tmp/root/.packages/user-installed-packages #v431
  621.     sync #120607
  622.     rm -f /tmp/root/.packages/*.files #120607
  623.     rm -f /tmp/root/.packages/*.remove #120607
  624.  
  625.     [ -f /tmp/root/.XLOADED ] && rm -f /tmp/root/.XLOADED #130527
  626.    #######END WORKING ON /root (Part #1)#######
  627.  
  628.  
  629.     #######START WORKING ON /etc#######
  630.     rm -rf /tmp/etc 2> /dev/null
  631.     #do some work on /etc before add it to the .sfs...
  632.     cp -a /initrd${PUP_LAYER}/etc /tmp/etc #pristine /etc.
  633.     #maybe this has been modified...
  634.     cp -af /etc/ld.so.conf /tmp/etc/
  635.  
  636.     #.packages/ .files, copy any files installed to /etc...
  637.     echo -n "" > /tmp/allpkgs.files
  638.     for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  639.     do
  640.         grep '^/etc/' $ONEPKG | \
  641.         while read -r ONEFILE
  642.         do
  643.             if [ -d "$ONEFILE" ] && [ ! -L "$ONEFILE" ];then #w018
  644.                 mkdir -p "/tmp${ONEFILE}"
  645.             fi
  646.             if [ -f "$ONEFILE" ] || [ -L "$ONEFILE" ];then #w018
  647.                 DIRNAME="`dirname "$ONEFILE"`"
  648.                 mkdir -p "/tmp${DIRNAME}"
  649.                 rm -f "/tmp${ONEFILE}" # if ONEFILE already exists and it's a link, needs to be removed
  650.                 cp -a -f "$ONEFILE" "/tmp${DIRNAME}/"
  651.             fi
  652.         done
  653.     done
  654.     sync
  655.  
  656.     cp -af /etc/eventmanager /tmp/etc/ #v411
  657.  
  658.     #what about settings for a particular pc?...
  659.     m_20="$(gettext 'Hardware customisation was not chosen.')"
  660.     MSG1="$m_20"
  661.     m_21="$(eval_gettext 'Have created the /etc directory for the new ${PUPPYSFS} file.')
  662. $(gettext "It is in a 'pristine' state, but you can choose to customise it.")
  663. $(gettext "Do you want to add customisations for your hardware? Examples are mouse, keyboard, video. But, if you answer 'Yes' here, the live-CD will be preconfigured for your PC only. Therefore, it is best to answer 'No' if you want to boot the new live-CD on different PCs.")
  664.  
  665. $(gettext "Click 'Yes' button to customise /etc...")
  666. $(gettext "Click 'No' button not to customise (recommended)...")"
  667.     Xdialog --wrap --left --title "$m_01" --default-no --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_21" 0 80
  668.     if [ $? -eq 0 ];then
  669.         cp -af /etc/codepage /tmp/etc/
  670.         cp -af /etc/fontmap /tmp/etc/
  671.         cp -af /etc/keymap /tmp/etc/
  672.         cp -af /etc/mousedevice /tmp/etc/
  673.         cp -af /etc/eth0mode /tmp/etc/
  674.         cp -af /etc/eth1mode /tmp/etc/
  675.         cp -af /etc/resolv.conf /tmp/etc/
  676.         rm -f /tmp/etc/localtime #a symlink
  677.         cp -af /etc/localtime /tmp/etc/
  678.         cp -af /etc/TZ /tmp/etc/
  679.         cp -af /etc/cdburnerdevice /tmp/etc/
  680.         cp -af /etc/dvddevice /tmp/etc/
  681.         cp -af /etc/modemdevice /tmp/etc/
  682.         cp -af /etc/securetelnetrc /tmp/etc/
  683.         cp -af /etc/modules.conf /tmp/etc/
  684.         cp -af /etc/modprobe.d /tmp/etc/ #101020
  685.         cp -af /etc/rdesktoprc /tmp/etc/
  686.         cp -af /etc/windowmanager /tmp/etc/
  687.         cp -af /etc/X11/xorg.conf /tmp/etc/X11
  688.         cp -af /etc/network-wizard /tmp/etc/
  689.         cp -af /etc/simple_network_setup/* /tmp/etc/simple_network_setup/
  690.         m_22="$(gettext 'These files were customised in /etc:')
  691. codepage fontmap keymap mousedevice eth0mode eth1mode resolv.conf localtime TZ cdburnerdevice dvddevice modemdevice securetelnetrc modprobe.d/* rdesktoprc windowmanager X11/xorg.conf
  692. $(gettext 'Also these directories:')
  693. network-wizard."
  694.         MSG1="$m_22"
  695.     fi
  696.  
  697.     #some files to always copy...
  698.     cp -af /etc/Puppybackgroundpicture /tmp/etc/
  699.     #TODO: other gtk and jwm customisations.
  700.  
  701.     cp -f /tmp/etc/DISTRO_SPECS /tmp/DISTRO_SPECSupdated #keep this to put into initrd.gz.
  702.  
  703.    #######END WORKING ON /etc (Part #1) #######
  704.  
  705.  
  706.     #######START WORKING ON /var#######
  707.     rm -rf /tmp/var 2> /dev/null
  708.     cp -a /initrd${PUP_LAYER}/var /tmp/var #pristine var
  709.  
  710.     #.packages/ .files, copy any files installed to /var...
  711.     echo -n "" > /tmp/allpkgs.files
  712.     #for ONEPKG in `ls -1 "$PKG_FILES_DIR/"*.files 2>/dev/null | tr "\n" " "`
  713.     #do
  714.     #   grep '^/var/' $ONEPKG | \
  715.     #
  716.         while read -r ONEFILE
  717.         do
  718.             if [ -d "$ONEFILE" ] && [ ! -L "$ONEFILE" ];then #w018
  719.                 mkdir -p "/tmp${ONEFILE}"
  720.             fi
  721.             if [ -f "$ONEFILE" ] || [ -L "$ONEFILE" ];then #w018
  722.                 DIRNAME="`dirname "$ONEFILE"`"
  723.                 mkdir -p "/tmp${DIRNAME}"
  724.                 rm -f "/tmp${ONEFILE}" # if ONEFILE already exists and it's a link, needs to be removed
  725.                 cp -a -f "$ONEFILE" "/tmp${DIRNAME}/"
  726.             fi
  727.         done < <(ls -1 "$PKG_FILES_DIR/"*.files 2>/dev/null)
  728.     #done
  729.     sync
  730.     [ "$CLEARPKGLOG" = "yes" ] && rm -f /tmp/var/log/packages/* #120607
  731.  
  732.    #######END WORKING ON /var (Part #1)#######
  733.  
  734.    
  735.     #######Start WORKING ON /root (Part #2) #######
  736.     m_19="$(eval_gettext 'This program has created folder /tmp/root, which has everything that is now going to be added as /root in the ${PUPPYSFS} file.')
  737. $(gettext "This is mostly 'pristine', as obviously you do not want all your cache files, temp files, email files, and other working/temporary files to be the ISO. However, if you are familiar with the workings of Puppy, you might like to take a look at /tmp/root right now, and possibly add anything that you want from /root (or remove something!)")
  738. $(gettext '(if you think that this program has missed out something important, please let us know..')
  739.  
  740. $(eval_gettext "After examining /tmp/root, click 'Ok' to add /root in \${PUPPYSFS} file...")"
  741.     Xdialog --wrap --left --title "$m_01" --msgbox "$m_19" 0 80
  742.     sync
  743.     [ "`ls /tmp/root/.packages/*.files`" = "" ] && CLEARPKGLOG="yes" || CLEARPKGLOG="no" #120607 in case user copied entire /root to /tmp for boot disk.
  744.     do_mksquashfs /tmp/root $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  745.     sync
  746.     rm -rf /tmp/root
  747.     #######END WORKING ON /root (Part #2) #######  
  748.    #######Start WORKING ON /etc (Part #2) #######
  749.     m_23="${MSG1}
  750.  
  751. $(gettext 'If you know what you are doing, you can now modify any files in /tmp/etc folder. This is just about to be added to /etc in the .sfs file.')
  752. $(gettext "Do anything you want before clicking 'Ok'.")
  753. $(gettext '(If this program has missed something important, let me know -- Barry Kauler)')
  754.  
  755. $(eval_gettext "Click 'Ok' to add /etc in \${PUPPYSFS} file...")"
  756.     Xdialog --wrap --left  --title "$m_01" --msgbox "$m_23" 0 80
  757.  
  758.     #120606 in case user just now replaced the /etc directory...
  759.     sync
  760.     #130527 .XLOADED moved to /root (see /usr/bin/xwin), change test...
  761.     MODIFETC="$(find /tmp/etc/modules -mindepth 1 -maxdepth 1 -name 'firmware.dep.inst.*')"
  762.     if [ "$MODIFETC" != "" ];then
  763.         #rm -f /tmp/etc/.XLOADED
  764.         rm -f /tmp/etc/modules/firmware.dep.inst.*
  765.         touch /tmp/etc/personal_settings_popup_disabled
  766.         touch /tmp/etc/personal_data_save_disabled
  767.     fi
  768.     [ -f /tmp/etc/.XLOADED ] && rm -f /tmp/etc/.XLOADED #130527 just in case old file still there.
  769.  
  770.     sync
  771.  
  772.     do_mksquashfs /tmp/etc $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  773.     sync
  774.     rm -rf /tmp/etc
  775.     #######END WORKING ON /etc (Part #2) #######   
  776.    
  777.    #######Start WORKING ON /var (Part #2) #######
  778.  
  779.     sync
  780.     do_mksquashfs /tmp/var $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  781.     sync
  782.     rm -rf /tmp/var
  783.    
  784.     #s243a: TODO: add prompt to modify the var folder like was done in the etc folder
  785.    
  786.     #######END WORKING ON /var#######
  787.    
  788.     chmod a+r $WKGMNTPT/puppylivecdbuild/* &>/dev/null
  789.     chmod a-x $WKGMNTPT/puppylivecdbuild/*.sfs &>/dev/null
  790.  
  791. fi ###### end of long skip if, cleating new sfs
  792.  
  793. #=================================================================
  794.  
  795. m_25="$(gettext 'Almost ready to create the new ISO file!')
  796.  
  797. $(gettext "If you want to add any more files, say extra SFS files, or to edit or modify the files in any way, do it now. Note, if you add an extra SFS file, say 'devx.sfs' then it will be available for use when you boot the new live-CD.")
  798.  
  799. $(eval_gettext "If you want to make any changes, use ROX-Filer to open \${WKGMNTPT}/puppylivecdbuild/ and do so now, before clicking the 'OK' button.")"
  800. Xdialog --wrap --left  --title "$m_01" --msgbox "$m_25" 0 80
  801. sync
  802.  
  803. BOOTLOADER=""
  804. [ -f $WKGMNTPT/puppylivecdbuild/grldr ] && BOOTLOADER="grldr"
  805. [ -f $WKGMNTPT/puppylivecdbuild/isolinux.bin ] && BOOTLOADER="isolinux.bin"
  806. if [ "$BOOTLOADER" = "" ]; then
  807.     m_25_1="$(gettext 'No boot loaders found. You need isolinux.bin or grldr to make bootable CD.')
  808. $(gettext "Click 'OK' to quit.")
  809. $(eval_gettext '(leaving ${WKGMNTPT}/puppylivecdbuild/ files in existence)')"
  810.     Xdialog --wrap --left  --title "$m_01" --msgbox "$m_25_1" 0 0
  811.     exit
  812. fi
  813.  
  814. if [ "$NEW" = "yes" ]; then #120628: no change id-string for reuse
  815.     sync
  816.     #100913 need to update file DISTRO_SPECS in initrd.gz, so init script can find puppy files...
  817.     mv -f $WKGMNTPT/puppylivecdbuild/initrd.gz /tmp #note $WKGMNTPT may be non-linux fs.
  818.     cd /tmp
  819.     gunzip initrd.gz
  820.     mkdir initrd-tree-tmp1
  821.     cd initrd-tree-tmp1
  822.     cat ../initrd | cpio -i -d -m
  823.     sync
  824.     rm -f ../initrd
  825.     cp -a -f /tmp/DISTRO_SPECSupdated ./DISTRO_SPECS #see earlier.
  826.     find . | cpio -o -H newc | gzip -9 > $WKGMNTPT/puppylivecdbuild/initrd.gz
  827.     sync
  828.     cd ..
  829.     rm -rf initrd-tree-tmp1
  830.     cd /root
  831. fi #120628 end
  832.  
  833. if [ -f $WKGMNTPT/puppylivecdbuild/efi.img ] ; then
  834.     EFI_IMG='efi.img'
  835. fi
  836.  
  837. #build new iso file
  838. MSG="$(gettext 'ISO file not created.')"
  839. m_27="$(eval_gettext "Click 'Yes' button to create a 'custom-puppy.iso' in \${WKGMNTPT}/ (assuming that there is 100MB-300MB free space)...")
  840. $(eval_gettext "Click 'No' button (or close-box on window) to quit program at this point (leaving  \${WKGMNTPT}/puppylivecdbuild/ files in existence)...")"
  841. Xdialog --wrap --left  --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_27" 0 80
  842. if [ $? -eq 0 ];then
  843.     VOLI=""
  844.     m_27_1="$(gettext 'You can add the CD volume ID.')"
  845.     VOLI=$(Xdialog --title "$m_01" --stdout --inputbox "$m_27_1" 0 60 "$SFSBASE")
  846.     [ "$VOLI" != "" ] && VOLI="-V $(echo "$VOLI"|tr ' ' '_')"
  847.     rm -f $WKGMNTPT/custom-puppy*.iso
  848.     #=
  849.     if [ "$EFI_IMG" ];then
  850.         UEFI='-uefi'
  851.         UEFI_OPT='-u'
  852.         # make uefi iso
  853.         rxvt -bg orange -fg black -title "$m_01" -e \
  854.             mkisofs -iso-level 4 -D -R $VOLI -o $WKGMNTPT/custom-puppy${UEFI}.iso \
  855.             -b ${BOOTLOADER} -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \
  856.             -eltorito-alt-boot -eltorito-platform efi -b "$EFI_IMG" -no-emul-boot \
  857.                 $WKGMNTPT/puppylivecdbuild/
  858.     else
  859.         rxvt -bg orange -fg black -title "$m_01" -e \
  860.             mkisofs -iso-level 4 -D -R $VOLI -o $WKGMNTPT/custom-puppy.iso \
  861.             -b ${BOOTLOADER} -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \
  862.                 $WKGMNTPT/puppylivecdbuild/
  863.     fi
  864.     case $BOOTLOADER in *"isolinux"*)
  865.         if which isohybrid ; then
  866.             echo "isohybrid ${UEFI_OPT} $WKGMNTPT/custom-puppy${UEFI}.iso"
  867.             isohybrid ${UEFI_OPT} "$WKGMNTPT/custom-puppy${UEFI}.iso"
  868.         fi ;;
  869.     esac
  870.     MSG="$(eval_gettext '${WKGMNTPT}/custom-puppy${UEFI}.iso created.')"
  871. fi
  872. sync
  873. m_28="$(eval_gettext '${WKGMNTPT}/puppylivecdbuild/ files left in existence.')
  874. $(gettext "Click 'Ok' button to quit...")"
  875. Xdialog --wrap --left  --title "$m_01" --msgbox "$MSG
  876. $m_28" 0 0
  877.  
  878. ### END ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement