"os/exec"
"os/user"
"path/filepath"
+ "regexp"
"runtime"
"strconv"
"strings"
const goversion = "1.20.6"
const (
- rubyversion = "3.2.2"
+ defaultRubyVersion = "3.2.2"
bundlerversion = "2.2.19"
singularityversion = "3.10.4"
pjsversion = "1.9.8"
type installCommand struct {
ClusterType string
SourcePath string
+ Commit string
PackageVersion string
+ RubyVersion string
EatMyData bool
}
versionFlag := flags.Bool("version", false, "Write version information to stdout and exit 0")
flags.StringVar(&inst.ClusterType, "type", "production", "cluster `type`: development, test, production, or package")
flags.StringVar(&inst.SourcePath, "source", "/arvados", "source tree location (required for -type=package)")
+ flags.StringVar(&inst.Commit, "commit", "", "source commit `hash` to embed (blank means use 'git log' or all-zero placeholder)")
flags.StringVar(&inst.PackageVersion, "package-version", "0.0.0", "version string to embed in executable files")
+ flags.StringVar(&inst.RubyVersion, "ruby-version", defaultRubyVersion, "Ruby `version` to install (do not override in production mode)")
flags.BoolVar(&inst.EatMyData, "eatmydata", false, "use eatmydata to speed up install")
if ok, code := cmd.ParseFlags(flags, prog, args, "", stderr); !ok {
return cmd.Version.RunCommand(prog, args, stdin, stdout, stderr)
}
+ if inst.Commit == "" {
+ if commit, err := exec.Command("env", "-C", inst.SourcePath, "git", "log", "-n1", "--format=%H").CombinedOutput(); err == nil {
+ inst.Commit = strings.TrimSpace(string(commit))
+ } else {
+ inst.Commit = "0000000000000000000000000000000000000000"
+ }
+ }
+
var dev, test, prod, pkg bool
switch inst.ClusterType {
case "development":
return 1
}
+ if ok, _ := regexp.MatchString(`^\d\.\d+\.\d+$`, inst.RubyVersion); !ok {
+ fmt.Fprintf(stderr, "invalid argument %q for -ruby-version\n", inst.RubyVersion)
+ return 64
+ }
+
osv, err := identifyOS()
if err != nil {
return 1
return 1
}
}
- rubymajorversion := rubyversion[:strings.LastIndex(rubyversion, ".")]
- if haverubyversion, err := exec.Command("/var/lib/arvados/bin/ruby", "-v").CombinedOutput(); err == nil && bytes.HasPrefix(haverubyversion, []byte("ruby "+rubyversion)) {
- logger.Print("ruby " + rubyversion + " already installed")
+ rubyminorversion := inst.RubyVersion[:strings.LastIndex(inst.RubyVersion, ".")]
+ if haverubyversion, err := exec.Command("/var/lib/arvados/bin/ruby", "-v").CombinedOutput(); err == nil && bytes.HasPrefix(haverubyversion, []byte("ruby "+inst.RubyVersion)) {
+ logger.Print("ruby " + inst.RubyVersion + " already installed")
} else {
err = inst.runBash(`
+rubyversion="`+inst.RubyVersion+`"
+rubyminorversion="`+rubyminorversion+`"
tmp="$(mktemp -d)"
trap 'rm -r "${tmp}"' ERR EXIT
-wget --progress=dot:giga -O- https://cache.ruby-lang.org/pub/ruby/`+rubymajorversion+`/ruby-`+rubyversion+`.tar.gz | tar -C "${tmp}" -xzf -
-cd "${tmp}/ruby-`+rubyversion+`"
+wget --progress=dot:giga -O- "https://cache.ruby-lang.org/pub/ruby/$rubyminorversion/ruby-$rubyversion.tar.gz" | tar -C "${tmp}" -xzf -
+cd "${tmp}/ruby-$rubyversion"
./configure --disable-install-static-library --enable-shared --disable-install-doc --prefix /var/lib/arvados
make -j8
-make install <(yes || true)
-/var/lib/arvados/bin/gem update --no-document --system 3.4.21
+rm -f /var/lib/arvados/bin/erb
+make install
+if [[ "$rubyversion" > "3" ]]; then
+ /var/lib/arvados/bin/gem update --no-document --system 3.4.21
+fi
/var/lib/arvados/bin/gem install bundler --no-document
`, stdout, stderr)
if err != nil {
// container using a non-root-owned git tree
// mounted from the host -- as in
// "arvados-package build".
- cmd := exec.Command("go", "install", "-buildvcs=false", "-ldflags", "-X git.arvados.org/arvados.git/lib/cmd.version="+inst.PackageVersion+" -X main.version="+inst.PackageVersion+" -s -w")
+ cmd := exec.Command("go", "install", "-buildvcs=false",
+ "-ldflags", "-s -w"+
+ " -X git.arvados.org/arvados.git/lib/cmd.version="+inst.PackageVersion+
+ " -X git.arvados.org/arvados.git/lib/cmd.commit="+inst.Commit)
cmd.Env = append(cmd.Env, os.Environ()...)
cmd.Env = append(cmd.Env, "GOBIN=/var/lib/arvados/bin")
cmd.Dir = filepath.Join(inst.SourcePath, srcdir)
tmp=/var/lib/arvados/tmp/python
python3 -m venv "$v"
. "$v/bin/activate"
-pip3 install --no-cache-dir 'setuptools>=62.4.0' 'pip>=7'
+pip3 install --no-cache-dir 'setuptools>=68' 'pip>=20'
export ARVADOS_BUILDING_VERSION="`+inst.PackageVersion+`"
for src in "`+inst.SourcePath+`/sdk/python" "`+inst.SourcePath+`/services/fuse"; do
rsync -a --delete-after "$src/" "$tmp/"
// BUILD_PATH=/var/lib/arvados/workbench2) instead of
// using two rsync steps here.
if err = inst.runBash(`
+src="`+inst.SourcePath+`/services/workbench2"
tmp=/var/lib/arvados/tmp/workbench2
trap "rm -r ${tmp}" ERR EXIT
-rsync -a --delete-after `+inst.SourcePath+`/services/workbench2/ "$tmp/"
-env -C "$tmp" VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT=000000000 yarn build
-rsync -a --delete-after "$tmp/build/" /var/lib/arvados/workbench2/
+dst=/var/lib/arvados/workbench2
+rsync -a --delete-after "$src/" "$tmp/"
+env -C "$tmp" VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT="`+inst.Commit[:9]+`" yarn build
+rsync -a --delete-after "$tmp/build/" "$dst/"
`, stdout, stderr); err != nil {
return 1
}