From 7c54fcf60ae9e555482113a3dcece885e1fa1590 Mon Sep 17 00:00:00 2001 From: Max Andreev Date: Tue, 23 Aug 2022 20:57:59 +0300 Subject: [PATCH] fix fbtenv.sh under zsh (#1645) * fix fbtenv under ZSH, some improovements, add amap workflow timeout * fix copy .map file in build.yml --- .github/workflows/amap_analyse.yml | 1 + .github/workflows/build.yml | 2 +- scripts/toolchain/fbtenv.sh | 58 +++++++++++++++++++++++++----- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/.github/workflows/amap_analyse.yml b/.github/workflows/amap_analyse.yml index dd903e2e..3443771d 100644 --- a/.github/workflows/amap_analyse.yml +++ b/.github/workflows/amap_analyse.yml @@ -15,6 +15,7 @@ env: jobs: amap_analyse: runs-on: [self-hosted,FlipperZeroMacShell] + timeout-minutes: 15 steps: - name: 'Wait Build workflow' uses: fountainhead/action-wait-for-check@v1.0.0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b677a293..7eeb5c22 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,7 +110,7 @@ jobs: - name: 'Copy .map file' run: | - cp build/f7-firmware-D/firmware.elf.map artifacts/flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf.map + cp build/f7-firmware-*/firmware.elf.map artifacts/flipper-z-f7-firmware-${{steps.names.outputs.suffix}}.elf.map - name: 'Upload artifacts to update server' if: ${{ !github.event.pull_request.head.repo.fork }} diff --git a/scripts/toolchain/fbtenv.sh b/scripts/toolchain/fbtenv.sh index b06c582a..6f3e8c66 100755 --- a/scripts/toolchain/fbtenv.sh +++ b/scripts/toolchain/fbtenv.sh @@ -8,20 +8,61 @@ SCRIPT_PATH="${SCRIPT_PATH:-$DEFAULT_SCRIPT_PATH}"; FBT_TOOLCHAIN_VERSION="${FBT_TOOLCHAIN_VERSION:-"8"}"; FBT_TOOLCHAIN_PATH="${FBT_TOOLCHAIN_PATH:-$SCRIPT_PATH}"; +fbtenv_show_usage() +{ + echo "Running this script manually is wrong, please source it"; + echo "Example:"; + printf "\tsource scripts/toolchain/fbtenv.sh\n"; +} + +fbtenv_curl() +{ + curl --progress-bar -SLo "$1" "$2"; +} + +fbtenv_wget() +{ + wget --show-progress --progress=bar:force -qO "$1" "$2"; +} + fbtenv_check_sourced() { case "${ZSH_EVAL_CONTEXT:-""}" in *:file:*) return 0;; esac + if [ ${0##*/} = "fbtenv.sh" ]; then # exluding script itself + fbtenv_show_usage; + return 1; + fi case ${0##*/} in dash|-dash|bash|-bash|ksh|-ksh|sh|-sh|*.sh|fbt) return 0;; esac - echo "Running this script manually is wrong, please source it"; - echo "Example:"; - printf "\tsource scripts/toolchain/fbtenv.sh\n"; + fbtenv_show_usage; return 1; } +fbtenv_chck_many_source() +{ + if ! echo "${PS1:-""}" | grep -q "[fbt]"; then + if ! echo "${PROMPT:-""}" | grep -q "[fbt]"; then + return 0; + fi + fi + echo "Warning! It script seen to be sourced more then once!"; + echo "It may signalise what you are making some mistakes, please open a new shell!"; + return 1; +} + +fbtenv_set_shell_prompt() +{ + if [ -n "${PS1:-""}" ]; then + PS1="[fbt]$PS1"; + elif [ -n "${PROMPT:-""}" ]; then + PROMPT="[fbt]$PROMPT"; + fi + return 0; # all other shells +} + fbtenv_check_script_path() { if [ ! -x "$SCRIPT_PATH/fbt" ]; then @@ -97,7 +138,7 @@ fbtenv_download_toolchain_tar() { echo "Downloading toolchain:"; mkdir -p "$FBT_TOOLCHAIN_PATH/toolchain" || return 1; - "$DOWNLOADER" $DOWNLOADER_ARGS "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR" "$TOOLCHAIN_URL" || return 1; + "$FBT_DOWNLOADER" "$FBT_TOOLCHAIN_PATH/toolchain/$TOOLCHAIN_TAR" "$TOOLCHAIN_URL" || return 1; echo "done"; return 0; } @@ -156,13 +197,11 @@ fbtenv_curl_wget_check() return 1; fi echo "yes" - DOWNLOADER="wget"; - DOWNLOADER_ARGS="--show-progress --progress=bar:force -qO"; + FBT_DOWNLOADER="fbtenv_wget"; return 0; fi echo "yes" - DOWNLOADER="curl"; - DOWNLOADER_ARGS="--progress-bar -SLo"; + FBT_DOWNLOADER="fbtenv_curl"; return 0; } @@ -196,10 +235,11 @@ fbtenv_download_toolchain() fbtenv_main() { fbtenv_check_sourced || return 1; + fbtenv_chck_many_source; # many source it's just a warning + fbtenv_set_shell_prompt; fbtenv_check_script_path || return 1; fbtenv_get_kernel_type || return 1; fbtenv_check_download_toolchain || return 1; - PS1="[FBT]${PS1-}"; PATH="$TOOLCHAIN_ARCH_DIR/python/bin:$PATH"; PATH="$TOOLCHAIN_ARCH_DIR/bin:$PATH"; PATH="$TOOLCHAIN_ARCH_DIR/protobuf/bin:$PATH";