Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/lib/build/build.sh
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2023-05-05 20:21:38 +0200
committerLevente Polyak <anthraxx@archlinux.org>2023-05-20 00:08:13 +0200
commit830dcde2d8353dbcce1e831adb7c7e8f538210a3 (patch)
treeb873975109448eb306b1d0309b3640b55947a644 /src/lib/build/build.sh
parent1da97a8b362addc1cf8b936d918bddfa92192aa6 (diff)
pkgctl build: support worker slots for none tty builds
Allow overriding the worker slot with a dedicated option. Furthermore detect if the current tty is no pts and fall back to choosing a random worker slot between 1 and number of available processing units. Fixes #137 Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'src/lib/build/build.sh')
-rw-r--r--src/lib/build/build.sh23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/build/build.sh b/src/lib/build/build.sh
index 2153200..191fded 100644
--- a/src/lib/build/build.sh
+++ b/src/lib/build/build.sh
@@ -25,6 +25,7 @@ source /usr/share/makepkg/util/config.sh
source /usr/share/makepkg/util/message.sh
set -e
+set -o pipefail
pkgctl_build_usage() {
@@ -47,6 +48,7 @@ pkgctl_build_usage() {
-o, --offload Build on a remote server and transfer artifacts afterwards
-c, --clean Recreate the chroot before building
-I, --install FILE Install a package into the working copy of the chroot
+ -w, --worker SLOT Name of the worker slot, useful for concurrent builds (disables automatic names)
--nocheck Do not run the check() function in the PKGBUILD
PKGBUILD OPTIONS
@@ -123,9 +125,8 @@ pkgctl_build() {
local RELEASE_OPTIONS=()
local MAKEPKG_OPTIONS=()
- local PTS
- PTS="$(tty | sed 's|/dev/pts/||')"
- local WORKER="${USER}-${PTS}"
+ local WORKER=
+ local WORKER_SLOT=
# variables
local path pkgbase pkgrepo source
@@ -224,6 +225,11 @@ pkgctl_build() {
DB_UPDATE=1
shift
;;
+ -w|--worker)
+ (( $# <= 1 )) && die "missing argument for %s" "$1"
+ WORKER_SLOT=$2
+ shift 2
+ ;;
--)
shift
break
@@ -258,6 +264,12 @@ pkgctl_build() {
fi
fi
+ # assign default worker slot
+ if [[ -z ${WORKER_SLOT} ]] && ! WORKER_SLOT="$(tty | sed 's|/dev/pts/||')"; then
+ WORKER_SLOT=$(( RANDOM % $(nproc) + 1 ))
+ fi
+ WORKER="${USER}-${WORKER_SLOT}"
+
# Update pacman cache for auto-detection
if [[ -z ${REPO} ]]; then
update_pacman_repo_cache
@@ -311,8 +323,9 @@ pkgctl_build() {
fi
# print gathered build modes
- msg2 "repo: ${pkgrepo}"
- msg2 "arch: ${BUILD_ARCH[*]}"
+ msg2 " repo: ${pkgrepo}"
+ msg2 " arch: ${BUILD_ARCH[*]}"
+ msg2 "worker: ${WORKER}"
# increment pkgrel on rebuild
if (( REBUILD )); then