made scripts more robust

This commit is contained in:
2026-01-14 12:23:42 +01:00
parent a263b8acab
commit d305fa282e
3 changed files with 23 additions and 7 deletions

View File

@@ -3,10 +3,10 @@ trap "echo 'Stopping...'; exit 0" SIGTERM
# source yocto # source yocto
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/setup-env.sh" source "${SCRIPT_DIR}/setup-env.sh" > /dev/null
# add add source to all zsh instances # add add source to all zsh instances
echo "source \"${YOCTO_ROOT}/scripts/setup-env.sh\"" >> ~/.zshrc echo "source \"${YOCTO_ROOT}/scripts/setup-env.sh\" > /dev/null" >> ~/.zshrc
# trap to keep container open in background # trap to keep container open in background
/bin/zsh /bin/zsh

View File

@@ -1,15 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env zsh
set -e
# ------------------------------------------------------------------- # -------------------------------------------------------------------
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [ -n "$BASH_SOURCE" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
elif [ -n "$ZSH_NAME" ]; then
SCRIPT_DIR="$(cd "$(dirname "${(%):-%N}")" && pwd)"
else
echo "This script must be run with bash or zsh!" >&2
exit 1
fi
source "${SCRIPT_DIR}/setup-paths.sh" source "${SCRIPT_DIR}/setup-paths.sh"
# ------------------------------------------------------------------- # -------------------------------------------------------------------
# Sanity checks # Sanity checks
if [ ! -d "${POKY_DIR}" ]; then if [ ! -d "${POKY_DIR}" ]; then
echo "ERROR: poky not found at ${POKY_DIR}" echo "ERROR: poky not found at ${POKY_DIR}" >&2
return 1 2>/dev/null || exit 1 return 1 2>/dev/null || exit 1
fi fi

View File

@@ -1,7 +1,16 @@
#!/bin/bash #!/bin/bash
if [ -n "$BASH_SOURCE" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
elif [ -n "$ZSH_NAME" ]; then
SCRIPT_DIR="$(cd "$(dirname "${(%):-%N}")" && pwd)"
else
echo "This script must be run with bash or zsh!" >&2
exit 1
fi
# ---- Configuration ------------------------------------------------- # ---- Configuration -------------------------------------------------
YOCTO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" YOCTO_ROOT="$(cd $SCRIPT_DIR/.. && pwd)"
BUILD_DIR="${1:-build}" BUILD_DIR="${1:-build}"
CACHE_BASE="${YOCTO_ROOT}/.cache/yocto" CACHE_BASE="${YOCTO_ROOT}/.cache/yocto"