OILS / soil / common.sh View on Github | oilshell.org

74 lines, 48 significant
1# Common functions for soil/
2
3# Include guard.
4test -n "${__SOIL_COMMON_SH:-}" && return
5readonly __SOIL_COMMON_SH=1
6
7log() {
8 echo "$@" 1>&2
9}
10
11log-context() {
12 local label=$1
13
14 log ''
15 log "$label: running as user '$(whoami)' on host '$(hostname)' in dir $PWD"
16 log ''
17}
18
19dump-env() {
20 env | grep -v '^encrypted_' | sort
21}
22
23if true; then
24 readonly SOIL_USER='travis_admin'
25 readonly SOIL_HOST='travis-ci.oilshell.org'
26 readonly SOIL_HOST_DIR=~/travis-ci.oilshell.org # used on server
27 readonly SOIL_REMOTE_DIR=travis-ci.oilshell.org # used on client
28else
29 readonly SOIL_USER='oils'
30 readonly SOIL_HOST='mb.oils.pub'
31 # Extra level
32 readonly SOIL_HOST_DIR=~/www/mb.oils.pub # used on server
33 readonly SOIL_REMOTE_DIR=www/travis-ci.oilshell.org # used on client
34fi
35
36readonly SOIL_USER_HOST="$SOIL_USER@$SOIL_HOST"
37
38html-head() {
39 # TODO: Shebang line should chang ecahnge to
40 PYTHONPATH=. python3 doctools/html_head.py "$@"
41}
42
43# NOTE: soil-html-head and table-sort-html-head are distinct, because they
44# collide with <td> styling and so forth
45
46soil-html-head() {
47 local title="$1"
48 local web_base_url=${2:-'/web'}
49
50 html-head --title "$title" \
51 "$web_base_url/base.css?cache=0" "$web_base_url/soil.css?cache=0"
52}
53
54table-sort-html-head() {
55 local title="$1"
56 local web_base_url=${2:-'/web'}
57
58 html-head --title "$title" \
59 "$web_base_url/base.css?cache=0" \
60 "$web_base_url/ajax.js?cache=0" \
61 "$web_base_url/table/table-sort.css?cache=0" "$web_base_url/table/table-sort.js?cache=0"
62}
63
64git-commit-dir() {
65 local prefix=$1
66
67 local commit_hash
68 # written by save-metadata in soil/worker.sh
69 commit_hash=$(cat _tmp/soil/commit-hash.txt)
70
71 local git_commit_dir="travis-ci.oilshell.org/${prefix}jobs/git-$commit_hash"
72
73 echo $git_commit_dir
74}