4quirkybuild 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. #!/bin/sh
  2. #the script 3builddistro has built it in sandbox3/build
  3. #the quirky build will be in sandbox4.
  4. #100912 changed name of quirky-kernel to 'kernel.qky', appended id-string. simplified puppy filenames.
  5. #110422 DISTRO_VERSION variable now has dotted format. note, also now using full dotted version# in puppy filenames.
  6. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  7. #130226 update.
  8. #. ./DISTRO_SPECS
  9. . ./sandbox3/rootfs-complete/etc/DISTRO_SPECS #100912 want DISTRO_IDSTRING, created by 3builddistro.
  10. #...also has DISTRO_PUPPYSFS, DISTRO_ZDRVSFS, DISTRO_DEVXSFS simplified puppy filenames.
  11. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  12. if [ "`echo -n "$DISTRO_VERSION" | grep '\.'`" = "" ];then #110422
  13. DIGIT1="`echo "$DISTRO_VERSION" | cut -b 1`"
  14. DIGIT2="`echo "$DISTRO_VERSION" | cut -b 2`"
  15. DIGIT3="`echo "$DISTRO_VERSION" | cut -b 3`"
  16. RIGHTVER="${DIGIT1}.${DIGIT2}.${DIGIT3}"
  17. [ "$DIGIT3" = "0" ] && RIGHTVER="${DIGIT1}.${DIGIT2}"
  18. else
  19. RIGHTVER="$DISTRO_VERSION"
  20. fi
  21. #use xorriso if it is installed (see also functions4puppy)...
  22. CDRECORD='cdrecord'
  23. MKISOFS='mkisofs'
  24. if [ "`which xorriso`" != "" ];then
  25. CDRECORD='xorrecord'
  26. MKISOFS='xorrisofs' #growisofs reads this variable.
  27. fi
  28. export CDRECORD MKISOFS
  29. #what kernel was chosen?...
  30. KERNVER="`find sandbox3/rootfs-complete/lib/modules -maxdepth 1 -type d -name '[23]*' | head -n 1 | rev | cut -f 1 -d '/' | rev`"
  31. if [ ! -f /usr/src/linux-${KERNVER}/Kbuild ];then
  32. echo
  33. echo "Linux kernel source version ${KERNVER} is required."
  34. echo "If you are running from live-CD or frugal install, download the"
  35. echo "source SFS file from puppylinux.com/sources, choose it in the"
  36. echo "BootManager, then reboot. Quiting script..."
  37. exit
  38. fi
  39. #it must have 'INITRD' in the filename... 130226 no
  40. #DOTCONFIG="`find sandbox3/rootfs-complete/etc/modules -maxdepth 1 -type f -name "DOTconfig*" | grep 'INITRD'`"
  41. DOTCONFIG="`find sandbox3/rootfs-complete/etc/modules -maxdepth 1 -type f -name 'DOTconfig*' | head -n 1`"
  42. #130226 bung this in...
  43. sed -i -e 's%^CONFIG_INITRAMFS_SOURCE=.*%CONFIG_INITRAMFS_SOURCE="initrd.cpio"%' $DOTCONFIG
  44. PREBUILD='yes'
  45. [ "$DOTCONFIG" = "" ] && PREBUILD='no'
  46. [ ! -f sandbox3/build/initrd.gz ] && PREBUILD='no'
  47. [ ! -f sandbox3/build/${DISTRO_PUPPYSFS} ] && PREBUILD='no'
  48. if [ "$PREBUILD" = "no" ];then
  49. echo "The needed files are missing from sandbox3/build"
  50. echo 'The previous scripts 0* - 3* have to be run first.'
  51. echo "Quiting script..."
  52. exit
  53. fi
  54. if [ ! -e /usr/bin/gcc ];then
  55. echo
  56. echo "The 'devx' SFS file must be loaded. Quiting script..."
  57. exit
  58. fi
  59. if [ "`grep 'initrd.cpio' $DOTCONFIG`" = "" ];then
  60. echo
  61. echo "Looking in $DOTCONFIG"
  62. echo "The kernel does not have a correct configuration for building Quirky."
  63. echo 'It needs this line: CONFIG_INITRAMFS_SOURCE="initrd.cpio"'
  64. echo "You will need to run through the build again, choosing a correct kernel."
  65. echo "Quiting script..."
  66. exit
  67. fi
  68. echo
  69. echo "The Linux kernel has to be compiled, and this requires a lot of space."
  70. echo "The free-space applet in the tray must be showing at least 2.8G free."
  71. echo "If not, and you are running from live-CD or frugal, go to the Utility menu"
  72. echo "and increase the size of the save-file, then reboot. Repeat if necessary."
  73. echo -n "Type ENTER to continue (CTRL-C to quit): "
  74. read keepgoing
  75. #build initrd.cpio...
  76. echo
  77. echo "Building initrd.cpio..."
  78. [ -f /usr/src/linux-${KERNVER}/initrd.cpio ] && mv -f /usr/src/linux-${KERNVER}/initrd.cpio /tmp/
  79. rm -rf sandbox4 2>/dev/null
  80. mkdir sandbox4
  81. cp -a sandbox3/build/initrd.gz sandbox4/
  82. sync
  83. cd sandbox4
  84. gunzip initrd.gz
  85. mkdir initrd-tree
  86. cd initrd-tree/
  87. cat ../initrd | ../../boot/cpio -i -d -m
  88. sync
  89. cp ../../sandbox3/build/${DISTRO_PUPPYSFS} ./
  90. [ -f ../../sandbox3/build/${DISTRO_ZDRVSFS} ] && cp ../../sandbox3/build/${DISTRO_ZDRVSFS} ./
  91. sync
  92. #now put it together again...
  93. rm -f ../initrd.cpio
  94. find . | ../../boot/cpio -o -H newc > ../initrd.cpio
  95. sync
  96. cd ..
  97. #copy it to the kernel source...
  98. cp -f initrd.cpio /usr/src/linux-${KERNVER}/
  99. cd ..
  100. echo "...initrd.cpio should now be at /usr/src/linux-${KERNVER}"
  101. echo -n "Press ENTER to continue: "
  102. read keepgoing
  103. #now recompile the kernel...
  104. echo
  105. echo "The kernel has to be recompiled..."
  106. CURRDIR="`pwd`"
  107. cd /usr/src/linux-${KERNVER}
  108. mv -f .config DOTconfigPREVIOUS 2>/dev/null
  109. make clean
  110. make mrproper
  111. cp -f ${CURRDIR}/${DOTCONFIG} ./.config
  112. echo
  113. echo "A kernel configuration menu will pop up next."
  114. echo 'Just select the <EXIT> button to quit and save configuration.'
  115. echo -n "Press ENTER to bring up menu: "
  116. read keepgoing
  117. make menuconfig
  118. echo
  119. echo "Now compiling kernel..."
  120. make bzImage
  121. sync
  122. cd $CURRDIR
  123. echo
  124. echo "Well, it should have been done!"
  125. echo
  126. echo "Now building live-CD..."
  127. rm -rf sandbox4/build
  128. mkdir sandbox4/build
  129. cd sandbox4
  130. QUIRKYKERNEL="kernel.qky" #100912
  131. cp -a ../sandbox3/build/isolinux.bin build/
  132. case $DISTRO_FILE_PREFIX in #091203
  133. quirky)
  134. BOOTLOGO="quirky"
  135. BOOTLABEL="quirky"
  136. REMOVELINE1='pfix=copy'
  137. ;;
  138. *)
  139. BOOTLOGO="puppy"
  140. BOOTLABEL="puppy"
  141. REMOVELINE1=''
  142. ;;
  143. esac
  144. blPATTERN="s%BOOTLABEL%${BOOTLABEL}%"
  145. namePATTERN="s/DISTRO_NAME/${DISTRO_NAME}/"
  146. verPATTERN="s/DISTRO_VERSION/${DISTRO_VERSION}/"
  147. prefixPATTERN="s/DISTRO_FILE_PREFIX/${DISTRO_FILE_PREFIX}/"
  148. sed -e "$namePATTERN" -e "$verPATTERN" -e "$prefixPATTERN" -e "$blPATTERN" ../boot/boot-dialog/help.msg > build/help.msg
  149. if [ "$REMOVELINE1" != "" ];then
  150. grep -v "$REMOVELINE1" build/help.msg > /tmp/3builddistro-help.msg
  151. mv -f /tmp/3builddistro-help.msg build/help.msg
  152. fi
  153. cp -f ../boot/boot-dialog/boot.msg build/boot.msg
  154. export RGBDEF=/usr/share/X11/rgb.txt
  155. ../boot/boot-dialog/textongif.sh ../boot/boot-dialog/${BOOTLOGO}.gif "$RIGHTVER" > logo.gif
  156. ../boot/boot-dialog/gif2lss logo.gif > build/logo.16
  157. echo "default BOOTLABEL
  158. display boot.msg
  159. prompt 1
  160. timeout 50
  161. F1 boot.msg
  162. F2 help.msg
  163. label BOOTLABEL
  164. kernel ${QUIRKYKERNEL}
  165. append pmedia=cd" | sed -e "$blPATTERN" > build/isolinux.cfg
  166. sync
  167. cp -f /usr/src/linux-${KERNVER}/arch/x86/boot/bzImage build/${QUIRKYKERNEL}
  168. sync
  169. echo -n "$DISTRO_IDSTRING" >> build/${QUIRKYKERNEL} #16-char id-string appended. see 3builddistro, init.
  170. sync
  171. echo "See big fat kernel here:
  172. sandbox4/build/${QUIRKYKERNEL}"
  173. ISONAME="${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}-quirky.iso"
  174. $MKISOFS -D -R -o ${ISONAME} -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ./build/
  175. sync
  176. md5sum ${ISONAME} > ${ISONAME}.md5.txt
  177. echo
  178. echo "${ISONAME} has been created."
  179. echo
  180. echo "Would you like to burn it to a CD? "
  181. echo -n "ENTER only for yes, or any printable char then ENTER not to: "
  182. read writeitnow
  183. if [ "$writeitnow" = "" ];then
  184. CDR=""
  185. [ -f /etc/cdburnerdevice ] && CDR="/dev/`cat /etc/cdburnerdevice`"
  186. [ "$CDR" = "" ] && CDR='/dev/sr0'
  187. CDDESCR="`probedisk | grep '|optical|' | grep "$CDR" | cut -f 3 -d '|'`"
  188. echo -n 'Type "y" for multisession, else just ENTER: '
  189. read BURNMULTI
  190. if [ "$BURNMULTI" = "y" ];then
  191. BURNMULTI="-multi -tao -pad"
  192. else
  193. BURNMULTI="-dao"
  194. fi
  195. echo "Please insert blank CD into $CDR
  196. (which is described as: ${CDDESCR})
  197. -- also be sure that it is unmounted."
  198. echo -n "Then hit ENTER key: "
  199. read yayburn
  200. # $CDRECORD $BURNMULTI -data -eject -v speed=4 padsize=300k dev=ATAPI:$CDR ${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}${SCSIFLAG}.iso
  201. $CDRECORD $BURNMULTI -data -eject -v speed=4 padsize=300k dev=$CDR ${ISONAME}
  202. sync
  203. eject $CDR
  204. echo "...done"
  205. fi
  206. ###END###