X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=common.sh;h=8e9f484d13ef16939ab16216807ace2330d6c5ac;hb=HEAD;hp=7eaa48620e0214885854a542a612c7e113c5f317;hpb=ed16f8131507c00a058568fc1d34169262ae40a4;p=next-scripts diff --git a/common.sh b/common.sh index 7eaa486..272d269 100644 --- a/common.sh +++ b/common.sh @@ -3,43 +3,67 @@ # # Just in case this gets included twice ... -[ "$_next_common_included" ] && return 0 +if [ "$_next_common_included" ]; then + return 0 +fi _next_common_included=1 -bin_dir=$(realpath $(dirname "$0")) +bin_dir=$(realpath "$(dirname "$0")") top_dir=$(dirname "$bin_dir") -[ "$LOG_FILE" ] || LOG_FILE="$top_dir/merge.log" +if [ -z "$LOG_FILE" ]; then + LOG_FILE="$top_dir/merge.log" +fi +# "... appears unused" +# shellcheck disable=SC2034 SHA1_FILE="$top_dir/SHA1s" CTRL_FILE="$top_dir/etc/control" build_host="ash" -build_dir="/home/sfr/next/next" +build_dir="$HOME/next/next" gcc_version="4.9.0" j_factor=$(nproc) +# "... appears unused" +# shellcheck disable=SC2034 gpg_key=89F91C0A41D5C07A +# "... appears unused" +# shellcheck disable=SC2034 kup_gpg_key=015042F34957D06C -[ "$NEXT_BUILD_HOST" ] && { +if [ "$NEXT_BUILD_HOST" ]; then build_host="$NEXT_BUILD_HOST" - [ "$build_host" = "none" ] && build_host="" -} -[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR" -[ "$NEXT_GCC_VERSION" ] && gcc_version="$NEXT_GCC_VERSION" + if [ "$build_host" = "none" ]; then + build_host="" + fi +fi +if [ "$NEXT_BUILD_DIR" ]; then + build_dir="$NEXT_BUILD_DIR" +fi +if [ "$NEXT_GCC_VERSION" ]; then + gcc_version="$NEXT_GCC_VERSION" +fi gcc_ppc_version=$gcc_version -[ "$NEXT_GCC_PPC_VERSION" ] && gcc_ppc_version="$NEXT_GCC_PPC_VERSION" +if [ "$NEXT_GCC_PPC_VERSION" ]; then + gcc_ppc_version="$NEXT_GCC_PPC_VERSION" +fi gcc_ppcle_version=$gcc_ppc_version -[ "$NEXT_GCC_PPCLE_VERSION" ] && gcc_ppcle_version="$NEXT_GCC_PPCLE_VERSION" -[ "$NEXT_J_FACTOR" ] && j_factor="$NEXT_J_FACTOR" +if [ "$NEXT_GCC_PPCLE_VERSION" ]; then + gcc_ppcle_version="$NEXT_GCC_PPCLE_VERSION" +fi +if [ "$NEXT_J_FACTOR" ]; then + j_factor="$NEXT_J_FACTOR" +fi -[ -n "$1" ] && { - build_host="$1" - shift -} -[ -n "$1" ] && { - build_dir="$1" - shift -} +if [ -z "$_next_common_no_args" ]; then + if [ -n "$1" ]; then + build_host="$1" + shift + fi + if [ -n "$1" ]; then + build_dir="$1" + shift + fi +fi export NEXT_BUILD_HOST="${build_host:-none}" export NEXT_BUILD_DIR="$build_dir" @@ -49,22 +73,63 @@ export NEXT_GCC_PPCLE_VERSION="$gcc_ppcle_version" export NEXT_J_FACTOR="$j_factor" # Support functions +_TAB=$(printf '\t') + +get_control_field() +{ + awk -F "$_TAB" -v branch="$1" -v field="$2" '/^[^-#]/ && $3==branch { print $field; }' "$CTRL_FILE" +} + +get_branches() +{ + awk -F "$_TAB" '/^[^-#]/ && $2=="git"{ print $3; }' "$CTRL_FILE" +} + +get_pending_branches() +{ + awk -F "$_TAB" '/^[^-#]/ && $2=="git"{ print $3; } $1=="pending-fixes" { exit; }' "$CTRL_FILE" +} + get_contacts() { - awk -F '\t' '/^[^#]/ && $3=="'"$1"'" { print $1; }' $CTRL_FILE + get_control_field "$1" 1 +} + +get_type() +{ + get_control_field "$1" 2 +} + +get_url() +{ + get_control_field "$1" 4 +} + +get_remote_branch() +{ + get_control_field "$1" 5 +} + +get_build_flag() +{ + get_control_field "$1" 6 } check_unmerged_files() { + # "In POSIX sh, 'local' is undefined." + # shellcheck disable=SC3043 local tree="$1" + # shellcheck disable=SC3043 local um_files + # shellcheck disable=SC3043 local rm_files um_files=$(git diff 2>&1 | sed -n 's/^\* Unmerged path //p') if [ "$um_files" ] && [ -f "../merge-files/$tree" ]; then rm_files=$(grep -F "$um_files" "../merge-files/$tree") if [ "$rm_files" ]; then - "$bin_dir/do_rm" $rm_files + "$bin_dir/do_rm" "$rm_files" fi fi }