X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=common.sh;h=8e9f484d13ef16939ab16216807ace2330d6c5ac;hb=HEAD;hp=1cd814fea35e036d1cfcc66746eb49260dda96cd;hpb=87f7336193d19fbf8b260a80c779ecc658696f59;p=next-scripts diff --git a/common.sh b/common.sh index 1cd814f..272d269 100644 --- a/common.sh +++ b/common.sh @@ -3,35 +3,135 @@ # # 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="$(dirname $0)" +bin_dir=$(realpath "$(dirname "$0")") +top_dir=$(dirname "$bin_dir") -LOG_FILE="../merge.log" -SHA1_FILE="../SHA1s" -CTRL_FILE="../etc/control" +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="alpine1.ozlabs.ibm.com" -build_dir="/home/michael/linux-next/tmpfs/next" -gcc_version="4.9.3" -j_factor=640 -ssh_key_file="~/work/topics/korg/ssh/korg-mpe" -gpg_key="C8E1A580" +build_host="ash" +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" ] && build_host="$NEXT_BUILD_HOST" -[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR" +if [ "$NEXT_BUILD_HOST" ]; then + build_host="$NEXT_BUILD_HOST" + 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 +if [ "$NEXT_GCC_PPC_VERSION" ]; then + gcc_ppc_version="$NEXT_GCC_PPC_VERSION" +fi +gcc_ppcle_version=$gcc_ppc_version +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 +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" +export NEXT_GCC_VERSION="$gcc_version" +export NEXT_GCC_PPC_VERSION="$gcc_ppc_version" +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" } -[ -n "$1" ] && { - build_dir="$1" - shift + +get_pending_branches() +{ + awk -F "$_TAB" '/^[^-#]/ && $2=="git"{ print $3; } $1=="pending-fixes" { exit; }' "$CTRL_FILE" } -export NEXT_BUILD_HOST="$build_host" -export NEXT_BUILD_DIR="$build_dir" +get_contacts() +{ + 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" + fi + fi +} true