mirror of
https://github.com/wahyd4/gvm.git
synced 2026-08-10 05:16:13 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23d74d510f | ||
|
|
cd26aff6f9 | ||
|
|
498fbe8ad3 | ||
|
|
aa144d900a | ||
|
|
2ad422375d | ||
|
|
e383017680 | ||
|
|
f987a3628c | ||
|
|
a19aa82656 | ||
|
|
310a36ced1 | ||
|
|
25ea8ae158 | ||
|
|
20fe6c5214 | ||
|
|
680e356630 | ||
|
|
f7916c90b4 | ||
|
|
2feeac7454 | ||
|
|
725bc293b2 | ||
|
|
98c36fedb9 | ||
|
|
f62c61ec5c | ||
|
|
8b7e848371 | ||
|
|
604e702e2a | ||
|
|
595852af11 | ||
|
|
e34bbfc017 | ||
|
|
707e5de0ba | ||
|
|
ff81688ece | ||
|
|
5366dd903d | ||
|
|
d32b62bf31 | ||
|
|
e66076be0d | ||
|
|
bba42f81f9 | ||
|
|
7fd2678da2 | ||
|
|
9cf079ba24 | ||
|
|
4231e20b6a | ||
|
|
670008ebb9 | ||
|
|
ece4351a6b | ||
|
|
d1db113a52 | ||
|
|
c6850e273a | ||
|
|
ccbb978c9a | ||
|
|
e1ea0e745f | ||
|
|
121663b898 | ||
|
|
f2a28de3cf | ||
|
|
b5144138b0 | ||
|
|
9bc84bc286 | ||
|
|
e5a06b52c7 | ||
|
|
51d149771f | ||
|
|
eb61d9dbd0 | ||
|
|
7fc9e0ef22 | ||
|
|
03d7843f69 | ||
|
|
ac17654314 | ||
|
|
dff56e69df | ||
|
|
fb0881a609 | ||
|
|
ae439a3560 | ||
|
|
f9b3d1699d | ||
|
|
b3ac750c04 | ||
|
|
112dfaac37 | ||
|
|
a71029eaa4 | ||
|
|
78e2e80d40 | ||
|
|
9a9aab4b12 | ||
|
|
38dfba78b8 | ||
|
|
3ffc794bc5 | ||
|
|
b914f5a6b3 | ||
|
|
3d465f0ead | ||
|
|
4ce01e1e16 | ||
|
|
a5ade13862 | ||
|
|
e06e446acf | ||
|
|
53fff83811 | ||
|
|
fa0f1b4d57 | ||
|
|
5ba804665d | ||
|
|
6b75a19639 | ||
|
|
739557089b | ||
|
|
99876c1786 | ||
|
|
cf394bb42c | ||
|
|
3ecd74b96e | ||
|
|
35d369dfd3 | ||
|
|
f43320ec82 | ||
|
|
1921cd7f0a | ||
|
|
97611a42eb | ||
|
|
f392f564c6 | ||
|
|
eaf768b7d1 | ||
|
|
22dc137459 | ||
|
|
c6527574be | ||
|
|
8954a3cb39 |
@@ -7,3 +7,5 @@ environments/
|
||||
tmp/
|
||||
*.log
|
||||
scripts/gvm
|
||||
Gemfile.lock
|
||||
.vagrant/
|
||||
|
||||
+7
-2
@@ -1,7 +1,12 @@
|
||||
language: c
|
||||
os: [linux, osx]
|
||||
osx_image: mavericks
|
||||
env:
|
||||
global:
|
||||
- SRC_REPO=$TRAVIS_BUILD_DIR
|
||||
- GVM_NO_GIT_BAK=1
|
||||
- GVM_NO_UPDATE_PROFILE=1
|
||||
before_install:
|
||||
- "binscripts/gvm-installer $TRAVIS_COMMIT $TRAVIS_BUILD_DIR/tmp"
|
||||
- binscripts/gvm-installer $TRAVIS_COMMIT $TRAVIS_BUILD_DIR/tmp
|
||||
install: gem install tf -v '>=0.4.1'
|
||||
script: source $TRAVIS_BUILD_DIR/tmp/gvm/scripts/gvm; tf --text tests/*
|
||||
script: source $TRAVIS_BUILD_DIR/tmp/gvm/scripts/gvm; rake default scenario
|
||||
|
||||
@@ -25,6 +25,8 @@ To install:
|
||||
|
||||
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
|
||||
|
||||
Or if you are using zsh just change `bash` with `zsh`
|
||||
|
||||
Installing Go
|
||||
=============
|
||||
gvm install go1
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
# gvm
|
||||
|
||||
[](https://travis-ci.org/moovweb/gvm)
|
||||
# gvm-cn
|
||||
|
||||
by Josh Bussdieker (jbuss, jaja, jbussdieker)
|
||||
|
||||
GVM provides an interface to manage Go versions.
|
||||
|
||||
说明
|
||||
========
|
||||
该版本使用github的源代码,解决在中国国内不能使用gvm安装Go的问题
|
||||
|
||||
Features
|
||||
========
|
||||
* Install/Uninstall Go versions with `gvm install [tag]` where tag is "60.3", "go1", "weekly.2011-11-08", or "tip"
|
||||
@@ -26,12 +28,14 @@ Installing
|
||||
|
||||
To install:
|
||||
|
||||
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
|
||||
bash < <(curl -s -S -L https://raw.githubusercontent.com/wahyd4/gvm/master/binscripts/gvm-installer)
|
||||
|
||||
Or if you are using zsh just change `bash` with `zsh`
|
||||
|
||||
Installing Go
|
||||
=============
|
||||
gvm install go1
|
||||
gvm use go1 [--default]
|
||||
gvm install go1.4
|
||||
gvm use go1.4 [--default]
|
||||
Once this is done Go will be in the path and ready to use. $GOROOT and $GOPATH are set automatically.
|
||||
|
||||
Additional options can be specified when installing Go:
|
||||
@@ -42,7 +46,19 @@ Additional options can be specified when installing Go:
|
||||
-pb, --with-protobuf Install Go protocol buffers.
|
||||
-b, --with-build-tools Install package build tools.
|
||||
-B, --binary Only install from binary.
|
||||
--prefer-binary Attempt a binary install, falling back to source.
|
||||
-h, --help Display this message.
|
||||
|
||||
### A Note on Compiling Go 1.5
|
||||
Go 1.5+ removed the C compilers from the toolchain and [replaced][compiler_note] them with one written in Go. Obviously, this creates a bootstrapping problem if you don't already have a working Go install. In order to compile Go 1.5+, make sure Go 1.4 is installed first.
|
||||
|
||||
```
|
||||
gvm install go1.4
|
||||
gvm use go1.4
|
||||
gvm install go1.5
|
||||
```
|
||||
|
||||
[compiler_note]: https://docs.google.com/document/d/1OaatvGhEAq7VseQ9kkavxKNAfepWy2yhPUBs96FGV28/edit
|
||||
|
||||
List Go Versions
|
||||
================
|
||||
@@ -50,6 +66,10 @@ To list all installed Go versions (The current version is prefixed with "=>"):
|
||||
|
||||
gvm list
|
||||
|
||||
To list all Go versions available for download:
|
||||
|
||||
gvm listall
|
||||
|
||||
Uninstalling
|
||||
============
|
||||
To completely remove gvm and all installed Go versions and packages:
|
||||
@@ -68,14 +88,7 @@ Linux Requirements
|
||||
|
||||
Debian/Ubuntu
|
||||
==================
|
||||
sudo apt-get install curl
|
||||
sudo apt-get install git
|
||||
sudo apt-get install mercurial
|
||||
sudo apt-get install make
|
||||
sudo apt-get install binutils
|
||||
sudo apt-get install bison
|
||||
sudo apt-get install gcc
|
||||
sudo apt-get install build-essential
|
||||
sudo apt-get install curl git mercurial make binutils bison gcc build-essential
|
||||
|
||||
Redhat/Centos
|
||||
==================
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
require 'tmpdir'
|
||||
|
||||
def root_path
|
||||
File.expand_path('../.', __FILE__)
|
||||
end
|
||||
|
||||
def commit
|
||||
@commit ||= (
|
||||
ENV['TRAVIS_COMMIT'] || `git rev-parse --abbrev-ref HEAD`.chomp
|
||||
)
|
||||
end
|
||||
|
||||
task :default do
|
||||
Dir.mktmpdir('gvm-test') do |tmpdir|
|
||||
system(<<-EOSH) || fail
|
||||
bash -c '
|
||||
set -e
|
||||
#{root_path}/binscripts/gvm-installer #{commit} #{tmpdir}
|
||||
source #{tmpdir}/gvm/scripts/gvm
|
||||
tf --text #{tmpdir}/gvm/tests/*.sh
|
||||
'
|
||||
EOSH
|
||||
end
|
||||
end
|
||||
|
||||
task :scenario do
|
||||
Dir["#{root_path}/tests/scenario/*_comment_test.sh"].each do |test|
|
||||
name = File.basename(test)
|
||||
puts "Running scenario #{name}..."
|
||||
Dir.mktmpdir('gvm-test') do |tmpdir|
|
||||
system(<<-EOSH) || fail
|
||||
bash -c '
|
||||
set -e
|
||||
#{root_path}/binscripts/gvm-installer #{commit} #{tmpdir}
|
||||
source #{tmpdir}/gvm/scripts/gvm
|
||||
tf --text #{tmpdir}/gvm/tests/scenario/#{name}
|
||||
'
|
||||
EOSH
|
||||
end
|
||||
end
|
||||
end
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.define "precise32" do |ubuntu|
|
||||
ubuntu.vm.box = "hashicorp/precise32"
|
||||
end
|
||||
|
||||
config.vm.define "precise64" do |ubuntu|
|
||||
ubuntu.vm.box = "hashicorp/precise64"
|
||||
end
|
||||
end
|
||||
@@ -34,9 +34,7 @@ else
|
||||
if [ -f "$GVM_ROOT/scripts/$command" ]; then
|
||||
shift
|
||||
"$GVM_ROOT/scripts/$command" "$@"
|
||||
elif [[ -n $command ]]; then
|
||||
display_fatal "Unrecognized command line argument: '$command'"
|
||||
else
|
||||
elif [[ -z $command || $command = help ]]; then
|
||||
echo "Usage: gvm [command]
|
||||
|
||||
Description:
|
||||
@@ -45,8 +43,9 @@ Description:
|
||||
Commands:
|
||||
version - print the gvm version number
|
||||
get - gets the latest code (for debugging)
|
||||
use - select a go version to use
|
||||
use - select a go version to use (--default to set permanently)
|
||||
diff - view changes to Go root
|
||||
help - display this usage text
|
||||
implode - completely remove gvm
|
||||
install - install go versions
|
||||
uninstall - uninstall go versions
|
||||
@@ -58,5 +57,7 @@ Commands:
|
||||
pkgset - manage go packages sets
|
||||
pkgenv - edit the environment for a package set
|
||||
"
|
||||
else
|
||||
display_fatal "Unrecognized command line argument: '$command'"
|
||||
fi
|
||||
fi
|
||||
|
||||
+16
-14
@@ -11,15 +11,15 @@ display_error() {
|
||||
update_profile() {
|
||||
[ -f "$1" ] || return 1
|
||||
|
||||
grep "$source_line" "$1" > /dev/null 2>&1
|
||||
grep -F "$source_line" "$1" > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$source_line" >> "$1"
|
||||
echo -e "\n$source_line" >> "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
check_existing_go() {
|
||||
|
||||
if [ "$GOROOT" == "" ]; then
|
||||
if [ "$GOROOT" = "" ]; then
|
||||
if which go > /dev/null; then
|
||||
GOROOT=$(go env | grep GOROOT | cut -d"=" -f2)
|
||||
else
|
||||
@@ -38,14 +38,14 @@ export gvm_go_name; gvm_go_name="system"
|
||||
export gvm_pkgset_name; gvm_pkgset_name="global"
|
||||
export GOROOT; GOROOT="$GOROOT"
|
||||
export GOPATH; GOPATH="$GVM_DEST/$GVM_NAME/pkgsets/system/global"
|
||||
export PATH; PATH="$GVM_DEST/$GVM_NAME/pkgsets/system/global:$GOROOT/bin:$GVM_ROOT/bin:\$PATH"
|
||||
export PATH; PATH="$GVM_DEST/$GVM_NAME/pkgsets/system/global/bin:$GOROOT/bin:$GVM_ROOT/bin:\$PATH"
|
||||
EOF
|
||||
}
|
||||
|
||||
BRANCH=${1:-master}
|
||||
GVM_DEST=${2:-$HOME}
|
||||
GVM_NAME="gvm"
|
||||
SRC_REPO=${SRC_REPO:-https://github.com/moovweb/gvm.git}
|
||||
SRC_REPO=${SRC_REPO:-https://github.com/wahyd4/gvm.git}
|
||||
|
||||
[ "$GVM_DEST" = "$HOME" ] && GVM_NAME=".gvm"
|
||||
|
||||
@@ -60,7 +60,7 @@ SRC_REPO=${SRC_REPO:-https://github.com/moovweb/gvm.git}
|
||||
|
||||
# Is gvm-installer being called from the origin repo?
|
||||
# If so, skip the clone and source locally!
|
||||
# This prevents, the CI to break on non-merge commits
|
||||
# This prevents CI from breaking on non-merge commits.
|
||||
|
||||
GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
|
||||
@@ -87,20 +87,22 @@ cd "$GVM_DEST/$GVM_NAME" && git checkout --quiet "$BRANCH" 2> /dev/null || displ
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
mv "$GVM_DEST/$GVM_NAME/.git" "$GVM_DEST/$GVM_NAME/git.bak"
|
||||
[ -z "$GVM_NO_GIT_BAK" ] && mv "$GVM_DEST/$GVM_NAME/.git" "$GVM_DEST/$GVM_NAME/git.bak"
|
||||
|
||||
source_line="[[ -s \"${GVM_DEST}/$GVM_NAME/scripts/gvm\" ]] && source \"${GVM_DEST}/$GVM_NAME/scripts/gvm\""
|
||||
source_file="${GVM_DEST}/$GVM_NAME/scripts/gvm"
|
||||
|
||||
if [ -n "$ZSH_NAME" ]; then
|
||||
update_profile "$HOME/.zshrc"
|
||||
elif [ "$(uname)" == "Linux" ]; then
|
||||
update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile"
|
||||
elif [ "$(uname)" == "Darwin" ]; then
|
||||
update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile"
|
||||
if [ -z "$GVM_NO_UPDATE_PROFILE" ] ; then
|
||||
if [ -n "$ZSH_NAME" ]; then
|
||||
update_profile "$HOME/.zshrc"
|
||||
elif [ "$(uname)" == "Linux" ]; then
|
||||
update_profile "$HOME/.bashrc" || update_profile "$HOME/.bash_profile"
|
||||
elif [ "$(uname)" == "Darwin" ]; then
|
||||
update_profile "$HOME/.profile" || update_profile "$HOME/.bash_profile"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
if [ -z "$GVM_NO_UPDATE_PROFILE" ] && [ "$?" != "0" ]; then
|
||||
echo "Unable to locate profile settings file(Something like $HOME/.bashrc or $HOME/.bash_profile)"
|
||||
echo
|
||||
echo " You will have to manually add the following line:"
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
/vagrant/extra/vagrant/install-deps.sh
|
||||
/vagrant/extra/vagrant/install-local.sh
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
sudo apt-get -y install curl git mercurial bison make
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
rm -rf /home/vagrant/.gvm
|
||||
cp -r /vagrant /home/vagrant/.gvm
|
||||
echo "export GVM_ROOT=/vagrant
|
||||
. \$GVM_ROOT/scripts/gvm-default" > /home/vagrant/.gvm/scripts/gvm
|
||||
echo ". /home/vagrant/.gvm/scripts/gvm"
|
||||
@@ -2,10 +2,10 @@
|
||||
. "$GVM_ROOT/scripts/functions"
|
||||
|
||||
[[ $1 != "" ]] ||
|
||||
display_fatal "Please specifiy the alias name"
|
||||
display_fatal "Please specify the alias name"
|
||||
|
||||
[[ $2 != "" ]] ||
|
||||
display_fatal "Please specifiy the go version name"
|
||||
display_fatal "Please specify the go version name"
|
||||
|
||||
[[ ! -f "$GVM_ROOT/environments/$1" ]] ||
|
||||
display_fatal "Alias already exists!"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
. "$GVM_ROOT/scripts/functions"
|
||||
|
||||
[[ $1 != "" ]] ||
|
||||
display_fatal "Please specifiy the name"
|
||||
display_fatal "Please specify the name"
|
||||
|
||||
[[ -f $GVM_ROOT/environments/$1 ]] ||
|
||||
display_fatal "Alias doesn't exist!"
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ _gvm()
|
||||
install)
|
||||
[ ! -d $GVM_ROOT/archive/go ] && return 1
|
||||
[[ $COMP_CWORD > 2 ]] && return 1
|
||||
local version="$(for x in `hg tags -R $GVM_ROOT/archive/go | awk '{print $1}' | $GREP_PATH -E "release|tip|go"`; do echo ${x} ; done )"
|
||||
local version="$(cd $GVM_ROOT/archive/go && for x in `git tag | $GREP_PATH -E "release|tip|go"`; do echo ${x} ; done )"
|
||||
COMPREPLY=( $(compgen -W "${version}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
|
||||
+15
-9
@@ -4,7 +4,7 @@
|
||||
display_usage() {
|
||||
display_message "Usage: gvm cross [os] [arch]"
|
||||
display_message " os = linux/darwin/windows"
|
||||
display_message " arch = amd64/386 (arm unsupported)"
|
||||
display_message " arch = amd64/386/arm"
|
||||
}
|
||||
|
||||
display_list() {
|
||||
@@ -25,13 +25,13 @@ which go &> /dev/null || display_fatal "Only available in versions after Go 1"
|
||||
[ -z "$1" ] && display_list
|
||||
|
||||
if [ ! -f "$GOROOT/pkg/tool/cross" ]; then
|
||||
display_message "Installing x86 and x86-64 commands"
|
||||
display_message "Installing x86, x86-64, and ARM commands"
|
||||
set -e
|
||||
for arch in 8 6; do
|
||||
for cmd in a c g l; do
|
||||
go tool dist install -v cmd/$arch$cmd ||
|
||||
display_fatal "Couldn't compile tool: $arch$cmd"
|
||||
done
|
||||
for arch in 8 6 5; do
|
||||
for cmd in a c g l; do
|
||||
go tool dist install -v cmd/$arch$cmd ||
|
||||
display_fatal "Couldn't compile tool: $arch$cmd"
|
||||
done
|
||||
done
|
||||
touch "$GOROOT/pkg/tool/cross"
|
||||
fi
|
||||
@@ -44,11 +44,17 @@ export GOARCH=$1
|
||||
if [ ! -d "$GOROOT/pkg/${GOOS}_${GOARCH}" ]; then
|
||||
display_message "Installing $GOOS $GOARCH runtime library"
|
||||
if [ "$GOOS" = "windows" ]; then
|
||||
export CGO_ENABLED=0
|
||||
export CGO_ENABLED=0
|
||||
fi
|
||||
|
||||
cd "$GOROOT/src"
|
||||
go tool dist install -v pkg/runtime ||
|
||||
if [ -d pkg/runtime ]; then
|
||||
runtime='pkg/runtime'
|
||||
else
|
||||
# Go 1.4 moved pkg/ up a level
|
||||
runtime='runtime'
|
||||
fi
|
||||
go tool dist install -v "$runtime" ||
|
||||
display_fatal "Couldn't compile runtime library for $GOOS $GOARCH"
|
||||
go install -v -a std ||
|
||||
display_fatal "Install runtime library for $GOOS $GOARCH"
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ function gvm_pkgset_use() {
|
||||
local LOCAL_TOP=$(find_local_pkgset)
|
||||
unset -f find_local_pkgset
|
||||
[[ -d $LOCAL_TOP ]] ||
|
||||
display_error "Caonnt find local pakcage set" || return 1
|
||||
display_error "Cannot find local package set" || return 1
|
||||
LOCAL_TOP=$LOCAL_TOP/.gvm_local
|
||||
|
||||
fuzzy_match=$($LS_PATH "$LOCAL_TOP/environments" | $SORT_PATH | $GREP_PATH "$gvm_go_name@" | $GREP_PATH "local" | $HEAD_PATH -n 1) ||
|
||||
|
||||
Vendored
+7
-2
@@ -1,12 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
function gvm_use() {
|
||||
if [[ "$1" == "-h" ]]; then
|
||||
display_message "Usage: gvm use VERSION [--default]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
[[ "$1" != "" ]] ||
|
||||
display_error "Please specifiy the version" || return 1
|
||||
display_error "Please specify the version" || return 1
|
||||
local VERSION=$1
|
||||
fuzzy_match=$($LS_PATH "$GVM_ROOT/gos" | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1")
|
||||
if [[ "$?" != "0" ]]; then
|
||||
GO_CACHE_PATH=$GVM_ROOT/archive/go
|
||||
version=$(hg tags -R "$GO_CACHE_PATH" | awk '{print $1}' | $SORT_PATH | $GREP_PATH "$VERSION" | $HEAD_PATH -n 1 | $GREP_PATH "$VERSION")
|
||||
version=$(cd "$GO_CACHE_PATH" && git tag -l "$VERSION")
|
||||
if [[ "x$version" == "x" ]]; then
|
||||
display_error "Version not found locally. Try 'gvm install $1'" || return 1
|
||||
else
|
||||
|
||||
@@ -9,3 +9,8 @@ GREP_PATH=$(unalias grep &> /dev/null; which grep) || display_error "$GREP_ERROR
|
||||
SORT_PATH=$(unalias sort &> /dev/null; which sort) || display_error "$SORT_ERROR" || return 1
|
||||
HEAD_PATH=$(unalias head &> /dev/null; which head) || display_error "$HEAD_ERROR" || return 1
|
||||
|
||||
GITHUB_REPO_URL=git@github.com:golang/go.git
|
||||
|
||||
repo_url() {
|
||||
return GITHUB_REPO_URL
|
||||
}
|
||||
+34
-14
@@ -1,37 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
. "$GVM_ROOT/scripts/functions"
|
||||
|
||||
# Check for hg
|
||||
which hg &> /dev/null ||
|
||||
display_warning "Could not find mercurial
|
||||
error_message=""
|
||||
|
||||
# Check for git
|
||||
which git &> /dev/null ||
|
||||
error_message="${error_message}
|
||||
Could not find git
|
||||
|
||||
linux: apt-get install mercurial
|
||||
mac: brew install mercurial
|
||||
" || exit 1
|
||||
"
|
||||
# Check for ar
|
||||
which ar &> /dev/null ||
|
||||
display_warning "Could not find binutils
|
||||
error_message="${error_message}
|
||||
Could not find binutils
|
||||
|
||||
linux: apt-get install binutils
|
||||
" || exit 1
|
||||
"
|
||||
# Check for bison
|
||||
which bison &> /dev/null ||
|
||||
display_warning "Could not find bison
|
||||
error_message="${error_message}
|
||||
Could not find bison
|
||||
|
||||
linux: apt-get install bison
|
||||
" || exit 1
|
||||
"
|
||||
# Check for gcc
|
||||
which gcc &> /dev/null ||
|
||||
display_warning "Could not find gcc
|
||||
error_message="${error_message}
|
||||
Could not find gcc
|
||||
|
||||
linux: apt-get install gcc
|
||||
" || exit 1
|
||||
"
|
||||
# Check for make
|
||||
which make &> /dev/null ||
|
||||
display_warning "Could not find make
|
||||
error_message="${error_message}
|
||||
Could not find make
|
||||
|
||||
linux: apt-get install make
|
||||
" || exit 1
|
||||
"
|
||||
# Check for curl
|
||||
which curl &> /dev/null ||
|
||||
error_message="${error_message}
|
||||
Could not find curl
|
||||
|
||||
# All good!
|
||||
exit 0
|
||||
linux: apt-get install curl
|
||||
mac: brew install curl
|
||||
"
|
||||
|
||||
if [ -n "$error_message" ]; then
|
||||
display_warning "$error_message"
|
||||
exit 1
|
||||
else
|
||||
# All good!
|
||||
exit 0
|
||||
fi
|
||||
|
||||
+93
-58
@@ -8,6 +8,7 @@ function show_usage() {
|
||||
echo " -pb, --with-protobuf Install Go protocol buffers."
|
||||
echo " -b, --with-build-tools Install package build tools."
|
||||
echo " -B, --binary Only install from binary."
|
||||
echo " --prefer-binary Attempt a binary install, falling back to source."
|
||||
echo " -h, --help Display this message."
|
||||
}
|
||||
|
||||
@@ -20,7 +21,7 @@ read_command_line() {
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
GO_SOURCE_URL=https://go.googlecode.com/hg/
|
||||
GO_SOURCE_URL=https://github.com/golang/go.git
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
-s=*|--source=*)
|
||||
@@ -38,6 +39,9 @@ read_command_line() {
|
||||
-B|--binary)
|
||||
INSTALL_SOURCE="binary"
|
||||
;;
|
||||
--prefer-binary)
|
||||
INSTALL_SOURCE="prefer-binary"
|
||||
;;
|
||||
-h|--help)
|
||||
show_usage
|
||||
exit 0
|
||||
@@ -55,35 +59,36 @@ download_source() {
|
||||
GO_CACHE_PATH=$GVM_ROOT/archive/go
|
||||
[[ -d $GO_CACHE_PATH ]] && return
|
||||
display_message "Downloading Go source..."
|
||||
hg clone "$GO_SOURCE_URL" "$GO_CACHE_PATH" >> "$GVM_ROOT/logs/go-download.log" 2>&1 ||
|
||||
display_fatal "Couldn't download Go source\nCheck the logs $GVM_ROOT/logs/go-download.log"
|
||||
git clone "$GO_SOURCE_URL" "$GO_CACHE_PATH" >> "$GVM_ROOT/logs/go-download.log" 2>&1 ||
|
||||
display_fatal "Couldn't download Go source. Check the logs $GVM_ROOT/logs/go-download.log"
|
||||
}
|
||||
|
||||
check_tag() {
|
||||
version=$(hg tags -R "$GO_CACHE_PATH" | awk '{print $1}' | $SORT_PATH | $GREP_PATH "$VERSION" | $HEAD_PATH -n 1 | $GREP_PATH -w "$VERSION")
|
||||
version=$(cd "$GO_CACHE_PATH" && git show-ref --heads --tags | awk -F/ '{ print $NF }' | $SORT_PATH | $GREP_PATH "$VERSION" | $HEAD_PATH -n 1 | $GREP_PATH -w "$VERSION")
|
||||
}
|
||||
|
||||
update_source() {
|
||||
display_message "Updating Go source..."
|
||||
hg pull -R "$GO_CACHE_PATH" >> "$GVM_ROOT/logs/go-download.log" 2>&1 ||
|
||||
display_fatal "Couldn't get latest Go version info\nCheck the logs $GVM_ROOT/logs/go-download.log"
|
||||
(cd "$GO_CACHE_PATH" && git pull >> "$GVM_ROOT/logs/go-download.log" 2>&1 ||
|
||||
display_fatal "Couldn't get latest Go version info. Check the logs $GVM_ROOT/logs/go-download.log")
|
||||
}
|
||||
|
||||
copy_source() {
|
||||
hg clone -u "$version" "$GO_CACHE_PATH" "$GO_INSTALL_ROOT" >> "$GVM_ROOT/logs/go-$GO_NAME-install.log" 2>&1 ||
|
||||
display_fatal "Couldn't copy source to target folder,\nCheck the logs $GVM_ROOT/logs/go-$GO_NAME-install.log"
|
||||
git clone -b "$version" "$GO_CACHE_PATH" "$GO_INSTALL_ROOT" >> "$GVM_ROOT/logs/go-$GO_NAME-install.log" 2>&1 ||
|
||||
display_fatal "Couldn't copy source to target folder. Check the logs $GVM_ROOT/logs/go-$GO_NAME-install.log"
|
||||
}
|
||||
|
||||
|
||||
compile_go() {
|
||||
display_message " * Compiling..."
|
||||
[ -z "$GOROOT_BOOTSTRAP" ] && export GOROOT_BOOTSTRAP=$GOROOT
|
||||
unset GOARCH && unset GOOS && unset GOPATH && unset GOBIN && unset GOROOT &&
|
||||
export GOBIN=$GO_INSTALL_ROOT/bin &&
|
||||
export PATH=$GOBIN:$PATH &&
|
||||
export GOROOT=$GO_INSTALL_ROOT &&
|
||||
#cd $GO_INSTALL_ROOT/src && ./all.bash &> $GVM_ROOT/logs/go-$GO_NAME-compile.log ||
|
||||
cd "$GO_INSTALL_ROOT/src" && ./make.bash &> "$GVM_ROOT/logs/go-$GO_NAME-compile.log" ||
|
||||
(rm -rf "$GO_INSTALL_ROOT" && display_fatal "Failed to compile\nCheck the logs at $GVM_ROOT/logs/go-$GO_NAME-compile.log")
|
||||
(rm -rf "$GO_INSTALL_ROOT" && display_fatal "Failed to compile. Check the logs at $GVM_ROOT/logs/go-$GO_NAME-compile.log")
|
||||
}
|
||||
|
||||
create_enviroment() {
|
||||
@@ -109,12 +114,12 @@ create_enviroment() {
|
||||
create_global_package_set() {
|
||||
# Create the global package set folder
|
||||
mkdir -p "$GVM_ROOT/pkgsets/$GO_NAME" >> "$GVM_ROOT/logs/go-$GO_NAME-install.log" 2>&1 ||
|
||||
display_fatal "Couldn't create global package set folder\nCheck the logs at ${GVM_ROOT}/logs/go-${GO_NAME}-install.log"
|
||||
display_fatal "Couldn't create global package set folder. Check the logs at ${GVM_ROOT}/logs/go-${GO_NAME}-install.log"
|
||||
GVM_OVERLAY_ROOT="${GVM_ROOT}/pkgsets/${GO_NAME}/global/overlay"
|
||||
mkdir -p "${GVM_OVERLAY_ROOT}/lib/pkgconfig" >> "${GVM_ROOT}/logs/go-${GO_NAME}-install.log" 2>&1 ||
|
||||
display_fatal "Couldn't create global overlay library directory\nCheck the logs at ${GVM_ROOT}/logs/go-${GO_NAME}-install.log"
|
||||
display_fatal "Couldn't create global overlay library directory. Check the logs at ${GVM_ROOT}/logs/go-${GO_NAME}-install.log"
|
||||
mkdir -p "${GVM_OVERLAY_ROOT}/bin" >> "${GVM_ROOT}/logs/go-${GO_NAME}-install.log" 2>&1 ||
|
||||
display_fatal "Couldn't create global overlay bin directory\nCheck the logs at ${GVM_ROOT}/logs/go-${GO_NAME}-install.log"
|
||||
display_fatal "Couldn't create global overlay bin directory. Check the logs at ${GVM_ROOT}/logs/go-${GO_NAME}-install.log"
|
||||
}
|
||||
|
||||
install_go() {
|
||||
@@ -141,6 +146,8 @@ install_go() {
|
||||
copy_source
|
||||
compile_go
|
||||
create_enviroment
|
||||
|
||||
display_message "$GO_NAME successfully installed!"
|
||||
}
|
||||
|
||||
download_binary() {
|
||||
@@ -148,28 +155,46 @@ download_binary() {
|
||||
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
GVM_OS="darwin"
|
||||
osx_major_version="$(sw_vers -productVersion | cut -d "." -f 2)"
|
||||
if [ "${osx_major_version}" -ge 8 ]; then
|
||||
GVM_OS_VERSION="-osx10.8"
|
||||
elif [ "${osx_major_version}" -ge 6 ]; then
|
||||
GVM_OS_VERSION="-osx10.6"
|
||||
else
|
||||
display_error "Binary Go unavailable for this platform"
|
||||
rm -rf $GO_INSTALL_ROOT
|
||||
rm -f $GO_BINARY_PATH
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
GVM_OS="linux"
|
||||
GVM_OS="linux"
|
||||
fi
|
||||
|
||||
if [ "$(uname -m)" == "x86_64" ]; then
|
||||
GVM_ARCH="amd64"
|
||||
GVM_ARCH="amd64"
|
||||
else
|
||||
GVM_ARCH="386"
|
||||
GVM_ARCH="386"
|
||||
fi
|
||||
|
||||
GO_BINARY_FILE=${VERSION}.${GVM_OS}-${GVM_ARCH}.tar.gz
|
||||
GO_BINARY_URL="https://storage.googleapis.com/golang/${GO_BINARY_FILE}"
|
||||
GO_BINARY_FILE=${VERSION}.${GVM_OS}-${GVM_ARCH}${GVM_OS_VERSION}.tar.gz
|
||||
GO_BINARY_URL="http://golang.org/dl/${GO_BINARY_FILE}"
|
||||
GO_BINARY_PATH=${GVM_ROOT}/archive/${GO_BINARY_FILE}
|
||||
|
||||
if [ ! -f $GO_BINARY_PATH ]; then
|
||||
curl -s -f -L $GO_BINARY_URL > ${GO_BINARY_PATH}
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_error "Failed to download binary go"
|
||||
rm -rf $GO_INSTALL_ROOT
|
||||
rm -f $GO_BINARY_PATH
|
||||
exit 1
|
||||
display_error "Failed to download binary go from http://golang.org. Trying https://go.googlecode.com"
|
||||
GO_BINARY_URL="https://go.googlecode.com/files/${GO_BINARY_FILE}"
|
||||
|
||||
curl -s -f -L $GO_BINARY_URL > ${GO_BINARY_PATH}
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_error "Failed to download binary go"
|
||||
rm -rf $GO_INSTALL_ROOT
|
||||
rm -f $GO_BINARY_PATH
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -224,67 +249,77 @@ install_goprotobuf() {
|
||||
if [[ "$GVM_GOINSTALL" == "goinstall" ]]; then
|
||||
$GVM_GOINSTALL goprotobuf.googlecode.com/hg/proto > "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_warning "Failed to install goprotobuf\nCheck the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
display_warning "Failed to install goprotobuf. Check the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
return 1
|
||||
fi
|
||||
cd "$GVM_ROOT/gos/$GO_NAME/src/pkg/goprotobuf.googlecode.com/hg/compiler"
|
||||
make install >> "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_warning "Failed to install goprotobuf compiler\nCheck the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
display_warning "Failed to install goprotobuf compiler. Check the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
$GVM_GOINSTALL code.google.com/p/goprotobuf/proto > "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
|
||||
$GVM_GOINSTALL github.com/golang/protobuf > "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_warning "Failed to install goprotobuf\nCheck the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
display_warning "Failed to install goprotobuf. Check the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
return 1
|
||||
fi
|
||||
$GVM_GOINSTALL code.google.com/p/goprotobuf/protoc-gen-go > "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
|
||||
$GVM_GOINSTALL github.com/golang/protobuf > "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_warning "Failed to install goprotobuf compiler\nCheck the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
display_warning "Failed to install goprotobuf compiler. Check the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
install_from_source() {
|
||||
download_source
|
||||
check_tag
|
||||
if [[ "$?" == "1" ]]; then
|
||||
update_source
|
||||
check_tag || display_fatal "Unrecognized Go version"
|
||||
fi
|
||||
if [[ "$GO_NAME" == "" ]]; then
|
||||
GO_NAME=$version
|
||||
fi
|
||||
install_go
|
||||
|
||||
GVM_GOINSTALL="goinstall"
|
||||
which goinstall &> /dev/null ||
|
||||
GVM_GOINSTALL="go get"
|
||||
|
||||
x="$(cd "$GO_CACHE_PATH" && git tag)"; echo "${x#*b0819469a6df}" | $GREP_PATH "$version " &> /dev/null
|
||||
if [[ "$?" == "1" ]]; then
|
||||
if [[ "$INSTALL_BUILD_TOOLS" == "true" ]]; then
|
||||
install_gb || display_warning "Failed to install gb"
|
||||
install_gpkg || display_warning "Failed to install gpkg"
|
||||
fi
|
||||
if [[ "$INSTALL_PB" == "true" ]]; then
|
||||
install_goprotobuf
|
||||
fi
|
||||
fi
|
||||
|
||||
cd "$GO_INSTALL_ROOT" && find . > manifest
|
||||
}
|
||||
|
||||
main() {
|
||||
trap 'display_fatal "Canceled!"' INT
|
||||
read_command_line "$@"
|
||||
[[ "$VERSION" == "" ]] && display_fatal "No version specified"
|
||||
|
||||
if [[ "x$INSTALL_SOURCE" != "xbinary" ]]; then
|
||||
download_source
|
||||
check_tag
|
||||
if [[ "$?" == "1" ]]; then
|
||||
update_source
|
||||
check_tag || display_fatal "Unrecognized Go version"
|
||||
fi
|
||||
if [[ "$GO_NAME" == "" ]]; then
|
||||
GO_NAME=$version
|
||||
fi
|
||||
install_go
|
||||
else
|
||||
if [[ "$GO_NAME" == "" ]]; then
|
||||
GO_NAME=$VERSION
|
||||
fi
|
||||
install_go_binary
|
||||
if [[ "$GO_NAME" == "" ]]; then
|
||||
GO_NAME=$VERSION
|
||||
fi
|
||||
|
||||
GVM_GOINSTALL="goinstall"
|
||||
which goinstall &> /dev/null ||
|
||||
GVM_GOINSTALL="go get"
|
||||
|
||||
if [[ "x$INSTALL_SOURCE" != "xbinary" ]]; then
|
||||
x="$(hg tags -R "$GO_CACHE_PATH")"; echo "${x#*b0819469a6df}" | $GREP_PATH "$version " &> /dev/null
|
||||
if [[ "$?" == "1" ]]; then
|
||||
if [[ "$INSTALL_BUILD_TOOLS" == "true" ]]; then
|
||||
install_gb || display_warning "Failed to install gb"
|
||||
install_gpkg || display_warning "Failed to install gpkg"
|
||||
fi
|
||||
if [[ "$INSTALL_PB" == "true" ]]; then
|
||||
install_goprotobuf
|
||||
fi
|
||||
fi
|
||||
if [[ "x$INSTALL_SOURCE" == "xbinary" ]]; then
|
||||
install_go_binary
|
||||
elif [[ "x$INSTALL_SOURCE" == "xprefer-binary" ]]; then
|
||||
install_go_binary || {
|
||||
display_message "Falling back to source installation of $GO_NAME"
|
||||
install_from_source
|
||||
}
|
||||
else
|
||||
install_from_source
|
||||
fi
|
||||
|
||||
cd "$GO_INSTALL_ROOT" && find . > manifest
|
||||
|
||||
+5
-2
@@ -32,10 +32,13 @@ read_command_line "$@"
|
||||
echo
|
||||
display_message "gvm gos (available)"
|
||||
echo
|
||||
versions=$(curl -s https://go.googlecode.com/hg/.hgtags | awk '{ print $2 }' | $SORT_PATH)
|
||||
display_message "h=========="
|
||||
go_repo_url=git@github.com:golang/go.git
|
||||
versions=$(git ls-remote -t ${go_repo_url} | awk -F/ '{ print $NF }' | $SORT_PATH)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_fatal "Failed to get version list from Google"
|
||||
display_fatal "Failed to get version list from Github"
|
||||
fi
|
||||
display_message "~~~~~~~~~~~~~"
|
||||
for version in $versions; do
|
||||
if [[ "$tag_filter" == "release" ]]; then
|
||||
if [[ "${version:0:7}" == "release" ]]; then
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
. "$GVM_ROOT/scripts/functions"
|
||||
|
||||
[[ $1 != "" ]] ||
|
||||
display_fatal "Please specifiy the name"
|
||||
display_fatal "Please specify the name"
|
||||
|
||||
target_top=$GVM_ROOT
|
||||
target_set_name=$1
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
display_fatal "No Go version selected"
|
||||
|
||||
[[ $1 != "" ]] ||
|
||||
display_fatal "Please specifiy the name"
|
||||
display_fatal "Please specify the name"
|
||||
|
||||
target_top=$GVM_ROOT
|
||||
target_set_name=$1
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
. "$GVM_ROOT/scripts/functions"
|
||||
|
||||
[[ "$1" == "" ]] &&
|
||||
display_fatal "Please specifiy the version"
|
||||
display_fatal "Please specify the version"
|
||||
|
||||
fuzzy_match=$($LS_PATH "$GVM_ROOT/gos" | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1") ||
|
||||
display_fatal "Invalid version $1"
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@
|
||||
cd "$GVM_ROOT/archive/go" &> /dev/null ||
|
||||
display_fatal "Failed to find local Go source"
|
||||
|
||||
hg pull || display_fatal "Failed to update"
|
||||
git pull || display_fatal "Failed to update"
|
||||
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
## Cleanup test objects
|
||||
gvm uninstall tip > /dev/null 2>&1
|
||||
gvm uninstall go1.0.3 > /dev/null 2>&1
|
||||
gvm uninstall go1.4 > /dev/null 2>&1
|
||||
gvm uninstall master > /dev/null 2>&1
|
||||
gvm uninstall go1.1.1 > /dev/null 2>&1
|
||||
gvm uninstall go1.2 > /dev/null 2>&1
|
||||
gvm uninstall go1.2.2 > /dev/null 2>&1
|
||||
#######################
|
||||
|
||||
gvm install tip #status=0
|
||||
gvm list #status=0; match=/tip/
|
||||
gvm install go1.0.3 #status=0
|
||||
gvm list #status=0; match=/go1.0.3/
|
||||
gvm install go1.4 #status=0
|
||||
GOROOT_BOOTSTRAP=$GVM_ROOT/gos/go1.4 gvm install master #status=0
|
||||
gvm list #status=0; match=/master/
|
||||
gvm install go1.1.1 #status=0
|
||||
gvm list #status=0; match=/go1.1.1/
|
||||
gvm install go1.2 #status=0
|
||||
gvm list #status=0; match=/go1.2/
|
||||
gvm install go1.2.2 #status=0
|
||||
gvm list #status=0; match=/go1.2.2/
|
||||
|
||||
@@ -6,14 +6,14 @@ gvm alias delete bar
|
||||
#######################
|
||||
|
||||
gvm alias # status=0
|
||||
gvm alias create foo go1.2 # status=0
|
||||
gvm alias create bar go1.0.3 # status=0
|
||||
gvm alias list # status=0; match=/gvm go aliases/; match=/foo \(go1\.2\)/; match=/bar \(go1\.0\.3\)/
|
||||
gvm alias create foo go1.2.2 # status=0
|
||||
gvm alias create bar go1.1.1 # status=0
|
||||
gvm alias list # status=0; match=/gvm go aliases/; match=/foo \(go1\.2\.2\)/; match=/bar \(go1\.1\.1\)/
|
||||
gvm use foo # status=0
|
||||
go version # status=0; match=/go1\.2/
|
||||
go version # status=0; match=/go1\.2\.2/
|
||||
gvm use bar # status=0
|
||||
go version # status=0; match=/go1\.0\.3/
|
||||
go version # status=0; match=/go1\.1\.1/
|
||||
gvm alias delete foo
|
||||
gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.2\)/; match=/bar \(go1\.0\.3\)/
|
||||
gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.2\.2\)/; match=/bar \(go1\.1\.1\)/
|
||||
gvm alias delete bar
|
||||
gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.2\)/; match!=/bar \(go1\.0\.3\)/
|
||||
gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.2\.2\)/; match!=/bar \(go1\.1\.1\)/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
source $GVM_ROOT/scripts/gvm
|
||||
gvm use go1.2 # status=0
|
||||
go version # status=0; match=/go1\.2/
|
||||
gvm use go1.0.3 # status=0
|
||||
go version # status=0; match=/go1\.0\.3/
|
||||
gvm use go1.2.2 # status=0
|
||||
go version # status=0; match=/go1\.2\.2/
|
||||
gvm use go1.1.1 # status=0
|
||||
go version # status=0; match=/go1\.1\.1/
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
gvm install go1.2.2 --binary #status=0
|
||||
@@ -0,0 +1 @@
|
||||
gvm install go1.2.2 #status=0
|
||||
@@ -0,0 +1 @@
|
||||
gvm install go1.2 --prefer-binary #status=0
|
||||
Reference in New Issue
Block a user