From 093336e9146e5e87e42acefe674bb564189db7d0 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Fri, 28 Oct 2022 00:13:12 +0200 Subject: [PATCH] armbian-next: `cli`: `distccd` launcher for build farm - relaunched under docker - possibly much nicer if zeroconf enabled? - this thing is ignoring signals. can't ctrl-c out of it. why? @TODO - pt 1, subpt 3: distccd - distcc-pump - avahi - pt 1, subpt 3: distccd + distcc-pump - pt 1, subpt 2: distccd + avahi - pt 1, subpt 1: distccd --- lib/functions/cli/cli-distccd.sh | 33 ++++++++++++++++++++++++++++++ lib/functions/cli/commands.sh | 1 + lib/functions/host/prepare-host.sh | 3 +++ lib/library-functions.sh | 9 ++++++++ 4 files changed, 46 insertions(+) create mode 100644 lib/functions/cli/cli-distccd.sh diff --git a/lib/functions/cli/cli-distccd.sh b/lib/functions/cli/cli-distccd.sh new file mode 100644 index 0000000000..14460ef13d --- /dev/null +++ b/lib/functions/cli/cli-distccd.sh @@ -0,0 +1,33 @@ +function cli_distccd_pre_run() { + : <<- 'HEADER' + Sets up an inline extension to include distccd in dependencies. + HEADER + display_alert "cli_distccd_pre_run" "func cli_distccd_run :: ${ARMBIAN_COMMAND}" "warn" + + # When being relaunched in Docker, I wanna add port-forwardings to the distccd ports. + declare -g DOCKER_EXTRA_ARGS+=("-p" "3632:3632" "-p" "3633:3633") + + # "gimme root on a Linux machine" + cli_standard_relaunch_docker_or_sudo +} + +function cli_distccd_run() { + : <<- 'HEADER' + Runs distccd in the foreground. + HEADER + + # Initialize the extension manager. distccd has no boards/etc. + initialize_extension_manager + + # Install hostdeps. Call directly the requirements cli command, they know what they're doing. + cli_requirements_run + + display_alert "cli_distccd_run" "func cli_distccd_run" "warn" + + # remove all bash traps + trap - INT TERM EXIT + + # @TODO: --zeroconf (not if under Docker) + # @TODO: --jobs (CPU count!) + display_alert "Run it yourself" "distccd --allow-private --verbose --no-detach --daemon --stats --log-level info --log-stderr --listen 0.0.0.0 --zeroconf" "warn" +} diff --git a/lib/functions/cli/commands.sh b/lib/functions/cli/commands.sh index 6c13a13da5..dec754c2e9 100644 --- a/lib/functions/cli/commands.sh +++ b/lib/functions/cli/commands.sh @@ -18,6 +18,7 @@ function armbian_register_commands() { ["json-info"]="json_info" # implemented in cli_json_info_pre_run and cli_json_info_run ["build"]="standard_build" # implemented in cli_standard_build_pre_run and cli_standard_build_run + ["distccd"]="distccd" # implemented in cli_distccd_pre_run and cli_distccd_run ["undecided"]="undecided" # implemented in cli_undecided_pre_run and cli_undecided_run - relaunches either build or docker ) diff --git a/lib/functions/host/prepare-host.sh b/lib/functions/host/prepare-host.sh index 482c340af2..83ba813844 100644 --- a/lib/functions/host/prepare-host.sh +++ b/lib/functions/host/prepare-host.sh @@ -233,6 +233,9 @@ function early_prepare_host_dependencies() { pkg-config pv python3-dev python3-distutils qemu-user-static rsync swig u-boot-tools udev uuid-dev whiptail zlib1g-dev busybox fdisk + + # distcc, experimental, optional; see cli-distcc.sh and kernel.sh + distcc # python2, including headers, mostly used by some u-boot builds (2017 et al, odroidxu4 and others). python2 python2-dev diff --git a/lib/library-functions.sh b/lib/library-functions.sh index f5a4b4e2ea..4e7c55dd99 100644 --- a/lib/library-functions.sh +++ b/lib/library-functions.sh @@ -46,6 +46,15 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true # shellcheck source=lib/functions/cli/cli-configdump.sh source "${SRC}"/lib/functions/cli/cli-configdump.sh +# no errors tolerated. invoked before each sourced file to make sure. +#set -o pipefail # trace ERR through pipes - will be enabled "soon" +#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled +set -o errtrace # trace ERR through - enabled +set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled +### lib/functions/cli/cli-distccd.sh +# shellcheck source=lib/functions/cli/cli-distccd.sh +source "${SRC}"/lib/functions/cli/cli-distccd.sh + # no errors tolerated. invoked before each sourced file to make sure. #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled