archive: dragora-tools/build-for-release: Use real cores in the final release build
[dragora.git] / archive / dragora-tools / build-for-release
blob44a516cf7244de454b8eb3ee85bd96b518e30448
1 #! /bin/bash -
2 # Specific script for the final Dragora release process.
4 # Copyright (c) 2021-2023 Matias Fonzo, <selk@dragora.org>.
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 ## ChangeLog.
20 #= Version 0.4:
22 # - Build the final system using real cores (instead of threads,
23 # if possible) to try to guarantee an error-free compilation.
24 # Instructions taken from https://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line
26 #= Version 0.3:
28 # - Use the -f (force) option when building on 'phase-1'.
30 #= Version 0.2:
32 # - Switch /bin/sh to /bin/bash for catching errors on pipes.
34 # - Upgrade packages on 'phase-2' to ensure no dependency on
35 # /tools (temporary system) or to ensure possible system
36 # breaks by cutting symbolic links using qi/graft.
38 #= Version 0.1:
40 # - Initial version.
43 set -e -o pipefail
45 rm -f /build-phase1-log.txt /build-phase2-log.txt
48 # Build all the packages to conform the final system.
51 echo ""
52 echo "*** Building Dragora for release [phase-1]..."
53 echo ""
54 echo "Using 1 parallel job for the compiler."
55 echo ""
57 qi order /usr/src/qi/recipes/*.order | \
58 qi build -f -j1 -p -i - 2>&1 | tee build-phase1-log.txt
61 # Build all the important packages against the final system
64 # Variables.
66 # Parallel jobs for the final system (phase-2)
68 # The default is to use the maximum number of
69 # installed processors (this should work on
70 # hyperthreading and non-hyperthreading systems)
71 JOBS="${JOBS:-$(awk -F: '/^physical/ && !ID[$2] { P++; ID[$2]=1 }; /^cpu cores/ { CORES=$2 }; END { print CORES*P }' /proc/cpuinfo)}"
73 # Declare recipes that do not require reconstruction:
74 exclude_list='!/pass-?|^data\/|docbook\/|xorg\/doc\/|xorg\/font\/|tde\/tde-i18n|devel\/fortify-headers|kernel\/headers|kernel\/generic|kernel\/buildtree-generic|kernel\/firmware|tools\/dragora-installer/'
76 echo ""
77 echo "*** Building Dragora for release [phase-2]..."
78 echo ""
79 echo "Using $JOBS parallel job(s) for the compiler."
80 echo ""
82 if test -d /tools
83 then
84 mv -f /tools /tools-to-be-renamed
85 sync
88 qi order /usr/src/qi/recipes/*.order | awk "$exclude_list" | \
89 qi build -f -j${JOBS} -p -u - 2>&1 | tee build-phase2-log.txt
91 unset -v JOBS exclude_list
93 if test -d /tools-to-be-renamed
94 then
95 mv -f /tools-to-be-renamed /tools
96 sync
99 echo ""
100 echo "^^^ Done."
101 echo ""