-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_linux.go
43 lines (37 loc) · 1.55 KB
/
setup_linux.go
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
package main
import (
"strings"
"path"
"os"
)
func setupRuntime(dir string) string {
root := path.Join(dir, "runtime", "lib", "ruby")
ruby := path.Join(root, "bin.real", "ruby")
version := "2.1.0"
arch := "x86_64-linux"
os.Setenv("RUNX_LD_LIBRARY_PATH", os.Getenv("LD_LIBRARY_PATH"))
os.Setenv("RUNX_SSL_CERT_DIR", os.Getenv("SSL_CERT_DIR"))
os.Setenv("RUNX_SSL_CERT_FILE", os.Getenv("SSL_CERT_FILE"))
os.Setenv("RUNX_RUBYOPT", os.Getenv("RUBYOPT"))
os.Setenv("RUNX_RUBYLIB", os.Getenv("RUBYLIB"))
os.Setenv("RUNX_GEM_HOME", os.Getenv("GEM_HOME"))
os.Setenv("RUNX_GEM_PATH", os.Getenv("GEM_PATH"))
os.Setenv("LD_LIBRARY_PATH", os.Getenv("LD_LIBRARY_PATH") + ":" + path.Join(root, "lib"))
os.Unsetenv("SSL_CERT_DIR")
os.Setenv("SSL_CERT_FILE", path.Join(root, "lib", "ca-bundle.crt"))
os.Setenv("RUBYOPT", "-r" + path.Join(root, "lib", "restore_environment"))
os.Setenv("GEM_HOME", path.Join(root, "lib", "ruby", "gems", version))
os.Setenv("GEM_PATH", path.Join(root, "lib", "ruby", "gems", version))
rubyLib := strings.Join([]string{
path.Join(root, "lib", "ruby", "site_ruby", version),
path.Join(root, "lib", "ruby", "site_ruby", version, arch),
path.Join(root, "lib", "ruby", "site_ruby"),
path.Join(root, "lib", "ruby", "vendor_ruby", version),
path.Join(root, "lib", "ruby", "vendor_ruby", version, arch),
path.Join(root, "lib", "ruby", "vendor_ruby"),
path.Join(root, "lib", "ruby", version),
path.Join(root, "lib", "ruby", version, arch),
}, ":")
os.Setenv("RUBYLIB", rubyLib)
return ruby
}