--- /dev/null
+#
+# Common setup for linux-next scripts
+#
+bin_dir="$(dirname $0)"
+
+LOG_FILE="../merge.log"
+SHA1_FILE="../SHA1s"
+
+build_host="ka2"
+build_dir="/scratch/sfr/next"
+
+[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
+[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
+
+[ -n "$1" ] && {
+       build_host="$1"
+       shift
+}
+[ -n "$1" ] && {
+       build_dir="$1"
+       shift
+}
+
+export NEXT_BUILD_HOST="$build_host"
+export NEXT_BUILD_DIR="$build_dir"
+
+true
 
 #!/bin/sh
 
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
+. "$(dirname $0)/common.sh"
 
 set -e
 
 
 #!/bin/sh
 
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
+. "$(dirname $0)/common.sh"
 
 set -e
 
 
 #!/bin/bash
 
-bin_dir="$(dirname $0)"
-
-LOG_FILE="../merge.log"
-SHA1_FILE="../SHA1s"
-
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
 no_build=false
 start_from=""
 
        }
        shift
 }
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
 
-export NEXT_BUILD_HOST="$build_host"
-export NEXT_BUILD_DIR="$build_dir"
+. "$(dirname $0)/common.sh"
 
 log()
 {
 
 #!/bin/bash
 
-bin_dir="$(dirname $0)"
-
-LOG_FILE="../merge.log"
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
 no_build=false
 [ "$1" = "-n" ] && {
        shift
 patch="$1"
 shift
 
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
-
-export NEXT_BUILD_HOST="$build_host"
-export NEXT_BUILD_DIR="$build_dir"
+. "$(dirname $0)/common.sh"
 
 log()
 {
 
 #!/bin/bash
 
-bin_dir="$(dirname $0)"
-
-LOG_FILE="../merge.log"
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
 
 no_build=false
 [ "$1" = "-n" ] && {
 rev=$1
 shift
 
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
-
-export NEXT_BUILD_HOST="$build_host"
-export NEXT_BUILD_DIR="$build_dir"
+. "$(dirname $0)/common.sh"
 
 log()
 {
 
 #!/bin/bash
 
-bin_dir="$(dirname $0)"
-
-LOG_FILE="../merge.log"
-SHA1_FILE="../SHA1s"
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
 today="$(date '+%Y%m%d')"
 
 no_build=false
        shift
        no_build=true
 }
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
 
-export NEXT_BUILD_HOST="$build_host"
-export NEXT_BUILD_DIR="$build_dir"
+. "$(dirname $0)/common.sh"
 
 log()
 {
 
 #!/bin/bash
 
-bin_dir="$(dirname $0)"
-
-LOG_FILE="../merge.log"
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
 no_build=false
 [ "$1" = "-n" ] && {
        shift
        echo "patch does not exist" 1>&2
        exit 1
 }
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
 
-export NEXT_BUILD_HOST="$build_host"
-export NEXT_BUILD_DIR="$build_dir"
+. "$(dirname $0)/common.sh"
 
 log()
 {
 
 #!/bin/bash
 
-bin_dir="$(dirname $0)"
-
-LOG_FILE="../merge.log"
-SHA1_FILE="../SHA1s"
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
 no_build=false
 [ "$1" = "-n" ] && {
        shift
 }
 
 tree=$1
-ver=$2
+shift
+ver=$1
+shift
 
 rev=$(git show next-${ver}:Next/SHA1s | sed -n "s/^$tree\t\t*//p")
 [ "$rev" ] || {
        exit 1
 }
 
-[ -n "$3" ] && {
-       build_host="$3"
-       shift
-}
-[ -n "$3" ] && {
-       build_dir="$3"
-       shift
-}
-
-export NEXT_BUILD_HOST="$build_host"
-export NEXT_BUILD_DIR="$build_dir"
+. "$(dirname $0)/common.sh"
 
 log()
 {