~ salmonella-environment-setup (master) 152b7c466591ac73cd79d7d38e89ba558fbf0b49


commit 152b7c466591ac73cd79d7d38e89ba558fbf0b49
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Sun Dec 24 11:20:55 2017 +0100
Commit:     Mario Domenech Goulart <mario@parenteses.org>
CommitDate: Sun Dec 24 12:48:12 2017 +0100

    salmonella-linux: Merge configuration files and runner scripts for x86 and x86-64
    
    Now there is a single script to run salmonella jobs for both supported
    linux architectures (x86 and x86-64).  The runner script has is in the
    salmonella directory (run-salmonella-linux.sh).  It uses the hardware
    architecture and a list of configuration files as inputs.
    
    Since most configuration files are the same for x86 and x86-64, they
    have been moved to the salmonella/linux-common directory.
    Machine-specific files have been kept in
    salmonella/salmonella-linux-x86 and salmonella-linux-x86-64
    directories (currently only chicken-4-debugbuild, as in the x86-64
    machine we don't use cache).

diff --git a/salmonella-linux-x86-64/chicken-4-clang.conf b/linux-common/chicken-4-clang.conf
similarity index 100%
rename from salmonella-linux-x86-64/chicken-4-clang.conf
rename to linux-common/chicken-4-clang.conf
diff --git a/salmonella-linux-x86/chicken-4-common.scm b/linux-common/chicken-4-common.scm
similarity index 54%
rename from salmonella-linux-x86/chicken-4-common.scm
rename to linux-common/chicken-4-common.scm
index ae16e65..c288d25 100644
--- a/salmonella-linux-x86/chicken-4-common.scm
+++ b/linux-common/chicken-4-common.scm
@@ -2,9 +2,7 @@
 
 (chicken-core-branch "chicken-4")
 
-(chicken-bootstrap-prefix
- (make-pathname (list (get-environment-variable "HOME") "local")
-                "chicken"))
+(chicken-bootstrap-prefix (get-environment-variable "CHICKEN_4_PREFIX"))
 
 (skip-eggs
  (append '(pledge spatial-trees)
diff --git a/salmonella-linux-x86-64/chicken-4.conf b/linux-common/chicken-4.conf
similarity index 100%
rename from salmonella-linux-x86-64/chicken-4.conf
rename to linux-common/chicken-4.conf
diff --git a/salmonella-linux-x86/chicken-5-common.scm b/linux-common/chicken-5-common.scm
similarity index 79%
rename from salmonella-linux-x86/chicken-5-common.scm
rename to linux-common/chicken-5-common.scm
index ddd1237..9473752 100644
--- a/salmonella-linux-x86/chicken-5-common.scm
+++ b/linux-common/chicken-5-common.scm
@@ -1,20 +1,16 @@
 (chicken-release 5)
 
-(chicken-bootstrap-prefix
- (make-pathname (list (get-environment-variable "HOME") "local")
-                "chicken-5"))
+(chicken-bootstrap-prefix (get-environment-variable "CHICKEN_5_PREFIX"))
 
 (salmonella-path
- (make-pathname (list (get-environment-variable "HOME")
-                      "local" "chicken-5" "bin")
+ (make-pathname (list (get-environment-variable "CHICKEN_5_PREFIX") "bin")
                 "salmonella"))
 
 
 ;; Use the chicken-5-eggs repo
 
 (define chicken-5-eggs-directory
-  (make-pathname (list (get-environment-variable "HOME") "src")
-                 "chicken-5-eggs"))
+  (get-environment-variable "CHICKEN_5_EGGS_DIR"))
 
 (list-eggs
  (lambda ()
diff --git a/salmonella-linux-x86-64/chicken-5.conf b/linux-common/chicken-5.conf
similarity index 100%
rename from salmonella-linux-x86-64/chicken-5.conf
rename to linux-common/chicken-5.conf
diff --git a/linux-common/common.scm b/linux-common/common.scm
new file mode 100644
index 0000000..45b9084
--- /dev/null
+++ b/linux-common/common.scm
@@ -0,0 +1,11 @@
+(use salmonella-run-publish-params posix files extras)
+
+(keep-repo? #t)
+
+(compress-report? #f)
+(create-report-tarball 'gzip)
+
+(web-dir (get-environment-variable "SALMONELLA_REPORTS_DIR"))
+
+(feeds-server
+ (sprintf "salmonella-linux-~a.call-cc.org" (machine-type)))
diff --git a/salmonella-linux-x86-64/prerelease.conf b/linux-common/prerelease.conf
similarity index 100%
rename from salmonella-linux-x86-64/prerelease.conf
rename to linux-common/prerelease.conf
diff --git a/run-salmonella-linux.sh b/run-salmonella-linux.sh
new file mode 100755
index 0000000..2722fd0
--- /dev/null
+++ b/run-salmonella-linux.sh
@@ -0,0 +1,103 @@
+#! /bin/sh
+
+usage() {
+    cat <<EOF
+Usage: $(basename "$0") <arch> <confs>
+
+<arch>: either "x86" or "x86-64"
+
+<conf>: configuration filenames without the ".conf" extension.  E.g.,
+        if you have chicken-5.conf, use "chicken-5" as argument.
+EOF
+}
+
+OS=linux
+SRC_DIR=$HOME/src/chicken-infrastructure
+WORK_DIR=$HOME/salmonella/build
+LOG_DIR=$HOME/salmonella
+
+# Conf files use these environment variables
+export CHICKEN_4_PREFIX=$HOME/local/chicken
+export CHICKEN_5_PREFIX=$HOME/local/chicken-5
+export CHICKEN_5_EGGS_DIR=$HOME/src/chicken-5-eggs
+export SALMONELLA_REPORTS_DIR=$HOME/salmonella/reports
+
+# Global settings for eggs
+export PATH=$PATH:/usr/local/bin/
+export BVSPIS_PATH=/usr/local/bvspis
+export LC_ALL=C
+export LANG=C
+# JAVA_HOME will be set in `main', according to $arch
+
+
+main() {
+    arch=$1
+    shift
+    confs=$@
+
+    mkdir -p "$LOG_DIR" "$WORK_DIR"
+    logfile="$LOG_DIR/watchdog.log"
+
+    # Run salmonella from $WORK_DIR
+    cd "$WORK_DIR"
+
+    ### Prevent two salmonellas from running simultaneously
+    while ps ax | grep '[s]almonella-run-publish'; do
+        echo "[`date`] Salmonella still running" >> $logfile
+        sleep 1h
+    done
+
+    ### Actually run salmonella
+    if [ "$arch" = "x86" ]; then
+        export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
+    else
+        export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
+    fi
+
+    # Remove leftovers from previous executions
+    rm -rf salmonella-run-publish
+
+    # The DEBUGBUILD build variable is set according to configuration
+    # filenames.  If conf file names contain "debugbuild", DEBUGBUILD
+    # is set.
+    debugbuild=
+    for conf in $confs; do
+        # The inline egg writes some stuff to the home dir
+        rm -rf ~/.chicken-inline
+
+        # Remove leftovers from previous executions
+        rm -rf salmonella-$conf
+
+        if echo "$conf" | grep -q debugbuild; then
+            debugbuild=1
+        else
+            debugbuild=
+        fi
+
+        # Prefer machine-specific configuration files
+        if [ -e "$SRC_DIR/salmonella/salmonella-${OS}-${arch}/${conf}.conf" ]; then
+            conf_path=$SRC_DIR/salmonella/salmonella-${OS}-${arch}/${conf}.conf
+        else
+            conf_path=$SRC_DIR/salmonella/${OS}-common/${conf}.conf
+        fi
+
+        DEBUGBUILD=$debugbuild "$CHICKEN_4_PREFIX/bin/salmonella-run-publish" "$conf_path"
+        mv salmonella-run-publish "salmonella-$conf"
+    done
+}
+
+
+if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
+    usage
+    exit 0
+elif [ "$#" -lt 2 ]; then
+    usage >&2
+    exit 1
+elif [ "$1" != "x86" ] && [ "$1" != "x86-64" ]; then
+    usage >&2
+    exit 2
+else
+    arch=$1
+    shift
+    main "$arch" $@
+fi
diff --git a/salmonella-linux-x86-64/chicken-4-common.scm b/salmonella-linux-x86-64/chicken-4-common.scm
deleted file mode 100644
index ae16e65..0000000
--- a/salmonella-linux-x86-64/chicken-4-common.scm
+++ /dev/null
@@ -1,11 +0,0 @@
-(use salmonella-run-publish-params)
-
-(chicken-core-branch "chicken-4")
-
-(chicken-bootstrap-prefix
- (make-pathname (list (get-environment-variable "HOME") "local")
-                "chicken"))
-
-(skip-eggs
- (append '(pledge spatial-trees)
-         (skip-eggs)))
diff --git a/salmonella-linux-x86-64/chicken-4-debugbuild.conf b/salmonella-linux-x86-64/chicken-4-debugbuild.conf
index 839876e..e53e564 100644
--- a/salmonella-linux-x86-64/chicken-4-debugbuild.conf
+++ b/salmonella-linux-x86-64/chicken-4-debugbuild.conf
@@ -1,5 +1,5 @@
-(load-relative "./common.scm")
-(load-relative "./chicken-4-common.scm")
+(load-relative "../linux-common/common.scm")
+(load-relative "../linux-common/chicken-4-common.scm")
 
 (keep-repo? #f)
 
diff --git a/salmonella-linux-x86-64/chicken-5-common.scm b/salmonella-linux-x86-64/chicken-5-common.scm
deleted file mode 100644
index ddd1237..0000000
--- a/salmonella-linux-x86-64/chicken-5-common.scm
+++ /dev/null
@@ -1,49 +0,0 @@
-(chicken-release 5)
-
-(chicken-bootstrap-prefix
- (make-pathname (list (get-environment-variable "HOME") "local")
-                "chicken-5"))
-
-(salmonella-path
- (make-pathname (list (get-environment-variable "HOME")
-                      "local" "chicken-5" "bin")
-                "salmonella"))
-
-
-;; Use the chicken-5-eggs repo
-
-(define chicken-5-eggs-directory
-  (make-pathname (list (get-environment-variable "HOME") "src")
-                 "chicken-5-eggs"))
-
-(list-eggs
- (lambda ()
-   (map (lambda (egg)
-          (string->symbol
-           (pathname-strip-directory (pathname-directory egg))))
-        (find-files chicken-5-eggs-directory
-                    test: (irregex ".*\\.egg$")))))
-
-(before-make-bootstrap-hook
- (lambda (sources-dir)
-   (let ((here (current-directory)))
-     (cond ((directory-exists? chicken-5-eggs-directory)
-            (change-directory chicken-5-eggs-directory)
-            (system* "git checkout -f")
-            (system* "git clean -dxf")
-            (system* "git checkout master")
-            (system* "git pull --rebase"))
-           (else
-            (change-directory (pathname-directory chicken-5-eggs-directory))
-            (system* "git clone git://code.call-cc.org/chicken-5-eggs")))
-     (change-directory here))))
-
-(after-make-check-hook
- (lambda (installation-prefix)
-   (with-output-to-file
-       (make-pathname (list installation-prefix "share" "chicken")
-                      "setup.defaults")
-     (lambda ()
-       (pp `(location ,chicken-5-eggs-directory)))
-     append:)
-   (system* "rm -rf /home/chicken/.chicken-install.cache")))
diff --git a/salmonella-linux-x86-64/common.scm b/salmonella-linux-x86-64/common.scm
deleted file mode 100644
index eff37f6..0000000
--- a/salmonella-linux-x86-64/common.scm
+++ /dev/null
@@ -1,13 +0,0 @@
-(use salmonella-run-publish-params posix files)
-
-(keep-repo? #t)
-
-(compress-report? #f)
-(create-report-tarball 'gzip)
-
-(web-dir
- (make-pathname (list (get-environment-variable "HOME")
-                      "salmonella")
-                "reports"))
-
-(feeds-server "salmonella-linux-x86-64.call-cc.org")
diff --git a/salmonella-linux-x86-64/run-salmonella.sh b/salmonella-linux-x86-64/run-salmonella.sh
deleted file mode 100755
index c57ea65..0000000
--- a/salmonella-linux-x86-64/run-salmonella.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#! /bin/sh
-
-logfile="$HOME/salmonella/watchdog.log"
-
-# Run salmonella from ~/salmonella/build
-mkdir -p ~/salmonella/build
-cd ~/salmonella/build
-
-###
-### Prevent two salmonellas from running simultaneously
-###
-while ps ax | grep '[s]almonella-run-publish'; do
-    echo "[`date`] Salmonella still running" >> $logfile
-    sleep 1h
-done
-
-
-###
-### Actually run salmonella
-###
-
-export PATH=$PATH:/usr/local/bin/
-export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
-export BVSPIS_PATH=/usr/local/bvspis
-export LC_ALL=C
-export LANG=C
-
-rm -rf salmonella-run-publish
-
-debugbuild=
-for conf in chicken-5 chicken-4-debugbuild chicken-4-clang prerelease; do
-    # The inline egg writes some stuff to the home dir
-    rm -rf ~/.chicken-inline
-
-    rm -rf salmonella-$conf
-    if echo "$conf" | grep -q debugbuild; then
-        debugbuild=1
-    else
-        debugbuild=
-    fi
-    DEBUGBUILD=$debugbuild \
-        ~/local/chicken/bin/salmonella-run-publish \
-        ~/src/chicken-infrastructure/salmonella/salmonella-linux-x86-64/${conf}.conf
-    mv salmonella-run-publish salmonella-$conf
-done
diff --git a/salmonella-linux-x86/chicken-4-clang.conf b/salmonella-linux-x86/chicken-4-clang.conf
deleted file mode 100644
index 258ce12..0000000
--- a/salmonella-linux-x86/chicken-4-clang.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-(load-relative "./common.scm")
-(load-relative "./chicken-4-common.scm")
-
-(c-compiler "clang")
-(c++-compiler "clang++")
diff --git a/salmonella-linux-x86/chicken-4-debugbuild.conf b/salmonella-linux-x86/chicken-4-debugbuild.conf
index 36e85ad..006d4f8 100644
--- a/salmonella-linux-x86/chicken-4-debugbuild.conf
+++ b/salmonella-linux-x86/chicken-4-debugbuild.conf
@@ -1,5 +1,5 @@
-(load-relative "./common.scm")
-(load-relative "./chicken-4-common.scm")
+(load-relative "../linux-common/common.scm")
+(load-relative "../linux-common/chicken-4-common.scm")
 
 (branch-publish-transformer
   (lambda (branch)
diff --git a/salmonella-linux-x86/chicken-4.conf b/salmonella-linux-x86/chicken-4.conf
deleted file mode 100644
index 38c4aa7..0000000
--- a/salmonella-linux-x86/chicken-4.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-(load-relative "./common.scm")
-(load-relative "./chicken-4-common.scm")
diff --git a/salmonella-linux-x86/chicken-5.conf b/salmonella-linux-x86/chicken-5.conf
deleted file mode 100644
index df5aed1..0000000
--- a/salmonella-linux-x86/chicken-5.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-(load-relative "./common.scm")
-(load-relative "./chicken-5-common.scm")
-
-(chicken-core-branch "master")
diff --git a/salmonella-linux-x86/common.scm b/salmonella-linux-x86/common.scm
deleted file mode 100644
index 0eb7f35..0000000
--- a/salmonella-linux-x86/common.scm
+++ /dev/null
@@ -1,13 +0,0 @@
-(use salmonella-run-publish-params posix files)
-
-(keep-repo? #t)
-
-(compress-report? #f)
-(create-report-tarball 'gzip)
-
-(web-dir
- (make-pathname (list (get-environment-variable "HOME")
-                      "salmonella")
-                "reports"))
-
-(feeds-server "salmonella-linux-x86.call-cc.org")
diff --git a/salmonella-linux-x86/prerelease.conf b/salmonella-linux-x86/prerelease.conf
deleted file mode 100644
index ca213a4..0000000
--- a/salmonella-linux-x86/prerelease.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-(load-relative "./common.scm")
-
-(chicken-core-branch "prerelease")
diff --git a/salmonella-linux-x86/run-salmonella.sh b/salmonella-linux-x86/run-salmonella.sh
deleted file mode 100755
index 3b9bd1f..0000000
--- a/salmonella-linux-x86/run-salmonella.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#! /bin/sh
-
-logfile="$HOME/salmonella/watchdog.log"
-
-# Run salmonella from ~/salmonella/build
-mkdir -p ~/salmonella/build
-cd ~/salmonella/build
-
-###
-### Prevent two salmonellas from running simultaneously
-###
-while ps ax | grep '[s]almonella-run-publish'; do
-    echo "[`date`] Salmonella still running" >> $logfile
-    sleep 1h
-done
-
-
-###
-### Actually run salmonella
-###
-
-export PATH=$PATH:/usr/local/bin/
-export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386/
-export BVSPIS_PATH=/usr/local/bvspis
-export LC_ALL=C
-export LANG=C
-
-rm -rf salmonella-run-publish
-
-debugbuild=
-for conf in chicken-5 chicken-4-debugbuild prerelease; do
-    # The inline egg writes some stuff to the home dir
-    rm -rf ~/.chicken-inline
-
-    rm -rf salmonella-$conf
-    if echo "$conf" | grep -q debugbuild; then
-        debugbuild=1
-    else
-        debugbuild=
-    fi
-    DEBUGBUILD=$debugbuild \
-        ~/local/chicken/bin/salmonella-run-publish \
-        ~/src/chicken-infrastructure/salmonella/salmonella-linux-x86/${conf}.conf
-    mv salmonella-run-publish salmonella-$conf
-done
Trap