build-for-release 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #! /bin/bash -
  2. # Specific script for the final Dragora release process.
  3. #
  4. # Copyright (c) 2021-2023 Matias Fonzo, <selk@dragora.org>.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. ## ChangeLog.
  19. #
  20. #= Version 0.7:
  21. #
  22. # - Change of strategy to build the 'phase-2' using a for loop,
  23. # this also makes the awk filter to exclude recipes work.
  24. #
  25. #= Version 0.6:
  26. #
  27. # - Adjusted the PATH in order to avoid possible influence of
  28. # the temporary system at /tools.
  29. #
  30. #= Version 0.5:
  31. #
  32. # - Added "libs/barelibs" recipe to the $exclude_list on 'phase-2'.
  33. # Thus shared libraries provided in barelibs must be replaced
  34. # with the installation of the proper software packages.
  35. #
  36. #= Version 0.4:
  37. #
  38. # - Build the final system using real cores (instead of threads,
  39. # if possible) to try to guarantee an error-free compilation.
  40. # Instructions taken from https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line
  41. #
  42. #= Version 0.3:
  43. #
  44. # - Use the -f (force) option when building on 'phase-1'.
  45. #
  46. #= Version 0.2:
  47. #
  48. # - Switch /bin/sh to /bin/bash for catching errors on pipes.
  49. #
  50. # - Upgrade packages on 'phase-2' to ensure no dependency on
  51. # /tools (temporary system) or to ensure possible system
  52. # breaks by cutting symbolic links using qi/graft.
  53. #
  54. #= Version 0.1:
  55. #
  56. # - Initial version.
  57. #
  58. set -e -o pipefail
  59. rm -f /build-phase1-log.txt /build-phase2-log.txt
  60. #
  61. # Build all the packages to conform the final system.
  62. #
  63. echo ""
  64. echo "*** Building Dragora for release [phase-1]..."
  65. echo ""
  66. echo "Using 1 parallel job for the compiler."
  67. echo ""
  68. qi order /usr/src/qi/recipes/*.order | \
  69. qi build -f -j1 -p -i - 2>&1 | tee build-phase1-log.txt
  70. #
  71. # Build all the important packages against the final system
  72. #
  73. # Variables.
  74. #
  75. # Parallel jobs for the final system (phase-2)
  76. #
  77. # The default is to use the maximum number of
  78. # installed processors (this should work on
  79. # hyperthreading and non-hyperthreading systems)
  80. JOBS="${JOBS:-$(awk -F: '/^physical/ && !ID[$2] { P++; ID[$2]=1 }; /^cpu cores/ { CORES=$2 }; END { print CORES*P }' /proc/cpuinfo)}"
  81. # Declare recipes that do not need to be a rebuild:
  82. exclude_list='!/pass-?|^data\/|docbook\/|xorg\/doc\/|xorg\/font\/|tde\/tde-i18n|devel\/fortify-headers|kernel\/headers|kernel\/generic|kernel\/buildtree-generic|kernel\/firmware|libs\/barelibs|tools\/dragora-installer/'
  83. echo ""
  84. echo "*** Building Dragora for release [phase-2]..."
  85. echo ""
  86. echo "Using $JOBS parallel job(s) for the compiler."
  87. echo ""
  88. # In order to cover a purest build, avoid influence of /tools
  89. export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/trinity/bin
  90. if test -d /tools
  91. then
  92. mv -f /tools /tools-to-be-renamed
  93. sync
  94. fi
  95. # Start to build the final phase (phase-2)
  96. : > build-phase2-log.txt
  97. for i in $(qi order /usr/src/qi/recipes/*.order | awk "$exclude_list")
  98. do
  99. echo "building -> $i"
  100. qi build -f -j${JOBS} -p -u "$i" 2>&1
  101. done | tee -a build-phase2-log.txt
  102. unset -v JOBS exclude_list i
  103. # Restore /tools for `enter-chroot`
  104. if test -d /tools-to-be-renamed
  105. then
  106. mv -f /tools-to-be-renamed /tools
  107. sync
  108. fi
  109. echo ""
  110. echo "^^^ Done."
  111. echo ""