work on remote builds
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 7 Jun 2010 05:55:42 +0000 (22:55 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 7 Jun 2010 05:55:42 +0000 (22:55 -0700)
need to avoid doing vpath build with non-gnu make

make-bin-dist.as
make-builder.as
make-src-dist.as
results2html

index 295b498a1661c1fbb906c14ef4f789eac27c8960..40d20bac474289756dab02db47504b992dcd2172 100644 (file)
@@ -8,6 +8,7 @@ where PSPP_DIST.TAR.GZ is a PSPP tarball prepared by \"make dist\"
   and BINID briefly identifies the target, e.g. \"debian-squeeze-i386\".
 
 Options:
+  --on HOST[:DIR]           Perform remote build using ssh and scp
   -h, --help                Print this usage message and exit
   -f, --force               Delete existing directory instead of aborting
 
@@ -35,6 +36,9 @@ exit_missing_arg='
 
 # Variables.
 overwrite=false
+remote=
+CONFIGUREFLAGS=
+n_envvars=0
 
 # Parse command line.
 while test $# -gt 0 ; do
@@ -49,15 +53,35 @@ while test $# -gt 0 ; do
        AS_ECHO(["$usage"]); exit ;;
 
     --force | -f )
-       overwrite=true ;;
+       overwrite=true
+       shift ;;
+
+    --on=* )
+       remote=$optarg
+       shift ;;
+    --on )
+       test $# = 1 && eval "$exit_missing_arg"
+       remote=$2
+       shift; shift ;;
+
+    --configureflags=* )
+       CONFIGUREFLAGS=$optarg
+       shift ;;
+    --configureflags )
+       test $# = 1 && eval "$exit_missing_arg"
+       CONFIGUREFLAGS=$2
+       shift; shift ;;
 
     -- )     # Stop option processing
        shift; break ;;
-    - )        # Use stdin as input.
-       break ;;
     -* )
        exec >&2
-       AS_ERROR([invalid option `$[1]'$as_nl$help]) ;; #`
+       AS_ERROR([invalid option `$[1]'$as_nl$help]) ;; #`(
+    *=* )
+       AS_VAR_ARITH([n_envvars], [$n_envvars + 1])
+       AS_VAR_SET([env$n_envvars], ["$[1]"])
+       shift
+       ;;
     * )
        break ;;
   esac
@@ -78,6 +102,48 @@ if test ! -e "$tarball"; then
    AS_ERROR([$tarball does not exist])
 fi
 
+REMOTE_HOST=
+REMOTE_DIR=
+case $remote in # (
+  "") 
+    ;; # (
+  *:*)
+    REMOTE_HOST=[`expr "$remote" : '\([^:]*\):'`]
+    REMOTE_DIR=[`expr "$remote" : '[^:]*:\(.*\)'`]
+    ;; # (
+  *)
+    REMOTE_HOST=$remote
+    ;;
+esac
+
+if test "X$REMOTE_HOST" != X; then
+  m4_pattern_allow([BP_SSH])
+  : ${BP_SSH=ssh}
+
+  escape () {
+    AS_ECHO("$1") | sed "s/'/'\\\\''/g"
+  }
+
+  options=
+  if test "x$CONFIGUREFLAGS" != x; then
+    options="--configureflags='"`escape "$CONFIGUREFLAGS"`\'
+  fi
+  $overwrite && options="$options --force"
+
+  i=0
+  while test $i -lt $n_envvars; do
+    AS_VAR_ARITH([i], [$i + 1])
+    AS_VAR_COPY([tmp], [env$i])
+    options="$options '"`escape "$tmp"`"\'
+  done
+  shift
+
+  rc=0
+  tar cf - make-bin-dist build-aux $tarball | gzip | $BP_SSH $REMOTE_HOST "cd $REMOTE_DIR && zcat | tar xf - && ./make-bin-dist $options $tarball $BINID" || rc=$?
+  $BP_SSH $REMOTE_HOST "cd $REMOTE_DIR && tar cf - $BINID" | tar xf - || rc=$?
+  exit $rc
+fi
+
 if test -e "$BINID"; then
   if test $overwrite = true; then
     chmod -R u+w "$BINID"
@@ -92,13 +158,14 @@ BP_INIT_RESULTS([$BINID])
 BP_INIT_LOG([$BINID/LOG])
 
 BP_SET_VAR([BUILD_NUMBER], [@BUILD_NUMBER@])
-BP_SET_VAR([PSPP_COMMIT], [@PSPP_COMMIT@])
 BP_SET_VAR([PSPP_REPO], [@PSPP_REPO@])
-BP_SET_VAR([GNULIB_COMMIT], [@GNULIB_COMMIT@])
+BP_SET_VAR([PSPP_BRANCH], [@PSPP_BRANCH@])
+BP_SET_VAR([PSPP_COMMIT], [@PSPP_COMMIT@])
 BP_SET_VAR([GNULIB_REPO], [@GNULIB_REPO@])
-BP_SET_VAR([BRANCH], [@BRANCH@])
+BP_SET_VAR([GNULIB_COMMIT], [@GNULIB_COMMIT@])
 
 BP_SET_VAR([BINID])
+BP_SET_VAR([CONFIGUREFLAGS])
 
 BP_START_STEP([Determining $tarball target directory])
 DIST_DIR=`zcat $tarball | tar tf - 2>/dev/null | sed 1q | sed s,/.*,,`
@@ -108,7 +175,7 @@ if test X$DIST_DIR = X; then
 fi
 
 BP_START_STEP([Extracting source tarball])
-BP_RUN([zcat $tarball | tar xkf - >&AS_MESSAGE_LOG_FD 2>&1])
+BP_RUN([zcat $tarball | tar xf - >&AS_MESSAGE_LOG_FD 2>&1])
 
 BP_START_STEP([Extracting tar version])
 DIST_VERSION=`$DIST_DIR/configure --version 2>/dev/null | sed 1q | sed 's/.* //'`
@@ -118,7 +185,17 @@ BP_START_STEP([Configuring])
 BP_RUN([mkdir $DIST_DIR/_$BINID >&AS_MESSAGE_LOG_FD 2>&1])
 BP_RUN([chmod -R a-w $DIST_DIR >&AS_MESSAGE_LOG_FD 2>&1])
 BP_RUN([chmod u+w $DIST_DIR/_$BINID >&AS_MESSAGE_LOG_FD 2>&1])
-BP_TRY_RUN([(cd $DIST_DIR/_$BINID && ../configure --enable-relocatable --prefix='') >&AS_MESSAGE_LOG_FD 2>&1])
+
+set x
+i=0
+while test $i -lt $n_envvars; do
+  AS_VAR_ARITH([i], [$i + 1])
+  AS_VAR_COPY([tmp], [env$i])
+  set "$@" "$tmp"
+done
+shift
+
+BP_TRY_RUN([(cd $DIST_DIR/_$BINID && ../configure --enable-relocatable --prefix='' $CONFIGUREFLAGS "$@") >&AS_MESSAGE_LOG_FD 2>&1])
 _bp_status=$?
 for base in config.h config.log; do
   fn=$DIST_DIR/_$BINID/$base
index 8a90693f351b35c9b8b807da3f08815ffd12bdb2..e7fd623a5f6658c8439869cf868474823ce048d6 100644 (file)
@@ -206,7 +206,6 @@ s,[@]PSPP_BRANCH[@],$PSPP_BRANCH,g
 s,[@]PSPP_COMMIT[@],$PSPP_COMMIT,g
 s,[@]GNULIB_COMMIT[@],$GNULIB_COMMIT,g
 s,[@]GNULIB_REPO[@],$GNULIB_REPO,g
-s,[@]CONFIGUREFLAGS[@],,g
 "
     chmod +x "$outdir/$base"
 done
index 81d42eabe88bdb1cae48e0d94c71043fee7c85cc..2e491de997258b5cf0b736fe460e45b16c026d02 100644 (file)
@@ -12,7 +12,7 @@ BP_SET_VAR([PSPP_COMMIT], [@PSPP_COMMIT@])
 BP_SET_VAR([GNULIB_COMMIT], [@GNULIB_COMMIT@])
 BP_SET_VAR([GNULIB_REPO], [@GNULIB_REPO@])
 
-ABBREV_COMMIT=`expr "$COMMIT" : '\(......\)'`
+ABBREV_COMMIT=`expr "$PSPP_COMMIT" : '\(......\)'`
 
 BP_START_STEP([Extracting Git sources])
 BP_RUN([(cd repo && zcat pspp-$PSPP_COMMIT.tar.gz | tar xf -) >&AS_MESSAGE_LOG_FD 2>&1])
@@ -46,9 +46,10 @@ BP_SET_VAR([VERSION])
 
 BP_START_STEP([Update version number in configure.ac])
 AS_ECHO(["AC_INIT([$PACKAGE], [$VERSION], [$BUG_REPORT], [$TARNAME], [$URL])]") > tmp$$
-sed -n "${LINE}r tmp$$
-$LINE!p" < repo/pspp-$PSPP_COMMIT/$FILE > repo/pspp-$PSPP_COMMIT/$FILE.new
-mv repo/pspp-$PSPP_COMMIT/$FILE.new repo/pspp-$PSPP_COMMIT/$FILE
+BP_RUN([sed -n "${LINE}r tmp$$
+$LINE!p" < repo/pspp-$PSPP_COMMIT/$FILE > repo/pspp-$PSPP_COMMIT/$FILE.new 2>&AS_MESSAGE_LOG_FD])
+BP_RUN([mv repo/pspp-$PSPP_COMMIT/$FILE.new repo/pspp-$PSPP_COMMIT/$FILE >&AS_MESSAGE_LOG_FD 2>&1])
+BP_RUN([rm tmp$$ >&AS_MESSAGE_LOG_FD 2>&1])
 
 BP_START_STEP([Updating NEWS])
 {
@@ -75,7 +76,7 @@ BP_RUN([(cd repo/pspp-$PSPP_COMMIT && make -f Smake GNULIB=../gnulib-$GNULIB_COM
 
 BP_START_STEP([Configure])
 mkdir repo/pspp-$PSPP_COMMIT/_dist
-BP_RUN([(cd repo/pspp-$PSPP_COMMIT/_dist && ../configure @CONFIGUREFLAGS@) >&AS_MESSAGE_LOG_FD 2>&1])
+BP_RUN([(cd repo/pspp-$PSPP_COMMIT/_dist && ../configure) >&AS_MESSAGE_LOG_FD 2>&1])
 
 BP_START_STEP([Make source tarball])
 BP_RUN([(cd repo/pspp-$PSPP_COMMIT/_dist && make dist) >&AS_MESSAGE_LOG_FD 2>&1])
index c6aaab634d1724057a80e7c0676dc76c237c2283..c682b5e514cf9755c60c36eb2155d0b9aed5ce98 100755 (executable)
@@ -142,7 +142,7 @@ print INDEX <<EOF;
 <body>
 EOF
 
-print INDEX "<h1>Build ", $vars{"build_number"}, ": $result</h1>\n";
+print INDEX "<h1>Build ", $vars{"BUILD_NUMBER"}, ": $result</h1>\n";
 
 print INDEX "<h2>Build Properties</h2>\n";
 print INDEX "<table>\n";