diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index a2e81f6..ac47079 100755 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -3,10 +3,10 @@ trap "echo 'Stopping...'; exit 0" SIGTERM # source yocto 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 -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 /bin/zsh diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh index 4f15669..44e9981 100755 --- a/scripts/setup-env.sh +++ b/scripts/setup-env.sh @@ -1,15 +1,22 @@ -#!/usr/bin/env bash -set -e +#!/usr/bin/env zsh + # ------------------------------------------------------------------- -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" # ------------------------------------------------------------------- # Sanity checks 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 fi diff --git a/scripts/setup-paths.sh b/scripts/setup-paths.sh index 6ed3fb6..89a29ba 100755 --- a/scripts/setup-paths.sh +++ b/scripts/setup-paths.sh @@ -1,7 +1,16 @@ #!/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 ------------------------------------------------- -YOCTO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +YOCTO_ROOT="$(cd $SCRIPT_DIR/.. && pwd)" BUILD_DIR="${1:-build}" CACHE_BASE="${YOCTO_ROOT}/.cache/yocto"