2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2025 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 NAME
="IPFire" # Software name
23 SNAME
="ipfire" # Short name
24 # If you update the version don't forget to update backupiso and add it to core update
25 VERSION
="2.29" # Version number
26 CORE
="196" # Core Level (Filename)
27 SLOGAN
="www.ipfire.org" # Software slogan
28 CONFIG_ROOT
=/var
/ipfire
# Configuration rootdir
30 # Information from Git
31 GIT_BRANCH
="$(git rev-parse --abbrev-ref HEAD)" # Git Branch
32 GIT_TAG
="$(git tag | tail -1)" # Git Tag
33 GIT_LASTCOMMIT
="$(git rev-parse --verify HEAD)" # Last commit
35 TOOLCHAINVER
="20250430"
37 KVER_SUFFIX
="-${SNAME}"
40 KVER
="$(grep --max-count=1 VER lfs/linux | awk '{ print $3 }')"
41 KVER
="${KVER/-rc/.0-rc}${KVER_SUFFIX}"
43 ###############################################################################
45 # Beautifying variables & presentation & input output interface
47 ###############################################################################
49 # All supported architectures
56 HOST_ARCH
="${HOSTTYPE}"
57 HOST_KERNEL
="$(uname -r)"
61 HAS_TIME_NAMESPACE
="true"
63 # Disable time namespaces for older kernels
64 case "${HOST_KERNEL}" in
66 HAS_TIME_NAMESPACE
="false"
70 # Are we reading from/writing to a terminal?
72 [ -t 0 ] && [ -t 1 ] && [ -t 2 ]
75 # Define color for messages
79 GREEN
="$(tput setaf 2)"
80 YELLOW
="$(tput setaf 3)"
81 CYAN
="$(tput setaf 6)"
85 # Sets or adjusts pretty formatting variables
87 # Find current screen size
88 COLUMNS
="$(tput cols)"
90 # When using remote connections, such as a serial port, stty size returns 0
91 if ! is_terminal ||
[ "${COLUMNS}" = "0" ]; then
95 # Wipe any previous content before updating the counters
96 if [ -n "${TIME_COL}" ]; then
97 tput hpa
"${TIME_COL}"
101 # The status column is always 8 characters wide
104 # The time column is always 12 characters wide
107 # Where do the columns start?
108 (( STATUS_COL
= COLUMNS
- STATUS_WIDTH
))
109 (( TIME_COL
= STATUS_COL
- TIME_WIDTH
))
112 # Initially setup terminal
115 # Call resize_terminal when terminal is being resized
116 trap "resize_terminal" WINCH
118 # Writes a line to the log file
122 # Fetch the current timestamp
123 local t
="$(date -u "+%b
%e
%T
")"
125 # Append the line to file
126 if [ -w "${LOGFILE}" ]; then
127 echo "${t}: ${line}" >> "${LOGFILE}"
136 # Figure out the absolute script path using readlink
137 path
="$(readlink -f "${0}" 2>&1)"
139 # If that failed, try realpath
140 if [ -z "${path}" ]; then
141 path
="$(realpath "${0}" 2>&1)"
144 # If that failed, I am out of ideas
145 if [ -z "${path}" ]; then
146 echo "${0}: Could not determine BASEDIR" >&2
154 system_processors
() {
155 getconf _NPROCESSORS_ONLN
2>/dev
/null ||
echo "1"
161 while read -r key val unit
; do
165 echo "$(( ${val} / 1024 ))"
175 if [ ${seconds} -ge 3600 ]; then
176 printf "%d:%02d:%02d\n" \
177 "$(( seconds / 3600 ))" \
178 "$(( seconds % 3600 / 60 ))" \
179 "$(( seconds % 3600 % 60 ))"
180 elif [ ${seconds} -ge 60 ]; then
182 "$(( seconds / 60 ))" \
183 "$(( seconds % 60 ))"
185 printf "%d\n" "${seconds}"
190 # Print the string all the way to the status column
191 printf "%-${STATUS_COL}s" "$*"
195 printf "${BOLD}%s${NORMAL}\n" "$*"
202 local version
="$(grep -E "^VER |^VER
=|^VER
" $BASEDIR/lfs/${name} | awk '{ print $3 }')"
205 local string
="${name}"
206 if [ -n "${version}" ] && [ "${version}" != "ipfire" ]; then
207 string
="${string} (${version})"
211 if [ -n "${options}" ]; then
212 string
="${string} ${options[@]}"
216 print_line
"${string}"
220 local runtime
=$
(format_runtime $@
)
222 # Move back the cursor to rewrite the runtime
224 tput hpa
"${TIME_COL}"
227 printf "[ ${BOLD}%$(( TIME_WIDTH - 4 ))s${NORMAL} ]" "${runtime}"
236 color
="${BOLD}${GREEN}"
239 color
="${BOLD}${RED}"
242 color
="${BOLD}${CYAN}"
245 color
="${BOLD}${YELLOW}"
252 # Move to the start of the column
254 tput hpa
"${STATUS_COL}"
257 printf "[ ${color}%$(( STATUS_WIDTH - 4 ))s${NORMAL} ]\n" "${status}"
260 print_build_summary
() {
263 print_line
"*** Build Finished"
264 print_runtime
"${runtime}"
268 # Launches a timer process as a co-process
270 # Do nothing if the timer is already running
271 if [ -n "${TIMER_PID}" ]; then
275 # Don't launch the timer when we are not on a terminal
276 if ! is_terminal
; then
280 # Launch the co-process
281 coproc TIMER
{ "${0}" "__timer" "$$"; }
283 # Register the signal handlers
284 trap "__timer_event" SIGUSR1
285 trap "terminate_timer" EXIT
288 # Terminates a previously launched timer
290 if [ -n "${TIMER_PID}" ]; then
291 kill -TERM "${TIMER_PID}"
295 # The timer main loop
299 # Send SIGUSR1 to the main process once a second
300 # If the parent process has gone away, we will terminate.
302 if ! kill -USR1 "${pid}" &>/dev
/null
; then
310 # Called when the timer triggers
311 # This function does nothing, but is needed interrupt the wait call
318 if [ -n "${LOGFILE}" ] && [ -e "${LOGFILE}" ]; then
322 while read -r line
; do
324 done <<< "$(tail -n30 ${LOGFILE})"
330 for line
in "ERROR: $@" " Check ${LOGFILE} for errors if applicable"; do
339 local network
="false"
341 # Are we running the right shell?
342 if [ -z "${BASH}" ]; then
343 exiterror
"BASH environment variable is not set. You're probably running the wrong shell."
346 if [ -z "${BASH_VERSION}" ]; then
347 exiterror
"Not running BASH shell."
350 # Trap on emergency exit
351 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGQUIT
353 # Checking if running as root user
354 if [ "${UID}" -ne 0 ]; then
355 exiterror
"root privileges required for building"
361 while [ $# -gt 0 ]; do
364 required_space
="${1#--required-space=}"
372 exiterror
"Unknown argument: ${1}"
378 # Do we need to check the required space?
379 if [ -n "${required_space}" ]; then
380 local free_space free_blocks block_size
381 local consumed_space path
384 read -r free_blocks block_size
<<< "$(stat --file-system --format="%a
%S
" "${BASEDIR}")"
386 # Calculate free space
387 (( free_space
= free_blocks
* block_size
/ 1024 / 1024 ))
389 # If we don't have the total space free, we need to check how much we have consumed already...
390 if [ "${free_space}" -lt "${required_space}" ]; then
391 # Add any consumed space
392 while read -r consumed_space path
; do
393 (( free_space
+= consumed_space
/ 1024 / 1024 ))
394 done <<< "$(du --summarize --bytes "${BUILD_DIR}" "${IMAGES_DIR}" "${LOG_DIR}" 2>/dev/null)"
397 # Check that we have the required space
398 if [ "${free_space}" -lt "${required_space}" ]; then
399 exiterror
"Not enough temporary space available, need at least ${required_space}MiB, but only have ${free_space}MiB"
406 # Make some extra directories
407 mkdir
-p "${CCACHE_DIR}"
408 mkdir
-p "${IMAGES_DIR}"
409 mkdir
-p "${PACKAGES_DIR}"
410 mkdir
-p "${BUILD_DIR}/${TOOLS_DIR}"
411 mkdir
-p "${BUILD_DIR}/cache"
412 mkdir
-p "${BUILD_DIR}/dev"
413 mkdir
-p "${BUILD_DIR}/etc"
414 mkdir
-p "${BUILD_DIR}/proc"
415 mkdir
-p "${BUILD_DIR}/root"
416 mkdir
-p "${BUILD_DIR}/sys"
417 mkdir
-p "${BUILD_DIR}/tmp"
418 mkdir
-p "${BUILD_DIR}/usr/src"
419 mkdir
-p "${BUILD_DIR}/usr/src/cache"
420 mkdir
-p "${BUILD_DIR}/usr/src/ccache"
421 mkdir
-p "${BUILD_DIR}/usr/src/config"
422 mkdir
-p "${BUILD_DIR}/usr/src/doc"
423 mkdir
-p "${BUILD_DIR}/usr/src/html"
424 mkdir
-p "${BUILD_DIR}/usr/src/images"
425 mkdir
-p "${BUILD_DIR}/usr/src/langs"
426 mkdir
-p "${BUILD_DIR}/usr/src/lfs"
427 mkdir
-p "${BUILD_DIR}/usr/src/log"
428 mkdir
-p "${BUILD_DIR}/usr/src/src"
430 # Make BUILD_DIR a mountpoint
431 mount
-o bind "${BUILD_DIR}" "${BUILD_DIR}"
433 # Create a new, minimal /dev
434 mount build_dev
"${BUILD_DIR}/dev" \
435 -t devtmpfs
-o "nosuid,noexec,mode=0755,size=4m,nr_inodes=64k"
437 # Mount a new /dev/pts
438 mount build_dev_pts
"${BUILD_DIR}/dev/pts" \
439 -t devpts
-o "nosuid,noexec,newinstance,ptmxmode=0666,mode=620"
441 # Mount a new /dev/shm
442 mount build_dev_shm
"${BUILD_DIR}/dev/shm" \
443 -t tmpfs
-o "nosuid,nodev,strictatime,mode=1777,size=1024m"
446 mount build_tmp
"${BUILD_DIR}/tmp" \
447 -t tmpfs
-o "nosuid,nodev,strictatime,size=4G,nr_inodes=1M,mode=1777"
449 # Create an empty /proc directory and make it a mountpoint
450 mkdir
-p "${BUILD_DIR}/proc"
451 mount
--bind "${BUILD_DIR}/proc" "${BUILD_DIR}/proc"
453 # Make all sources and proc available under lfs build
454 mount
--bind /sys
"${BUILD_DIR}/sys"
455 mount
--bind -o ro
"${BASEDIR}/cache" "${BUILD_DIR}/usr/src/cache"
456 mount
--bind -o ro
"${BASEDIR}/config" "${BUILD_DIR}/usr/src/config"
457 mount
--bind -o ro
"${BASEDIR}/doc" "${BUILD_DIR}/usr/src/doc"
458 mount
--bind -o ro
"${BASEDIR}/html" "${BUILD_DIR}/usr/src/html"
459 mount
--bind -o ro
"${BASEDIR}/langs" "${BUILD_DIR}/usr/src/langs"
460 mount
--bind -o ro
"${BASEDIR}/lfs" "${BUILD_DIR}/usr/src/lfs"
461 mount
--bind -o ro
"${BASEDIR}/src" "${BUILD_DIR}/usr/src/src"
463 # Mount the log directory
464 mount
--bind "${LOG_DIR}" "${BUILD_DIR}/usr/src/log"
467 mount
--bind "${CCACHE_DIR}" "${BUILD_DIR}/usr/src/ccache"
469 # Mount the images directory
470 mount
--bind "${IMAGES_DIR}" "${BUILD_DIR}/usr/src/images"
472 # Bind-mount files requires for networking if requested
473 if [ "${network}" = "true" ]; then
476 for file in /etc
/resolv.conf
/etc
/hosts
; do
477 # Skip if the source files does not exist
478 if [ ! -e "${file}" ]; then
482 # Create the destination if it does not exist
483 if [ ! -e "${BUILD_DIR}/${file}" ]; then
484 touch "${BUILD_DIR}/${file}"
487 # Mount the file read-only
488 mount
--bind -o ro
"${file}" "${BUILD_DIR}/${file}"
492 # Configure the ccache
493 export CCACHE_TEMPDIR
="/tmp"
494 export CCACHE_COMPILERCHECK
="string:toolchain-${TOOLCHAINVER} ${BUILD_ARCH}"
496 # Install the QEMU helper
499 # Remove pre-install list of installed files in case user erase some files before rebuild
500 rm -f "${BUILD_DIR}/usr/src/lsalr"
502 # Prepare string for /etc/system-release.
503 local system_release
="${NAME} ${VERSION} (${BUILD_ARCH})"
505 case "${GIT_BRANCH}" in
507 system_release
="${system_release} - ${GIT_BRANCH}"
510 system_release
="${system_release} - core${CORE} Development Build: ${GIT_BRANCH}/${GIT_LASTCOMMIT:0:8}"
514 # Append -dirty tag for local changes
515 if [ "$(git status -s | wc -l)" != "0" ]; then
516 system_release
="${system_release}-dirty"
520 SYSTEM_RELEASE
="${system_release}"
522 # Decide on PAKFIRE_TREE
523 case "${GIT_BRANCH}" in
525 PAKFIRE_TREE
="stable"
528 PAKFIRE_TREE
="testing"
531 PAKFIRE_TREE
="unstable"
535 # Setup ccache cache size
536 execute
--chroot ccache
--max-size="${CCACHE_CACHE_SIZE}"
540 echo "Entering to a shell inside the build environment, go out with exit"
542 local PS1
="ipfire build chroot (${BUILD_ARCH}) \u:\w\$ "
544 # Run an interactive shell
545 execute
--chroot --interactive --network bash
-i
548 lfsmakecommoncheck
() {
550 if [ ! -f $BASEDIR/lfs
/$1 ]; then
551 exiterror
"No such file or directory: $BASEDIR/$1"
554 # Print package name and version
557 # Check if this package is supported by our architecture.
558 # If no SUP_ARCH is found, we assume the package can be built for all.
559 if grep "^SUP_ARCH" ${BASEDIR}/lfs
/${1} >/dev
/null
; then
560 # Check if package supports ${BUILD_ARCH} or all architectures.
561 if ! grep -E "^SUP_ARCH.*${BUILD_ARCH}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
568 echo -ne "`date -u '+%b %e %T'`: Building $
* " >> $LOGFILE
576 local interactive="false
"
578 local network="false
"
580 # Collect environment variables
582 [PATH]="${TOOLS_DIR}/ccache/bin:${TOOLS_DIR}/sbin:${TOOLS_DIR}/bin:${PATH}"
590 [VERSION]="${VERSION}"
593 [SYSTEM_RELEASE]="${SYSTEM_RELEASE}"
594 [PAKFIRE_TREE]="${PAKFIRE_TREE}"
595 [CONFIG_ROOT]="${CONFIG_ROOT}"
599 [KVER_SUFFIX]="${KVER_SUFFIX}"
602 [CFLAGS]="${CFLAGS[@]}"
603 [CXXFLAGS]="${CFLAGS[@]}"
604 [RUSTFLAGS]="${RUSTFLAGS[@]}"
607 [CCACHE_DIR]="${CCACHE_DIR}"
608 [CCACHE_TEMPDIR]="${CCACHE_TEMPDIR}"
609 [CCACHE_COMPILERCHECK]="${CCACHE_COMPILERCHECK}"
612 [SYSTEM_PROCESSORS]="${SYSTEM_PROCESSORS}"
613 [SYSTEM_MEMORY]="${SYSTEM_MEMORY}"
616 [DEFAULT_PARALLELISM]="${DEFAULT_PARALLELISM}"
618 # Compression Options
619 [XZ_OPT]="${XZ_OPT[*]}"
620 [ZSTD_OPT]="${ZSTD_OPT[*]}"
623 [BUILD_ARCH]="${BUILD_ARCH}"
624 [BUILD_PLATFORM]="${BUILD_PLATFORM}"
627 [CROSSTARGET]="${CROSSTARGET}"
628 [BUILDTARGET]="${BUILDTARGET}"
631 [LFS_BASEDIR]="${BASEDIR}"
632 [BUILD_DIR]="${BUILD_DIR}"
633 [IMAGES_DIR]="${IMAGES_DIR}"
634 [LOG_DIR]="${LOG_DIR}"
635 [PACKAGES_DIR]="${PACKAGES_DIR}"
636 [TOOLS_DIR]="${TOOLS_DIR}"
641 # Configure a new namespace
642 if [ -n "${IN_NAMESPACE}" ]; then
644 # Create a new cgroup namespace
647 # Create a new mount namespace
649 "--propagation=slave
"
651 # Create a new PID namespace and fork
655 # Create a new UTS namespace
658 # Mount /proc so that the build environment does not see
659 # any foreign processes.
660 "--mount-proc=${BUILD_DIR}/proc
"
662 # If unshare is asked to terminate, terminate all child processes
666 # Optionally set up a new time namespace
667 if [ "${HAS_TIME_NAMESPACE}" = "true
" ]; then
668 unshare+=( "--time" )
672 while [ $# -gt 0 ]; do
677 # Update some variables
679 [PATH]="${TOOLS_DIR}/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/sbin:${TOOLS_DIR}/bin
"
683 [LFS_BASEDIR]="/usr
/src
"
685 [IMAGES_DIR]="/usr
/src
/images
"
686 [LOG_DIR]="/usr
/src
/log
"
687 [PACKAGES_DIR]="/usr
/src
/images
/packages
"
690 [CCACHE_DIR]="/usr
/src
/ccache
"
693 [GOCACHE]="/usr
/src
/ccache
/go
"
697 if [ -e "${BUILD_DIR}${TOOLS_DIR}/lib
/libpakfire_preload.so
" ]; then
699 [LD_PRELOAD]="${TOOLS_DIR}/lib
/libpakfire_preload.so
"
701 # Fake kernel version, because some of the packages do not
702 # compile with kernel 3.0 and later
703 [UTS_RELEASE]="${KVER}"
706 [UTS_MACHINE]="${BUILD_ARCH}"
714 # Use the actual value of $TERM
723 # Export the proxy configuration
725 [https_proxy]="${https_proxy}"
726 [http_proxy]="${http_proxy}"
731 timer="${1#--timer=}"
735 echo "Unknown argument
: ${1}" >&2
739 # Parse any custom environment variables
741 environ["${1%=*}"]="${1#*=}"
744 # The rest is the command
753 # Prepend any custom changes to PATH
754 if [ -n "${CUSTOM_PATH}" ]; then
755 environ[PATH]="${CUSTOM_PATH}:${environ[PATH]}"
759 if qemu_is_required; then
761 [QEMU_TARGET_HELPER]="${QEMU_TARGET_HELPER}"
767 case "${BUILD_ARCH}" in
770 [QEMU_CPU]="${QEMU_CPU:-cortex-a9}"
776 [QEMU_CPU]="${QEMU_CPU:-sifive-u54}"
778 # Bug fix for QEMU locking up
779 [G_SLICE]="always-malloc
"
786 if [ "${network}" = "false
" ]; then
793 # Create new namespaces
794 if [ "${#unshare[@]}" -gt 0 ]; then
796 "unshare
" "${unshare[@]}"
800 # Call a setup script in the new namespaces to perform
801 # further set up, but before we change root.
802 execute+=( "${BASEDIR}/tools
/execute.sh
" )
805 if [ "${chroot}" = "true
" ]; then
806 execute+=( "chroot
" "${BUILD_DIR}" )
809 # Set PATH so that we can find the env binary
810 local PATH="${environ[PATH]}:${PATH}"
812 # Reset the environment
816 # Clear the previous environment
817 "--ignore-environment"
819 # Change to the home directory
820 --chdir="${environ[HOME]}"
823 # Export the environment
824 for env in ${!environ[@]}; do
825 execute+=( "${env}=${environ[${env}]}" )
829 execute+=( "${command[@]}" )
836 # Store the start time
839 # Run the command in the background and pipe all output to the logfile
840 case "${interactive}" in
842 "${execute[@]}" || return $?
846 # Launch the timer if needed
847 if [ -n "${timer}" ]; then
851 # Dispatch the command to the background
853 "${execute[@]}" >> "${LOGFILE}" 2>&1 </dev/null
859 # Wait for the process to complete
863 # Store the return code
867 # Code means that we have received SIGUSR1 from the timer
869 # Call the timer callback
870 if [ -n "${timer}" ]; then
887 # Call the timer callback at least once
888 if [ -n "${timer}" ]; then
896 # Calls the makefile of a package
901 local basedir="${BASEDIR}"
903 while [ $# -gt 0 ]; do
925 # Execute the make command in the environment
926 execute "${args[@]}" make --directory="${basedir}/lfs" --file="${pkg}" "$@
"
933 # Run the common check
934 lfsmakecommoncheck "${pkg}" "$@
"
935 [ $? == 1 ] && return 0
937 # Download source outside of the toolchain
938 if ! make_pkg --network "${pkg}" download "$@
"; then
939 exiterror "Downloading
${pkg}"
942 if ! make_pkg --timer="update_runtime
" "${pkg}" TOOLCHAIN=1 ROOT="${BUILD_DIR}" b2 install "$@
"; then
945 exiterror "Building
${pkg}"
955 # Run the common check
956 lfsmakecommoncheck "${pkg}" "$@
"
957 [ $? == 1 ] && return 0
959 # Download source outside of the toolchain
960 if ! make_pkg --network "${pkg}" download "$@
"; then
961 exiterror "Downloading
${pkg}"
964 # Run install on the package
965 if ! make_pkg --chroot --timer="update_runtime
" "${pkg}" b2 install "$@
"; then
968 exiterror "Building
${pkg}"
978 # Run the common check
979 lfsmakecommoncheck "${pkg}" "$@
"
980 [ $? == 1 ] && return 0
982 # Run dist on the package
983 if ! make_pkg --chroot --timer="update_runtime
" "${pkg}" dist "$@
"; then
986 exiterror "Packaging
${pkg}"
993 print_runtime "$
(( SECONDS
- t
))"
997 local build_arch="${1}"
999 if [ -z "${build_arch}" ]; then
1000 build_arch="${BUILD_ARCH}"
1003 case "${HOST_ARCH},${build_arch}" in
1004 x86_64,arm*|x86_64,aarch64|x86_64,riscv64|i?86,arm*|i?86,aarch64|i?86,x86_64)
1013 qemu_install_helper() {
1014 # Do nothing, if qemu is not required
1015 if ! qemu_is_required; then
1019 if [ ! -e /proc/sys/fs/binfmt_misc/status ]; then
1020 exiterror "binfmt_misc not mounted. QEMU_TARGET_HELPER not useable.
"
1023 if [ ! $(cat /proc/sys/fs/binfmt_misc/status) = 'enabled' ]; then
1024 exiterror "binfmt_misc not enabled. QEMU_TARGET_HELPER not useable.
"
1027 # Search for the helper binary
1028 local qemu_build_helper="$
(qemu_find_build_helper_name
"${BUILD_ARCH}")"
1030 # Try to find a suitable binary that we can install
1031 # to the build environment.
1033 for file in "${qemu_build_helper}" "${qemu_build_helper}-static"; do
1034 # file must exist and be executable.
1035 [ -x "${file}" ] || continue
1038 file_is_static "${file}" || continue
1040 local dirname="${BUILD_DIR}$
(dirname "${file}")"
1041 mkdir -p "${dirname}"
1043 # Create the mountpoint
1044 touch "${BUILD_DIR}${file}"
1047 if ! mount --bind -o ro "${file}" "${BUILD_DIR}${file}"; then
1048 exiterror "Could not mount
${file}"
1052 QEMU_TARGET_HELPER="${file}"
1057 exiterror "Could not
find a statically-linked QEMU emulator
: ${qemu_build_helper}"
1060 qemu_find_build_helper_name() {
1061 local build_arch="${1}"
1064 case "${build_arch}" in
1066 magic="7f454c460201010000000000000000000200b700
"
1069 magic="7f454c4601010100000000000000000002002800
"
1072 magic="7f454c460201010000000000000000000200f300
"
1075 magic="7f454c4602010100000000000000000002003e00
"
1079 [ -z "${magic}" ] && return 1
1082 for file in /proc/sys/fs/binfmt_misc/*; do
1083 # skip write only register entry
1084 [ $(basename "${file}") = "register
" ] && continue
1085 # Search for the file with the correct magic value.
1086 grep -qE "^magic
${magic}$
" "${file}" || continue
1088 local interpreter="$
(grep "^interpreter" "${file}" |
awk '{ print $2 }')"
1090 [ -n "${interpreter}" ] || continue
1091 [ "${interpreter:0:1}" = "/" ] || continue
1092 [ -x "${interpreter}" ] || continue
1094 echo "${interpreter}"
1104 file -L "${file}" 2>/dev/null | grep -q -e "statically linked
" -e "static-pie linked
"
1107 update_language_list() {
1111 for lang in ${path}/*.po; do
1112 lang="$
(basename "${lang}")"
1114 done | sort -u > "${path}/LINGUAS
"
1120 git shortlog --summary --numbered | while read -r commits name; do
1122 done | grep -vE -e "^
(alpha197|morlix|root|ummeegge
)$
" -e "via Development$
" -e "@
" -e "#$"
1125 update_contributors
() {
1126 echo -n "Updating list of contributors"
1128 local contributors
="$(contributors | paste -sd , - | sed -e "s
/,/&\\\\n
/g
")"
1130 # Edit contributors into credits.cgi
1131 local tmp
="$(mktemp)"
1133 awk "/<!-- CONTRIBUTORS -->/{ p=1; print; printf \"${contributors}\n\"}/<!-- END -->/{ p=0 } !p" \
1134 < "${BASEDIR}/html/cgi-bin/credits.cgi" > "${tmp}"
1136 # Copy back modified content
1137 cat "${tmp}" > "${BASEDIR}/html/cgi-bin/credits.cgi"
1145 download_sources
() {
1149 local failed_packages
=()
1151 # Walk through all files in LFS
1152 for file in "${BASEDIR}/lfs/"*; do
1155 # Skip some packages
1162 # Run the common check
1163 lfsmakecommoncheck
"${pkg}"
1164 [ $?
== 1 ] && continue
1166 # Download and check the package
1167 if ! make_pkg
--network "${pkg}" download b2
; then
1168 failed_packages
+=( "${pkg}" )
1176 # Fail if we could not download/verify all packages
1177 if [ "${#failed_packages[@]}" -gt 0 ]; then
1178 exiterror
"Failed to download or verify some packages: ${failed_packages[@]}"
1182 # Download the toolchain
1183 download_toolchain
() {
1184 local toolchain
="${1}"
1186 # Do nothing if the toolchain has already been downloaded
1187 if [ -e "${TOOLCHAIN_DIR}/${toolchain}" ]; then
1191 # Ensure the directory exists
1192 mkdir
-p "${TOOLCHAIN_DIR}"
1194 # Create a temporary directory
1195 local tmp
="$(mktemp -d)"
1197 # Make the name for the checksum file
1198 local checksums
="${toolchain/.tar.zst/.b2}"
1200 # Download the toolchain and checksum files
1201 if ! wget
--quiet --directory-prefix="${tmp}" \
1202 "${TOOLCHAIN_URL}/${toolchain}" \
1203 "${TOOLCHAIN_URL}/${checksums}"; then
1211 if ! cd "${tmp}" && b2sum
--quiet --check "${checksums}"; then
1218 # Everything is good, move the files to their destination
1220 "${tmp}/${toolchain}" \
1221 "${tmp}/${checksums}" \
1222 "${TOOLCHAIN_DIR}"; then
1235 # Extracts the toolchain
1236 extract_toolchain
() {
1237 local toolchain
="${1}"
1239 local build_dir
="${BUILD_DIR#${BASEDIR}/}"
1240 local log_dir
="${LOG_DIR#${BASEDIR}/}"
1246 # The file to extract
1247 "-f" "${TOOLCHAIN_DIR}/${toolchain}"
1252 # Transform any older toolchains
1253 "--transform" "s@^build/@${build_dir}/@"
1254 "--transform" "s@^log/@${log_dir}/@"
1257 # Extract the toolchain
1258 tar "${args[@]}" ||
return $?
1261 # Compresses the toolchain
1262 compress_toolchain
() {
1263 local toolchain
="${1}"
1265 log
"Creating toolchain image for ${BUILD_ARCH}"
1267 # Create a temporary directory
1268 local tmp
="$(mktemp -d)"
1270 # Make the name for the checksum file
1271 local checksums
="${toolchain/.tar.zst/.b2}"
1273 local build_dir
="${BUILD_DIR#${BASEDIR}/}"
1274 local log_dir
="${LOG_DIR#${BASEDIR}/}"
1279 # Filter through zstd with custom options
1280 "-I" "zstd ${ZSTD_OPT[*]}"
1282 # Write to the temporary directory
1283 "-f" "${tmp}/${toolchain}"
1285 # Start in the base directory
1288 # Exclude the build logs
1289 "--exclude" "${log_dir}/_build.*.log"
1292 "${build_dir}/bin/sh"
1294 # Include the /tools_${BUILD_ARCH} directory
1295 "${build_dir}/${TOOLS_DIR}"
1297 # Include the log directory
1301 # Create the archive
1302 if ! tar "${args[@]}"; then
1309 # Change to the temporary directory
1310 pushd "${tmp}" &>/dev
/null
1312 # Create the checksums
1313 if ! b2sum
"${toolchain}" > "${tmp}/${checksums}"; then
1324 # Everything is good, move the files to their destination
1326 "${tmp}/${toolchain}" \
1327 "${tmp}/${checksums}" \
1328 "${TOOLCHAIN_DIR}"; then
1339 local gcc
=$
(type -p gcc
)
1340 if [ -z "${gcc}" ]; then
1341 exiterror
"Could not find GCC. You will need a working build enviroment in order to build the toolchain."
1344 # Check ${TOOLS_DIR} symlink
1345 if [ -h "${TOOLS_DIR}" ]; then
1346 rm -f "${TOOLS_DIR}"
1349 if [ ! -e "${TOOLS_DIR}" ]; then
1350 ln -s "${BUILD_DIR}${TOOLS_DIR}" "${TOOLS_DIR}"
1353 if [ ! -h "${TOOLS_DIR}" ]; then
1354 exiterror
"Could not create ${TOOLS_DIR} symbolic link"
1357 local LOGFILE
="${LOG_DIR}/_build.toolchain.log"
1360 lfsmake1 binutils PASS
=1
1362 lfsmake1 linux HEADERS
=1
1367 lfsmake1 binutils PASS
=2
1397 lfsmake1 fake-environ
1398 CUSTOM_PATH
="${PATH}" lfsmake1 strip
1399 lfsmake1 cleanup-toolchain
1403 local LOGFILE
="${LOG_DIR}/_build.${SNAME}.log"
1406 lfsmake2 linux HEADERS
=1
1410 lfsmake2 cleanup-toolchain
1412 [ "${BUILD_ARCH}" = "riscv64" ] && lfsmake2 gcc PASS
=A
1415 lfsmake2 autoconf-archive
1461 lfsmake2 libpipeline
1476 lfsmake2 initscripts
1487 lfsmake2 python3-setuptools
1503 lfsmake2 libnfnetlink
1504 lfsmake2 libnetfilter_queue
1505 lfsmake2 libnetfilter_conntrack
1506 lfsmake2 libnetfilter_cthelper
1507 lfsmake2 libnetfilter_cttimeout
1518 lfsmake2 python3-MarkupSafe
1519 lfsmake2 python3-Jinja2
1526 lfsmake2 multipath-tools
1529 lfsmake2 libgpg-error
1548 lfsmake2 rust-dissimilar
1549 lfsmake2 rust-cfg-if
1551 lfsmake2 rust-getrandom
1552 lfsmake2 rust-typenum
1553 lfsmake2 rust-version-check
1554 lfsmake2 rust-generic-array
1555 lfsmake2 rust-crypto-common
1556 lfsmake2 rust-cipher
1558 lfsmake2 rust-unicode-xid
1559 lfsmake2 rust-unicode-ident
1560 lfsmake2 rust-proc-macro2
1562 lfsmake2 rust-syn-1.0
.109
1565 lfsmake2 rust-lazy-static
1566 lfsmake2 rust-memchr
1567 lfsmake2 rust-aho-corasick
1568 lfsmake2 rust-regex-syntax
1570 lfsmake2 rust-ucd-trie
1572 lfsmake2 rust-semver-parser
1573 lfsmake2 rust-semver
1574 lfsmake2 rust-same-file
1575 lfsmake2 rust-walkdir
1577 lfsmake2 rust-toolchain_find
1578 lfsmake2 rust-serde_derive
1582 lfsmake2 rust-serde_json
1583 lfsmake2 rust-synstructure
1584 lfsmake2 rust-block-buffer
1585 lfsmake2 rust-digest
1586 lfsmake2 rust-ppv-lite86
1587 lfsmake2 rust-rand_core
1588 lfsmake2 rust-rand_core-0.4
.2
1589 lfsmake2 rust-rand_core-0.3
.1
1590 lfsmake2 rust-rand_chacha
1591 lfsmake2 rust-rand_hc
1593 lfsmake2 rust-rdrand
1594 lfsmake2 rust-rand-0.4
1596 lfsmake2 rust-num_cpus
1597 lfsmake2 rust-crossbeam-utils
1598 lfsmake2 rust-autocfg
1599 lfsmake2 rust-memoffset
1600 lfsmake2 rust-scopeguard
1601 lfsmake2 rust-crossbeam-epoch
1602 lfsmake2 rust-crossbeam-deque
1603 lfsmake2 rust-either
1604 lfsmake2 rust-crossbeam-channel
1605 lfsmake2 rust-rayon-core
1607 lfsmake2 rust-remove_dir_all
1608 lfsmake2 rust-tempdir
1610 lfsmake2 rust-once_cell
1611 lfsmake2 rust-termcolor
1612 lfsmake2 rust-serde_spanned
1613 lfsmake2 rust-toml_datetime
1614 lfsmake2 rust-equivalent
1615 lfsmake2 rust-allocator-api2
1616 lfsmake2 rust-foldhash
1617 lfsmake2 rust-hashbrown
1618 lfsmake2 rust-indexmap
1619 lfsmake2 rust-winnow
1620 lfsmake2 rust-toml_edit
1622 lfsmake2 rust-target-triple
1623 lfsmake2 rust-trybuild
1624 lfsmake2 rust-unindent
1625 lfsmake2 rust-proc-macro-hack
1626 lfsmake2 rust-indoc-impl
1627 lfsmake2 rust-indoc-impl-0.3
.6
1629 lfsmake2 rust-indoc-0.3
.6
1630 lfsmake2 rust-instant
1631 lfsmake2 rust-lock_api
1632 lfsmake2 rust-smallvec
1633 lfsmake2 rust-parking_lot_core
1634 lfsmake2 rust-parking_lot
1635 lfsmake2 rust-paste-impl
1637 lfsmake2 rust-paste-0.1
.18
1640 lfsmake2 rust-inventory-impl
1641 lfsmake2 rust-inventory
1642 lfsmake2 rust-pyo3-build-config
1643 lfsmake2 rust-pyo3-macros-backend
1644 lfsmake2 rust-pyo3-macros
1646 lfsmake2 rust-num-traits
1647 lfsmake2 rust-num-integer
1648 lfsmake2 rust-num_threads
1650 lfsmake2 rust-iana-time-zone
1651 lfsmake2 rust-chrono
1652 lfsmake2 rust-asn1_derive
1654 lfsmake2 rust-proc-macro-error-attr
1655 lfsmake2 rust-proc-macro-error
1656 lfsmake2 rust-Inflector
1657 lfsmake2 rust-ouroboros_macro
1658 lfsmake2 rust-aliasable
1659 lfsmake2 rust-stable_deref_trait
1660 lfsmake2 rust-ouroboros
1661 lfsmake2 rust-base64
1670 lfsmake2 ca-certificates
1687 lfsmake2 perl-BerkeleyDB
1691 lfsmake2 web-user-interface
1702 lfsmake2 reiserfsprogs
1709 lfsmake2 wireguard-tools
1710 lfsmake2 perl-ExtUtils-PkgConfig
1712 lfsmake2 perl-GD-Graph
1713 lfsmake2 perl-GD-TextUtil
1714 lfsmake2 perl-Device-SerialPort
1715 lfsmake2 perl-Device-Modem
1716 lfsmake2 perl-Parse-Yapp
1717 lfsmake2 perl-Data-UUID
1718 lfsmake2 perl-Try-Tiny
1719 lfsmake2 perl-HTTP-Message
1720 lfsmake2 perl-HTTP-Date
1725 lfsmake2 conntrack-tools
1727 lfsmake2 l7-protocols
1735 lfsmake2 perl-Switch
1736 lfsmake2 perl-HTML-Tagset
1737 lfsmake2 perl-HTML-Parser
1738 lfsmake2 perl-HTML-Template
1739 lfsmake2 perl-libwww
1740 lfsmake2 perl-LWP-Protocol-https
1741 lfsmake2 perl-Net-HTTP
1742 lfsmake2 perl-Net-DNS
1743 lfsmake2 perl-Net-IPv4Addr
1744 lfsmake2 perl-Net_SSLeay
1745 lfsmake2 perl-IO-Stringy
1746 lfsmake2 perl-IO-Socket-SSL
1747 lfsmake2 perl-Unix-Syslog
1748 lfsmake2 perl-Mail-Tools
1749 lfsmake2 perl-MIME-Tools
1750 lfsmake2 perl-Net-Server
1751 lfsmake2 perl-Canary-Stability
1752 lfsmake2 perl-Convert-TNEF
1753 lfsmake2 perl-Convert-UUlib
1754 lfsmake2 perl-Archive-Zip
1755 lfsmake2 perl-Text-Tabs
+Wrap
1756 lfsmake2 perl-XML-Parser
1757 lfsmake2 perl-Crypt-PasswdMD5
1758 lfsmake2 perl-Net-Telnet
1759 lfsmake2 perl-Capture-Tiny
1760 lfsmake2 perl-Config-AutoConf
1761 lfsmake2 perl-File-LibMagic
1762 lfsmake2 perl-Object-Tiny
1763 lfsmake2 perl-Archive-Peek-Libarchive
1764 lfsmake2 python3-inotify
1765 lfsmake2 python3-docutils
1766 lfsmake2 python3-daemon
1770 lfsmake2 dejavu-fonts-ttf
1771 lfsmake2 ubuntu-font-family
1787 lfsmake2 ids-ruleset-sources
1788 lfsmake2 ipblocklist-sources
1807 lfsmake2 rpcsvc-proto
1815 lfsmake2 bridge-utils
1816 lfsmake2 smartmontools
1822 lfsmake2 perl-NetAddr-IP
1849 lfsmake2 libstatgrab
1855 lfsmake2 linux-firmware
1856 lfsmake2 dvb-firmwares
1857 lfsmake2 zd1211-firmware
1858 lfsmake2 rpi-firmware
1859 lfsmake2 intel-microcode
1860 lfsmake2 pcengines-apu-firmware
1864 lfsmake2 python3-toml
1865 lfsmake2 python3-pyproject2setuppy
1866 lfsmake2 python3-pyparsing
1867 lfsmake2 spice-protocol
1870 lfsmake2 libusbredir
1874 lfsmake2 python3-tomli
1876 lfsmake2 nagios_nrpe
1877 lfsmake2 nagios-plugins
1878 lfsmake2 observium-agent
1884 lfsmake2 vdr_streamdev
1885 lfsmake2 vdr_epgsearch
1891 lfsmake2 libmpdclient
1893 lfsmake2 perl-Net-CIDR-Lite
1894 lfsmake2 perl-Net-SMTP-SSL
1895 lfsmake2 perl-Authen-SASL
1896 lfsmake2 perl-MIME-Lite
1897 lfsmake2 perl-Email-Date-Format
1900 lfsmake2 wpa_supplicant
1904 lfsmake2 cpufrequtils
1914 lfsmake2 perl-gettext
1915 lfsmake2 perl-Sort-Naturally
1918 lfsmake2 perl-DBD-SQLite
1919 lfsmake2 perl-File-ReadBackwards
1920 lfsmake2 openvmtools
1924 lfsmake2 usb_modeswitch
1925 lfsmake2 usb_modeswitch_data
1931 lfsmake2 python3-pyelftools
1933 lfsmake2 wireless-regdb
1935 lfsmake2 python3-pycparser
1936 lfsmake2 python3-charset-normalizer
1937 lfsmake2 python3-certifi
1938 lfsmake2 python3-idna
1939 lfsmake2 python3-requests
1940 lfsmake2 python3-pep517
1941 lfsmake2 python3-build
1942 lfsmake2 python3-install
1943 lfsmake2 python3-urllib3
1944 lfsmake2 python3-flit
1945 lfsmake2 python3-packaging
1946 lfsmake2 python3-typing-extensions
1947 lfsmake2 python3-semantic-version
1948 lfsmake2 python3-setuptools-scm
1949 lfsmake2 python3-setuptools-rust
1950 lfsmake2 python3-six
1951 lfsmake2 python3-dateutil
1952 lfsmake2 python3-jmespath
1953 lfsmake2 python3-colorama
1954 lfsmake2 python3-yaml
1955 lfsmake2 python3-s3transfer
1956 lfsmake2 python3-rsa
1957 lfsmake2 python3-pyasn1
1958 lfsmake2 python3-botocore
1959 lfsmake2 python3-cffi
1960 lfsmake2 python3-cryptography
1961 lfsmake2 python3-circuitbreaker
1962 lfsmake2 python3-pytz
1963 lfsmake2 python3-click
1964 lfsmake2 python3-arrow
1965 lfsmake2 python3-terminaltables
1966 lfsmake2 python3-pkgconfig
1967 lfsmake2 python3-msgpack
1968 lfsmake2 python3-editables
1969 lfsmake2 python3-pathspec
1970 lfsmake2 python3-pluggy
1971 lfsmake2 python3-calver
1972 lfsmake2 python3-trove-classifiers
1973 lfsmake2 python3-hatchling
1974 lfsmake2 python3-hatch-vcs
1975 lfsmake2 python3-hatch-fancy-pypi-readme
1976 lfsmake2 python3-attrs
1977 lfsmake2 python3-sniffio
1978 lfsmake2 python3-sortedcontainers
1979 lfsmake2 python3-outcome
1980 lfsmake2 python3-async_generator
1981 lfsmake2 python3-flit_scm
1982 lfsmake2 python3-exceptiongroup
1983 lfsmake2 python3-trio
1984 lfsmake2 python3-pyfuse3
1986 lfsmake2 oci-python-sdk
1988 lfsmake2 transmission
2001 lfsmake2 ipfire-netboot
2004 lfsmake2 perl-Carp-Clan
2005 lfsmake2 perl-Date-Calc
2006 lfsmake2 perl-Date-Manip
2007 lfsmake2 perl-File-Tail
2008 lfsmake2 perl-TimeDate
2016 lfsmake2 perl-Font-TTF
2017 lfsmake2 perl-IO-String
2018 lfsmake2 perl-PDF-API2
2019 lfsmake2 proxy-accounting
2021 lfsmake2 perl-Text-CSV_XS
2034 lfsmake2 libpciaccess
2038 lfsmake2 perl-common-sense
2039 lfsmake2 perl-inotify2
2040 lfsmake2 perl-Net-IP
2043 lfsmake2 mdns-repeater
2045 lfsmake2 nss-myhostname
2049 lfsmake2 shairport-sync
2052 lfsmake2 spectre-meltdown-checker
2053 lfsmake2 zabbix_agentd
2055 lfsmake2 firmware-update
2057 lfsmake2 asciidoctor
2060 lfsmake2 speedtest-cli
2061 lfsmake2 amazon-ssm-agent
2068 lfsmake2 squid-asnbl
2071 lfsmake2 oath-toolkit
2073 lfsmake2 perl-File-Remove
2074 lfsmake2 perl-Module-Build
2075 lfsmake2 perl-Module-ScanDeps
2076 lfsmake2 perl-YAML-Tiny
2077 lfsmake2 perl-Module-Install
2078 lfsmake2 perl-Imager
2079 lfsmake2 perl-Imager-QRCode
2080 lfsmake2 perl-MIME-Base32
2081 lfsmake2 perl-URI-Encode
2085 lfsmake2 btrfs-progs
2086 lfsmake2 inotify-tools
2088 lfsmake2 fort-validator
2092 lfsmake2 linux-initrd
2096 # Build the installer
2101 lfsmake2 flash-images
2102 lfsmake2 core-updates
2106 local LOGFILE
="${LOG_DIR}/_build.packages.log"
2109 print_headline
"Building Packages"
2115 # Collect all packages
2117 "${BASEDIR}/config/rootfiles/packages/"* \
2118 "${BASEDIR}/config/rootfiles/packages/${BUILD_ARCH}"/*; do
2120 if [ -d "${path}" ]; then
2124 pkgs
["${path##*/}"]="${path}"
2128 for pkg
in ${!pkgs[@]}; do
2133 # This function will re-execute a command in a new namespace
2134 exec_in_namespace
() {
2135 # Nothing to do if we are already in a new namespace
2136 if [ -n "${IN_NAMESPACE}" ]; then
2140 # Forward any configuration
2142 "--target=${BUILD_ARCH}"
2148 --propagation=private \
2149 "${0}" "${args[@]}" "$@"
2152 check_for_missing_rootfiles
() {
2153 print_headline
"Checking for missing rootfiles..."
2156 for file in ${LOG_DIR}/*_missing_rootfile
; do
2157 [ -e "${file}" ] ||
continue
2160 file="${file/_missing_rootfile/}";
2162 print_line
"${file} is missing a rootfile"
2169 check_rootfiles_for_arch
() {
2174 "${BASEDIR}/config/rootfiles"
2176 # Exclude old core updates
2177 "--exclude-dir" "oldcore"
2179 # Ignore the update scripts
2180 "--exclude" "update.sh"
2183 # A list of files that are not scanned
2184 # because they probably cause some false positives.
2185 local excluded_files
=(
2198 # Exclude any architecture-specific directories
2200 for a
in ${ARCHES[@]}; do
2201 args
+=( "--exclude-dir" "${a}" )
2204 # Exclude all excluded files
2206 for x
in ${excluded_files[@]}; do
2207 args
+=( "--exclude" "${x}" )
2210 # Search for all files that contain the architecture
2212 $
(grep --files-with-matches -r "^.*${arch}" "${args[@]}")
2216 for file in ${files[@]}; do
2217 print_line
"${file} contains ${arch}"
2221 return "${#files[@]}"
2224 check_rootfiles_for_pattern
() {
2225 local pattern
="${1}"
2226 local message
="${2}"
2230 "${BASEDIR}/config/rootfiles"
2232 # Exclude old core updates
2233 "--exclude-dir" "oldcore"
2235 # Ignore the update scripts
2236 "--exclude" "update.sh"
2239 if grep -r "${pattern}" "${args[@]}"; then
2240 if [ -n "${message}" ]; then
2241 print_line
"${message}"
2244 print_file
"Files matching '${pattern}' have been found in the rootfiles"
2256 print_headline
"Checking for rootfile consistency..."
2259 if ! check_rootfiles_for_pattern
"^[\+\-]" \
2260 "Rootfiles have changed in them"; then
2264 # Check for /etc/init.d
2265 if ! check_rootfiles_for_pattern
"^etc/init\.d/" \
2266 "/etc/init.d/* has been found. Please replace by /etc/rc.d/init.d"; then
2270 # Check for /var/run
2271 if ! check_rootfiles_for_pattern
"^var/run/.*" \
2272 "You cannot ship files in /var/run as it is a ramdisk"; then
2276 # Check architectures
2278 for arch
in ${ARCHES[@]}; do
2279 check_rootfiles_for_arch
"${arch}" || failed
=$?
2286 check_changed_rootfiles
() {
2288 $
(grep --files-with-matches -r "^+" "${LOG_DIR}" --exclude="_*" |
sort)
2291 # If we have no matches, there is nothing to do
2292 [ "${#files[@]}" -eq 0 ] && return 0
2294 print_line
"Packages have created new files"
2298 for file in ${files[@]}; do
2299 print_line
" ${file##*/}"
2307 readonly BASEDIR
="$(find_base)"
2309 # Get some information about the host system
2310 SYSTEM_PROCESSORS
="$(system_processors)"
2311 SYSTEM_MEMORY
="$(system_memory)"
2314 BUILD_ARCH
="${HOST_ARCH}"
2315 CCACHE_CACHE_SIZE
="4G"
2317 # Load configuration file
2318 if [ -f .config
]; then
2322 # Parse any command line options (not commands)
2323 while [ $# -gt 0 ]; do
2326 BUILD_ARCH
="${1#--target=}"
2330 exiterror
"Unknown configuration option: ${1}"
2333 # Found a command, so exit options parsing
2341 # Check the architecture
2342 case "${BUILD_ARCH}" in
2343 aarch64|x86_64|riscv64
)
2347 exiterror
"Unsupported architecture: ${BUILD_ARCH}"
2351 # Set build platform
2352 case "${BUILD_ARCH}" in
2354 BUILD_PLATFORM
="arm"
2358 BUILD_PLATFORM
="riscv"
2362 BUILD_PLATFORM
="x86"
2366 # Configure the C compiler
2371 # Do not compile in any debugging information
2374 # Do not write temporary files
2377 # Enable all warnings
2383 # Compile place-independent code
2387 "-Wp,-U_FORTIFY_SOURCE"
2388 "-Wp,-D_FORTIFY_SOURCE=3"
2390 # Enable additional checks for C++ in glibc
2391 "-Wp,-D_GLIBCXX_ASSERTIONS"
2393 # Enable stack smashing protection
2394 "-fstack-protector-strong"
2396 # Enable stack clash protection
2397 "-fstack-clash-protection"
2400 # Architecture-dependent compiler flags
2401 case "${BUILD_ARCH}" in
2404 "-mbranch-protection=standard"
2410 "-m64" "-mtune=generic" "-fcf-protection=full"
2415 # Configure the Rust compiler
2418 "-Clink-arg=-Wl,-z,relro,-z,now"
2423 # Configure the compiler tuple
2424 CROSSTARGET
="${BUILD_ARCH}-cross-linux-gnu"
2425 BUILDTARGET
="${BUILD_ARCH}-pc-linux-gnu"
2427 # Use this as default PARALLELISM
2428 DEFAULT_PARALLELISM
="${SYSTEM_PROCESSORS}"
2430 # Limit lauched ninja build jobs to computed parallel value
2431 NINJAJOBS
="${DEFAULT_PARALLELISM}"
2438 # Configure Zstandard
2440 "-T0" "-19" "--long"
2444 readonly CACHE_DIR
="${BASEDIR}/cache"
2445 readonly TOOLCHAIN_DIR
="${CACHE_DIR}/toolchains"
2446 readonly CCACHE_DIR
="${BASEDIR}/ccache/${BUILD_ARCH}/${TOOLCHAINVER}"
2447 readonly BUILD_DIR
="${BASEDIR}/build_${BUILD_ARCH}"
2448 readonly IMAGES_DIR
="${BASEDIR}/images_${BUILD_ARCH}"
2449 readonly LOG_DIR
="${BASEDIR}/log_${BUILD_ARCH}"
2450 readonly PACKAGES_DIR
="${IMAGES_DIR}/packages"
2451 readonly TOOLS_DIR
="/tools_${BUILD_ARCH}"
2454 readonly SOURCE_URL
="https://source.ipfire.org/ipfire-2.x"
2455 readonly TOOLCHAIN_URL
="https://source.ipfire.org/toolchains"
2458 LOGFILE
="${LOG_DIR}/_build.preparation.log"
2460 # Ensure that some basic directories exist
2461 mkdir
-p "${CACHE_DIR}" "${LOG_DIR}"
2464 readonly TOOLCHAIN
="${SNAME}-${VERSION}-toolchain-${TOOLCHAINVER}-${BUILD_ARCH}.tar.zst"
2466 # See what we're supposed to do
2469 START_TIME
="${SECONDS}"
2471 # Launch in a new namespace
2472 exec_in_namespace
"$@"
2474 # Prepare the environment
2475 prepareenv
--required-space=8192
2477 # Check if the toolchain is available
2478 if [ ! -e "${BUILD_DIR}${TOOLS_DIR}/.toolchain-successful" ]; then
2479 # If we have the toolchain available, we extract it into the build environment
2480 if [ -r "${TOOLCHAIN_DIR}/${TOOLCHAIN}" ]; then
2481 print_headline
"Packaged toolchain compilation"
2483 # Extract the toolchain
2484 if ! extract_toolchain
"${TOOLCHAIN}"; then
2485 exiterror
"Failed extracting the toolchain"
2488 # Otherwise perform a full toolchain compilation
2490 print_headline
"Full toolchain compilation"
2495 print_headline
"Building ${NAME}"
2498 # Build all packages
2501 # Check for missing rootfiles
2502 check_for_missing_rootfiles
2504 # Check for rootfile consistency
2505 if ! check_rootfiles
; then
2506 exiterror
"Rootfiles are inconsistent"
2509 check_changed_rootfiles
2511 print_build_summary $
(( SECONDS
- START_TIME
))
2515 "${LOG_DIR}/_build.preparation.log" \
2516 "${LOG_DIR}/_build.toolchain.log" \
2517 "${LOG_DIR}/_build.${SNAME}.log" \
2518 "${LOG_DIR}/_build.packages.log" 2>/dev
/null
2521 # Launch in a new namespace
2522 exec_in_namespace
"$@"
2524 # enter a shell inside LFS chroot
2525 # may be used to changed kernel settings
2526 prepareenv
--network
2530 # Check for rootfile consistency
2531 if ! check_rootfiles
; then
2532 exiterror
"Rootfiles are inconsistent"
2535 check_changed_rootfiles
2538 print_line
"Cleaning build directory..."
2540 # Cleanup build files
2546 # Remove the /tools symlink
2547 if [ -h "${TOOLS_DIR}" ]; then
2548 rm -f "${TOOLS_DIR}"
2554 # Tell the user what we are about to do
2555 print_headline
"Pre-loading all source files"
2557 # Download all sources
2561 # Launch in a new namespace
2562 exec_in_namespace
"$@"
2564 # Prepare the environment
2567 print_headline
"Toolchain compilation (${BUILD_ARCH})"
2569 # Build the toolchain
2572 # Ensure the toolchain directory exists
2573 mkdir
-p "${TOOLCHAIN_DIR}"
2575 # Compress the toolchain
2576 if ! compress_toolchain
"${TOOLCHAIN}"; then
2577 exiterror
"Could not compress toolchain"
2582 download_toolchain
"${TOOLCHAIN}"
2585 # Check if IPFIRE_USER is set
2586 if [ -z "${IPFIRE_USER}" ]; then
2587 exiterror
"You have to setup IPFIRE_USER first. See .config for details."
2590 # Sync with upstream
2597 --exclude="toolchains/" \
2599 "${IPFIRE_USER}@people.ipfire.org:/pub/sources/source-2.x"
2604 echo -ne "Checking the translations for missing or obsolete strings..."
2605 chmod 755 $BASEDIR/tools
/{check_strings.pl
,sort_strings.pl
,check_langs.sh
}
2606 $BASEDIR/tools
/sort_strings.pl en
2607 $BASEDIR/tools
/sort_strings.pl de
2608 $BASEDIR/tools
/sort_strings.pl fr
2609 $BASEDIR/tools
/sort_strings.pl es
2610 $BASEDIR/tools
/sort_strings.pl pl
2611 $BASEDIR/tools
/sort_strings.pl ru
2612 $BASEDIR/tools
/sort_strings.pl
nl
2613 $BASEDIR/tools
/sort_strings.pl
tr
2614 $BASEDIR/tools
/sort_strings.pl it
2615 $BASEDIR/tools
/check_strings.pl en
> $BASEDIR/doc
/language_issues.en
2616 $BASEDIR/tools
/check_strings.pl de
> $BASEDIR/doc
/language_issues.de
2617 $BASEDIR/tools
/check_strings.pl fr
> $BASEDIR/doc
/language_issues.fr
2618 $BASEDIR/tools
/check_strings.pl es
> $BASEDIR/doc
/language_issues.es
2619 $BASEDIR/tools
/check_strings.pl pl
> $BASEDIR/doc
/language_issues.pl
2620 $BASEDIR/tools
/check_strings.pl ru
> $BASEDIR/doc
/language_issues.ru
2621 $BASEDIR/tools
/check_strings.pl
nl > $BASEDIR/doc
/language_issues.
nl
2622 $BASEDIR/tools
/check_strings.pl
tr > $BASEDIR/doc
/language_issues.
tr
2623 $BASEDIR/tools
/check_strings.pl it
> $BASEDIR/doc
/language_issues.it
2624 $BASEDIR/tools
/check_langs.sh
> $BASEDIR/doc
/language_missings
2627 echo -ne "Updating language lists..."
2628 update_language_list
${BASEDIR}/src
/installer
/po
2629 update_language_list
${BASEDIR}/src
/setup
/po
2632 update-contributors
)
2637 exec "${BASEDIR}/tools/find-dependencies" "${BUILD_DIR}" "$@"
2640 echo "Checking the manual pages for broken links..."
2642 chmod 755 $BASEDIR/tools
/check_manualpages.pl
2643 if $BASEDIR/tools
/check_manualpages.pl
; then
2650 __timer
"${2}" ||
exit $?
2653 echo "Usage: $0 [OPTIONS] {build|check-manualpages|clean|downloadsrc|find-dependencies|gettoolchain|lang|shell|tail|toolchain|update-contributors|uploadsrc}"
2654 cat doc
/make.sh-usage