~ salmonella-environment-setup (master) 69ee37cf7dfdf19daa4e03a1f3c8b07c51dc06ba


commit 69ee37cf7dfdf19daa4e03a1f3c8b07c51dc06ba
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Fri Apr 16 19:06:47 2021 +0200
Commit:     Mario Domenech Goulart <mario@parenteses.org>
CommitDate: Fri Apr 16 19:06:51 2021 +0200

    conf: use ensure-environment-variable
    
    ensure-environment-variable makes clear what variables are required by
    configuration files.  If they are not set, a clear error is raised.

diff --git a/conf/chicken-4-clang.conf b/conf/chicken-4-clang.conf
index b8c8be1..871949f 100644
--- a/conf/chicken-4-clang.conf
+++ b/conf/chicken-4-clang.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-4.scm")
 
 (c-compiler "clang")
diff --git a/conf/chicken-4-debugbuild-no-cache.conf b/conf/chicken-4-debugbuild-no-cache.conf
index 0d3bda3..bdea62d 100644
--- a/conf/chicken-4-debugbuild-no-cache.conf
+++ b/conf/chicken-4-debugbuild-no-cache.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-4.scm")
 (load-relative "./common/debugbuild.scm")
 
diff --git a/conf/chicken-4-debugbuild.conf b/conf/chicken-4-debugbuild.conf
index 7c08991..5596255 100644
--- a/conf/chicken-4-debugbuild.conf
+++ b/conf/chicken-4-debugbuild.conf
@@ -4,6 +4,5 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-4.scm")
 (load-relative "./common/debugbuild.scm")
diff --git a/conf/chicken-4.conf b/conf/chicken-4.conf
index 1eabed5..bb1698e 100644
--- a/conf/chicken-4.conf
+++ b/conf/chicken-4.conf
@@ -4,5 +4,4 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-4.scm")
diff --git a/conf/chicken-5-clang-speed.conf b/conf/chicken-5-clang-speed.conf
index ab1018b..e00cea0 100644
--- a/conf/chicken-5-clang-speed.conf
+++ b/conf/chicken-5-clang-speed.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 (load-relative "./common/speed.scm")
 
diff --git a/conf/chicken-5-clang.conf b/conf/chicken-5-clang.conf
index 7678789..82fc11f 100644
--- a/conf/chicken-5-clang.conf
+++ b/conf/chicken-5-clang.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 
 (c-compiler "clang")
diff --git a/conf/chicken-5-debugbuild-no-cache.conf b/conf/chicken-5-debugbuild-no-cache.conf
index e82a67e..1b272d9 100644
--- a/conf/chicken-5-debugbuild-no-cache.conf
+++ b/conf/chicken-5-debugbuild-no-cache.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 (load-relative "./common/debugbuild.scm")
 
diff --git a/conf/chicken-5-debugbuild.conf b/conf/chicken-5-debugbuild.conf
index 944a57c..b46e688 100644
--- a/conf/chicken-5-debugbuild.conf
+++ b/conf/chicken-5-debugbuild.conf
@@ -4,6 +4,5 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 (load-relative "./common/debugbuild.scm")
diff --git a/conf/chicken-5-speed.conf b/conf/chicken-5-speed.conf
index 53ca470..68cbe0d 100644
--- a/conf/chicken-5-speed.conf
+++ b/conf/chicken-5-speed.conf
@@ -4,6 +4,5 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 (load-relative "./common/speed.scm")
diff --git a/conf/chicken-5-tcc-no-cache.conf b/conf/chicken-5-tcc-no-cache.conf
index 5091b4b..3b7b68e 100644
--- a/conf/chicken-5-tcc-no-cache.conf
+++ b/conf/chicken-5-tcc-no-cache.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 
 (c-compiler "tcc")
diff --git a/conf/chicken-5-tcc.conf b/conf/chicken-5-tcc.conf
index d27042c..f4a7ab4 100644
--- a/conf/chicken-5-tcc.conf
+++ b/conf/chicken-5-tcc.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 
 (c-compiler "tcc")
diff --git a/conf/chicken-5.conf b/conf/chicken-5.conf
index 76a31a6..35231dc 100644
--- a/conf/chicken-5.conf
+++ b/conf/chicken-5.conf
@@ -4,7 +4,6 @@
   (import (chicken load)))
  (else))
 
-(load-relative "./common/common.scm")
 (load-relative "./common/chicken-5.scm")
 
 (chicken-core-branch "master")
diff --git a/conf/common/chicken-4.scm b/conf/common/chicken-4.scm
index 14c147c..c260fa1 100644
--- a/conf/common/chicken-4.scm
+++ b/conf/common/chicken-4.scm
@@ -4,14 +4,17 @@
    (import chicken)
    (use salmonella-run-publish-params))
   (chicken-5
-   (import (chicken process-context))
+   (import (chicken load)
+           (chicken process-context))
    (import salmonella-run-publish-params))
   (else
    (error "Unsupported CHICKEN version.")))
 
+(load-relative "./common.scm")
+
 (chicken-core-branch "chicken-4")
 
-(chicken-bootstrap-prefix (get-environment-variable "CHICKEN_4_PREFIX"))
+(chicken-bootstrap-prefix (ensure-environment-variable "CHICKEN_4_PREFIX"))
 
 (skip-eggs
  (append '(async-io pledge spatial-trees)
diff --git a/conf/common/chicken-5.scm b/conf/common/chicken-5.scm
index b0ae38e..3b7580e 100644
--- a/conf/common/chicken-5.scm
+++ b/conf/common/chicken-5.scm
@@ -3,18 +3,21 @@
   (chicken-4
    (import chicken files))
   (chicken-5
-   (import (chicken pathname)
+   (import (chicken load)
+           (chicken pathname)
            (chicken platform)
            (chicken process-context)))
   (else
    (error "Unsupported CHICKEN version.")))
 
+(load-relative "./common.scm")
+
 (chicken-release 5)
 
-(chicken-bootstrap-prefix (get-environment-variable "CHICKEN_5_PREFIX"))
+(chicken-bootstrap-prefix (ensure-environment-variable "CHICKEN_5_PREFIX"))
 
 (salmonella-path
- (make-pathname (list (get-environment-variable "CHICKEN_5_PREFIX") "bin")
+ (make-pathname (list (chicken-bootstrap-prefix) "bin")
                 "salmonella"))
 
 (case (software-version)
diff --git a/conf/common/common.scm b/conf/common/common.scm
index d360a68..6985438 100644
--- a/conf/common/common.scm
+++ b/conf/common/common.scm
@@ -11,12 +11,19 @@
   (else
    (error "Unsupported CHICKEN version.")))
 
+(define (ensure-environment-variable var)
+  (let ((val (get-environment-variable var)))
+    (or val
+        (error 'ensure-environment-variable
+               "Environment variable is not set"
+               var))))
+
 (keep-repo? #t)
 
 (compress-report? #f)
 (create-report-tarball 'gzip)
 
-(web-dir (get-environment-variable "SALMONELLA_REPORTS_DIR"))
+(web-dir (ensure-environment-variable "SALMONELLA_REPORTS_DIR"))
 
 (feeds-server
  (sprintf "salmonella-~a-~a.call-cc.org"
Trap