forked from code-golf/code-golf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-langs
executable file
·81 lines (62 loc) · 2.11 KB
/
build-langs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash -e
declare -A urls=(
["bash"]="//www.gnu.org/software/bash/"
["haskell"]="//www.haskell.org/ghc/"
["j"]="http://jsoftware.com"
["javascript"]="//v8.dev"
["julia"]="//julialang.org"
["lisp"]="//clisp.sourceforge.io"
["lua"]="//www.lua.org"
["perl"]="//www.perl.org"
["perl6"]="//perl6.org"
["php"]="//secure.php.net"
["python"]="//www.python.org"
["ruby"]="//www.ruby-lang.org"
)
docker pull alpine:edge
cd containers
for name in Bash Haskell J JavaScript Julia Lisp Lua Perl Perl\ 6 PHP Python Ruby; do
lang=${name,,} # lowercase
lang=${lang// /} # trim space
# Start with a clean rootfs.
rm -rf $lang/rootfs
mkdir $lang/rootfs
# Tag the builder stage so "docker system prune" won't remove it.
if [ $lang != haskell ]; then
docker build --target builder -t code-golf-$lang-builder $lang
fi
docker build -t code-golf-$lang $lang
if [ $lang = j ]; then
ver=`echo echo JLIB | docker run --rm --tmpfs /tmp -i code-golf-j`
else
ver=`docker run --rm code-golf-$lang`
fi
# Remove some crap from version strings.
ver=${ver#Lua }
ver=${ver#The Glorious }
ver=${ver#This is }
ver=${ver#JavaScript-C}
ver=${ver/ation/er}
ver=${ver/built /}
ver=${ver/System, /}
ver=${ver//$'\n'/ }
ver=${ver//version /}
ver=${ver%.}
ver=${ver% d8> }
ver=${ver% Copyright (C) 1994-2018 Lua.org, PUC-Rio}
ver=${ver/ (*/}
html+="<tr><th class=$lang>$name<td>$ver<td><a href=${urls[$lang]}></a>"
id=`docker run -d code-golf-$lang`
docker export $id | tar -C $lang/rootfs -xf -
docker rm -f $id
# Remove the crap we gained from running the container, this is hacky.
rm -fr $lang/rootfs/{.dockerenv,dev,etc,proc,sys,tmp}
mkdir $lang/rootfs/{old-root,proc,tmp}
# Lisp & Python need UIDs to actually resolve, madness!
if [ $lang = lisp -o $lang = python ]; then
mkdir $lang/rootfs/etc
echo nobody:x:99:99::/: > $lang/rootfs/etc/passwd
fi
done
echo "package routes
const versionTable = \"$html\"" > ../routes/versions.go