Advertisement
Onryo

Build OpenBSD - make release image

Nov 3rd, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.54 KB | None | 0 0
  1. #!/bin/ksh
  2.  
  3. ######################################################
  4. ###### BUILDS A FULL RELEASE IMAGE FOR OPENBSD #######
  5. ######################################################
  6. ### This script will build a fully patched ISO ###
  7. ### with patched sets and patched source code. ###
  8. ### The iso can be burned to a CD and used for ###
  9. ### installing on other machines. All compiled ###
  10. ### code is signed using OPENBSD's signify. ###
  11. ### ###
  12. ### By Erik Adler aka Onryo. ###
  13. ### GPG/PGP key ID: 0x2B4B58FE ###
  14. ######################################################
  15. # BSD license #
  16. # Copyright (c) 2014 ERIK ADLER erik.adler@mensa.se #
  17. # aka Onryo #
  18. # GPG/PGP key ID: 0x2B4B58FE #
  19. # #
  20. # Permission to use, copy, modify, and distribute #
  21. # this software for any purpose with or without fee #
  22. # is hereby granted, provided that the above #
  23. # copyright notice and this permission notice appear #
  24. # in all copies. #
  25. # #
  26. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR #
  27. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS #
  28. # SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF #
  29. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL #
  30. # THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, #
  31. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES #
  32. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR #
  33. # PROFITS, WHETHER IN AN ACTION OF CONTRACT, #
  34. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT #
  35. # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE #
  36. # OF THIS SOFTWARE. #
  37. ######################################################
  38. # Supports the following architectures as of 2014: #
  39. # alpha amd64 arm armish armv7 aviion hppa hppa64 #
  40. # i386 ia64 landisk loongson luna88k m88k macppc #
  41. # mips64 octeon powerpc sgi sh socppc solbourne #
  42. # sparc sparc64 vax zaurus #
  43. ######################################################
  44.  
  45. CORES=$(sysctl hw.ncpufound)
  46. BUILDLOG=/var/log
  47. mkdir -p ${BUILDLOG}/buildlogs
  48. # Using the following ram tmpfs while building will
  49. # speed up the compile time by mitigating ufs slow IOs.
  50. # Be warned that data can be lost in case of a crash or
  51. # power outage.
  52. mount -t tmpfs tmpfs ${BUILDLOG}/buildlogs
  53. mount -t tmpfs tmpfs /usr/obj
  54.  
  55. export NAME=GENERIC.MP
  56. #export NAME=GENERIC
  57.  
  58. #### 1. BUILD AND INSTALL A NEW KERNEL
  59. ##############################################
  60. # This will build a kernel for the architecture
  61. # from above. MP is for multiprocessor.
  62.  
  63. cd /usr/src/sys/arch/`machine`/conf
  64. config ${NAME}
  65. cd /usr/src/sys/arch/`machine`/compile/${NAME}
  66. make clean
  67. make -j${CORES#*=} 2>&1 | tee ${BUILDLOG}/buildlogs/logfile_1_build_kernel
  68. make install
  69. # shutdown -r now
  70.  
  71.  
  72. #### 2. BUILD AND INSTALL SYSTEM
  73. ##############################################
  74. # After this step we will now be running the
  75. # built system from this step.
  76.  
  77. cd /usr/obj
  78.  
  79. mkdir -p old_obj #Safely delete old objs in backgroupd with &
  80. mv * old_obj
  81. rm -rf old_obj &
  82.  
  83. cd /usr/src
  84. make obj
  85. cd /usr/src/etc
  86. env DESTDIR=/ make distrib-dirs
  87. cd /usr/src
  88. make -j${CORES#*=} build 2>&1 | tee ${BUILDLOG}/buildlogs/logfile_2_build_system
  89.  
  90.  
  91. #### 3. MAKE THE SYSTEM RELEASE AND VALIDATE
  92. ##############################################
  93. # In the last step we built the system that is
  94. # now running. We now will build our release
  95. # sets for system and put them in the RELEASEDIR.
  96. # base55.tgz, comp55.tgz, etc55.tgz game55.tgz
  97. # man55.tgz
  98.  
  99. export DESTDIR=/root/dest
  100. export RELEASEDIR=/root/rel
  101.  
  102. test -d ${DESTDIR}
  103. mv ${DESTDIR} ${DESTDIR}.old # safely deletes OLD DESTDIR in bkground &
  104. rm -rf ${DESTDIR}.old &
  105. mkdir -p ${DESTDIR} ${RELEASEDIR}
  106.  
  107. cd /usr/src/etc
  108. make release 2>&1 | tee ${BUILDLOG}/buildlogs/logfile_3_sys_release
  109. cd /usr/src/distrib/sets
  110. sh checkflist
  111. cd ${RELEASEDIR}
  112. mv SHA256 SHA256_temp
  113.  
  114.  
  115. #### 4. BUILD AND INSTALL XENOCARA
  116. ##############################################
  117. # In this step we will build and install the
  118. # X windows. This will be installed in /usr/X11R6
  119.  
  120. cd /usr/xobj
  121. mkdir -p old_xobj
  122. mv * old_xobj
  123. rm -rf old_xobj &
  124.  
  125. cd /usr/xenocara
  126. make bootstrap
  127. make obj
  128. make -j${CORES#*=} build 2>&1 | tee ${BUILDLOG}/buildlogs/logfile_4_build_xenocara
  129.  
  130.  
  131. #### 5. MAKE THE SYSTEM RELEASE AND VALIDATE
  132. ##############################################
  133. # In the last step we built xenocara (X.org)
  134. # We now will build our release sets for X
  135. # windows. These sets will be added with the
  136. # system sets in the RELEASEDIR.
  137. # xbase55.tgz xetc.tgz xfont55.tgz xserv55.tgz
  138. # xshare55.tgz.
  139.  
  140. test -d ${DESTDIR}
  141. mv ${DESTDIR} ${DESTDIR}.old
  142. rm -rf ${DESTDIR}.old &
  143. mkdir -p ${DESTDIR} ${RELEASEDIR}
  144.  
  145. cd /usr/xenocara # build inside /usr/xenocara
  146. make release 2>&1 | tee ${BUILDLOG}/buildlogs/logfile_5_xenocara_release
  147. cd ${RELEASEDIR}
  148. cat SHA256 >> SHA256_temp && mv SHA256_temp SHA256
  149.  
  150.  
  151. #### 6. ORGANIZE TO RELEASE STRUCTURE
  152. ##############################################
  153. # In this step the sets will be organized
  154. # into the same structure found on the images
  155. # CDs ie OpenBSD/5.6/amd64.
  156.  
  157. export IMGROOT=/root
  158. cd ${IMGROOT}
  159. test -d OpenBSD && mv OpenBSD OpenBSD.previous
  160. mkdir -p ${IMGROOT}/OpenBSD
  161.  
  162. mv ${RELEASEDIR} `machine`
  163. mkdir `uname -r`
  164. mv `machine` `uname -r`/
  165. mv `uname -r` OpenBSD/
  166.  
  167. cd ${IMGROOT}/OpenBSD/`uname -r`
  168. tar zcf src_stable_errata.tar.gz /usr/src
  169. tar zcf xenocara_stable_errata.tar.gz /usr
  170. tar zcf ports_stable.tar.gz /usr
  171. tar zcf buildlogs.tar.gz ${BUILDLOG}/buildlogs
  172. cksum -a SHA256 *.gz > SHA256
  173.  
  174.  
  175. #### 7. SIGN ALL SETS USING OUR OWN KEY
  176. ##############################################
  177. # We use OpenBSD signify to make a private key
  178. # if we don't have one. Then we will sign our
  179. # sets so we later can verify they have not been
  180. # tampered with. If you have not already made a
  181. # private key then uncomment the key generator.
  182. # The patched code is also signed and archived.
  183.  
  184. cd ${IMGROOT}/OpenBSD/`uname -r`/`machine`
  185. #echo "Generate key pair to sign your release with."
  186. #signify -G -p /etc/signify/rolled-stable-base.pub -s /etc/signify/rolled-stable-base.sec
  187. echo "Sign your sets with your key."
  188. signify -S -s /etc/signify/rolled-stable-base.sec -m SHA256 -e -x SHA256.sig
  189. ls -1 > index.txt
  190. cd ${IMGROOT}/OpenBSD/`uname -r`
  191. echo "Sign your patched source with your key."
  192. signify -S -s /etc/signify/rolled-stable-base.sec -m SHA256 -e -x SHA256.sig
  193. ls -1 > index.txt
  194.  
  195. #### 8. ISO IMAGE THAT CAN BE BURNED TO DISK
  196. ##############################################
  197. # This will make an iso with the sets in the
  198. # correct places for installing from disk. The image
  199. # is a fully patched OS that is signed with your
  200. # own key. Your patched source code is included
  201. # and signed also. When new errata patches are
  202. # released just add them to your source repos.
  203.  
  204. export PKG_PATH=http://ftp.eu.openbsd.org/pub/OpenBSD/`uname -r`/packages/`machine`
  205. pkg_add cdrtools
  206. cd ${IMGROOT}
  207. mkisofs -r -no-emul-boot -b `uname -r`/`machine`/cdbr -c boot.catalog -o install-full.iso ${IMGROOT}/OpenBSD
  208.  
  209. # clean up.
  210. ##############################################
  211. cd ${BUILDLOG}/buildlogs && mkdir -p tmp_logs && mv * tmp_logs
  212. rm -rf tmp_logs &
  213. unset RELEASEDIR DESTDIR IMGROOT PKG_PATH CORES NAME BUILDLOG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement