65 Commits
Author SHA1 Message Date
Joshua Bussdieker 1b690b3099 Merge branch 'master' into ltr 2012-03-22 22:11:01 -07:00
Joshua Bussdieker e5d5641e31 Bump version 2012-03-22 22:10:54 -07:00
Joshua Bussdieker f99f732164 Merge branch 'master' into ltr 2012-03-22 22:10:33 -07:00
Joshua Bussdieker 52a6e4afc9 Merge branch 'master' of github.com:moovweb/gvm 2012-03-22 22:09:30 -07:00
Joshua Bussdieker 3a5813784e Find the system ls command and use it to fix issue #6 2012-03-22 22:09:05 -07:00
Hampton Catlin 12b1d1a254 adding in joshs credit 2012-03-22 13:18:00 -07:00
Joshua Bussdieker be751c7d69 Bump version 2012-03-20 05:43:25 -07:00
Joshua Bussdieker 68c0ffdf9e Don't know how this got deleted 2012-03-20 05:39:50 -07:00
Joshua Bussdieker 469bd7c81c Cleanup system package install 2012-03-20 05:36:27 -07:00
Joshua Bussdieker a9640b0bbc Better error messages 2012-03-20 03:16:32 -07:00
Joshua Bussdieker 631872e847 Merge branch 'master' into ltr 2012-03-20 03:01:03 -07:00
Joshua Bussdieker aec0080464 Check for git before install 2012-03-20 03:00:40 -07:00
Joshua Bussdieker 0771bd160e Merge branch 'master' into ltr 2012-03-20 01:03:32 -07:00
Joshua Bussdieker 13ef2e1f19 Bump version 2012-03-20 01:03:26 -07:00
Joshua Bussdieker 6050e54ba7 Merge branch 'master' into ltr 2012-03-20 01:02:02 -07:00
Joshua Bussdieker 03ae59f0ff Detect existing versions of Go 2012-03-20 01:01:00 -07:00
Joshua Bussdieker bc2ef7ba41 Fix bug in pb option 2012-03-19 22:05:49 -07:00
Joshua Bussdieker a28c8f220e Use display_warning function 2012-03-19 21:51:54 -07:00
Joshua Bussdieker 6bbf1f3bb5 Safer strings 2012-03-19 21:44:39 -07:00
Joshua Bussdieker 55ae6dd774 Make protocol buffer support optional 2012-03-19 21:44:14 -07:00
Joshua Bussdieker aaf041ac83 Merge branch 'master' into ltr 2012-03-19 21:11:52 -07:00
Joshua Bussdieker 293096ad05 That's a bug if I've ever seen one! 2012-03-19 21:11:18 -07:00
Joshua Bussdieker 4558bd0b53 That's a bug if I've ever seen one! 2012-03-19 21:09:25 -07:00
Joshua Bussdieker f0e3956030 Bump version 2012-03-19 20:37:52 -07:00
Joshua Bussdieker e3246cef0d Match gpkg help format 2012-03-19 20:36:05 -07:00
Joshua Bussdieker 4359f5252f Fix path bug and add back config 2012-03-18 11:13:41 -07:00
jbussdieker e8076a83fb Merge pull request #4 from hoisie/master
Use HTTPS instead of SSH when downloading the git repo
2012-03-17 16:49:47 -07:00
Michael Hoisie bc1fc149f3 Use HTTP instead of SSH to access the git repo. Some firewalls block port port 9418 (the defailt for git ssh) 2012-03-17 14:23:12 -07:00
Joshua Bussdieker 6e8720de05 Bumping version 2012-03-17 06:58:43 -07:00
Joshua Bussdieker 0cae267942 Update source 2012-03-17 06:56:41 -07:00
Joshua Bussdieker 578436bb4e Update help and remove more gvm pkg artifacts 2012-03-14 04:42:37 -07:00
Joshua Bussdieker 97ed989f6a Long term release 2012-03-14 03:39:09 -07:00
Joshua Bussdieker 413af34098 Fix output bug 2012-03-14 03:35:00 -07:00
Joshua Bussdieker 31403a1024 Leftover from gvm pkg 2012-03-14 03:33:05 -07:00
Joshua Bussdieker 36c74ada3f Display install location 2012-03-14 03:26:18 -07:00
Joshua Bussdieker 28e9e0cd8b Update install script 2012-03-14 03:25:13 -07:00
Joshua Bussdieker d10899c1a4 Install any branch 2012-03-14 02:43:50 -07:00
Joshua Bussdieker 60b04451a3 master will now be stable. dev will be done in unstable branch 2012-03-14 02:40:58 -07:00
jbussdieker 8a65c2d001 Update README.md 2012-03-14 01:29:58 -07:00
jbussdieker eabc181127 Update README.md 2012-03-07 23:18:39 -08:00
Joshua Bussdieker 79b475b3c4 Fix indentation. Prefer .profile over .bashrc 2012-03-07 02:24:57 -08:00
Joshua Bussdieker de99e332ac Merge branch 'master' of github.com:moovweb/gvm 2012-03-07 02:19:08 -08:00
Joshua Bussdieker 043e6a44f7 Fixed profile install issue 2012-03-07 02:18:55 -08:00
jbussdieker 2b3fb6da35 Update README.md 2012-03-07 02:11:24 -08:00
Joshua Bussdieker a3da2239c9 Merge branch 'master' of github.com:moovweb/gvm 2012-03-07 01:40:14 -08:00
Joshua Bussdieker e02f21ed01 Fix pkgset list bug 2012-03-07 01:38:54 -08:00
jbussdieker 7237f663fd Update README.md 2012-03-05 04:33:34 -08:00
jbussdieker 218d322710 Update README.md 2012-03-05 04:11:47 -08:00
Joshua Bussdieker 0b7eeb4a3d 0.0.9 now in dev 2012-03-05 03:57:55 -08:00
Joshua Bussdieker 595531b7fc Taken over by gpkg 2012-03-04 22:54:05 -08:00
Joshua Bussdieker 85db8304cc Safety feature 2012-03-04 22:09:41 -08:00
Joshua Bussdieker de9ceccb78 More message cleanup 2012-03-04 18:01:08 -08:00
Joshua Bussdieker 4933d13418 Fix tabs. Can now gvm pkgset use blah --default 2012-03-04 17:34:37 -08:00
Joshua Bussdieker 9e1c0b67de Use message function 2012-03-04 17:28:47 -08:00
Joshua Bussdieker 6e720f80c1 Fix tabs 2012-03-04 17:28:35 -08:00
Joshua Bussdieker 5ef8b40fa8 Better error handling in uninstall script 2012-03-04 17:24:11 -08:00
Joshua Bussdieker 3a45cde1aa Make template Mac compatible 2012-03-02 19:15:25 -08:00
Joshua Bussdieker bdc0eb2fda More pkg install improvements 2012-03-02 19:02:51 -08:00
Joshua Bussdieker 2f562e6d3c Template for installed binaries 2012-03-02 19:02:37 -08:00
Joshua Bussdieker 99f4c5035c Fix pkg install 2012-03-02 17:52:08 -08:00
Joshua Bussdieker 503ec01aaa Added gvm update to download updateds to the Go source 2012-03-02 01:31:00 -08:00
Joshua Bussdieker d4fa2d8bdb Cleanup Go install script. 2012-03-02 01:30:51 -08:00
Joshua Bussdieker 9711c445d8 Skip tests for now... 2012-03-02 01:30:43 -08:00
Joshua Bussdieker 6d5e3ec8d5 These will be replaced with gpkg 2012-03-01 23:27:41 -08:00
Joshua Bussdieker 1b5197c450 Bump again 2012-03-01 23:27:16 -08:00
29 changed files with 291 additions and 433 deletions
+13
View File
@@ -1,3 +1,16 @@
Version: 1.0.x
State: LTR
CHANGES:
* Minor bug fixes and cleanup. 1.0.x will always be a safe upgrade path.
Version: 0.0.8
State: Stable
CHANGES:
* Complete overhaul of the package system. Now uses
http://github.com/moovweb/gpkg
Version: 0.0.7
State: Stable
+24 -13
View File
@@ -1,30 +1,36 @@
# gvm
by Josh Bussdieker (jbuss, jaja, jbussdieker)
GVM provides an interface to manage Go versions.
Features
========
* Install/Uninstall Go versions with `gvm install [tag]` where tag is "60.3", "weekly.2011-11-08", or "tip"
* List added/removed files in GOROOT with `gvm diff`
* Manage GOPATHs with `gvm pkgset [create/use/delete] [name]`
* 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.
Background
==========
When we started developing in Go mismatched dependencies and API changes plauged our build process and made it extremely difficult to merge with other peoples changes.
After nuking my entire GOROOT several times and rebuilding I decided to come up with a tool to oversee the process. It eventually evolved into what gvm is today.
Installing
==========
To install the stable release run:
bash -s stable < <(curl -s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)
To install the development branch (NOT USUALLY RECOMMENDED!) run:
To install:
bash < <(curl -s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)
Protect Your GO!
================
sudo chown -R root:root ~/.gvm/gos/
This will keep libraries from accidentally installing into the main Go soure tree
Installing Go
=============
gvm install 60.3
gvm use 60.3
Once this is done Go will be in the path and ready to use. $GOROOT is set automatically.
Once this is done Go will be in the path and ready to use. $GOROOT and $GOPATH are set automatically.
You are now ready to create and use packages built using gpkg. Instructions can be found at http://github.com/moovweb/gpkg
List Go Versions
================
@@ -38,6 +44,8 @@ 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 OSX Requirements
====================
Install mercurial from http://mercurial.berkwood.com/
@@ -52,3 +60,6 @@ Linux Requirements
sudo apt-get install bison
sudo apt-get install gcc
Troubleshooting
===============
Sometimes especially during upgrades the state of gvm's files can get mixed up. This is mostly true for upgrade from older version than 0.0.8. Changes are slowing down and a LTR is imminent. But for now `rm -rf ~/.gvm` will always remove gvm. Stay tuned!
+1 -1
View File
@@ -1 +1 @@
0.0.7
1.0.14
+9 -15
View File
@@ -20,11 +20,11 @@ fi
$GVM_ROOT/scripts/gvm-check
if [[ "$?" != "0" ]]; then
display_error "Missing requirements. Please see messages above"
display_error "Missing requirements."
fi
if [[ $command == "version" ]]; then
display_message "Go Version Manager v$GVM_VERSION"
display_message "Go Version Manager v$GVM_VERSION installed at $GVM_ROOT"
else
if [ -f $GVM_ROOT/scripts/$command ]; then
shift
@@ -32,28 +32,22 @@ else
elif [[ -n $command ]]; then
display_error "Unrecognized command line argument: '$command'"
else
echo "= gvm
echo "Usage: gvm [command]
* http://github.com/moovweb/gvm
== DESCRIPTION:
GVM is the Go Version Manager
== Usage
gvm Command
== Command
Description:
GVM is the Go Version Manager
Commands:
version - print the gvm version number
get - gets the latest code (for debugging)
use - select a go version to use
diff - view changes to Go root
implode - completely remove gvm
install - install go versions
uninstall - uninstall go versions
list - list installed go versions
listall - list available versions
pkgset - manage go packages sets
pkg - manage go packages"
"
fi
fi
-6
View File
@@ -1,6 +0,0 @@
if [[ -f Makefile.gvm ]]; then
make -f Makefile.gvm $@
else
gb -bi
fi
+72 -34
View File
@@ -7,55 +7,93 @@ display_error() {
exit 1
}
update_profile() {
[ -f $1 ] || return 1
cat $1 | grep "$source_line" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$source_line" >> $1
fi
}
check_existing_go() {
if [ "$GOROOT" == "" ]; then
echo "No existing Go versions detected"
return
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"
cat << EOF > $GVM_DEST/$GVM_NAME/environments/system
# Automatically generated file. DO NOT EDIT!
export GVM_ROOT; GVM_ROOT="$GVM_DEST/$GVM_NAME"
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"
EOF
}
BRANCH=$1
if [ "$(whoami)" != "root" ]; then
GVM_DEST=~
GVM_NAME=.gvm
GVM_DEST=$2
if [ "$GVM_DEST" == "" ]; then
GVM_DEST="$HOME"
GVM_NAME=".gvm"
else
GVM_DEST=/usr/local
GVM_NAME=gvm
GVM_NAME="gvm"
fi
ENV_FILE=~/.bashrc
SRC_REPO=git://github.com/moovweb/gvm.git
#SRC_REPO=~/install.gvm
SRC_REPO=https://github.com/moovweb/gvm.git
[ "$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
linux: apt-get 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"
if [ "$BRANCH" == "stable" ]; then
cd $GVM_DEST/$GVM_NAME && git checkout $BRANCH > /dev/null 2>&1 ||
display_error "Failed to checkout $BRANCH branch"
if [ "$BRANCH" != "" ]; then
cd $GVM_DEST/$GVM_NAME && git checkout $BRANCH > /dev/null 2>&1 ||
display_error "Failed to checkout $BRANCH branch"
fi
mv $GVM_DEST/$GVM_NAME/.git $GVM_DEST/$GVM_NAME/git.bak
if [ "$(whoami)" != "root" ]; then
if [ -e ~/.bashrc ]; then
cat ~/.bashrc | grep "\[\[ -s \"\$HOME/.gvm/scripts/gvm\" ]] && source \"\$HOME/.gvm/scripts/gvm\"" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo '[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"' >> $ENV_FILE
fi
elif [ -e ~/.profile ]; then
cat ~/.bashrc | grep "\[\[ -s \"\$HOME/.gvm/scripts/gvm\" ]] && source \"\$HOME/.gvm/scripts/gvm\"" > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo '[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"' >> $ENV_FILE
fi
else
echo 'Unable to location profile settings file'
echo
echo " You will have to manually add the following line:"
echo " [[ -s \"\$HOME/.gvm/scripts/gvm\" ]] && source \"\$HOME/.gvm/scripts/gvm\""
echo
echo "To get started right away run \`source ~/.gvm/scripts/gvm\`"
echo
fi
if [ "$GVM_NAME" == ".gvm" ]; then
source_line="[[ -s \"\$HOME/.gvm/scripts/gvm\" ]] && source \"\$HOME/.gvm/scripts/gvm\""
source_file="\$HOME/.gvm/scripts/gvm"
else
source_line="[[ -s \"${GVM_DEST}/gvm/scripts/gvm\" ]] && source \"${GVM_DEST}/gvm/scripts/gvm\""
source_file="${GVM_DEST}/gvm/scripts/gvm"
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
fi
if [ "$?" != "0" ]; then
echo 'Unable to locate profile settings file'
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
check_existing_go
[[ -s "$GVM_DEST/$GVM_NAME/scripts/gvm" ]] && source "$GVM_DEST/$GVM_NAME/scripts/gvm"
echo "Installed GVM v$GVM_VERSION"
echo "Please restart your terminal session"
echo "Installed GVM v${GVM_VERSION}"
echo
echo "Please restart your terminal session or to get started right away run"
echo " \`source ${source_file}\`"
echo
+1 -1
View File
@@ -1 +1 @@
git@github.com:moovweb
git://github.com/moovweb
+6 -4
View File
@@ -1,5 +1,7 @@
_gvm()
{
LS_PATH=`which ls` || return 1
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@@ -13,7 +15,7 @@ _gvm()
use|delete|empty)
[[ "$gvm_go_name" == "" ]] && return 1
[[ $COMP_CWORD > 3 ]] && return 1
local version=$(for x in `ls $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
;;
@@ -33,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 $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 $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
@@ -63,7 +65,7 @@ _gvm()
use|uninstall)
[ ! -d $GVM_ROOT/gos ] && return 1
[[ $COMP_CWORD > 2 ]] && return 1
local installed_versions=$(for x in `ls $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
;;
+2 -1
View File
@@ -1,10 +1,11 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1
version=$1
if [ "$version" != "" ]; then
fuzzy_match=`ls $GVM_ROOT/gos | sort | grep "$version" | head -n 1 | grep "$version"` ||
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | sort | grep "$version" | head -n 1 | grep "$version"` ||
display_error "Invalid version $version"
foldername=$GVM_ROOT/gos/$fuzzy_match
+4
View File
@@ -12,6 +12,10 @@ function 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 ||
display_error "Failed to move git info out of the way"
fi
if [[ ! -d $GVM_ROOT ]]; then
display_error "GVM_ROOT does not exist. Please reinstall GVM"
return $?
+20 -2
View File
@@ -1,4 +1,7 @@
display_error() {
#!/bin/bash
. $GVM_ROOT/scripts/function/errors
function display_error() {
tput sgr0
tput setaf 1
echo "ERROR: $1" >&2
@@ -6,19 +9,34 @@ display_error() {
return 1
}
function display_message() {
# GREEN!
tput sgr0
tput setaf 2
echo "$1"
tput sgr0
}
function gvm_pkgset_use() {
LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1
[[ "$1" != "" ]] ||
display_error "Please specify a package set" || return 1
[[ "$gvm_go_name" != "" ]] ||
display_error "No Go version selected" || return 1
fuzzy_match=`ls $GVM_ROOT/environments | sort | grep "$gvm_go_name@" | grep "$1" | head -n 1` ||
fuzzy_match=`$LS_PATH $GVM_ROOT/environments | sort | grep "$gvm_go_name@" | grep "$1" | head -n 1` ||
display_error "Invalid package set" || return 1
export PATH=$GVM_PATH_BACKUP
. "$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
fi
echo "Now using version $fuzzy_match"
}
+9 -4
View File
@@ -1,3 +1,6 @@
#!/bin/bash
. $GVM_ROOT/scripts/function/errors
function display_error() {
tput sgr0
tput setaf 1
@@ -6,7 +9,7 @@ function display_error() {
return 1
}
display_message() {
function display_message() {
# GREEN!
tput sgr0
tput setaf 2
@@ -15,15 +18,17 @@ display_message() {
}
function gvm_use() {
LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1
[[ "$1" != "" ]] ||
display_error "Please specifiy the version" || return 1
fuzzy_match=`ls $GVM_ROOT/gos | sort | grep "$1" | head -n 1 | grep "$1"` ||
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | sort | grep "$1" | head -n 1 | grep "$1"` ||
display_error "Invalid version $1" || return 1
export PATH=$GVM_PATH_BACKUP
. $GVM_ROOT/environments/$fuzzy_match
. $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
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"
+7
View File
@@ -0,0 +1,7 @@
display_warning() {
# YELLOW!
tput sgr0
tput setaf 3
echo "$1"
tput sgr0
}
+1
View File
@@ -0,0 +1 @@
LS_ERROR="Couldn't find ls"
+1 -1
View File
@@ -8,7 +8,7 @@ cd $GVM_ROOT && git checkout -f ||
display_error "Failed to clean install"
if [[ -n $1 ]]; then
cd $GVM_ROOT && git checkout $1 -f ||
cd $GVM_ROOT && git checkout $1 -f ||
display_error "Failed to checkout $1 branch"
fi
+31 -9
View File
@@ -1,15 +1,37 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
# Check for hg
[ -z `which hg` ] &&
display_error '* Could not find mercurial (try `sudo apt-get install mercurial`)'
[ -z `which ar` ] &&
display_error '* Could not find binutils (try `sudo apt-get install binutils (or binutils-multiarch)`)'
[ -z `which bison` ] &&
display_error '* Could not find bison (try `sudo apt-get install bison`)'
[ -z `which gcc` ] &&
display_error '* Could not find gcc (try `sudo apt-get install gcc`)'
[ -z `which make` ] &&
display_error '* Could not find make (try `sudo apt-get install make`)'
display_warning "Could not find mercurial
linux: apt-get install mercurial
mac: brew install mercurial
" && exit 1
# Check for ar
[ -z `which ar` ] &&
display_warning "Could not find binutils
linux: apt-get install binutils
" && exit 1
# Check for bison
[ -z `which bison` ] &&
display_warning "Could not find bison
linux: apt-get install bison
" && exit 1
# Check for gcc
[ -z `which gcc` ] &&
display_warning "Could not find gcc
linux: apt-get install gcc
" && exit 1
# Check for make
[ -z `which make` ] &&
display_warning "Could not find make
linux: apt-get install make
" && exit 1
# All good!
exit 0
+40 -35
View File
@@ -3,25 +3,35 @@
function show_usage() {
echo "Usage: gvm install [version] [options]"
echo " -s, --source=SOURCE Install Go from specified source."
echo " -h, --help Display this message."
echo " -s, --source=SOURCE Install Go from specified source."
echo " -pb, --with-protobuf Install Go protocol buffers."
echo " -h, --help Display this message."
}
read_command_line() {
VERSION=$1
shift
if [ "${VERSION:0:1}" != "-" ]; then
shift
else
display_warning "Invalid version: $1"
show_usage
exit 1
fi
GO_SOURCE_URL=https://go.googlecode.com/hg/
for i in $*; do
case $i in
-s=*|--source=*)
GO_SOURCE_URL=$i
;;
-h|--help*)
-pb|--with-protobuf)
INSTALL_PB="true"
;;
-h|--help)
show_usage
exit 0
;;
*)
echo "Invalid option $i"
display_warning "Invalid option $i"
show_usage
exit 65 # Bad arguments
;;
@@ -32,17 +42,17 @@ read_command_line() {
download_source() {
GO_CACHE_PATH=$GVM_ROOT/archive/go
[ -d $GO_CACHE_PATH ] && return
echo "Downloading Go source..."
display_message "Downloading Go source..."
hg clone $GO_SOURCE_URL $GO_CACHE_PATH >> $GVM_ROOT/logs/go-download.log 2>&1 ||
display_error "Couldn't download Go source"
}
check_tag() {
version=`hg tags -R $GO_CACHE_PATH | awk '{print $1}' | sort | grep $VERSION | head -n 1 | grep $VERSION`
version=`hg tags -R $GO_CACHE_PATH | awk '{print $1}' | sort | grep "$VERSION" | head -n 1 | grep "$VERSION"`
}
update_source() {
echo "Updating Go source..."
display_message "Updating Go source..."
hg pull -R $GO_CACHE_PATH >> $GVM_ROOT/logs/go-download.log 2>&1 ||
display_error "Couldn't get latest Go version info"
}
@@ -54,7 +64,7 @@ copy_source() {
compile_go() {
echo " * Compiling..."
display_message " * Compiling..."
unset GOARCH && unset GOOS && unset GOPATH && unset GOBIN && unset GOROOT &&
export GOBIN=$GO_INSTALL_ROOT/bin &&
export PATH=$GOBIN:$PATH &&
@@ -84,10 +94,14 @@ install_go() {
trap 'rm -rf $GO_INSTALL_ROOT; display_error "Canceled!"' INT
# Check for existing install
[ -d $GO_INSTALL_ROOT ] &&
display_error "Already installed!"
if [ -d "$GO_INSTALL_ROOT" ]; then
[ -f "$GO_INSTALL_ROOT/manifest" ] &&
display_error "Already installed!"
display_warning "Removing corrupt install..."
gvm uninstall $version
fi
echo "Installing $version..."
display_message "Installing $version..."
# Create the global package set folder
mkdir -p $GVM_ROOT/pkgsets/$version >> $GVM_ROOT/logs/go-$version-install.log 2>&1 ||
@@ -99,35 +113,27 @@ install_go() {
}
install_gpkg() {
echo " * Installing gpkg..."
$GVM_GOINSTALL github.com/moovweb/gpkg > $GVM_ROOT/logs/$version-gpkg.log 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install gpkg"
return 1
fi
display_message " * Installing gpkg..."
$GVM_GOINSTALL github.com/moovweb/gpkg > $GVM_ROOT/logs/$version-gpkg.log 2>&1 || return 1
}
install_gb() {
echo " * Installing gb..."
$GVM_GOINSTALL github.com/skelterjohn/go-gb/gb > $GVM_ROOT/logs/$version-gb.log 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install gb"
return 1
fi
display_message " * Installing gb..."
$GVM_GOINSTALL github.com/jbussdieker/go-gb/gb > $GVM_ROOT/logs/$version-gb.log 2>&1 || return 1
}
install_goprotobuf() {
echo " * Installing goprotobuf..."
display_message " * Installing goprotobuf..."
$GVM_GOINSTALL goprotobuf.googlecode.com/hg/proto > $GVM_ROOT/logs/$version-pb-compiler.log 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install goprotobuf"
display_warning "Failed to install goprotobuf"
return 1
fi
#if [[ $version == "release.r60.3" ]]; then
cd $GVM_ROOT/gos/$version/src/pkg/goprotobuf.googlecode.com/hg/compiler
make install >> $GVM_ROOT/logs/$version-pb-compiler.log 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install goprotobuf compiler"
display_warning "Failed to install goprotobuf compiler"
return 1
fi
#fi
@@ -136,24 +142,23 @@ install_goprotobuf() {
main() {
trap 'display_error "Canceled!"' INT
read_command_line $@
# GREEN!
tput sgr0
tput setaf 2
[ -z $VERSION ] && display_error "No version specified"
[ "$VERSION" == "" ] && display_error "No version specified"
download_source
check_tag || (update_source && check_tag) || display_error "Unrecognized Go version"
install_go
GVM_GOINSTALL="goinstall"
which goinstall &> /dev/null ||
GVM_GOINSTALL="go get"
x="`hg tags -R ~/.gvm/archive/go`"; echo ${x#*b0819469a6df} | grep "$version " &> /dev/null
if [[ "$?" == "1" ]]; then
install_gpkg
install_gb
install_goprotobuf
install_gb || display_warning "Failed to install gb"
install_gpkg || display_warning "Failed to install gpkg"
if [ "$INSTALL_PB" == "true" ]; then
install_goprotobuf
fi
fi
cd $GO_INSTALL_ROOT && find . > manifest
tput sgr0
}
main $@
+3 -2
View File
@@ -1,14 +1,15 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1
echo
display_message "gvm gos (installed)"
echo
if [ -d $GVM_ROOT/gos ]; then
if [[ "$gvm_go_name" != "" ]]; then
ls -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 -1 $GVM_ROOT/gos | sed 's/^/ /g'
$LS_PATH -1 $GVM_ROOT/gos | sed 's/^/ /g'
fi
fi
echo
-36
View File
@@ -1,36 +0,0 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
[[ $gvm_go_name != "" ]] ||
display_error "No Go version selected"
[[ -d $GVM_ROOT/gos/$gvm_go_name ]] ||
display_error "Invalid or corrupt Go version"
[[ -d $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name ]] ||
display_error "Missing package set folder"
command=$1
if [ -f $GVM_ROOT/scripts/pkg-$command ]; then
shift
$GVM_ROOT/scripts/pkg-$command $@
elif [[ -n $command ]]; then
display_error "Unrecognized command line argument: '$command'"
else
echo "= gvm pkg
* http://github.com/moovweb/gvm
== DESCRIPTION:
GVM Package is used to manage various Go packages
== Usage
gvm pkg Command
== Command
install - install go packages
uninstall - uninstall go packages
list - list installed go packages"
fi
-171
View File
@@ -1,171 +0,0 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
show_usage() {
echo "Usage: gvm pkg install Package [options]"
echo " -v, --version=VERSION Set the package version to install."
echo " -s, --source=SORUCE Specify the source for this package."
echo " --strict Only use installed packages."
echo " -a, --all Update all dependencies."
echo " -h, --help Display this message."
}
function read_command_line() {
[[ "$1" == "" ]] &&
display_error "Please specify package name"
# Get package name
package_name=$1
source="git@github.com:moovweb/$1"
shift
for i in $*; do
case $i in
-v=*|--version=*)
version=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
-s=*|--source=*)
source=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
-a|--all)
all_deps="true"
;;
-h|--help*)
show_usage
exit 0
;;
--strict)
strict="true"
;;
*)
echo "Invalid option $i"
show_usage
exit 65 # Bad arguments
;;
esac
done
gvm_go_path=$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name
source_dir=$GVM_ROOT/tmp/$package_name/src
build_dir=$GVM_ROOT/tmp/$package_name/build
}
function download_package() {
rm -rf $source_dir && mkdir -p $source_dir
if [[ "$source" != "." ]]; then
echo "Downloading $package_name..."
git clone $source $source_dir > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
rm -rf $source_dir
display_error "Could not find $package_name in any sources"
fi
fi
}
function select_version() {
if [ "$version" != "" ]; then
echo "Checking out $version"
cd $source_dir > /dev/null 2>&1 ||
display_error "Source directory doesn't exist"
git checkout $version > /dev/null 2>&1 ||
display_error "Invalid version $version"
fi
}
function setup_build_env() {
rm -rf $build_dir && mkdir -p $build_dir
select_version
if [[ -f $source_dir/VERSION ]]; then
SOURCE_VERSION=`cat $source_dir/VERSION`
else
SOURCE_VERSION="0.0"
fi
if [[ -n $BUILD_NUMBER ]]; then
BUILD_NUMBER="$SOURCE_VERSION.$BUILD_NUMBER"
else
BUILD_NUMBER="$SOURCE_VERSION.dev"
fi
}
function install_dep() {
[[ "$strict" == "true" ]] && display_error "Missing dependancy ($1) and strict mode is set"
[[ "$source" == "." ]] && passthrough_options="--source=. "$passthrough_options
[[ "$all_deps" == "true" ]] && passthrough_options="--all "$passthrough_options
gvm pkg install $1 $passthrough_options ||
display_error "Failed to install dependency $1"
}
function load_dep() {
if [[ "$all_deps" == "true" ]]; then
install_dep $1
fi
CUR_PKG=$gvm_go_path/pkg.gvm/$1/current
if [ -e "$CUR_PKG/BUILD_VERSION" ]; then
echo "pkg $1 `cat $CUR_PKG/BUILD_VERSION`" >> $build_dir/manifest
else
install_dep $1
fi
cp -rf $CUR_PKG/pkg $build_dir
}
function check_deps() {
export GOPATH=$build_dir
echo ":source $source" >> $build_dir/manifest
if [ -f "$source_dir/Package.gvm" ]; then
for line in `cat $source_dir/Package.gvm | grep ^pkg | awk '{ print $2 }'`; do
load_dep $line
done
fi
echo ":complete" >> $build_dir/manifest
}
function copy_source() {
mkdir -p $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER
cp -rf $source_dir $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER/
}
function build_package() {
echo "Installing $package_name..."
echo "$BUILD_NUMBER" > $build_dir/BUILD_VERSION
cd $source_dir && gvmake > $build_dir/build.log 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: Failed to build"
cat "$build_dir/build.log"
exit 1
fi
}
function install_package() {
mkdir -p $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER &&
cp -r $build_dir/* $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER &&
rm -f $gvm_go_path/pkg.gvm/$package_name/current &&
ln -s $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER $gvm_go_path/pkg.gvm/$package_name/current &&
if [ $? -ne 0 ]; then
echo "ERROR: Failed to install"
exit 1
fi
if [ -d $build_dir/bin ]; then
echo " * Installing binaries"
mkdir -p $gvm_go_path/bin &&
cp -f $build_dir/bin/* $gvm_go_path/bin/
fi
}
function cleanup() {
rm -rf $build_dir
rm -rf $source_dir
}
read_command_line $@
download_package
setup_build_env
check_deps
copy_source
build_package
install_package
cleanup
-39
View File
@@ -1,39 +0,0 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
echo "
gvm packages $gvm_go_name@$gvm_pkgset_name"
echo
package_folder=$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name
for package in $package_folder/pkg.gvm/*; do
if [ $package == "$package_folder/pkg.gvm/*" ]; then
break
fi
package_name=`echo $package | awk '{ n=split($1,path,"/"); print path[n] }'`
output=$package_name" ("
first=true
for version in $package/*; do
version=`echo $version | awk '{ n=split($1,path,"/"); print path[n] }'`
if [ "$version" != "current" ]; then
if [ $first == true ]; then
first=false
else
output=$output", "
fi
version=`echo $version | awk '{ n=split($1,path,"/"); print path[n] }'`
output=$output$version
fi
done
output=$output")"
echo $output
done
if [ -f $package_folder/goinstall.log ]; then
echo
echo "Installing via goinstall"
echo
cat $package_folder/goinstall.log
fi
echo
-31
View File
@@ -1,31 +0,0 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
[[ "$1" == "" ]] &&
display_error "Please specify package name"
gvm_go_path=$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name
UNINSTALL_ROOT=$gvm_go_path/pkg.gvm/$1
if [[ ! -d $UNINSTALL_ROOT ]]; then
echo "ERROR: Invalid package name"
exit 1
fi
if [[ "$2" != "" ]]; then
UNINSTALL_ROOT=$UNINSTALL_ROOT/$2
fi
if [[ -d $UNINSTALL_ROOT ]]; then
rm -rf $UNINSTALL_ROOT
else
echo "ERROR: Invalid package version"
exit 1
fi
if [[ "$4" != "" ]]; then
echo "Uninstalled $1 version $2"
else
echo "Uninstalled $1"
fi
+2 -2
View File
@@ -13,8 +13,8 @@ cp $GVM_ROOT/environments/$gvm_go_name $GVM_ROOT/environments/$gvm_go_name@$1 ||
display_error "Could copy environment"
echo "export gvm_pkgset_name=\"$1\"" >> $GVM_ROOT/environments/$gvm_go_name@$1 ||
display_error "Could not extend environment"
echo "export GOPATH; GOPATH=\"$GVM_ROOT/pkgsets/release.r60.3/$1:\$GOPATH\"" >> $GVM_ROOT/environments/$gvm_go_name@$1 ||
echo "export GOPATH; GOPATH=\"$GVM_ROOT/pkgsets/$gvm_go_name/$1:\$GOPATH\"" >> $GVM_ROOT/environments/$gvm_go_name@$1 ||
display_error "Could not extend environment"
echo "export PATH; PATH=\"$GVM_ROOT/pkgsets/release.r60.3/$1/bin:\$PATH\"" >> $GVM_ROOT/environments/$gvm_go_name@$1 ||
echo "export PATH; PATH=\"$GVM_ROOT/pkgsets/$gvm_go_name/$1/bin:\$PATH\"" >> $GVM_ROOT/environments/$gvm_go_name@$1 ||
display_error "Could not extend environment"
+2 -2
View File
@@ -1,8 +1,8 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
[[ $gvm_pkgset_name != "" ]] ||
[[ $gvm_pkgset_name != "" ]] ||
display_error "No Package set selected"
rm -rf $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/* ||
display_error "Could not delete package set files"
display_error "Could not delete package set files"
+16 -9
View File
@@ -1,13 +1,20 @@
#!/bin/bash
echo "
gvm go package sets ($gvm_go_name)
"
if [ -d $GVM_ROOT/pkgsets ]; then
if [[ $gvm_pkgset_name == "" ]]; then
ls -1 $GVM_ROOT/pkgsets/$gvm_go_name | sed 's/^/ /g'
else
ls -1 $GVM_ROOT/pkgsets/$gvm_go_name | sed 's/^/ /g' | sed 's/^ '$gvm_pkgset_name'/=> '$gvm_pkgset_name'/g'
fi
. $GVM_ROOT/scripts/functions
echo
display_message "gvm go package sets ($gvm_go_name)"
echo
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`
if [[ "$gvm_pkgset_name" == "$pkgset" ]]; then
echo "=> $pkgset"
else
echo " $pkgset"
fi
done
fi
echo
-6
View File
@@ -1,6 +0,0 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
display_message "*** CURRENT SOURCES ***"
echo
cat $GVM_ROOT/config/sources
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
echo $1 | sed -n -e '/_.*_/ p' | grep "_" &> /dev/null
if [ "$?" == "0" ]; then
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}} $@
else
$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/{{package_name}}/current/bin/{{binary_name}} $@
fi
+12 -8
View File
@@ -1,19 +1,23 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
LS_PATH=`which ls` || display_error "$LS_ERROR" || return 1
[[ "$1" == "" ]] &&
display_error "Please specifiy the version"
fuzzy_match=`ls $GVM_ROOT/gos | sort | grep "$1" | head -n 1 | grep "$1"` ||
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | sort | grep "$1" | head -n 1 | grep "$1"` ||
display_error "Invalid version $1"
if [ -d $GVM_ROOT/gos/$fuzzy_match ]; then
rm -rf $GVM_ROOT/gos/$fuzzy_match
rm -rf $GVM_ROOT/pkgsets/$fuzzy_match
rm -f $GVM_ROOT/environments/$fuzzy_match
rm -f "$GVM_ROOT/environments/$fuzzy_match@"*
echo "Uninstalled version $fuzzy_match"
rm -rf $GVM_ROOT/pkgsets/$fuzzy_match &> /dev/null ||
display_error "Couldn't remove pkgsets"
rm -f $GVM_ROOT/environments/$fuzzy_match &> /dev/null ||
display_error "Couldn't remove environment files"
rm -f "$GVM_ROOT/environments/$fuzzy_match@"* &> /dev/null ||
display_error "Couldn't remove pkgset environment files"
rm -rf $GVM_ROOT/gos/$fuzzy_match &> /dev/null ||
display_error "Couldn't remove Go folder"
display_message "Uninstalled version $fuzzy_match"
else
display_error "Invalid version"
display_error "Invalid version"
fi
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
cd $GVM_ROOT/archive/go ||
cd $GVM_ROOT/archive/go &> /dev/null ||
display_error "Failed to find local Go source"
cd $GVM_ROOT/archive/go && hg pull ||