103 Commits
Author SHA1 Message Date
Joshua B. Bussdieker dff56e69df Bump version to 1.0.21 2014-07-21 22:14:26 -07:00
Joshua Bussdieker ae439a3560 Merge pull request #92 from tianon/arm
Update "gvm cross" to support ARM properly
2014-07-21 22:13:08 -07:00
Joshua Bussdieker 112dfaac37 Merge pull request #88 from amitkgupta/master
gvm-check shows all missing requirements.
2014-07-21 22:08:07 -07:00
Joshua Bussdieker a71029eaa4 Merge pull request #89 from meatballhat/normalize-prefer-binary
Making all prefer-binary bits consistent
2014-07-21 22:07:26 -07:00
Tianon Gravi 78e2e80d40 Update "gvm cross" to support ARM properly 2014-07-21 10:29:38 -06:00
Dan Buch 9a9aab4b12 Correcting download URL construction
to not have a double `go`, e.g. when running one of the following:

    gvm install go1.3 --binary

or:

    gvm install go1.3 --prefer-binary
2014-07-21 11:27:12 -04:00
Dan Buch 38dfba78b8 Making all prefer-binary bits consistent 2014-07-21 10:37:42 -04:00
Amit Gupta 3ffc794bc5 gvm-check shows all missing requirements. 2014-07-20 23:52:59 -04:00
Joshua Bussdieker b914f5a6b3 Merge pull request #85 from jambli/master
Fix typos in pkgset-use
2014-07-12 12:20:15 -07:00
jambli 3d465f0ead Fix typos in pkgset-use 2014-07-12 11:22:01 -04:00
Joshua Bussdieker 4ce01e1e16 Merge pull request #81 from CoolOppo/patch-1
Merge the apt-get commands
2014-07-09 14:43:15 -07:00
Joshua Bussdieker a5ade13862 Merge pull request #84 from hoffoo/master
fix binary download path to golang.org/dl
2014-07-09 14:43:01 -07:00
Joshua Bussdieker e06e446acf Merge pull request #83 from meatballhat/support-prefer-binary
Adding support for --preferbinary
2014-07-09 14:41:34 -07:00
Marin 53fff83811 fall back to google code
if http://golang.org/dl (newer versions) fails, try to download from google code.
2014-07-08 20:03:34 -07:00
Marin fa0f1b4d57 fix binary download path to google code 2014-07-08 19:25:31 -07:00
Dan Buch 5ba804665d Renaming scenario to match its content 2014-06-25 10:42:43 -04:00
Dan Buch 6b75a19639 Adding support for --preferbinary
to attempt an install from binary, falling back to source install.
2014-06-25 10:27:19 -04:00
CoolOppo 739557089b Merge the apt-get commands 2014-06-14 03:50:56 -04:00
Joshua Bussdieker 99876c1786 Merge pull request #80 from michaelmaltese/79-fix_system_path
Fix PATH for system Go
2014-06-13 13:15:29 -07:00
Michael Maltese cf394bb42c Fix PATH for system Go
Fixes #79
2014-06-13 13:08:49 -07:00
Joshua B. Bussdieker 3ecd74b96e Older versions of go now require patches on newer systems 2014-06-12 15:11:10 -07:00
Joshua B. Bussdieker 35d369dfd3 Cleanup error output 2014-06-12 15:10:37 -07:00
Joshua B. Bussdieker f43320ec82 Fix issue with matcher 2014-06-12 14:47:47 -07:00
Joshua B. Bussdieker 1921cd7f0a Ignore local vagrant stuff 2014-06-12 14:46:32 -07:00
Joshua B. Bussdieker 97611a42eb Add some new tests 2014-06-12 14:45:56 -07:00
Joshua B. Bussdieker f392f564c6 Remove test code 2014-06-12 14:32:23 -07:00
Joshua B. Bussdieker eaf768b7d1 Make running tests easier 2014-06-12 14:31:13 -07:00
Joshua B. Bussdieker 22dc137459 Some vagrant stuff 2014-06-12 12:59:05 -07:00
Joshua Bussdieker c6527574be Merge pull request #78 from michaelmaltese/77-fix_mac_download_urls
Mac binary package URLs contain system version
2014-06-12 12:44:44 -07:00
Michael Maltese 8954a3cb39 Mac binary package URLs contain system version
Fixes #77
2014-06-12 12:42:52 -07:00
Joshua B. Bussdieker 1218d4ed0f Fix typo 2014-06-12 12:20:45 -07:00
Joshua B. Bussdieker 29c60060c3 Bump version 2014-06-12 12:12:25 -07:00
Joshua Bussdieker 535e0d569e Merge pull request #76 from moovweb/binary_install
Binary install
2014-06-12 12:11:12 -07:00
Joshua B. Bussdieker f265a1caca Try to detect OS and ARCH. Also cache downloaded binary. 2014-06-12 12:09:49 -07:00
Joshua B. Bussdieker 0bd1e648d8 MVP of binary install 2014-06-12 11:29:42 -07:00
Joshua Bussdieker 52d80ab5fd Merge pull request #75 from michaelmaltese/74-read-goroot-from-goenv
Pick up system Go even if GOROOT isn't set
2014-06-12 10:03:40 -07:00
Michael Maltese cb37fb4b34 Pick up system Go even if GOROOT isn't set
Fixes #74
2014-06-11 18:39:51 -07:00
Joshua Bussdieker d108d7d500 Merge pull request #70 from alouche/master
Display curl error message, add debug option + agnostic git gvm-installer
2014-05-23 12:01:11 -07:00
Ali Abbas 11f9d95444 add environment variable to enable global bash debug mode 2014-05-19 21:48:14 +02:00
Ali Abbas 557ddf9e4c display curl error message on failure (i.e: timeout, dns lookup etc.) 2014-05-18 23:22:40 +02:00
Ali Abbas 8ffc7cc61e in case gvm-installer within a git repository other than the gvm repo itself 2014-05-18 23:18:26 +02:00
Joshua B. Bussdieker f320151f4a Fixes issue #65: Use the new domain and follow redirects 2014-04-27 12:13:17 -07:00
jbussdieker 0f01e8130d Merge pull request #63 from alouche/master
Implode function + Test - Various best practices implemented
2014-04-12 10:17:40 -07:00
Ali Abbas e27f83653f - implode function + confirmation prompt when invoking gvm implode
- test case
2014-04-12 15:57:26 +02:00
Ali Abbas b38be0c606 use GREP_PATH variable instead 2014-04-12 15:57:17 +02:00
Ali Abbas c1ec392bdd - Double quoting to avoid globbing
- Remove unecessary $(cat)
- switch * to ./* to avoid entries with dashes to be treated as options
- replace $* with "$@"
- repeating change path serial calls - unecessary if change path is called one (get script)
2014-04-12 15:56:54 +02:00
jbussdieker bc2b638de8 Merge pull request #61 from alouche/master
Minor refactoring + best practices (bin/*, gvm, gvm-check, gvm-installer)
2014-04-07 11:54:26 -07:00
Ali Abbas ff6c3be377 * avoid unecessary clone
* workaround travis-ci broken build test
2014-04-05 11:56:16 +02:00
Ali Abbas 7d722aee3f * Switch $* to $@
* Use double quote everywhere, to avoid potential future globbing or word splitting
* Beautify EDITOR eval
* Fix typo in gvm-installer
* bin double quotes - best practice to avoid potential shell globbing and word splitting
* properly reference variable label
* simplify gvm-installer
2014-04-05 10:13:57 +02:00
jbussdieker 0e7aeb4975 Merge pull request #59 from moovweb/lots_of_tests
Lots of tests
2014-04-04 08:10:19 -07:00
Joshua B. Bussdieker 049692d68e Fix test ordering and default to empty install 2014-04-03 21:00:17 -07:00
Joshua B. Bussdieker dffb71a9b6 Add alias test and basic gvm command test 2014-04-03 20:51:14 -07:00
Joshua B. Bussdieker 4b719612ef Test cases for gvm use 2014-04-03 20:40:47 -07:00
Joshua B. Bussdieker 42acf600b1 Remove this test for now 2014-04-03 19:18:53 -07:00
Joshua B. Bussdieker 0ee31867c6 Add a couple basic tests 2014-04-03 18:46:22 -07:00
jbussdieker e9a74f86ad Update README.md
We love Travis CI!
2014-04-03 18:10:13 -07:00
Joshua B. Bussdieker b5be10428c More work on travis CI testing 2014-04-03 18:07:36 -07:00
Joshua B. Bussdieker 53a7b7de5b Testing testing 2014-04-03 17:13:58 -07:00
jbussdieker 38f97024af Merge pull request #56 from alouche/master
Linux distributions specific + minor shell safety belts
2014-03-29 10:09:11 -07:00
Ali Abbas c8410e0ca9 Linux distro specificities 2014-03-29 17:16:48 +01:00
Ali Abbas 330dad10e4 * Best practice, to avoid possible break on space as in $* 2014-03-29 16:43:09 +01:00
Ali Abbas 51130f4be3 * Proper use of printf
* Prevent possible word splitting when eval sudo
2014-03-29 16:42:11 +01:00
Ali Abbas 175625a166 * $GVM_ROOT is the variable content, not the variable itself - better display GVM_ROOT to the user than $GVM_ROOT
* When executing $GVM_ROOT/scripts/$command - args need to be quoted otherwise they are treated as $*, which will break on spaces
2014-03-29 16:38:04 +01:00
Ali Abbas 3554b6ae2a * Use $(..) instead of deprecated .., which can produce unknown behaviors on posix systems
* No need to change path when git cloning - use --quiet instead of redirecting stdout
2014-03-29 16:34:57 +01:00
jbussdieker 391fd44838 Merge pull request #47 from shovon/master
Added build-essential to the Linux requirements
2014-03-06 12:04:53 -08:00
jbussdieker 1e78c798d2 Merge pull request #54 from extraordinaire/master
add output option to pkgenv
2014-03-06 12:04:41 -08:00
jbussdieker edbcda1745 Merge pull request #55 from zhibinr/patch-1
Update gvm-installer
2014-03-06 12:01:17 -08:00
zhibinr d0b8ae1cf4 Update gvm-installer
Add some description for "profile settings file"
2014-03-05 18:47:41 +08:00
Andrei Serdeliuc 1e9bca22a8 add output option to pkgenv
Using `pkgenv -o` or `pkgenv --output` will now cat the file instead of editing it.
2014-02-27 12:06:31 +01:00
Manoj Dayaram 402f71240e Merge pull request #51 from fdr/editor
Make gvm pkgenv sensitive to the EDITOR environment variable
2014-02-07 19:46:27 -08:00
Manoj Dayaram 9022d4b148 Merge pull request #52 from manveru/patch-1
Use "$PATH" to avoid weirdness.
2014-02-07 19:36:53 -08:00
Michael Fellinger 81fc036d26 Use "$PATH" to avoid weirdness.
Without this, I get this error when gvm is being loaded:

    /home/manveru/.gvm/scripts/gvm-default:export:17: not an identifier: 2:/home/manveru/node_modules/.bin:/home/manveru/github/akunspy/gopbuf/bin:./node_modules/.bin:.
2014-02-07 19:23:23 +01:00
Daniel Farina aa8763043d Make gvm pkgenv sensitive to the EDITOR environment variable
For those who do not use 'vi', although 'vi' is still the default.
2014-02-06 11:20:53 -08:00
Salehen Shovon Rahman 2eaf690325 Added build-essential to the Linux requirements
Without this instruction change, people might come across a "`unistd.h` not found" error.
2014-01-10 14:05:58 -08:00
jbussdieker 37e9909e3d Merge pull request #44 from wting/add_zsh_install_support
Add zsh install support
2013-12-27 21:38:13 -08:00
William Ting 74380b3454 add zsh install support 2013-12-25 16:55:55 -06:00
jbussdieker 9a5ffcb189 Merge pull request #42 from eaigner/master
pkgenv command to edit package set environments. Fixes #41.
2013-12-12 05:44:50 -08:00
Erik Aigner ab0e9e7c25 pkgenv command to edit package set environments. Fixes #41. 2013-11-16 17:20:42 +01:00
Joshua Bussdieker 99abb6d6ee Cleanup log location code 2013-11-12 01:55:37 -05:00
Peter Souter 3d24872ac7 Show log location when errors occur...
Makes it easier for users to figure out what happened :)
2013-10-17 10:34:09 +01:00
jbussdieker ed13433a66 Merge pull request #33 from modcloth-labs/filling-in-linkthis-docs
Filling in some docs for the `linkthis` command
2013-08-05 11:49:35 -07:00
Dan Buch 224a8deb25 Filling in some docs for the linkthis command
as well as some minor space/tab touchup.
2013-07-26 08:44:36 -04:00
jbussdieker c94d65bce5 More completion updates 2013-07-25 17:50:50 -07:00
jbussdieker 189e5403e4 Add go* versions to completion for gvm install 2013-07-25 17:47:22 -07:00
jbussdieker 3df1de73d7 Merge pull request #32 from benizi/fix-more-zsh-completion
Fixes more broken zsh completion cases
2013-07-25 17:44:32 -07:00
Benjamin R. Haskell 4465f22f83 Fixes more broken zsh completion cases
There were more instances where the version parameter should be
quoted in zsh.
2013-07-25 19:36:13 -04:00
jbussdieker 77f7e03c3d Update VERSION 2013-07-25 08:08:40 -07:00
jbussdieker 38c97abde2 Merge pull request #31 from modcloth-labs/linkthis
Adding `gvm linkthis` command
2013-07-25 07:57:42 -07:00
Rafe ColtonandDan Buch 24e475d6ff Adding gvm linkthis command
This links the current project into the $GOPATH/src to allow `go get` to
find the local development copy instead of the one on GitHub (or
wherever)

Signed-off-by: Dan Buch <d.buch@modcloth.com>
2013-07-24 13:15:39 -04:00
jbussdieker 0792044442 Update other README 2013-07-13 13:43:10 -07:00
jbussdieker 85f613741a Use bullet points for Mac requirements 2013-07-13 13:42:45 -07:00
jbussdieker 621fba9837 Merge pull request #29 from moovweb/consistent_readmes
making readmes consistent with eachother.
2013-07-13 13:41:02 -07:00
jbussdieker fd0ab70399 Merge pull request #30 from moovweb/issue_28
adding command line dev tools to requirement list for macs
2013-07-13 13:40:16 -07:00
Manoj Dayaram c14d8b0560 adding command line dev tools to requirement list for macs 2013-07-01 17:13:32 -07:00
Manoj Dayaram 52e888f187 making readmes consistent with eachother. 2013-07-01 17:05:06 -07:00
jbussdieker c8b4b1f4ed Update VERSION 2013-06-24 19:04:46 -06:00
jbussdieker 325e9a75f3 Merge pull request #26 from meatballhat/allow-in-session-path-changes
Allow for in-session changes to $PATH
2013-06-20 06:52:59 -07:00
Dan Buch 033c72a113 Seeing if this makes the experience with $PATH more like I'd expect 2013-06-12 08:50:10 -04:00
jbussdieker 45a4d1ff42 Merge pull request #25 from benizi/fix-zsh-completion
Fixes quoting so completion works in zsh
2013-05-29 02:40:23 -07:00
jbussdieker faac33ab5e Merge pull request #24 from benizi/fix-hardcoded-path
Fixes hard-coded path to cache
2013-05-29 02:09:34 -07:00
Benjamin R. Haskell 8999f3f072 Fixes quoting so completion works in zsh 2013-05-29 00:00:23 -04:00
Benjamin R. Haskell 3f72ed5f89 Fixes hard-coded path to cache 2013-05-28 23:53:37 -04:00
jbussdieker 7765f13d9a Merge pull request #21 from matttproud/feature/native-code-support
Provide support for vendored native code workflow.
2013-05-24 06:43:10 -07:00
57 changed files with 652 additions and 260 deletions
+2
View File
@@ -7,3 +7,5 @@ environments/
tmp/
*.log
scripts/gvm
Gemfile.lock
.vagrant/
+7
View File
@@ -0,0 +1,7 @@
language: c
os: [linux, osx]
osx_image: mavericks
before_install:
- "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/*.sh
+3
View File
@@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem 'tf', '>=0.4.1'
+22 -3
View File
@@ -7,9 +7,10 @@ Features
========
* Install/Uninstall Go versions with `gvm install [tag]` where tag is "60.3", "go1", "weekly.2011-11-08", or "tip"
* List added/removed files in GOROOT with `gvm diff`
* Manage GOPATHs with `gvm pkgset [create/use/delete] [name]`
* Manage GOPATHs with `gvm pkgset [create/use/delete] [name]`. Use `--local` as `name` to manage repository under local path (`/path/to/repo/.gvm_local`).
* List latest release tags with `gvm listall`. Use `--all` to list weekly as well.
* Cache a clean copy of the latest Go source for multiple version installs.
* Link project directories into GOPATH
Background
==========
@@ -22,7 +23,7 @@ Installing
To install:
bash < <(curl -s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
Installing Go
=============
@@ -37,6 +38,7 @@ Additional options can be specified when installing Go:
-n, --name=NAME Override the default name for this version.
-pb, --with-protobuf Install Go protocol buffers.
-b, --with-build-tools Install package build tools.
-B, --binary Only install from binary.
-h, --help Display this message.
List Go Versions
@@ -55,9 +57,13 @@ If that doesn't work see the troubleshooting steps at the bottom of this page.
Mac OS X Requirements
====================
Install mercurial from http://mercurial.berkwood.com/
* Install Mercurial from http://mercurial.berkwood.com/
* Install Xcode Command Line Tools from the App Store.
Linux Requirements
==================
Debian/Ubuntu
==================
sudo apt-get install curl
sudo apt-get install git
@@ -66,6 +72,19 @@ Linux Requirements
sudo apt-get install binutils
sudo apt-get install bison
sudo apt-get install gcc
sudo apt-get install build-essential
Redhat/Centos
==================
sudo yum install curl
sudo yum install git
sudo yum install make
sudo yum install gcc
sudo yum install bison-devel
sudo yum install glibc-devel
* Install Mercurial from http://pkgs.repoforge.org/mercurial/
FreeBSD Requirements
====================
+27 -9
View File
@@ -1,4 +1,7 @@
# gvm
[![Build Status](https://travis-ci.org/moovweb/gvm.svg?branch=master)](https://travis-ci.org/moovweb/gvm)
by Josh Bussdieker (jbuss, jaja, jbussdieker)
GVM provides an interface to manage Go versions.
@@ -10,6 +13,7 @@ Features
* Manage GOPATHs with `gvm pkgset [create/use/delete] [name]`. Use `--local` as `name` to manage repository under local path (`/path/to/repo/.gvm_local`).
* List latest release tags with `gvm listall`. Use `--all` to list weekly as well.
* Cache a clean copy of the latest Go source for multiple version installs.
* Link project directories into GOPATH
Background
==========
@@ -22,7 +26,7 @@ Installing
To install:
bash < <(curl -s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
Installing Go
=============
@@ -37,6 +41,8 @@ Additional options can be specified when installing Go:
-n, --name=NAME Override the default name for this version.
-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.
List Go Versions
@@ -51,19 +57,31 @@ To completely remove gvm and all installed Go versions and packages:
gvm implode
If that doesn't work see the troubleshooting steps at the bottom of this page.
Mac OS X Requirements
====================
Install mercurial from http://mercurial.berkwood.com/
* Install Mercurial from http://mercurial.berkwood.com/
* Install Xcode Command Line Tools from the App Store.
Linux Requirements
==================
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
Debian/Ubuntu
==================
sudo apt-get install curl git mercurial make binutils bison gcc build-essential
Redhat/Centos
==================
sudo yum install curl
sudo yum install git
sudo yum install make
sudo yum install bison
sudo yum install gcc
sudo yum install glibc-devel
* Install Mercurial from http://pkgs.repoforge.org/mercurial/
FreeBSD Requirements
====================
+27
View File
@@ -0,0 +1,27 @@
require 'tmpdir'
task :default do
root_path = File.expand_path "../.", __FILE__
Dir.mktmpdir("gvm-test") do |tmpdir|
puts `binscripts/gvm-installer binary_default #{tmpdir}`
pid = fork do
exec("bash -c 'source #{tmpdir}/gvm/scripts/gvm; tf --text #{tmpdir}/gvm/tests/*.sh'")
end
Process.waitpid(pid)
end
end
task :scenario do
root_path = File.expand_path "../.", __FILE__
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|
install = `binscripts/gvm-installer binary_default #{tmpdir}`
pid = fork do
exec("bash -c 'source #{tmpdir}/gvm/scripts/gvm; tf --text #{tmpdir}/gvm/tests/scenario/#{name}'")
end
Process.waitpid(pid)
end
end
end
+1 -1
View File
@@ -1 +1 @@
1.0.17
1.0.21
Vendored
+9
View File
@@ -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
+13 -6
View File
@@ -1,8 +1,13 @@
#!/usr/bin/env bash
[ -n "$GVM_DEBUG" ] && {
set -x
}
if [ -z "$GVM_ROOT" ]; then
tput sgr0
tput setaf 1
echo 'ERROR: $GVM_ROOT is not set! Please add the following line to your .bashrc or .profile
echo 'ERROR: GVM_ROOT is not set! Please add the following line to your .bashrc or .profile
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"
' >&2
@@ -10,15 +15,15 @@ if [ -z "$GVM_ROOT" ]; then
exit 1
fi
. $GVM_ROOT/scripts/functions || exit 1
. "$GVM_ROOT/scripts/functions" || exit 1
command=$1
if [[ $command == "implode" ]]; then
rm -rf $GVM_ROOT
gvm_implode
exit 0
fi
$GVM_ROOT/scripts/gvm-check
"$GVM_ROOT/scripts/gvm-check"
if [[ "$?" != "0" ]]; then
display_fatal "Missing requirements."
fi
@@ -26,9 +31,9 @@ fi
if [[ $command == "version" ]]; then
display_message "Go Version Manager v$GVM_VERSION installed at $GVM_ROOT"
else
if [ -f $GVM_ROOT/scripts/$command ]; then
if [ -f "$GVM_ROOT/scripts/$command" ]; then
shift
$GVM_ROOT/scripts/$command $@
"$GVM_ROOT/scripts/$command" "$@"
elif [[ -n $command ]]; then
display_fatal "Unrecognized command line argument: '$command'"
else
@@ -46,10 +51,12 @@ Commands:
install - install go versions
uninstall - uninstall go versions
cross - install go cross compilers
linkthis - link this directory into GOPATH
list - list installed go versions
listall - list available versions
alias - manage go version aliases
pkgset - manage go packages sets
pkgenv - edit the environment for a package set
"
fi
fi
+5 -4
View File
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
function gvm_prompt() {
if [[ "$1" == "g" ]]; then
echo $gvm_go_name
echo "$gvm_go_name"
elif [[ "$1" == "ps" ]]; then
echo $gvm_pkgset_name
echo "$gvm_pkgset_name"
else
if [[ $gvm_pkgset_name != "" ]]; then
if [[ $gvm_pkgset_name != "global" ]]; then
@@ -11,8 +12,8 @@ function gvm_prompt() {
return 0
fi
fi
echo $gvm_go_name
echo "$gvm_go_name"
fi
}
gvm_prompt $@
gvm_prompt "$@"
+2 -2
View File
@@ -43,8 +43,8 @@ done
if [[ $# -gt 0 ]]
then
eval sudo "${sudo_args[@]}" /usr/bin/env $(/usr/bin/env | grep -E '^GO|^GVM|^PATH' | sed 's/=\(.*\)$/="\1"/' ) "$@"
eval sudo "${sudo_args[@]}" /usr/bin/env "$(/usr/bin/env | grep -E '^GO|^GVM|^PATH' | sed 's/=\(.*\)$/="\1"/' )" "$@"
else
printf "Usage:\n $0 [--trace] [--verbose] [sudo-options] command [command-options]\n"
printf "Usage:\n %s [--trace] [--verbose] [sudo-options] command [command-options]\n $0"
fi
+63 -44
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
display_error() {
tput sgr0
tput setaf 1
@@ -8,23 +9,28 @@ display_error() {
}
update_profile() {
[ -f $1 ] || return 1
[ -f "$1" ] || return 1
cat $1 | grep "$source_line" > /dev/null 2>&1
grep "$source_line" "$1" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$source_line" >> $1
echo "$source_line" >> "$1"
fi
}
check_existing_go() {
if [ "$GOROOT" == "" ]; then
echo "No existing Go versions detected"
return
if which go > /dev/null; then
GOROOT=$(go env | grep GOROOT | cut -d"=" -f2)
else
echo "No existing Go versions detected"
return
fi
fi
echo "Created profile for existing install of Go at $GOROOT"
mkdir -p $GVM_DEST/$GVM_NAME/environments &> /dev/null || display_error "Failed to create environment directory"
mkdir -p $GVM_DEST/$GVM_NAME/pkgsets/system/global &> /dev/null || display_error "Failed to create new package set"
mkdir -p $GVM_DEST/$GVM_NAME/gos/system &> /dev/null || display_error "Failed to create new Go folder"
mkdir -p "$GVM_DEST/$GVM_NAME/environments" &> /dev/null || display_error "Failed to create environment directory"
mkdir -p "$GVM_DEST/$GVM_NAME/pkgsets/system/global" &> /dev/null || display_error "Failed to create new package set"
mkdir -p "$GVM_DEST/$GVM_NAME/gos/system" &> /dev/null || display_error "Failed to create new Go folder"
cat << EOF > $GVM_DEST/$GVM_NAME/environments/system
# Automatically generated file. DO NOT EDIT!
export GVM_ROOT; GVM_ROOT="$GVM_DEST/$GVM_NAME"
@@ -32,66 +38,79 @@ 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
GVM_DEST=$2
if [ "$GVM_DEST" == "" ]; then
GVM_DEST="$HOME"
GVM_NAME=".gvm"
else
GVM_NAME="gvm"
fi
BRANCH=${1:-master}
GVM_DEST=${2:-$HOME}
GVM_NAME="gvm"
SRC_REPO=${SRC_REPO:-https://github.com/moovweb/gvm.git}
if [ "$SRC_REPO" == "" ]; then
SRC_REPO=https://github.com/moovweb/gvm.git
fi
[ "$GVM_DEST" = "$HOME" ] && GVM_NAME=".gvm"
[ "$GVM_DEST" == "" ] && display_error "No destination specified!"
[ -d $GVM_DEST/$GVM_NAME ] && display_error "Already installed!"
[ -d $GVM_DEST ] || mkdir -p $GVM_DEST > /dev/null 2>&1 || display_error "Failed to create $GVM_DEST"
[ -z `which git` ] && display_error "Could not find git
[ -d "$GVM_DEST/$GVM_NAME" ] && display_error "Already installed!"
[ -d "$GVM_DEST" ] || mkdir -p "$GVM_DEST" > /dev/null 2>&1 || display_error "Failed to create $GVM_DEST"
[ -z "$(which git)" ] && display_error "Could not find git
linux: apt-get install git
debian/ubuntu: apt-get install git
redhat/centos: yum install git
mac: brew install git
"
cd $GVM_DEST && git clone $SRC_REPO $GVM_NAME > /dev/null 2>&1 ||
display_error "Failed to clone from $SRC_REPO into $GVM_DEST/$GVM_NAME"
# 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
if [ "$BRANCH" != "" ]; then
cd $GVM_DEST/$GVM_NAME && git checkout $BRANCH > /dev/null 2>&1 ||
display_error "Failed to checkout $BRANCH branch"
fi
GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
mv $GVM_DEST/$GVM_NAME/.git $GVM_DEST/$GVM_NAME/git.bak
if [[ -z "$GIT_ROOT" || "$(basename "$GIT_ROOT")" != "gvm" ]]
then
echo "Cloning from $SRC_REPO to $GVM_DEST/$GVM_NAME"
if [ "$GVM_NAME" == ".gvm" ]; then
source_line="[[ -s \"\$HOME/.gvm/scripts/gvm\" ]] && source \"\$HOME/.gvm/scripts/gvm\""
source_file="\$HOME/.gvm/scripts/gvm"
git clone --quiet "$SRC_REPO" "$GVM_DEST/$GVM_NAME" 2> /dev/null ||
display_error "Failed to clone from $SRC_REPO into $GVM_DEST/$GVM_NAME"
else
source_line="[[ -s \"${GVM_DEST}/gvm/scripts/gvm\" ]] && source \"${GVM_DEST}/gvm/scripts/gvm\""
source_file="${GVM_DEST}/gvm/scripts/gvm"
if [[ $GVM_DEST == *"$GIT_ROOT"* ]]
then
ln -s "$GIT_ROOT" "$GVM_DEST"
else
cp -r "$GIT_ROOT" "$GVM_DEST/$GVM_NAME"
fi
fi
if [ "`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
# GVM_DEST may be a non-relative path
# i.e: gvm-installer master foo
pushd . > /dev/null
cd "$GVM_DEST/$GVM_NAME" && git checkout --quiet "$BRANCH" 2> /dev/null || display_error "Failed to checkout $BRANCH branch"
popd > /dev/null
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"
fi
if [ "$?" != "0" ]; then
echo 'Unable to locate profile settings file'
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:"
echo
echo " $source_line"
echo
fi
echo "export GVM_ROOT=$GVM_DEST/$GVM_NAME" > $GVM_DEST/$GVM_NAME/scripts/gvm
echo ". \$GVM_ROOT/scripts/gvm-default" >> $GVM_DEST/$GVM_NAME/scripts/gvm
echo "export GVM_ROOT=$GVM_DEST/$GVM_NAME" > "$GVM_DEST/$GVM_NAME/scripts/gvm"
echo ". \$GVM_ROOT/scripts/gvm-default" >> "$GVM_DEST/$GVM_NAME/scripts/gvm"
check_existing_go
[[ -s "$GVM_DEST/$GVM_NAME/scripts/gvm" ]] && source "$GVM_DEST/$GVM_NAME/scripts/gvm"
echo "Installed GVM v${GVM_VERSION}"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
/vagrant/extra/vagrant/install-deps.sh
/vagrant/extra/vagrant/install-local.sh
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
sudo apt-get -y install curl git mercurial bison make
+6
View File
@@ -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 -2
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
command=$1
if [[ -f $GVM_ROOT/scripts/alias-$command ]]; then
shift
$GVM_ROOT/scripts/alias-$command $@
"$GVM_ROOT/scripts/alias-$command" "$@"
elif [[ -n $command ]]; then
display_fatal "Unrecognized command line argument: '$command'"
else
+5 -5
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ $1 != "" ]] ||
display_fatal "Please specifiy the alias name"
@@ -12,12 +12,12 @@
[[ -f "$GVM_ROOT/environments/$2" ]] ||
display_fatal "Target doesn't exist!"
mkdir -p $GVM_ROOT/environments ||
mkdir -p "$GVM_ROOT/environments" ||
display_fatal "Could not create folder"
mkdir -p $GVM_ROOT/gos/$1 ||
mkdir -p "$GVM_ROOT/gos/$1" ||
display_fatal "Could not create folder"
cp $GVM_ROOT/environments/$2 $GVM_ROOT/environments/$1 ||
cp "$GVM_ROOT/environments/$2" "$GVM_ROOT/environments/$1" ||
display_fatal "Could copy environment"
echo "export gvm_alias_name=\"$1\"" >> $GVM_ROOT/environments/$1 ||
echo "export gvm_alias_name=\"$1\"" >> "$GVM_ROOT/environments/$1" ||
display_fatal "Could not extend environment"
+4 -4
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ $1 != "" ]] ||
display_fatal "Please specifiy the name"
@@ -7,12 +7,12 @@
[[ -f $GVM_ROOT/environments/$1 ]] ||
display_fatal "Alias doesn't exist!"
cat $GVM_ROOT/environments/$1 | $GREP_PATH "gvm_alias_name" > /dev/null ||
$GREP_PATH "gvm_alias_name" "$GVM_ROOT/environments/$1" > /dev/null ||
display_fatal "$1 is not an alias!"
rm -rf $GVM_ROOT/environments/$1 ||
rm -rf "$GVM_ROOT/environments/$1" ||
display_fatal "Could not delete alias"
rm -rf $GVM_ROOT/gos/$1 ||
rm -rf "$GVM_ROOT/gos/$1" ||
display_fatal "Could not delete alias"
+2 -2
View File
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
echo
display_message "gvm go aliases"
echo
for a in $(cd $GVM_ROOT/environments ; grep -l "gvm_alias_name" *); do
for a in $(cd "$GVM_ROOT/environments" ; $GREP_PATH -l "gvm_alias_name" ./*); do
t=$(sh -c ". $GVM_ROOT/environments/$a ; echo \$gvm_go_name")
echo " $a ($t)"
done
+8 -8
View File
@@ -15,7 +15,7 @@ _gvm()
use|delete|empty)
[[ "$gvm_go_name" == "" ]] && return 1
[[ $COMP_CWORD > 3 ]] && return 1
local version=$(for x in `$LS_PATH $GVM_ROOT/pkgsets/$gvm_go_name`; do echo ${x} ; done )
local version="$(for x in `$LS_PATH $GVM_ROOT/pkgsets/$gvm_go_name`; do echo ${x} ; done )"
COMPREPLY=( $(compgen -W "${version}" -- ${cur}) )
return 0
;;
@@ -35,11 +35,11 @@ _gvm()
[[ "$gvm_go_name" == "" ]] && return 1
[[ "$gvm_pkgset_name" == "" ]] && return 1
if [[ "$COMP_CWORD" == "3" ]]; then
local version=$(for x in `$LS_PATH $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm`; do echo ${x} ; done )
local version="$(for x in `$LS_PATH $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm`; do echo ${x} ; done )"
COMPREPLY=( $(compgen -W "${version}" -- ${cur}) )
return 0
elif [[ "$COMP_CWORD" == "4" ]]; then
local version=$(for x in `$LS_PATH $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/${COMP_WORDS[3]}`; do echo ${x} ; done )
local version="$(for x in `$LS_PATH $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/${COMP_WORDS[3]}`; do echo ${x} ; done )"
COMPREPLY=( $(compgen -W "${version}" -- ${cur}) )
return 0
fi
@@ -58,22 +58,22 @@ _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"`; do echo ${x} ; done )
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 )"
COMPREPLY=( $(compgen -W "${version}" -- ${cur}) )
return 0
;;
use|uninstall)
[ ! -d $GVM_ROOT/gos ] && return 1
[[ $COMP_CWORD > 2 ]] && return 1
local installed_versions=$(for x in `$LS_PATH $GVM_ROOT/gos`; do echo ${x} ; done )
local installed_versions="$(for x in `$LS_PATH $GVM_ROOT/gos`; do echo ${x} ; done )"
COMPREPLY=( $(compgen -W "${installed_versions}" -- ${cur}) )
return 0
;;
*)
[[ $COMP_CWORD > 1 ]] && return 1
opts="get install list listall uninstall use version"
[[ "$gvm_go_name" != "" ]] && opts="get install list listall pkgset uninstall use version"
[[ "$gvm_pkgset_name" != "" ]] && opts="get install list listall pkg pkgset uninstall use version"
opts="alias get install list listall uninstall use version"
[[ "$gvm_go_name" != "" ]] && opts="alias cross diff get install list listall pkgset uninstall use version"
[[ "$gvm_pkgset_name" != "" ]] && opts="alias cross diff get install list listall pkg pkgset uninstall use version"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
+9 -9
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
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() {
@@ -13,9 +13,9 @@ display_list() {
echo
display_message "Installed platforms:"
echo
$LS_PATH $GOROOT/pkg | $GREP_PATH windows_ | sed 's/^/ /g'
$LS_PATH $GOROOT/pkg | $GREP_PATH darwin_ | sed 's/^/ /g'
$LS_PATH $GOROOT/pkg | $GREP_PATH linux_ | sed 's/^/ /g'
$LS_PATH "$GOROOT/pkg" | $GREP_PATH windows_ | sed 's/^/ /g'
$LS_PATH "$GOROOT/pkg" | $GREP_PATH darwin_ | sed 's/^/ /g'
$LS_PATH "$GOROOT/pkg" | $GREP_PATH linux_ | sed 's/^/ /g'
echo
exit 1
}
@@ -25,15 +25,15 @@ 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 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
touch "$GOROOT/pkg/tool/cross"
fi
export GOOS=$1
@@ -47,7 +47,7 @@ if [ ! -d "$GOROOT/pkg/${GOOS}_${GOARCH}" ]; then
export CGO_ENABLED=0
fi
cd $GOROOT/src
cd "$GOROOT/src"
go tool dist install -v pkg/runtime ||
display_fatal "Couldn't compile runtime library for $GOOS $GOARCH"
go install -v -a std ||
+3 -3
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
version=$1
if [ "$version" != "" ]; then
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$version" | $HEAD_PATH -n 1 | $GREP_PATH "$version"` ||
fuzzy_match=$($LS_PATH "$GVM_ROOT/gos" | $SORT_PATH | $GREP_PATH "$version" | $HEAD_PATH -n 1 | $GREP_PATH "$version") ||
display_fatal "Invalid version $version"
foldername=$GVM_ROOT/gos/$fuzzy_match
@@ -17,7 +17,7 @@ else
fi
if [[ -d $foldername ]]; then
cd $foldername
cd "$foldername"
find . > /tmp/manifest.test
diff manifest /tmp/manifest.test
if [[ "$?" == "0" ]]; then
+15 -14
View File
@@ -1,13 +1,13 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions || return 1
. "$GVM_ROOT/scripts/functions" || return 1
function gvm() {
if [[ "$GVM_ROOT" == "" ]]; then
display_error "GVM_ROOT not set. Please source GVM_ROOT/scripts/gvm"
display_error "GVM_ROOT not set. Please source \$GVM_ROOT/scripts/gvm"
return $?
fi
if [[ -d $GVM_ROOT/.git ]]; then
mv $GVM_ROOT/.git $GVM_ROOT/git.bak ||
mv "$GVM_ROOT/.git" "$GVM_ROOT/git.bak" ||
display_error "Failed to move git info out of the way"
fi
if [[ ! -d $GVM_ROOT ]]; then
@@ -15,25 +15,26 @@ function gvm() {
return $?
fi
mkdir -p $GVM_ROOT/logs > /dev/null 2>&1
mkdir -p $GVM_ROOT/gos > /dev/null 2>&1
mkdir -p $GVM_ROOT/archive > /dev/null 2>&1
mkdir -p $GVM_ROOT/archive/package > /dev/null 2>&1
mkdir -p $GVM_ROOT/environments > /dev/null 2>&1
mkdir -p "$GVM_ROOT/logs" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/gos" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/archive" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/archive/package" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/environments" > /dev/null 2>&1
if [[ "$1" == "use" ]]; then
. $GVM_ROOT/scripts/env/use
. "$GVM_ROOT/scripts/env/use"
shift
gvm_use $@
gvm_use "$@"
elif [[ "$1" == "implode" ]]; then
rm -rf $GVM_ROOT
. "$GVM_ROOT/scripts/env/implode"
gvm_implode
elif [[ "$1" == "pkgset" ]] && [[ "$2" == "use" ]]; then
. $GVM_ROOT/scripts/env/pkgset-use
. "$GVM_ROOT/scripts/env/pkgset-use"
shift
shift
gvm_pkgset_use $@
gvm_pkgset_use "$@"
else
$GVM_ROOT/bin/gvm $@
"$GVM_ROOT/bin/gvm" "$@"
fi
}
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
function gvm_implode() {
read -p "Are you sure? [Y/n] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
display_message "Action cancelled"
else
(rm -rf "$GVM_ROOT" && display_message "GVM successfully removed") || display_error "Failed to uninstall gvm"
fi
}
+7 -7
View File
@@ -7,35 +7,35 @@ function gvm_pkgset_use() {
display_error "No Go version selected" || return 1
if [[ "$1" == "--local" ]]; then
. $GVM_ROOT/scripts/function/find_local_pkgset
. "$GVM_ROOT/scripts/function/find_local_pkgset"
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` ||
fuzzy_match=$($LS_PATH "$LOCAL_TOP/environments" | $SORT_PATH | $GREP_PATH "$gvm_go_name@" | $GREP_PATH "local" | $HEAD_PATH -n 1) ||
display_error "Cannot find local package set" || return 1
[[ "$2" != "--default" ]] ||
display_error "Cannot set local pkgset as default" || return 1
export PATH=$GVM_PATH_BACKUP
gvm_export_path
. "$LOCAL_TOP/environments/$fuzzy_match" ||
display_error "Failed to source the package set environment" || return 1
echo "Now using version $gvm_go_name in local package set"
echo "Local GOPATH is now $LOCAL_TOP"
else
fuzzy_match=`$LS_PATH $GVM_ROOT/environments | $SORT_PATH | $GREP_PATH "$gvm_go_name@" | $GREP_PATH "$1" | $HEAD_PATH -n 1` ||
fuzzy_match=$($LS_PATH "$GVM_ROOT/environments" | $SORT_PATH | $GREP_PATH "$gvm_go_name@" | $GREP_PATH "$1" | $HEAD_PATH -n 1) ||
display_error "Invalid package set" || return 1
export PATH=$GVM_PATH_BACKUP
gvm_export_path
. "$GVM_ROOT/environments/$fuzzy_match" ||
display_error "Failed to source the package set environment" || return 1
if [[ "$2" == "--default" ]]; then
cp $GVM_ROOT/environments/$fuzzy_match $GVM_ROOT/environments/default
cp "$GVM_ROOT/environments/$fuzzy_match" "$GVM_ROOT/environments/default"
fi
echo "Now using version $fuzzy_match"
+5 -5
View File
@@ -3,10 +3,10 @@ function gvm_use() {
[[ "$1" != "" ]] ||
display_error "Please specifiy 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"`
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=$(hg tags -R "$GO_CACHE_PATH" | awk '{print $1}' | $SORT_PATH | $GREP_PATH "$VERSION" | $HEAD_PATH -n 1 | $GREP_PATH "$VERSION")
if [[ "x$version" == "x" ]]; then
display_error "Version not found locally. Try 'gvm install $1'" || return 1
else
@@ -14,10 +14,10 @@ function gvm_use() {
fi
fi
export PATH=$GVM_PATH_BACKUP
. $GVM_ROOT/environments/$fuzzy_match &> /dev/null || display_error "Couldn't source environment" || return 1
gvm_export_path
. "$GVM_ROOT/environments/$fuzzy_match" &> /dev/null || display_error "Couldn't source environment" || return 1
if [[ "$2" == "--default" ]]; then
cp $GVM_ROOT/environments/$fuzzy_match $GVM_ROOT/environments/default || display_error "Couldn't make $fuzzy_match default"
cp "$GVM_ROOT/environments/$fuzzy_match" "$GVM_ROOT/environments/default" || display_error "Couldn't make $fuzzy_match default"
fi
display_message "Now using version $fuzzy_match"
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
function gvm_export_path() {
export PATH="$GVM_ROOT/bin:$(echo "$PATH" | tr ":" "\n" | grep -v '^$' | egrep -v "$GVM_ROOT/(pkgsets|gos|bin)" | tr "\n" ":" | sed 's/:*$//')"
export GVM_PATH_BACKUP="$PATH"
}
+4 -4
View File
@@ -4,8 +4,8 @@ GREP_ERROR="GVM couldn't find grep"
SORT_ERROR="GVM couldn't find sort"
HEAD_ERROR="GVM couldn't find head"
LS_PATH=`unalias ls &> /dev/null; which ls` || display_error "$LS_ERROR" || return 1
GREP_PATH=`unalias grep &> /dev/null; which grep` || display_error "$GREP_ERROR" || return 1
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
LS_PATH=$(unalias ls &> /dev/null; which ls) || display_error "$LS_ERROR" || return 1
GREP_PATH=$(unalias grep &> /dev/null; which grep) || display_error "$GREP_ERROR" || return 1
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
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
for function in $GVM_ROOT/scripts/function/*; do
. $function
. "$function"
done
+8 -11
View File
@@ -1,20 +1,17 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ -d $GVM_ROOT/.git ]] || mv $GVM_ROOT/git.bak $GVM_ROOT/.git &> /dev/null ||
[[ -d $GVM_ROOT/.git ]] || mv "$GVM_ROOT/git.bak" "$GVM_ROOT/.git" &> /dev/null ||
display_fatal "Couldn't find git info"
cd $GVM_ROOT && git checkout -f ||
display_fatal "Failed to clean install"
cd "$GVM_ROOT"
if [[ -n $1 ]]; then
cd $GVM_ROOT && git checkout $1 -f ||
display_fatal "Failed to checkout $1 branch"
git checkout "$1" -f || display_fatal "Failed to checkout $1 branch"
else
git checkout -f || display_fatal "Failed to clean install"
fi
cd $GVM_ROOT && git pull ||
display_fatal "Failed to update"
mv $GVM_ROOT/.git $GVM_ROOT/git.bak ||
display_fatal "Couldn't backup git info"
git pull || display_fatal "Failed to update"
mv ".git" "git.bak" || display_fatal "Couldn't backup git info"
+25 -13
View File
@@ -1,37 +1,49 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
error_message=""
# Check for hg
which hg &> /dev/null ||
display_warning "Could not find mercurial
error_message="${error_message}
Could not find mercurial
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
"
# All good!
exit 0
if [ -n "$error_message" ]; then
display_warning "$error_message"
exit 1
else
# All good!
exit 0
fi
+10 -10
View File
@@ -7,15 +7,15 @@ unset GOBIN
unset gvm_go_name
unset gvm_pkgset_name
mkdir -p $GVM_ROOT/logs > /dev/null 2>&1
mkdir -p $GVM_ROOT/gos > /dev/null 2>&1
mkdir -p $GVM_ROOT/archive > /dev/null 2>&1
mkdir -p $GVM_ROOT/archive/package > /dev/null 2>&1
mkdir -p $GVM_ROOT/environments > /dev/null 2>&1
mkdir -p "$GVM_ROOT/logs" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/gos" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/archive" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/archive/package" > /dev/null 2>&1
mkdir -p "$GVM_ROOT/environments" > /dev/null 2>&1
export GVM_VERSION=`cat $GVM_ROOT/VERSION`
export PATH=$GVM_ROOT/bin:$PATH
export GVM_PATH_BACKUP=$PATH
[ -f $GVM_ROOT/environments/default ] && . $GVM_ROOT/environments/default
. $GVM_ROOT/scripts/env/gvm
export GVM_VERSION=$(cat "$GVM_ROOT/VERSION")
export PATH="$GVM_ROOT/bin:$PATH"
export GVM_PATH_BACKUP="$PATH"
[ -f "$GVM_ROOT/environments/default" ] && . "$GVM_ROOT/environments/default"
. "$GVM_ROOT/scripts/env/gvm"
+164 -52
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
function show_usage() {
echo "Usage: gvm install [version] [options]"
@@ -7,6 +7,8 @@ function show_usage() {
echo " -n, --name=NAME Override the default name for this version."
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,13 +22,13 @@ read_command_line() {
exit 1
fi
GO_SOURCE_URL=https://go.googlecode.com/hg/
for i in $*; do
for i in "$@"; do
case $i in
-s=*|--source=*)
GO_SOURCE_URL=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
GO_SOURCE_URL=$(echo "$i" | sed 's/[-a-zA-Z0-9]*=//')
;;
-n=*|--name=*)
GO_NAME=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
GO_NAME=$(echo "$i" | sed 's/[-a-zA-Z0-9]*=//')
;;
-pb|--with-protobuf)
INSTALL_PB="true"
@@ -34,6 +36,12 @@ read_command_line() {
-b|--with-build-tools)
INSTALL_BUILD_TOOLS="true"
;;
-B|--binary)
INSTALL_SOURCE="binary"
;;
--prefer-binary)
INSTALL_SOURCE="prefer-binary"
;;
-h|--help)
show_usage
exit 0
@@ -51,23 +59,23 @@ 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"
hg 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=$(hg tags -R "$GO_CACHE_PATH" | awk '{print $1}' | $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"
hg pull -R "$GO_CACHE_PATH" >> "$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"
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. Check the logs $GVM_ROOT/logs/go-$GO_NAME-install.log"
}
@@ -78,29 +86,41 @@ compile_go() {
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")
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. Check the logs at $GVM_ROOT/logs/go-$GO_NAME-compile.log")
}
create_enviroment() {
new_env_file=$GVM_ROOT/environments/$GO_NAME
echo "export GVM_ROOT; GVM_ROOT=\"$GVM_ROOT\"" > $new_env_file
echo "export gvm_go_name; gvm_go_name=\"$GO_NAME\"" >> $new_env_file
echo "export gvm_pkgset_name; gvm_pkgset_name=\"global\"" >> $new_env_file
echo "export GOROOT; GOROOT=\"\$GVM_ROOT/gos/$GO_NAME\"" >> $new_env_file
echo "export GOPATH; GOPATH=\"\$GVM_ROOT/pkgsets/$GO_NAME/global\"" >> $new_env_file
echo "export GVM_OVERLAY_PREFIX; GVM_OVERLAY_PREFIX=\"\${GVM_ROOT}/pkgsets/${GO_NAME}/global/overlay\"" >> $new_env_file
echo "export PATH; PATH=\"\${GVM_ROOT}/pkgsets/${GO_NAME}/global/bin:\${GVM_ROOT}/gos/${GO_NAME}/bin:\${GVM_OVERLAY_PREFIX}/bin:\${GVM_ROOT}/bin:\${PATH}\"" >> $new_env_file
echo "export LD_LIBRARY_PATH; LD_LIBRARY_PATH=\"\${GVM_OVERLAY_PREFIX}/lib:\${LD_LIBRARY_PATH}\"" >> $new_env_file
echo "export DYLD_LIBRARY_PATH; DYLD_LIBRARY_PATH=\"\${GVM_OVERLAY_PREFIX}/lib:\${DYLD_LIBRARY_PATH}\"" >> $new_env_file
echo "export PKG_CONFIG_PATH; PKG_CONFIG_PATH=\"\${GVM_OVERLAY_PREFIX}/lib/pkgconfig:\${PKG_CONFIG_PATH}\"" >> $new_env_file
. $GVM_ROOT/scripts/env/use
gvm_use $GO_NAME &> /dev/null ||
echo "export GVM_ROOT; GVM_ROOT=\"$GVM_ROOT\"" > "$new_env_file"
echo "export gvm_go_name; gvm_go_name=\"$GO_NAME\"" >> "$new_env_file"
echo "export gvm_pkgset_name; gvm_pkgset_name=\"global\"" >> "$new_env_file"
echo "export GOROOT; GOROOT=\"\$GVM_ROOT/gos/$GO_NAME\"" >> "$new_env_file"
echo "export GOPATH; GOPATH=\"\$GVM_ROOT/pkgsets/$GO_NAME/global\"" >> "$new_env_file"
echo "export GVM_OVERLAY_PREFIX; GVM_OVERLAY_PREFIX=\"\${GVM_ROOT}/pkgsets/${GO_NAME}/global/overlay\"" >> "$new_env_file"
echo "export PATH; PATH=\"\${GVM_ROOT}/pkgsets/${GO_NAME}/global/bin:\${GVM_ROOT}/gos/${GO_NAME}/bin:\${GVM_OVERLAY_PREFIX}/bin:\${GVM_ROOT}/bin:\${PATH}\"" >> "$new_env_file"
echo "export LD_LIBRARY_PATH; LD_LIBRARY_PATH=\"\${GVM_OVERLAY_PREFIX}/lib:\${LD_LIBRARY_PATH}\"" >> "$new_env_file"
echo "export DYLD_LIBRARY_PATH; DYLD_LIBRARY_PATH=\"\${GVM_OVERLAY_PREFIX}/lib:\${DYLD_LIBRARY_PATH}\"" >> "$new_env_file"
echo "export PKG_CONFIG_PATH; PKG_CONFIG_PATH=\"\${GVM_OVERLAY_PREFIX}/lib/pkgconfig:\${PKG_CONFIG_PATH}\"" >> "$new_env_file"
. "$GVM_ROOT/scripts/env/use"
. "$GVM_ROOT/scripts/env/implode"
gvm_use "$GO_NAME" &> /dev/null ||
display_fatal "Failed to use installed version"
gvm pkgset create global
unset GOPATH
}
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. 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. 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. Check the logs at ${GVM_ROOT}/logs/go-${GO_NAME}-install.log"
}
install_go() {
GO_INSTALL_ROOT=$GVM_ROOT/gos/$GO_NAME
trap 'rm -rf $GO_INSTALL_ROOT; display_fatal "Cancelled!"' INT
@@ -112,7 +132,7 @@ install_go() {
exit 0
fi
display_warning "Removing corrupt install..."
gvm uninstall $GO_NAME
gvm uninstall "$GO_NAME"
fi
if [[ "$version" != "$GO_NAME" ]]; then
@@ -121,27 +141,99 @@ install_go() {
display_message "Installing $version..."
fi
# 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"
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"
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"
create_global_package_set
copy_source
compile_go
create_enviroment
}
download_binary() {
mkdir -p $GO_INSTALL_ROOT >> "${GVM_ROOT}/logs/go-${GO_NAME}-download-binary" 2>&1
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"
fi
if [ "$(uname -m)" == "x86_64" ]; then
GVM_ARCH="amd64"
else
GVM_ARCH="386"
fi
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 from http://golang.org. Trying https://go.googlecode.com"
GO_BINARY_URL="https://go.googlecode.com/files/go${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
tar zxf ${GO_BINARY_PATH} -C $GO_INSTALL_ROOT --strip-components 1 >> "${GVM_ROOT}/logs/go-${GO_NAME}-download-binary" 2>&1
if [[ $? -ne 0 ]]; then
display_error "Failed to extract binary go"
rm -rf $GO_INSTALL_ROOT
rm -f $GO_BINARY_PATH
exit 1
fi
}
install_go_binary() {
GO_INSTALL_ROOT=$GVM_ROOT/gos/$GO_NAME
trap 'rm -rf $GO_INSTALL_ROOT; display_fatal "Cancelled!"' INT
# Check for existing install
if [[ -d "$GO_INSTALL_ROOT" ]]; then
if [[ -f "$GO_INSTALL_ROOT/manifest" ]]; then
display_message "Already installed!"
exit 0
fi
display_warning "Removing corrupt install..."
gvm uninstall "$GO_NAME"
fi
display_message "Installing $GO_NAME from binary source"
create_global_package_set
download_binary
create_enviroment
}
install_gpkg() {
display_message " * Installing gpkg..."
$GVM_GOINSTALL github.com/moovweb/gpkg > $GVM_ROOT/logs/$GO_NAME-gpkg.log 2>&1 || return 1
$GVM_GOINSTALL github.com/moovweb/gpkg > "$GVM_ROOT/logs/$GO_NAME-gpkg.log" 2>&1 || return 1
}
install_gb() {
display_message " * Installing gb..."
$GVM_GOINSTALL github.com/jbussdieker/go-gb/gb > $GVM_ROOT/logs/$GO_NAME-gb.log 2>&1 || return 1
$GVM_GOINSTALL github.com/jbussdieker/go-gb/gb > "$GVM_ROOT/logs/$GO_NAME-gb.log" 2>&1 || return 1
}
install_goprotobuf() {
@@ -152,35 +244,32 @@ install_goprotobuf() {
"
display_message " * Installing goprotobuf..."
if [[ "$GVM_GOINSTALL" == "goinstall" ]]; then
$GVM_GOINSTALL goprotobuf.googlecode.com/hg/proto > $GVM_ROOT/logs/$GO_NAME-pb-compiler.log 2>&1
$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"
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
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"
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 code.google.com/p/goprotobuf/proto > "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
if [[ $? -ne 0 ]]; then
display_warning "Failed to install goprotobuf"
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 code.google.com/p/goprotobuf/protoc-gen-go > "$GVM_ROOT/logs/$GO_NAME-pb-compiler.log" 2>&1
if [[ $? -ne 0 ]]; then
display_warning "Failed to install goprotobuf compiler"
display_warning "Failed to install goprotobuf compiler. Check the logs at $GVM_ROOT/logs/$GO_NAME-pb-compiler.log"
return 1
fi
fi
}
main() {
trap 'display_fatal "Canceled!"' INT
read_command_line $@
[[ "$VERSION" == "" ]] && display_fatal "No version specified"
install_from_source() {
download_source
check_tag
if [[ "$?" == "1" ]]; then
@@ -196,7 +285,7 @@ main() {
which goinstall &> /dev/null ||
GVM_GOINSTALL="go get"
x="`hg tags -R ~/.gvm/archive/go`"; echo ${x#*b0819469a6df} | $GREP_PATH "$version " &> /dev/null
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"
@@ -207,7 +296,30 @@ main() {
fi
fi
cd $GO_INSTALL_ROOT && find . > manifest
cd "$GO_INSTALL_ROOT" && find . > manifest
}
main $@
main() {
trap 'display_fatal "Canceled!"' INT
read_command_line "$@"
[[ "$VERSION" == "" ]] && display_fatal "No version specified"
if [[ "$GO_NAME" == "" ]]; then
GO_NAME=$VERSION
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
}
main "$@"
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
. "$GVM_ROOT/scripts/functions"
function show_usage() {
echo "Usage: gvm linkthis [package-name] [options]"
echo " -h, --help Display this message."
echo
echo "If the [package-name] is provided, it will be used in the path based"
echo "at \${GOPATH%%:*}/src, e.g.:"
echo
echo " gvm linkthis github.com/moovweb/gpkg"
echo
echo "If omitted, the [package-name] will be the basename of the current"
echo "directory, e.g. '$package_name_basename'."
}
function read_command_line() {
for i in "$@"; do
case $i in
-h|--help*)
show_usage
exit 0
;;
-*|--*)
echo "Invalid option $i"
show_usage
exit 65 # Bad arguments
;;
*)
package_name="$i"
;;
esac
done
}
package_name="$(basename "$PWD")"
package_name_basename="$package_name"
read_command_line "$@"
target="${GOPATH%%:*}/src/$package_name"
mkdir -p "$(dirname "$target")"
ln -sv "$PWD" "$target"
+3 -3
View File
@@ -1,14 +1,14 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
echo
display_message "gvm gos (installed)"
echo
if [[ -d $GVM_ROOT/gos ]]; then
if [[ "$gvm_go_name" != "" ]]; then
$LS_PATH -1 $GVM_ROOT/gos | sed 's/^/ /g' | sed 's/^ '$gvm_go_name\$'/=> '$gvm_go_name'/g'
$LS_PATH -1 "$GVM_ROOT/gos" | sed 's/^/ /g' | sed 's/^ '$gvm_go_name\$'/=> '$gvm_go_name'/g'
else
$LS_PATH -1 $GVM_ROOT/gos | sed 's/^/ /g'
$LS_PATH -1 "$GVM_ROOT/gos" | sed 's/^/ /g'
fi
fi
echo
+4 -4
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
function show_usage() {
echo "Usage: gvm listall [options]"
@@ -9,7 +9,7 @@ function show_usage() {
function read_command_line() {
tag_filter="release"
for i in $*; do
for i in "$@"; do
case $i in
-a|--all)
tag_filter=""
@@ -27,12 +27,12 @@ function read_command_line() {
done
}
read_command_line $@
read_command_line "$@"
echo
display_message "gvm gos (available)"
echo
versions=`curl -s https://go.googlecode.com/hg/.hgtags | awk '{ print $2 }' | $SORT_PATH`
versions=$(curl -s https://go.googlecode.com/hg/.hgtags | awk '{ print $2 }' | $SORT_PATH)
if [[ $? -ne 0 ]]; then
display_fatal "Failed to get version list from Google"
fi
Executable
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
. "$GVM_ROOT/scripts/functions"
function show_usage() {
echo "Usage: gvm pkgenv [packageset-name]"
echo
echo " -h, --help Display this message."
echo " -o, --output Write content to stdout"
echo
echo "The [packageset-name] is optional."
echo
}
for i in "$@"; do
case $i in
-h|--help*)
show_usage
exit 0
;;
-o|--output*)
output=true
;;
*)
gvm_env="$i"
;;
esac
done
if [ -z "$gvm_go_name" ]; then
display_fatal "current go version not managed by gvm"
fi
if [ ! -z "$gvm_env" ]; then
gvm_env="@$gvm_env"
fi
env_file=$GVM_ROOT/environments/$gvm_go_name$gvm_env
if [ $output ]; then
cat "$env_file"
exit 0
fi
${EDITOR:-vi} "$env_file"
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ $gvm_go_name != "" ]] ||
display_fatal "No Go version selected"
@@ -11,7 +11,7 @@
command=$1
if [[ -f $GVM_ROOT/scripts/pkgset-$command ]]; then
shift
$GVM_ROOT/scripts/pkgset-$command $@
"$GVM_ROOT/scripts/pkgset-$command" "$@"
elif [[ -n $command ]]; then
display_fatal "Unrecognized command line argument: '$command'"
else
+7 -7
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ $1 != "" ]] ||
display_fatal "Please specifiy the name"
@@ -27,17 +27,17 @@ fi
[[ ! -f "$target_top/environments/$gvm_go_name@$target_set_name" ]] ||
display_fatal "Packageset already exists!"
mkdir -p $target_top/environments ||
mkdir -p "$target_top/environments" ||
display_fatal "Could not create environments folder"
mkdir -p $target_top/pkgsets/$gvm_go_name/$target_set_name ||
mkdir -p "$target_top/pkgsets/$gvm_go_name/$target_set_name" ||
display_fatal "Could not create packageset folder"
cp $GVM_ROOT/environments/$gvm_go_name $target_top/environments/$gvm_go_name@$target_set_name ||
cp "$GVM_ROOT/environments/$gvm_go_name" "$target_top/environments/$gvm_go_name@$target_set_name" ||
display_fatal "Could copy environment"
echo "export gvm_pkgset_name=\"$target_set_name_str\"" >> $target_top/environments/$gvm_go_name@$target_set_name ||
echo "export gvm_pkgset_name=\"$target_set_name_str\"" >> "$target_top/environments/$gvm_go_name@$target_set_name" ||
display_fatal "Could not extend environment"
echo "export GOPATH; GOPATH=\"$add_gopath:\$GOPATH\"" >> $target_top/environments/$gvm_go_name@$target_set_name ||
echo "export GOPATH; GOPATH=\"$add_gopath:\$GOPATH\"" >> "$target_top/environments/$gvm_go_name@$target_set_name" ||
display_fatal "Could not extend environment"
echo "export PATH; PATH=\"$add_path:\$PATH\"" >> $target_top/environments/$gvm_go_name@$target_set_name ||
echo "export PATH; PATH=\"$add_path:\$PATH\"" >> "$target_top/environments/$gvm_go_name@$target_set_name" ||
display_fatal "Could not extend environment"
if [ "${target_set_name}" != "global" ]; then
+3 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ $gvm_go_name != "" ]] ||
display_fatal "No Go version selected"
@@ -17,9 +17,9 @@ fi
[[ -d $target_top/pkgsets/$gvm_go_name/$target_set_name ]] ||
display_fatal "Packageset doesn't exist!"
rm -rf $target_top/pkgsets/$gvm_go_name/$target_set_name ||
rm -rf "$target_top/pkgsets/$gvm_go_name/$target_set_name" ||
display_fatal "Could not delete package set"
rm -rf $target_top/environments/$gvm_go_name@$target_set_name ||
rm -rf "$target_top/environments/$gvm_go_name@$target_set_name" ||
display_fatal "Could not delete package set"
+2 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ $gvm_pkgset_name != "" ]] ||
display_fatal "No Package set selected"
rm -rf $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/* ||
rm -rf "$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/"* ||
display_fatal "Could not delete package set files"
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
echo
display_message "gvm go package sets ($gvm_go_name)"
@@ -17,7 +17,7 @@ if [[ -d $GVM_ROOT/pkgsets/$gvm_go_name ]]; then
for cur_dir in $GVM_ROOT/pkgsets/$gvm_go_name/*; do
[[ "$cur_dir" == "$GVM_ROOT/pkgsets/$gvm_go_name/*" ]] && exit
pkgset=`basename $cur_dir`
pkgset=$(basename "$cur_dir")
if [[ "$gvm_pkgset_name" == "$pkgset" ]]; then
echo "=> $pkgset"
else
+5 -5
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions/tools
echo $1 | sed -n -e '/_.*_/ p' | $GREP_PATH "_" &> /dev/null
. "$GVM_ROOT/scripts/functions/tools"
echo "$1" | sed -n -e '/_.*_/ p' | $GREP_PATH "_" &> /dev/null
if [ "$?" == "0" ]; then
version=`echo $1 | sed 's/_\(.*\)_/\1/'`
version=$(echo $1 | sed 's/_\(.*\)_/\1/')
if [[ ! -f $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/{{package_name}}/$version/bin/{{binary_name}} ]]; then
echo "GVM: Invalid version"
exit 1
fi
shift
$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/{{package_name}}/$version/bin/{{binary_name}} $@
"$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/{{package_name}}/$version/bin/{{binary_name}}" "$@"
else
$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/{{package_name}}/current/bin/{{binary_name}} $@
"$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/{{package_name}}/current/bin/{{binary_name}}" "$@"
fi
+5 -5
View File
@@ -1,20 +1,20 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
[[ "$1" == "" ]] &&
display_fatal "Please specifiy the version"
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1"` ||
fuzzy_match=$($LS_PATH "$GVM_ROOT/gos" | $SORT_PATH | $GREP_PATH "$1" | $HEAD_PATH -n 1 | $GREP_PATH "$1") ||
display_fatal "Invalid version $1"
if [[ -d $GVM_ROOT/gos/$fuzzy_match ]]; then
rm -rf $GVM_ROOT/pkgsets/$fuzzy_match &> /dev/null ||
rm -rf "$GVM_ROOT/pkgsets/$fuzzy_match" &> /dev/null ||
display_fatal "Couldn't remove pkgsets"
rm -f $GVM_ROOT/environments/$fuzzy_match &> /dev/null ||
rm -f "$GVM_ROOT/environments/$fuzzy_match" &> /dev/null ||
display_fatal "Couldn't remove environment files"
rm -f "$GVM_ROOT/environments/$fuzzy_match@"* &> /dev/null ||
display_fatal "Couldn't remove pkgset environment files"
rm -rf $GVM_ROOT/gos/$fuzzy_match &> /dev/null ||
rm -rf "$GVM_ROOT/gos/$fuzzy_match" &> /dev/null ||
display_fatal "Couldn't remove Go folder"
display_message "Uninstalled version $fuzzy_match"
else
+3 -4
View File
@@ -1,9 +1,8 @@
#!/usr/bin/env bash
. $GVM_ROOT/scripts/functions
. "$GVM_ROOT/scripts/functions"
cd $GVM_ROOT/archive/go &> /dev/null ||
cd "$GVM_ROOT/archive/go" &> /dev/null ||
display_fatal "Failed to find local Go source"
cd $GVM_ROOT/archive/go && hg pull ||
display_fatal "Failed to update"
hg pull || display_fatal "Failed to update"
+12
View File
@@ -0,0 +1,12 @@
## Cleanup test objects
gvm uninstall tip > /dev/null 2>&1
gvm uninstall go1.1.1 > /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.1.1 #status=0
gvm list #status=0; match=/go1.1.1/
gvm install go1.2.2 #status=0
gvm list #status=0; match=/go1.2.2/
+19
View File
@@ -0,0 +1,19 @@
source $GVM_ROOT/scripts/gvm
## Cleanup test objects
gvm alias delete foo
gvm alias delete bar
#######################
gvm alias # status=0
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\.2/
gvm use bar # status=0
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\.2\)/; match=/bar \(go1\.1\.1\)/
gvm alias delete bar
gvm alias list # status=0; match=/gvm go aliases/; match!=/foo \(go1\.2\.2\)/; match!=/bar \(go1\.1\.1\)/
+1
View File
@@ -0,0 +1 @@
gvm # status=0; match=/GVM is the Go Version Manager/
+1
View File
@@ -0,0 +1 @@
gvm list # status=0
+1
View File
@@ -0,0 +1 @@
gvm listall #status=0
+5
View File
@@ -0,0 +1,5 @@
source $GVM_ROOT/scripts/gvm
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/
-4
View File
@@ -1,4 +0,0 @@
#!/usr/bin/env bash -ex
TEST_OUTPUT=`gvm version`
[ "$TEST_OUTPUT" != "" ]
echo "Success!"
+1
View File
@@ -0,0 +1 @@
gvm version # status=0
@@ -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
+3
View File
@@ -0,0 +1,3 @@
source $GVM_ROOT/scripts/gvm
yes n | gvm implode # status=0; match=/Action cancelled/
yes | gvm implode # status=0; match=/GVM successfully removed/