You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.7 KiB

  1. #!/bin/sh
  2. #-
  3. # Copyright (c) 2019 HardenedBSD
  4. # Author: Shawn Webb <shawn.webb@hardenedbsd.org>
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  16. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  19. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  21. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. # SUCH DAMAGE.
  26. _skip_build=0
  27. skip_build() {
  28. _skip_build=1
  29. }
  30. clean_build() {
  31. [ ${_skip_build} -gt 0 ] && return 0
  32. (
  33. set -ex
  34. cd ${HBSD_SRC}/release
  35. make \
  36. TARGET=${HBSD_TARGET} \
  37. TARGET_ARCH=${HBSD_TARGET_ARCH} \
  38. clean
  39. )
  40. return 0
  41. }
  42. build_hardenedbsd() {
  43. [ ${_skip_build} -gt 0 ] && return 0
  44. (
  45. set -ex
  46. cd ${HBSD_SRC}
  47. make \
  48. -j ${HBSD_NJOBS} \
  49. TARGET=${HBSD_TARGET} \
  50. TARGET_ARCH=${HBSD_TARGET_ARCH} \
  51. ${HBSD_NOCLEAN} \
  52. buildworld
  53. make \
  54. -j ${HBSD_NJOBS} \
  55. TARGET=${HBSD_TARGET} \
  56. TARGET_ARCH=${HBSD_TARGET_ARCH} \
  57. KERNCONF=${HBSD_KERNEL} \
  58. ${HBSD_NOCLEAN} \
  59. buildkernel
  60. )
  61. return ${?}
  62. }
  63. build_release() {
  64. [ ${_skip_build} -gt 0 ] && return 0
  65. (
  66. set -ex
  67. cd ${HBSD_SRC}/release
  68. make \
  69. TARGET=${HBSD_TARGET} \
  70. TARGET_ARCH=${HBSD_TARGET_ARCH} \
  71. clean
  72. make \
  73. TARGET=${HBSD_TARGET} \
  74. TARGET_ARCH=${HBSD_TARGET_ARCH} \
  75. obj
  76. make \
  77. TARGET=${HBSD_TARGET} \
  78. TARGET_ARCH=${HBSD_TARGET_ARCH} \
  79. KERNCONF=${HBSD_KERNEL} \
  80. NOPORTS=1 \
  81. real-release
  82. )
  83. return ${?}
  84. }
  85. stage_release() {
  86. local f
  87. local file
  88. local res
  89. mkdir -p \
  90. ${HBSD_STAGEDIR} \
  91. ${HBSD_PUBDIR}
  92. for file in $(find ${HBSD_OBJRELDIR} -maxdepth 1 \
  93. -name '*.iso' \
  94. -o -name '*.img' \
  95. -o -name 'MANIFEST'); do
  96. f=${file##*/}
  97. mv ${file} ${HBSD_STAGEDIR}/${f}
  98. res=${?}
  99. if [ ${res} -gt 0 ]; then
  100. return ${res}
  101. fi
  102. xz -kc9 ${HBSD_STAGEDIR}/${f} > ${HBSD_STAGEDIR}/${f}.xz
  103. res=${?}
  104. if [ ${res} -gt 0 ]; then
  105. return ${res}
  106. fi
  107. done
  108. # No need to compress the .txz files
  109. for file in $(find ${HBSD_OBJRELDIR} -maxdepth 1 \
  110. -name '*.txz'); do
  111. f=${file##*/}
  112. mv ${file} ${HBSD_STAGEDIR}/${f}
  113. res=${?}
  114. if [ ${res} -gt 0 ]; then
  115. return ${res}
  116. fi
  117. done
  118. codebase_hashish > ${HBSD_STAGEDIR}/revision.txt
  119. return 0
  120. }
  121. sign_release() {
  122. (
  123. set -ex
  124. cd ${HBSD_STAGEDIR}
  125. for file in $(find . \
  126. -name '*.txz' \
  127. -o -name '*.img' \
  128. -o -name '*.iso' \
  129. -o -name '*xz' \
  130. -o -name 'MANIFEST' \
  131. -o -name 'revision.txt'); do
  132. f=${file##*/}
  133. sha256 ${f} >> CHECKSUMS.SHA256
  134. sha512 ${f} >> CHECKSUMS.SHA512
  135. if [ ! -z "${HBSD_GPG_KEY}" ]; then
  136. gpg --sign -a --detach \
  137. -u ${HBSD_GPG_KEY} \
  138. -o ${f}.asc \
  139. ${f}
  140. fi
  141. done
  142. )
  143. return ${?}
  144. }