remasterpup2 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  1. #!/bin/sh
  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. #BK 9 oct 2007: updated for puppy v3.01.
  6. #RE 9 apr 2008: v3.99 copy active post-install scripts
  7. #v4.02 /lib/modules/firmware.dep.<kern>,DOTconfig-K<kern> moved to /etc/modules. ...um no mods this script.
  8. #v411 update what gets copied from /root and /etc.
  9. #v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
  10. #w001 pup files renamed to woof-555.sfs, woofsave.2fs (or similar).
  11. #w018 april 2009: Woof-related fixes, new standardised package database format.
  12. #w460 zdrv has new name format, ex zu500269.sfs.
  13. # 22jun09 by Masaki Shinomiya <shino@pos.to> bugfix in cd drive selection
  14. # 23jun09 I18N
  15. # 27jun09 copy all *.msg and *.16 from Live CD
  16. # 01jul09 needed space calculation
  17. # 02jul09 I18N bugfix to burn CD
  18. # 08jul09 remove kernel modules from initrd
  19. # 08jul09 loop mounted iso file usable
  20. # 7aug09 grub4dos support
  21. #w482 shinobar: exclude /lib/modules/${KERNELVER}/initrd.
  22. #v423 bugfix.
  23. # 2oct09 v430JPRC shinobar: make ZDRVSFS
  24. #v431 bugfixes.
  25. #v431JP add application ID on iso image.(removed)
  26. #v431JP removed app ID code, permitions of sfs files, forground collor of rxvt
  27. #v431JP mkisofs with Joliet option, volume id, what copied from cd, remove slmodems
  28. #v431JP error message for full install
  29. #091212 weird bug, no processes but when run this, x restarts...
  30. # 28dec09 remove /modules/${KERNELVER}/modules.*
  31. #100117 save user-modified rox globicons file.
  32. # 20jan10 Puppy v4.x(before woof) backward compatibility
  33. #100913 simplified puppy filenames. see variables in /etc/DISTRO_SPECS.
  34. #100916 no longer have DISTRO_DEVXSFS in /etc/DISTRO_SPECS.(it was only there briefly)
  35. #101020 no longer have /etc/modprobe.conf.
  36. #101107 bug fix from zygo.
  37. #110505 support sudo for non-root user.
  38. #110722 tweak sort.
  39. #110808 PANZERKOPF: bug fix. 110822 reverted.
  40. #120323 replace 'xmessage' with 'pupmessage'.
  41. #120329 Xdialog bug --yesno supposed to "yes" "No" buttons, but they are "OK" "Cancel".
  42. #120512 01micko: support xz compression.
  43. #120605 rerwin: omit /dev/snd content, /dev/.udev subdirectory and modem daemons from new master (because daemons reinstalled from firmware if needed).
  44. #120606 rerwin: support users' replacement of stripped /root & /etc with complete directories (for "boot disk").
  45. #120607 rerwin: Remove indicators/files for integrated user-installed packages.
  46. #120628 shinobar: no change id-string for reuse
  47. #120721 revert 'wildcards' option (from 120605); improve /dev/snd file exclusion; exclude /usr/share/icons/hicolor/icon-theme.cache (shinobar).
  48. #121021 rerwin: revert 120605 modem daemon removals (because daemons no longer copied from firmware directory).
  49. #130203 change probedisk2 to probedisk.
  50. #130216 partial support f2fs.
  51. #130222 convert internationalization from "technosaurus method" to gettext method.
  52. #130222 virtual-CD detection was broken.
  53. #130223 various fixes. note, also fixed /usr/sbin/filemnt. now can retain files between remasters.
  54. #130301 o/p of "losetup" (BB), shows all in use, but "losetup-FULL -a" needs param, also o/p format different.
  55. #130302 L18L: moved m_09 m_10 m_11 top and made another use of it.
  56. #130304 cp -n not supported, use -u
  57. #130306 gettext translation fixed, line 354. 130307 again.
  58. #130308 npierce: filter out wrong CDs from choices offered to user; remove CD drive from VIRTUALCD list.
  59. #130527 /etc/.XLOADED has been moved to /root, refer /usr/bin/xwin.
  60. [ "`whoami`" != "root" ] && exec sudo -A ${0} ${@} #110505
  61. #NOTE: rename to avoid clash with 'remasterpup2.mo' used by previous i18n method.
  62. export TEXTDOMAIN=remasterpup2x
  63. export OUTPUT_CHARSET=UTF-8
  64. . gettext.sh
  65. Yes_lbl="$(gettext 'Yes')"
  66. No_lbl="$(gettext 'No')"
  67. m_01="$(gettext 'Puppy simple CD remaster')" #window title.
  68. m_02="$(gettext 'ERROR')"
  69. m_07="$(gettext 'currently mounted')"
  70. m_08="$(gettext 'not mounted')"
  71. m_09="$(gettext 'Filesystem')" #130302
  72. m_10="$(gettext 'Size')" #130302
  73. m_11="$(gettext 'Free')" #130302
  74. choice_cdd () {
  75. #copy files off live-cd.... w018 use probedisk2...
  76. SELECTIONS="`probedisk 2>&1 | grep '^/dev/' | grep "|optical|" | cut -f 1,3 -d "|" | tr " " "_" | tr "|" " " | tr '$' "_"`"
  77. SELECTIONS="$SELECTIONS $VIRTUALCD"
  78. if [ "$(echo "$SELECTIONS"|tr -d ' ')" = "" ]; then
  79. m_14_2="$(gettext 'NO CD/DVD drives found.')"
  80. Xdialog --wrap --left --title "$m_01: $m_02" --msgbox "$m_14_2
  81. $MSG" 0 80
  82. exit
  83. fi
  84. if [ "$1" = "filter" ];then #130308 Filter out devices with a missing file.
  85. FILT_SELECTIONS=""
  86. i="0"
  87. for ASELECTION in $SELECTIONS
  88. do
  89. if [ "$((i++&1))" -eq "0" ];then
  90. BLKDEV="$ASELECTION"
  91. else
  92. DEVNAME="$ASELECTION"
  93. MNTPNT="`mount | grep "$BLKDEV" | tr -s " " | cut -f 3 -d " "`"
  94. [ -z "$MNTPNT" -o -f "$MNTPNT/initrd.gz" -a -f "$MNTPNT/$PUPPYSFS" ] && FILT_SELECTIONS="$FILT_SELECTIONS $BLKDEV $DEVNAME"
  95. fi
  96. done
  97. SELECTIONS="$FILT_SELECTIONS"
  98. if [ -z "$SELECTIONS" ];then
  99. m_14_3="$(gettext 'Puppy live-CD or virtual CD was not found.')
  100. $(eval_gettext "(No CD or .iso file has both 'initrd.gz' and '${PUPPYSFS}'.)")"
  101. Xdialog --wrap --left --title "$m_01: $m_02" --msgbox "$m_14_3" 0 0
  102. exit
  103. fi
  104. fi #130308 end of filter
  105. m_14_1="$(gettext 'Choose the CD/DVD drive...')"
  106. DIALOG="Xdialog --wrap --left --title \"$m_01\" --stdout --menubox \"$MSG\n\n$m_14_1\" 0 56 4 $SELECTIONS 2> /dev/null"
  107. BURNERDRV=""
  108. RESULT=$(eval $DIALOG) #w018 # 22jun09
  109. [ $? -ne 0 ] && exit
  110. BURNERDRV=$RESULT
  111. [ "$BURNERDRV" = "" ] && exit
  112. BURNERDRV="`echo -n "$BURNERDRV" | cut -f 3 -d '/'`"
  113. }
  114. #LANG=C #faster, plus Xdialog happier.
  115. KERNELVER="`uname -r`"
  116. #120512 01micko: set compression
  117. COMP=""
  118. mksquashfs -help &>/tmp/mk #refuses to grep from stdout
  119. grep 'xz' /tmp/mk &>/dev/null
  120. [ "$?" = "0" ] && COMP="-comp xz"
  121. ARCH="`uname -m`"
  122. [ "$(uname -m|grep ^i)" ] && ARCH="`uname -m|cut -c3,4`"
  123. case "$ARCH" in
  124. 86)AOPT="-Xbcj x86" ;;
  125. *)AOPT="" ;; #todo add other arches
  126. esac
  127. rm /tmp/mk
  128. COPTIONS=""${COMP}" "${AOPT}""
  129. #end set compression
  130. #variables created at bootup by /initrd/usr/sbin/init...
  131. . /etc/rc.d/PUPSTATE
  132. [ "$PUP_LAYER" = "" ] && PUP_LAYER="/pup_ro2"
  133. . /etc/DISTRO_SPECS
  134. if [ ! "$DISTRO_IDSTRING" ];then #101107
  135. #need some stuff in here if want to support older puppies. maybe also more fixes needed further down.
  136. pupmessage -bg red -title "RemasterPup" -center "Sorry, your Puppy is too old for this script"
  137. exit
  138. else
  139. PUPPYSFS="$DISTRO_PUPPYSFS" #ex: puppy.sfs
  140. ZDRVSFS="$DISTRO_ZDRVSFS" #ex: zdrv.sfs
  141. SFSBASE="`basename $PUPPYSFS .sfs`" #ex: puppy
  142. fi
  143. #100913 generate a new id-string...
  144. IDDATE="`date +%y%m%d%H%M%S`" #12 bytes, ex: 100911153319
  145. IDPREFIX="`echo -n "$DISTRO_FILE_PREFIX" | cut -b 1`"
  146. #...needs to be appended to vmlinuz, puppy.sfs, zdrv.sfs and devx.sfs
  147. #110422 increase size of idstring to 32 bytes...
  148. IDSTRING="${IDPREFIX}${IDDATE}ZZZZ${DISTRO_VERSION}"
  149. #...ZZZZ reserved space for future use.
  150. LEN1=`echo -n "$IDSTRING" | wc -c`
  151. LEN2=`expr 32 - $LEN1`
  152. EXTX=''
  153. while [ $LEN2 -gt 0 ];do
  154. LEN2=`expr $LEN2 - 1`
  155. EXTX="${EXTX}X"
  156. done
  157. IDSTRING="${IDSTRING}${EXTX}" #32 bytes ex: w110423092024ZZZZ5.1.2XXXXXXXXXX
  158. PPATTERN="/initrd${PUP_LAYER}"
  159. if [ "`mount | grep "$PPATTERN"`" = "" ];then
  160. #no puppy.sfs file mounted on pup_ro2, probably h.d. install...
  161. m_03="$(eval_gettext 'This program requires a ${PUPPYSFS} file mounted on /initrd${PUP_LAYER}.')
  162. $(gettext 'Which is not the case here, probably because this is a full hard drive installation?')
  163. $(gettext 'Whatever, boot Puppy from live-CD and then you will be able to use this script.')
  164. $(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.')
  165. $(gettext 'You will also need a current live-CD, as the program gets files off it.')
  166. $(gettext 'Anyone want to try it?')
  167. $(gettext "Click 'Ok' button to quit...")"
  168. Xdialog --wrap --left --title "m_01: m_02" --msgbox "$m_03" 0 80
  169. exit
  170. fi
  171. SAVEPART="$PDEV1" #from PUPSTATE.
  172. CDR="/dev/$SAVEPART"
  173. #choose where to create isolinux-builds/ directory...
  174. m_05="$(gettext 'Welcome! This little program takes a snapshot of your current system and burns it to CD.')
  175. $(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}.')
  176. $(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} and burnt to CD.")
  177. $(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!")
  178. $(gettext 'Click OK button to continue (or close window to quit)...')"
  179. Xdialog --wrap --left --title "$m_01" --msgbox "$m_05" 0 80
  180. [ $? -ne 0 ] && exit
  181. #calc size needed...
  182. m_06="$(gettext 'Calculating needed working space.')
  183. $(gettext 'Please wait, this may take awhile...')"
  184. Xdialog --wrap --left --title "$m_01" --no-buttons --ignore-eof --infobox "$m_06" 0 0 0 &
  185. XPID=$!
  186. SIZEOPT=0
  187. SIZEBIN=`du -sk /bin | cut -f 1`
  188. SIZESBIN=`du -sk /sbin | cut -f 1`
  189. SIZELIB=`du -sk /lib | cut -f 1`
  190. SIZEUSR=`du -sk /usr | cut -f 1`
  191. SIZEOPT=0 # 01jul09
  192. [ -d /opt ] && SIZEOPT=`du -sk /opt | cut -f 1`
  193. sync
  194. SIZETOTALK=`LANG=C dc $SIZEBIN $SIZESBIN + $SIZELIB + $SIZEUSR + $SIZEOPT + p`
  195. SIZETOTALM=`LANG=C dc $SIZETOTALK 1024 \/ p| cut -d'.' -f1` # 01jul09
  196. [ "$SIZETOTALM" ] || SIZETOTALM=1
  197. #estimate a compressed size...
  198. SIZENEEDEDM=`expr $SIZETOTALM \/ 3`
  199. SIZESLACKM=`expr $SIZENEEDEDM \/ 3` #guess
  200. SIZENEEDEDM=`expr $SIZENEEDEDM + $SIZESLACKM`
  201. SIZENEEDEDM=`expr $SIZENEEDEDM + 25` #space for vmlinuz, initrd.gz, zdrv, etc
  202. #now choose working partition... v431 add ext4... 130216 add f2fs...
  203. PARTSLIST="`probepart -m 2> /dev/null | grep '^/dev/' | grep -E 'f2fs|ext2|ext3|ext4|reiserfs|msdos|vfat|ntfs' | cut -f 1-3 -d '|'`"
  204. echo -n "" > /tmp/schoices.txt
  205. echo "$PARTSLIST" |
  206. while read APART
  207. do
  208. [ "$APART" = "" ] && continue #v3.01 preaution
  209. MNTSTATUS="($m_07)" #"currently mounted"
  210. ATAG="`echo -n "$APART" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
  211. ASIZE="`echo -n "$APART" | cut -f 3 -d '|'`"
  212. AFS="`echo -n "$APART" | cut -f 2 -d '|'`"
  213. AFPATTERN="^/dev/$ATAG " #v3.01
  214. AFREE="`df -m | grep "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`"
  215. FLAG_RO='no' #v431
  216. if [ ! "$AFREE" ];then
  217. MNTSTATUS="($m_08)" #"not mounted"
  218. mkdir -p /mnt/$ATAG
  219. mount -t $AFS /dev/$ATAG /mnt/$ATAG > /dev/null 2>&1
  220. if [ $? -eq 0 ];then
  221. if [ "$ATAG" = "fd0" ];then
  222. FFREE=`df -k | grep "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`
  223. AFREE="`LANG=C dc $FFREE 1024 \/ p`"
  224. else
  225. AFREE="`df -m | grep "$AFPATTERN" | tr -s " " | cut -f 4 -d " "`"
  226. fi
  227. [ "`mount | grep "$AFPATTERN" | grep ' (rw'`" = "" ] && FLAG_RO='yes' #v431 make sure writable.
  228. umount /dev/$ATAG
  229. else #v431
  230. continue
  231. fi
  232. else
  233. [ "`mount | grep "$AFPATTERN" | grep ' (rw'`" = "" ] && FLAG_RO='yes' #v431 make sure writable.
  234. fi
  235. [ "$FLAG_RO" = "yes" ] && continue #v431
  236. [ "$AFS" ] && echo "${ATAG} \"${m_09}: $AFS ${m_10}: ${ASIZE}M ${m_11}: ${AFREE}M ${MNTSTATUS}\" \\" >> /tmp/schoices.txt #v3.01 added precaution. #130302 L18L
  237. done
  238. SCHOICES="`cat /tmp/schoices.txt`"
  239. #add tmpfs ramdisk choice...
  240. SIZETMPFSM="`df -m | grep '^tmpfs' | grep '/initrd/pup_rw' | tr -s " " | cut -f 4 -d " "`"
  241. TMPFSMSG=''
  242. if [ "$SIZETMPFSM" != "" ];then
  243. TOTALTMPFSM="`df -m | grep '^tmpfs' | grep '/initrd/pup_rw' | tr -s " " | cut -f 2 -d " "`"
  244. if [ "$SCHOICES" = "" ];then #v3.01
  245. SCHOICES="ramdisk \"$m_09: tmpfs $m_10: ${TOTALTMPFSM}M $m_11: ${SIZETMPFSM}M ($m_07)\" \\"
  246. else
  247. SCHOICES="$SCHOICES
  248. ramdisk \"$m_09: tmpfs $m_10: ${TOTALTMPFSM}M $m_11: ${SIZETMPFSM}M ($m_07)\" \\"
  249. fi
  250. m_12="$(gettext 'Note 2: you can use the tmpfs ramdisk, which is in RAM, if it has enough space.')"
  251. TMPFSMSG="$m_12
  252. "
  253. fi
  254. [ "$SCHOICES" = "" ] && exit #precaution.
  255. m_13="$(gettext 'A working area is required in which to create the new live-CD iso file.')
  256. $(eval_gettext 'Here are the available partitions. You must choose one that has at least ${SIZENEEDEDM}M free space on it.') $(gettext 'Also, if you choose to create an ISO file rather than burn direct to CD/DVD, then you will need an extra 100 - 300MB space (whatever the size of ISO file is going to be).')
  257. $(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.')
  258. $(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.')
  259. ${TMPFSMSG}
  260. $(gettext 'Highlight desired choice then click OK button...')"
  261. echo '#!/bin/sh' > /tmp/savedlg
  262. echo -n "Xdialog --wrap --left --stdout --title \"$m_01\" --menubox \"$m_13\" 0 80 5 " >> /tmp/savedlg
  263. echo "$SCHOICES" >> /tmp/savedlg
  264. echo ' > /tmp/tag.txt' >> /tmp/savedlg
  265. chmod 755 /tmp/savedlg
  266. kill $XPID
  267. /tmp/savedlg
  268. [ $? -ne 0 ] && exit #130223
  269. WKGPART="`cat /tmp/tag.txt`"
  270. echo "WKGPART=$WKGPART"
  271. [ "$WKGPART" = "" ] && exit
  272. #now get the files off it...
  273. #firstly need working place to write to...
  274. [ "$WKGPART" = "ramdisk" ] && WKGMNTPT="/"
  275. WPATTERN="/dev/$WKGPART "
  276. [ "$WKGMNTPT" = "" ] && WKGMNTPT="`mount | grep "$WPATTERN" | tr -s " " | cut -f 3 -d " "`"
  277. if [ "$WKGMNTPT" = "" ];then
  278. PPATTERN="^$WKGPART "
  279. WKGFS="`echo "$SCHOICES" | grep "$PPATTERN" | cut -f 2 -d ':' | cut -f 2 -d " "`"
  280. [ "$WKGFS" = "msdos" ] && WKGFS="vfat"
  281. mkdir -p /mnt/$WKGPART
  282. mount -t $WKGFS /dev/$WKGPART /mnt/$WKGPART
  283. [ $? -ne 0 ] && exit #precaution.
  284. WKGMNTPT="/mnt/$WKGPART"
  285. fi
  286. [ "$WKGMNTPT" = "/" ] && WKGMNTPT=""
  287. # reuse if sfs file already exists
  288. NEW="yes"
  289. SFSPATH=$(ls -1 $WKGMNTPT/puppylivecdbuild/$PUPPYSFS 2>/dev/null)
  290. if [ "$SFSPATH" != "" -a $(echo "$SFSPATH" | wc -l) -eq 1 ]; then
  291. m_35="$(eval_gettext '${SFSPATH} found.')
  292. $(gettext 'Do you want to reuse it without any change?')
  293. $(gettext "If uncertain, click the 'No' button")"
  294. Xdialog --wrap --left --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_35" 0 0 && NEW="no"
  295. fi
  296. SFSPATH=""
  297. if [ "$NEW" = "yes" ]; then ###### long skip if, cleating new sfs
  298. #130223 i think should wipe contents of $WKGMNTPT/puppylivecdbuild?
  299. if [ -d $WKGMNTPT/puppylivecdbuild ];then
  300. [ -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ] && rm -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS
  301. [ -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS ] && rm -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS
  302. m_41="$(eval_gettext 'Directory ${WKGMNTPT}/puppylivecdbuild already exists.')
  303. $(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.")
  304. $(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.')
  305. $(gettext "WARNING: If the files in 'puppylivecdbuild' are for a different version of Puppy, click the 'Erase' button.")
  306. $(gettext "Again, warning, if at all uncertain, click the 'Erase' button.")
  307. $(gettext "Click 'Keep' button to retain the files...")
  308. $(gettext "Click 'Erase' button to delete the files...")"
  309. lbl_41="$(gettext 'Keep')"
  310. lbl_42="$(gettext 'Erase')"
  311. Xdialog --wrap --left --title "$m_01" --ok-label "$lbl_41" --cancel-label "$lbl_42" --yesno "$m_41" 0 80
  312. [ $? -ne 0 ] && rm -rf $WKGMNTPT/puppylivecdbuild
  313. fi
  314. #130222
  315. #130307 notice, line 356 "WARNING:....", the $ is not backslashed, which is confusing...
  316. m_42=""
  317. if [ -d $WKGMNTPT/puppylivecdbuild ];then
  318. m_42="
  319. $(gettext 'NOTICE:')
  320. $(eval_gettext 'Directory ${WKGMNTPT}/puppylivecdbuild already exists.')
  321. $(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.')
  322. $(gettext '(You may view the directory contents with a file-manager to satisfy yourself whether these files should be re-used)')"
  323. fi
  324. m_40="$(gettext 'This remaster program needs to read some files off the current live-CD.')
  325. $(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.")
  326. $(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}'")
  327. $(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)")
  328. $(gettext "Alternatively, if you want to read the files off a Puppy live-CD, insert it in drive, then click 'OK' button.")${m_42}"
  329. Xdialog --wrap --left --title "$m_01" --msgbox "$m_40" 0 80
  330. if [ $? -eq 0 ];then #130223 big if "BIGIF2"
  331. #130222 fix this...
  332. VIRTUALCD=""
  333. #130301 crap, earlier was using losetup-FULL from util-linux git, now using older 2.21.1, it needs -a param,
  334. #but also truncates long lines (same as bb losetup) -- what a nuisance...
  335. for ONELOOP in `cat /proc/mounts | grep -E '(^/dev/loop.*)( udf | iso9660 )' | cut -f 1 -d ' ' | tr '\n' ' '` #130308 /dev/loop only
  336. do
  337. oPTN="^${ONELOOP} "
  338. ONEISO="$(cat /proc/mounts | grep "$oPTN" | cut -f 2 -d ' ' | rev | cut -f 1 -d '+' | cut -f 1 -d '/' | rev)" #130301
  339. [ "$ONEISO" = "" ] && continue #130301 precaution.
  340. VIRTUALCD="${VIRTUALCD} ${ONELOOP} ${ONEISO}"
  341. done
  342. m_14="$(gettext 'This remaster program needs to read some files off the current live-CD.')
  343. $(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).')"
  344. MSG="$m_14"
  345. choice_cdd filter #130308 Use filtering.
  346. CDPATTERN="/dev/$BURNERDRV "
  347. CDMNTPT="`mount | grep "$CDPATTERN" | tr -s " " | cut -f 3 -d " "`"
  348. if [ "$CDMNTPT" != "" ];then
  349. if [ ! -f $CDMNTPT/initrd.gz ];then #130308 In theory, this will now never be true.
  350. #091212 weird bug, no processes but when run this, x restarts...
  351. xFUSER="`fuser -m /dev/$BURNERDRV 2>/dev/null`" #do this first, seems to fix it.
  352. [ "$xFUSER" != "" ] && fuser -k -m /dev/$BURNERDRV
  353. sync
  354. umount /dev/$BURNERDRV 2> /dev/null
  355. if [ $? -ne 0 ];then
  356. m_15="$(gettext 'Mounted CD, get rid of it before running this program!')"
  357. Xdialog --wrap --left --title "$m_02" --msgbox "$m_15" 0 0
  358. exit
  359. fi
  360. CDMNTPT=""
  361. fi
  362. fi
  363. if [ "$CDMNTPT" = "" ];then
  364. m_16="$(eval_gettext 'Please insert the current Puppy live-CD into drive ${BURNERDRV}.')
  365. $(gettext 'Then click OK...')"
  366. while [ 1 ];do
  367. Xdialog --wrap --left --title "$m_01" --msgbox "$m_16" 0 0
  368. [ $? -eq 0 ] || exit # 22jun09
  369. #now mount it...
  370. CDMNTPT="/mnt/$BURNERDRV"
  371. mkdir -p /mnt/$BURNERDRV
  372. mount -t iso9660 /dev/$BURNERDRV /mnt/$BURNERDRV
  373. [ $? -eq 0 ] && break
  374. done
  375. fi
  376. #now get the files off it...
  377. m_17="$(eval_gettext 'Copying files from CD to ${WKGMNTPT}/puppylivecdbuild/, please wait...')"
  378. Xdialog --wrap --left --title "$m_01" --no-buttons --ignore-eof --infobox "$m_17" 0 0 0 &
  379. XPID=$!
  380. mkdir -p $WKGMNTPT/puppylivecdbuild
  381. #now copy the files... # v431JP HTM, ICO, INF
  382. sync
  383. for F in vmlinuz initrd.gz ${ZDRVSFS} grldr menu.lst '*.xpm' isolinux.bin isolinux.cfg '*.msg' '*.16' '*.HTM*' '*.ICO' '*.INF'
  384. do
  385. #130223 -n means do not override an existing file... 130304 hmmm, -n not supported, use -u ...
  386. cp -a -u $CDMNTPT/$F $WKGMNTPT/puppylivecdbuild/ 2> /dev/null
  387. sync
  388. done
  389. umount /dev/$BURNERDRV 2> /dev/null
  390. rox -D $CDMNTPT #130223
  391. kill $XPID
  392. fi #end "BIGIF2"
  393. m_16_1="$(eval_gettext 'Do you like to make ${ZDRVSFS}, the separate driver file?')"
  394. Xdialog --wrap --left --title "$m_01" --default-no --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_16_1" 0 0
  395. [ $? -eq 0 ] && MKZDRV="yes" || MKZDRV=""
  396. [ $? -eq 255 ] && exit #130223
  397. m_18="$(eval_gettext 'Creating the ${PUPPYSFS} file in ${WKGMNTPT}/puppylivecdbuild/.')
  398. $(gettext 'This can take quite a long time, so please wait.... and wait...')
  399. $(eval_gettext 'This window will disappear when ${PUPPYSFS} is finally created.')
  400. $(gettext 'Please wait...')"
  401. Xdialog --wrap --left --title "$m_01" --no-buttons --ignore-eof --infobox "$m_18" 0 0 0 &
  402. XPID=$!
  403. #create new puppy.sfs file...
  404. squash() {
  405. echo $0 $@
  406. rxvt -bg orange -fg black -title "$m_01" -geometry 80x6 -e mksquashfs $@ 2> /dev/null
  407. }
  408. DIRHOME=""
  409. [ -d /home ] && DIRHOME="/home"
  410. [ -d /sys ] && DIRSYS="/sys"
  411. [ -d /lost+found ] && DIRLOST="/lost+found"
  412. rm -f ${WKGMNTPT}/puppylivecdbuild/$PUPPYSFS 2> /dev/null
  413. sync
  414. #note, /puppy.sfs is not normally there, i relocated it to a separate tmpfs,
  415. #however have not yet done that for multisession-cd/dvd (PUPMODE=77).
  416. #note, /home could be in underdog linux...
  417. # modules copied from initrd
  418. ANOTHER_REMOVE="/lib/modules/$KERNELVER/initrd /lib/modules/*/modules.*" # 28dec09 modules.*
  419. if [ "$MKZDRV" = "yes" ]; then
  420. rm -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS 2> /dev/null
  421. mksquashfs /lib $WKGMNTPT/puppylivecdbuild/$ZDRVSFS -keep-as-directory -e /lib/[^m]* $ANOTHER_REMOVE
  422. ANOTHER_REMOVE="/lib/modules"
  423. fi
  424. #120605 Omit certain /dev subdir content and modem components loaded from firmware tarballs...
  425. [ -d /dev/snd ] && [ "`ls /dev/snd`" != "" ] && DIRDEVSNDFILES="/dev/snd/*" #120721
  426. [ -d /dev/.udev ] && DIRDEVUDEV="/dev/.udev"
  427. #121021 modem daemons now left in place.
  428. [ -f /usr/share/icons/hicolor/icon-theme.cache ] && ICONCACHE=/usr/share/icons/hicolor/icon-theme.cache #120721
  429. TOPPLCDB=''
  430. [ -e /puppylivecdbuild ] && TOPPLCDB='/puppylivecdbuild'
  431. TOPPUPSFS=''
  432. [ -e /${PUPPYSFS} ] && TOPPUPSFS="/${PUPPYSFS}"
  433. # display terminal only for the first stage because it takes the most of time. 'squash' is a function, see above. 120512 $COPTIONS added...
  434. squash / $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ${COPTIONS} -e /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
  435. sync
  436. #add pristine folders (out of current puppy.sfs)...
  437. mksquashfs /initrd${PUP_LAYER}/proc $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  438. sync
  439. mksquashfs /initrd${PUP_LAYER}/tmp $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  440. sync
  441. mksquashfs /initrd${PUP_LAYER}/mnt $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  442. sync
  443. kill $XPID
  444. #######START WORKING ON /root#######
  445. rm -rf /tmp/root 2> /dev/null
  446. #do some work on /root before add it to the squashfs...
  447. cp -a /initrd${PUP_LAYER}/root /tmp/root #pristine /root
  448. #copy all of my-applications/
  449. cp -af /root/my-applications/* /tmp/root/my-applications/
  450. #some dotpups get installed here...
  451. cp -af /root/my-roxapps /tmp/root/ 2>/dev/null
  452. #window manager config files...
  453. cp -af /root/.jwmrc /tmp/root/
  454. cp -af /root/.jwmrc-tray /tmp/root/ #v411
  455. cp -af /root/.fvwm95rc /tmp/root/
  456. cp -af /root/.icewm/menu /tmp/root/.icewm/
  457. #rox desktop settings...
  458. cp -af /root/Choices/ROX-Filer/PuppyPin /tmp/root/Choices/ROX-Filer/
  459. cp -af /root/Choices/ROX-Filer/globicons /tmp/root/Choices/ROX-Filer/
  460. #100117 user changes get saved here, which overrides original...
  461. if [ -f /root/.config/rox.sourceforge.net/ROX-Filer/globicons ];then
  462. mkdir -p /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  463. cp -af /root/.config/rox.sourceforge.net/ROX-Filer/globicons /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  464. fi
  465. #100117 i think also save user settings...
  466. if [ -f /root/.config/rox.sourceforge.net/ROX-Filer/Options ];then
  467. mkdir -p /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  468. cp -af /root/.config/rox.sourceforge.net/ROX-Filer/Options /tmp/root/.config/rox.sourceforge.net/ROX-Filer/
  469. fi
  470. #v411 tidy up, remove desktop drive icons...
  471. grep -v '/root/.pup_event/drive_' /tmp/root/Choices/ROX-Filer/PuppyPin > /tmp/remaster-PuppyPin
  472. mv -f /tmp/remaster-PuppyPin /tmp/root/Choices/ROX-Filer/PuppyPin
  473. #this may have been modified for a different w.m...
  474. cp -af /root/.xinitrc /tmp/root/
  475. #also this...
  476. [ -f /root/.xset.sh ] && cp -af /root/.xset.sh /tmp/root/
  477. #v411 gtk theme may have been changed...
  478. cp -af /root/.gtkrc-2.0 /tmp/root/
  479. #v411 jwm theme may have changed...
  480. cp -af /root/.jwm/jwm_colors /tmp/root/.jwm/
  481. cp -af /root/.jwm/jwmrc-personal /tmp/root/.jwm/
  482. cp -af /root/.jwm/jwmrc-personal2 /tmp/root/.jwm/
  483. cp -af /root/.jwm/jwmrc-theme /tmp/root/.jwm/
  484. #v411 pmount preferences...
  485. cp -af /root/.pmountauto /tmp/root/
  486. cp -af /root/.pmountengine /tmp/root/
  487. cp -af /root/.pmountquit /tmp/root/
  488. cp -af /root/.pmountsingle /tmp/root/
  489. #TODO think need to do this for /var also...
  490. #.packages/ .files, copy any files installed to /root...
  491. echo -n "" > /tmp/allpkgs.files
  492. for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  493. do
  494. for ONEFILE in `cat $ONEPKG | grep '^/root/' | tr "\n" " "`
  495. do
  496. if [ -d $ONEFILE ];then #w018
  497. mkdir -p /tmp$ONEFILE
  498. fi
  499. if [ -f $ONEFILE ];then #w018
  500. DIRNAME="`dirname $ONEFILE`"
  501. mkdir -p /tmp$DIRNAME
  502. cp -a -f $ONEFILE /tmp$DIRNAME/
  503. fi
  504. done
  505. done
  506. #w018...
  507. #modify /root/.packages/ files, as all installed packages are now part of the new cd...
  508. cp -a -f /root/.packages /tmp/root/
  509. touch /root/.packages/user-installed-packages
  510. cat /root/.packages/user-installed-packages >> /tmp/root/.packages/woof-installed-packages
  511. sort -u --key=1 --field-separator="|" /tmp/root/.packages/woof-installed-packages > /tmp/woof-installed-packages-tmp #110722
  512. mv -f /tmp/woof-installed-packages-tmp /tmp/root/.packages/woof-installed-packages
  513. echo -n "" > /tmp/root/.packages/user-installed-packages #v431
  514. sync #120607
  515. rm -f /tmp/root/.packages/*.files #120607
  516. rm -f /tmp/root/.packages/*.remove #120607
  517. [ -f /tmp/root/.XLOADED ] && rm -f /tmp/root/.XLOADED #130527
  518. 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.')
  519. $(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 burnt onto the CD. 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!)")
  520. $(gettext '(if you think that this program has missed out something important that should be burnt into /root on the CD, please let me know -- Barry Kauler)')
  521. $(eval_gettext "After examining /tmp/root, click 'Ok' to add /root in \${PUPPYSFS} file...")"
  522. Xdialog --wrap --left --title "$m_01" --msgbox "$m_19" 0 80
  523. sync
  524. [ "`ls /tmp/root/.packages/*.files`" = "" ] && CLEARPKGLOG="yes" || CLEARPKGLOG="no" #120607 in case user copied entire /root to /tmp for boot disk.
  525. mksquashfs /tmp/root $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  526. sync
  527. rm -rf /tmp/root
  528. #######END WORKING ON /root#######
  529. #######START WORKING ON /etc#######
  530. rm -rf /tmp/etc 2> /dev/null
  531. #do some work on /etc before add it to the .sfs...
  532. cp -a /initrd${PUP_LAYER}/etc /tmp/etc #pristine /etc.
  533. #maybe this has been modified...
  534. cp -af /etc/ld.so.conf /tmp/etc/
  535. #.packages/ .files, copy any files installed to /etc...
  536. echo -n "" > /tmp/allpkgs.files
  537. for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  538. do
  539. for ONEFILE in `cat $ONEPKG | grep '^/etc/' | tr "\n" " "`
  540. do
  541. if [ -d $ONEFILE ];then #w018
  542. mkdir -p /tmp$ONEFILE
  543. fi
  544. if [ -f $ONEFILE ];then #w018
  545. DIRNAME="`dirname $ONEFILE`"
  546. mkdir -p /tmp$DIRNAME
  547. cp -a -f $ONEFILE /tmp$DIRNAME/
  548. fi
  549. done
  550. done
  551. sync
  552. cp -af /etc/eventmanager /tmp/etc/ #v411
  553. #what about settings for a particular pc?...
  554. m_20="$(gettext 'Hardware customisation was not chosen.')"
  555. MSG1="$m_20"
  556. m_21="$(eval_gettext 'Have created the /etc directory for the new ${PUPPYSFS} file.')
  557. $(gettext "It is in a 'pristine' state, but you can choose to customise it.")
  558. $(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.")
  559. $(gettext "Click 'Yes' button to customise /etc...")
  560. $(gettext "Click 'No' button not to customise (recommended)...")"
  561. Xdialog --wrap --left --title "$m_01" --default-no --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_21" 0 80
  562. if [ $? -eq 0 ];then
  563. cp -af /etc/codepage /tmp/etc/
  564. cp -af /etc/fontmap /tmp/etc/
  565. cp -af /etc/keyboardtype /tmp/etc/
  566. cp -af /etc/keymap /tmp/etc/
  567. cp -af /etc/mousebuttons /tmp/etc/
  568. cp -af /etc/mousedevice /tmp/etc/
  569. cp -af /etc/videomode /tmp/etc/
  570. cp -af /etc/eth0mode /tmp/etc/
  571. cp -af /etc/eth1mode /tmp/etc/
  572. cp -af /etc/resolv.conf /tmp/etc/
  573. rm -f /tmp/etc/localtime #a symlink
  574. cp -af /etc/localtime /tmp/etc/
  575. cp -af /etc/TZ /tmp/etc/
  576. cp -af /etc/cdburnerdevice /tmp/etc/
  577. cp -af /etc/dvddevice /tmp/etc/
  578. cp -af /etc/modemdevice /tmp/etc/
  579. cp -af /etc/securetelnetrc /tmp/etc/
  580. cp -af /etc/modules.conf /tmp/etc/
  581. cp -af /etc/modprobe.d /tmp/etc/ #101020
  582. cp -af /etc/rdesktoprc /tmp/etc/
  583. cp -af /etc/windowmanager /tmp/etc/
  584. cp -af /etc/xextraoptions /tmp/etc/
  585. cp -af /etc/X11/xorg.conf /tmp/etc/X11
  586. cp -af /etc/network-wizard /tmp/etc/
  587. cp -af /etc/simple_network_setup/* /tmp/etc/simple_network_setup/
  588. m_22="$(gettext 'These files were customised in /etc:')
  589. codepage fontmap keyboardtype keymap mousebuttons mousedevice videomode eth0mode eth1mode resolv.conf localtime TZ cdburnerdevice dvddevice modemdevice securetelnetrc modprobe.d/* rdesktoprc windowmanager xextraoptions X11/xorg.conf
  590. $(gettext 'Also these directories:')
  591. network-wizard."
  592. MSG1="$m_22"
  593. fi
  594. #some files to always copy...
  595. cp -af /etc/Puppybackgroundpicture /tmp/etc/
  596. #TODO: other gtk and jwm customisations.
  597. #100913 fix id-string variable...
  598. idPATTERN="s%^DISTRO_IDSTRING.*%DISTRO_IDSTRING='${IDSTRING}'%"
  599. sed -i -e "$idPATTERN" /tmp/etc/DISTRO_SPECS
  600. cp -f /tmp/etc/DISTRO_SPECS /tmp/DISTRO_SPECSupdated #keep this to put into initrd.gz.
  601. m_23="${MSG1}
  602. $(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.')
  603. $(gettext "Do anything you want before clicking 'Ok'.")
  604. $(gettext '(If this program has missed something important, let me know -- Barry Kauler)')
  605. $(eval_gettext "Click 'Ok' to add /etc in \${PUPPYSFS} file...")"
  606. Xdialog --wrap --left --title "$m_01" --msgbox "$m_23" 0 80
  607. #120606 in case user just now replaced the /etc directory...
  608. sync
  609. #130527 .XLOADED moved to /root (see /usr/bin/xwin), change test...
  610. MODIFETC="$(find /tmp/etc/modules -mindepth 1 -maxdepth 1 -name 'firmware.dep.inst.*')"
  611. if [ "$MODIFETC" != "" ];then
  612. #rm -f /tmp/etc/.XLOADED
  613. rm -f /tmp/etc/modules/firmware.dep.inst.*
  614. touch /tmp/etc/personal_settings_popup_disabled
  615. touch /tmp/etc/personal_data_save_disabled
  616. fi
  617. [ -f /tmp/etc/.XLOADED ] && rm -f /tmp/etc/.XLOADED #130527 just in case old file still there.
  618. sync
  619. mksquashfs /tmp/etc $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  620. sync
  621. rm -rf /tmp/etc
  622. #######END WORKING ON /etc#######
  623. #######START WORKING ON /var#######
  624. rm -rf /tmp/var 2> /dev/null
  625. cp -a /initrd${PUP_LAYER}/var /tmp/var #pristine var
  626. #.packages/ .files, copy any files installed to /var...
  627. echo -n "" > /tmp/allpkgs.files
  628. for ONEPKG in `ls -1 /root/.packages/*.files 2>/dev/null | tr "\n" " "`
  629. do
  630. for ONEFILE in `cat $ONEPKG | grep '^/var/' | tr "\n" " "`
  631. do
  632. if [ -d $ONEFILE ];then #w018
  633. mkdir -p /tmp$ONEFILE
  634. fi
  635. if [ -f $ONEFILE ];then #w018
  636. DIRNAME="`dirname $ONEFILE`"
  637. mkdir -p /tmp$DIRNAME
  638. cp -a -f $ONEFILE /tmp$DIRNAME/
  639. fi
  640. done
  641. done
  642. sync
  643. [ "$CLEARPKGLOG" = "yes" ] && rm -f /tmp/var/log/packages/* #120607
  644. sync
  645. mksquashfs /tmp/var $WKGMNTPT/puppylivecdbuild/$PUPPYSFS -keep-as-directory
  646. sync
  647. rm -rf /tmp/var
  648. #######END WORKING ON /var#######
  649. chmod a+r $WKGMNTPT/puppylivecdbuild/* &>/dev/null
  650. chmod a-x $WKGMNTPT/puppylivecdbuild/*.sfs &>/dev/null
  651. fi ###### end of long skip if, cleating new sfs
  652. if [ -f $WKGMNTPT/puppylivecdbuild/isolinux.cfg ]; then
  653. #edit isolinux.cfg...
  654. ISOLINUXCFG="`cat $WKGMNTPT/puppylivecdbuild/isolinux.cfg`"
  655. #small tweaks, like acpi=on, ide=nodma...
  656. m_24="$(gettext 'Almost ready to burn the CD!')
  657. $(eval_gettext 'All the files that will be burnt to CD are in ${WKGMNTPT}/puppylivecdbuild/.')
  658. $(gettext 'The thing that you may want to do is edit isolinux.cfg. It has this:')
  659. ${ISOLINUXCFG}
  660. $(gettext "'pmedia' parameter is a hint to Puppy what media you are booting Puppy from.")
  661. $(gettext "'pmedia=cd' means any CD/DVD drive. Other options are:")
  662. usbflash usbhd usbcd ataflash atahd atacd atazip scsihd scsicd
  663. $(gettext "(where 'ata' means either IDE or SATA interface, i.e. an internal drive)")
  664. $(gettext "'pkeys' is the default keyboard layout. Example: 'pkeys=us' Choices are:")
  665. azerty be-latin1 br-abnt2 br-abnt br-latin1-abnt2 br-latin1-us by cf croat cz de de-latin1 dk dvorak dvorak-l dvorak-r es et fi fr gr hu101 hu il it jp106 lt mk nl no pl pt-latin1 ro ru se sg sk-qwerty sk-qwertz slovene sv-latin1 uk us wangbe
  666. $(gettext "You may also add any kernel parameters. Some PCs require 'acpi=off' to boot properly.")
  667. $(gettext "(If answer 'Yes', an editor will appear, must exit editor before this program will continue)")
  668. $(gettext "Click 'Yes' button to edit isolinux.cfg...")"
  669. Xdialog --wrap --left --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_24" 0 80
  670. if [ $? -eq 0 ];then
  671. defaulttexteditor $WKGMNTPT/puppylivecdbuild/isolinux.cfg
  672. fi
  673. sync
  674. fi
  675. m_25="$(gettext 'Almost ready to burn the CD!')
  676. $(eval_gettext 'All the files that will be burnt to CD are in ${WKGMNTPT}/puppylivecdbuild/.')
  677. $(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.")
  678. $(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.")"
  679. Xdialog --wrap --left --title "$m_01" --msgbox "$m_25" 0 80
  680. sync
  681. BOOTPARM=""
  682. [ -f $WKGMNTPT/puppylivecdbuild/grldr ] && BOOTPARM="-b grldr"
  683. [ -f $WKGMNTPT/puppylivecdbuild/isolinux.bin ] && BOOTPARM="-b isolinux.bin -c boot.cat"
  684. if [ "$BOOTPARM" = "" ]; then
  685. m_25_1="$(gettext 'No boot loaders found. You need isolinux.bin or grldr to make bootable CD.')
  686. $(gettext "Click 'OK' to quit.")
  687. $(eval_gettext '(leaving ${WKGMNTPT}/puppylivecdbuild/ files in existence)')"
  688. Xdialog --wrap --left --title "$m_01" --msgbox "$m_25_1" 0 0
  689. exit
  690. fi
  691. if [ "$NEW" = "yes" ]; then #120628: no change id-string for reuse
  692. #100913 append id-string. doesn't matter if already have an id-string appended...
  693. echo -n "$IDSTRING" >> $WKGMNTPT/puppylivecdbuild/vmlinuz
  694. [ -f $WKGMNTPT/puppylivecdbuild/$PUPPYSFS ] && echo -n "$IDSTRING" >> $WKGMNTPT/puppylivecdbuild/$PUPPYSFS
  695. [ -f $WKGMNTPT/puppylivecdbuild/$ZDRVSFS ] && echo -n "$IDSTRING" >> $WKGMNTPT/puppylivecdbuild/$ZDRVSFS
  696. sync
  697. #100913 need to update file DISTRO_SPECS in initrd.gz, so init script can find puppy files...
  698. mv -f $WKGMNTPT/puppylivecdbuild/initrd.gz /tmp #note $WKGMNTPT may be non-linux fs.
  699. cd /tmp
  700. gunzip initrd.gz
  701. mkdir initrd-tree-tmp1
  702. cd initrd-tree-tmp1
  703. cat ../initrd | cpio -i -d -m
  704. sync
  705. rm -f ../initrd
  706. cp -a -f /tmp/DISTRO_SPECSupdated ./DISTRO_SPECS #see earlier.
  707. find . | cpio -o -H newc | gzip -9 > $WKGMNTPT/puppylivecdbuild/initrd.gz
  708. sync
  709. cd ..
  710. rm -rf initrd-tree-tmp1
  711. cd /root
  712. fi #120628 end
  713. #build new iso file, or direct burn to cd...
  714. #to save space, burn direct from $WKGMNTPT/puppylivecdbuild/ to cd...
  715. m_26="$(eval_gettext 'All the files that will be burnt to CD/DVD are in ${WKGMNTPT}/puppylivecdbuild/.')
  716. $(gettext 'As the working partition may have limited space (for example, you are using a USB pen drive), these files are burnt direct to CD/DVD, rather than create an intermediary iso file. If you do need an iso file, you can copy it from the CD afterward:')
  717. $(eval_gettext '(dd if=/dev/${BURNERDRV} of=puppy.iso seek=0 bs=32k)')
  718. $(gettext "However, if you just want to create an iso file now and not burn to CD/DVD, click the 'No' button.")
  719. $(eval_gettext "Click 'No' button (or close-box on window) to quit program at this point (leaving \${WKGMNTPT}/puppylivecdbuild/ files in existence), and further option to create an iso file...")
  720. $(gettext "Click 'Yes' button to burn to CD/DVD...")"
  721. Xdialog --wrap --left --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_26" 0 80
  722. if [ ! $? -eq 0 ];then
  723. MSG="$(gettext 'ISO file not created.')"
  724. m_27="$(eval_gettext "Click 'Yes' button to create a 'custom-puppy.iso' in \${WKGMNTPT}/ (assuming that there is 100MB-300MB free space)...")
  725. $(eval_gettext "Click 'No' button (or close-box on window) to quit program at this point (leaving \${WKGMNTPT}/puppylivecdbuild/ files in existence)...")"
  726. Xdialog --wrap --left --title "$m_01" --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$m_27" 0 80
  727. if [ $? -eq 0 ];then
  728. VOLI=""
  729. m_27_1="$(gettext 'You can add the CD volume ID, it can be used on Windows and on some Linux system.')"
  730. VOLI=$(Xdialog --title "$m_01" --stdout --inputbox "$m_27_1" 0 60 "$SFSBASE")
  731. [ "$VOLI" != "" ] && VOLI="-V $(echo "$VOLI"|tr ' ' '_')"
  732. [ -f $WKGMNTPT/custom-puppy.iso ] && rm -f $WKGMNTPT/custom-puppy.iso #130223
  733. # Joliet option
  734. rxvt -bg orange -fg black -title "$m_01" -e mkisofs -J -D -R $VOLI -o $WKGMNTPT/custom-puppy.iso $BOOTPARM -no-emul-boot -boot-load-size 4 -boot-info-table $WKGMNTPT/puppylivecdbuild/
  735. MSG="$(eval_gettext '${WKGMNTPT}/custom-puppy.iso created.')"
  736. fi
  737. sync
  738. m_28="$(eval_gettext '${WKGMNTPT}/puppylivecdbuild/ files left in existence.')
  739. $(gettext "Click 'Ok' button to quit...")"
  740. Xdialog --wrap --left --title "$m_01" --msgbox "$MSG
  741. $m_28" 0 0
  742. exit
  743. fi
  744. VIRTUALCD=""
  745. MSG="$(gettext 'You need to choose a burner drive so that the files created by this program can be burnt to a new CD/DVD.')"
  746. if [ "$BURNERDRV" = "" -o "$(echo "$BURNERDRV" | grep 'loop')" != "" ]; then
  747. choice_cdd
  748. fi
  749. if [ "`echo "$BURNERDRV" | grep 'hd'`" != "" ];then
  750. DEVDEV="ATAPI:/dev/$BURNERDRV"
  751. else
  752. DEVDEV="/dev/$BURNERDRV"
  753. fi
  754. #now for the actual burn...
  755. m_29="$(gettext 'Please choose the media to burn to.')
  756. $(eval_gettext 'The burner drive is /dev/${BURNERDRV}, and obviously it must be able to burn a DVD if you want to burn a DVD!')
  757. $(gettext "Note, you can later use the 'dd' program to create an iso file:")
  758. # dd if=/dev/${BURNERDRV} of=puppy.iso seek=0 bs=32k
  759. $(gettext 'PLEASE INSERT THE NEW CD OR DVD RIGHT NOW, THEN CHOOSE FROM MENU...')"
  760. m_30="$(gettext 'New blank recordable CD')"
  761. m_31="$(gettext 'New blank DVD-R (not +R, -RW, +RW)')"
  762. CDCHOICE="`Xdialog --wrap --left --stdout --title \"$m_01\" --menubox \"$m_29\" 0 0 4 CD-R \"$m_30\" DVD-R \"$m_31\"`"
  763. echo '#!/bin/sh' > /tmp/new2cd.sh
  764. if [ "`echo "$CDCHOICE" | grep 'DVD'`" = "" ];then
  765. #burn to CD...
  766. echo "mkisofs -D -R -quiet $BOOTPARM -no-emul-boot -boot-load-size 4 -boot-info-table $WKGMNTPT/puppylivecdbuild/ | cdrecord -multi -tao -pad -data -v speed=4 gracetime=2 dev=$DEVDEV -" >> /tmp/new2cd.sh
  767. else
  768. echo "growisofs -speed=4 -Z /dev/$BURNERDRV -R -D -quiet $BOOTPARM -no-emul-boot -boot-load-size 4 -boot-info-table $WKGMNTPT/puppylivecdbuild/" >> /tmp/new2cd.sh
  769. fi
  770. m_32="$(gettext 'Finished. Press ENTER key to continue')"
  771. echo "echo -n \"$m_32\": " >> /tmp/new2cd.sh
  772. echo 'read nippi' >> /tmp/new2cd.sh
  773. chmod 755 /tmp/new2cd.sh
  774. rxvt -bg orange -fg black -title "$m_01" -e /tmp/new2cd.sh
  775. sync
  776. rm -rf /puppylivecdbuild
  777. rm -rf $WKGMNTPT/puppylivecdbuild
  778. sync
  779. umount /dev/$WKGPART
  780. eject /dev/$BURNERDRV
  781. m_33="$(gettext 'You should now have a new custom Puppy live-CD!')
  782. $(gettext 'WARNING:')
  783. $(gettext 'There is a tricky situation here, as all the installed packages (plus anything else that you may have installed, such as loaded .sfs extension files, have all been burnt to CD/DVD).')
  784. $(eval_gettext 'But, they are still installed in the current ${DISTRO_FILE_PREFIX}save.2fs, the Puppy persistent storage file (where all your stuff gets saved, so it is there next time Puppy is booted).')
  785. $(gettext "All those files are duplicated, but will that do any harm if you boot the new CD? ...should be okay, but I recommend that you uninstall as much as possible right now, before booting the new CD. Note, do not uninstall them after booting the new CD as that will also 'delete' the packages burnt onto the CD.")
  786. $(eval_gettext "Or, easiest and cleanest option, boot Puppy with 'pfix=ram' boot parameter then at shutdown create a brand new '${DISTRO_FILE_PREFIX}save' file.")
  787. $(gettext "In fact, this is the wisest thing to do regardless, as you don't even know if the custom CD is going to work properly -- so it is best to bootup in ram only to find out!")" #'geany
  788. Xdialog --wrap --left --title "$m_01" --msgbox "$m_33" 0 80
  789. ####THE END######