This commit is contained in:
Joshua Bussdieker
2012-03-28 11:01:18 -07:00
18 changed files with 67 additions and 96 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ if [ -z "$GVM_ROOT" ]; then
exit 1
fi
. $GVM_ROOT/scripts/functions
. $GVM_ROOT/scripts/functions || exit 1
command=$1
if [[ $command == "implode" ]]; then
+5
View File
@@ -0,0 +1,5 @@
Package: gvm
Version: 1.0.15
Architecture: all
Maintainer: Joshua Bussdieker <josh.bussdieker@moovweb.com>
Description: Go Version Manager
+3 -3
View File
@@ -5,14 +5,14 @@ version=$1
if [ "$version" != "" ]; then
fuzzy_match=`$LS_PATH $GVM_ROOT/gos | $SORT_PATH | $GREP_PATH "$version" | $HEAD_PATH -n 1 | $GREP_PATH "$version"` ||
display_error "Invalid version $version"
display_fatal "Invalid version $version"
foldername=$GVM_ROOT/gos/$fuzzy_match
else
if [[ "$gvm_go_name" != "" ]]; then
foldername=$GVM_ROOT/gos/$gvm_go_name
else
display_error "No version selected"
display_fatal "No version selected"
fi
fi
@@ -26,5 +26,5 @@ if [[ -d $foldername ]]; then
display_message "*Dirty* $foldername"
fi
else
display_error "Invalid version"
display_fatal "Invalid version"
fi
+1 -7
View File
@@ -1,11 +1,5 @@
#!/bin/bash
function display_error() {
tput sgr0
tput setaf 1
echo "ERROR: $1" >&2
tput sgr0
return 1
}
. $GVM_ROOT/scripts/functions || return 1
function gvm() {
if [[ "$GVM_ROOT" == "" ]]; then
-18
View File
@@ -1,22 +1,4 @@
#!/bin/bash
. $GVM_ROOT/scripts/function/tools
function display_error() {
tput sgr0
tput setaf 1
echo "ERROR: $1" >&2
tput sgr0
return 1
}
function display_message() {
# GREEN!
tput sgr0
tput setaf 2
echo "$1"
tput sgr0
}
function gvm_pkgset_use() {
[[ "$1" != "" ]] ||
display_error "Please specify a package set" || return 1
-18
View File
@@ -1,22 +1,4 @@
#!/bin/bash
. $GVM_ROOT/scripts/function/tools
function display_error() {
tput sgr0
tput setaf 1
echo "ERROR: $1" >&2
tput sgr0
return 1
}
function display_message() {
# GREEN!
tput sgr0
tput setaf 2
echo "$1"
tput sgr0
}
function gvm_use() {
[[ "$1" != "" ]] ||
display_error "Please specifiy the version" || return 1
+1 -1
View File
@@ -3,6 +3,6 @@ display_error() {
tput setaf 1
echo "ERROR: $1" >&2
tput sgr0
exit 1
return 1
}
+8
View File
@@ -0,0 +1,8 @@
display_fatal() {
tput sgr0
tput setaf 1
echo "ERROR: $1" >&2
tput sgr0
exit 1
}
+4 -4
View File
@@ -1,8 +1,8 @@
#!/bin/bash
LS_ERROR="Couldn't find ls"
GREP_ERROR="Couldn't find grep"
SORT_ERROR="Couldn't find sort"
HEAD_ERROR="Couldn't find head"
LS_ERROR="GVM couldn't find ls"
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
+5 -5
View File
@@ -2,19 +2,19 @@
. $GVM_ROOT/scripts/functions
[[ -d $GVM_ROOT/.git ]] || mv $GVM_ROOT/git.bak $GVM_ROOT/.git &> /dev/null ||
display_error "Couldn't find git info"
display_fatal "Couldn't find git info"
cd $GVM_ROOT && git checkout -f ||
display_error "Failed to clean install"
display_fatal "Failed to clean install"
if [[ -n $1 ]]; then
cd $GVM_ROOT && git checkout $1 -f ||
display_error "Failed to checkout $1 branch"
display_fatal "Failed to checkout $1 branch"
fi
cd $GVM_ROOT && git pull ||
display_error "Failed to update"
display_fatal "Failed to update"
mv $GVM_ROOT/.git $GVM_ROOT/git.bak ||
display_error "Couldn't backup git info"
display_fatal "Couldn't backup git info"
+11 -11
View File
@@ -44,7 +44,7 @@ download_source() {
[[ -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_error "Couldn't download Go source"
display_fatal "Couldn't download Go source"
}
check_tag() {
@@ -54,12 +54,12 @@ check_tag() {
update_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"
display_fatal "Couldn't get latest Go version info"
}
copy_source() {
hg clone -u $version $GO_CACHE_PATH $GO_INSTALL_ROOT >> $GVM_ROOT/logs/go-$version-install.log 2>&1 ||
display_error "Couldn't copy source to target folder"
display_fatal "Couldn't copy source to target folder"
}
@@ -71,7 +71,7 @@ compile_go() {
export GOROOT=$GO_INSTALL_ROOT &&
#cd $GO_INSTALL_ROOT/src && ./all.bash &> $GVM_ROOT/logs/go-$version-compile.log ||
cd $GO_INSTALL_ROOT/src && ./make.bash &> $GVM_ROOT/logs/go-$version-compile.log ||
(rm -rf $GO_INSTALL_ROOT && display_error "Failed to compile")
(rm -rf $GO_INSTALL_ROOT && display_fatal "Failed to compile")
}
create_enviroment() {
@@ -84,19 +84,19 @@ create_enviroment() {
echo "export PATH; PATH=\"\$GVM_ROOT/pkgsets/$version/global/bin:\$GVM_ROOT/gos/$version/bin:\$GVM_ROOT/bin:\$PATH\"" >> $new_env_file
. $GVM_ROOT/scripts/env/use
gvm_use $version &> /dev/null ||
display_error "Failed to use installed version"
display_fatal "Failed to use installed version"
gvm pkgset create global
unset GOPATH
}
install_go() {
GO_INSTALL_ROOT=$GVM_ROOT/gos/$version
trap 'rm -rf $GO_INSTALL_ROOT; display_error "Canceled!"' INT
trap 'rm -rf $GO_INSTALL_ROOT; display_fatal "Canceled!"' INT
# Check for existing install
if [[ -d "$GO_INSTALL_ROOT" ]]; then
[[ -f "$GO_INSTALL_ROOT/manifest" ]] &&
display_error "Already installed!"
display_fatal "Already installed!"
display_warning "Removing corrupt install..."
gvm uninstall $version
fi
@@ -105,7 +105,7 @@ install_go() {
# Create the global package set folder
mkdir -p $GVM_ROOT/pkgsets/$version >> $GVM_ROOT/logs/go-$version-install.log 2>&1 ||
display_error "Couldn't create global package set folder"
display_fatal "Couldn't create global package set folder"
copy_source
compile_go
@@ -140,11 +140,11 @@ install_goprotobuf() {
}
main() {
trap 'display_error "Canceled!"' INT
trap 'display_fatal "Canceled!"' INT
read_command_line $@
[[ "$VERSION" == "" ]] && display_error "No version specified"
[[ "$VERSION" == "" ]] && display_fatal "No version specified"
download_source
check_tag || (update_source && check_tag) || display_error "Unrecognized Go version"
check_tag || (update_source && check_tag) || display_fatal "Unrecognized Go version"
install_go
GVM_GOINSTALL="goinstall"
+1 -1
View File
@@ -34,7 +34,7 @@ display_message "gvm gos (available)"
echo
versions=`curl -s https://go.googlecode.com/hg/.hgtags | awk '{ print $2 }' | $SORT_PATH`
if [[ $? -ne 0 ]]; then
display_error "Failed to get version list from Google"
display_fatal "Failed to get version list from Google"
fi
for version in $versions; do
if [[ "$tag_filter" == "release" ]]; then
+4 -4
View File
@@ -2,18 +2,18 @@
. $GVM_ROOT/scripts/functions
[[ $gvm_go_name != "" ]] ||
display_error "No Go version selected"
display_fatal "No Go version selected"
[[ -d $GVM_ROOT/gos/$gvm_go_name ]] ||
display_error "Invalid or corrupt Go version"
display_fatal "Invalid or corrupt Go version"
[[ -d $GVM_ROOT/pkgsets/$gvm_go_name ]] ||
display_error "Missing package set folder for this Go version"
display_fatal "Missing package set folder for this Go version"
command=$1
if [[ -f $GVM_ROOT/scripts/pkgset-$command ]]; then
shift
$GVM_ROOT/scripts/pkgset-$command $@
elif [[ -n $command ]]; then
display_error "Unrecognized command line argument: '$command'"
display_fatal "Unrecognized command line argument: '$command'"
else
echo "= gvm pkgset
+7 -7
View File
@@ -2,19 +2,19 @@
. $GVM_ROOT/scripts/functions
[[ $1 != "" ]] ||
display_error "Please specifiy the name"
display_fatal "Please specifiy the name"
[[ ! -f "$GVM_ROOT/environments/$gvm_go_name@$1" ]] ||
display_error "Packageset already exists!"
display_fatal "Packageset already exists!"
mkdir -p $GVM_ROOT/pkgsets/$gvm_go_name/$1 ||
display_error "Could not create folder"
display_fatal "Could not create folder"
cp $GVM_ROOT/environments/$gvm_go_name $GVM_ROOT/environments/$gvm_go_name@$1 ||
display_error "Could copy environment"
display_fatal "Could copy environment"
echo "export gvm_pkgset_name=\"$1\"" >> $GVM_ROOT/environments/$gvm_go_name@$1 ||
display_error "Could not extend environment"
display_fatal "Could not extend environment"
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"
display_fatal "Could not extend environment"
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"
display_fatal "Could not extend environment"
+5 -5
View File
@@ -2,17 +2,17 @@
. $GVM_ROOT/scripts/functions
[[ $gvm_go_name != "" ]] ||
display_error "No Go version selected"
display_fatal "No Go version selected"
[[ $1 != "" ]] ||
display_error "Please specifiy the name"
display_fatal "Please specifiy the name"
[[ -d $GVM_ROOT/pkgsets/$gvm_go_name/$1 ]] ||
display_error "Packageset doesn't exist!"
display_fatal "Packageset doesn't exist!"
rm -rf $GVM_ROOT/pkgsets/$gvm_go_name/$1 ||
display_error "Could not delete package set"
display_fatal "Could not delete package set"
rm -rf $GVM_ROOT/environments/$gvm_go_name@$1 ||
display_error "Could not delete package set"
display_fatal "Could not delete package set"
+2 -2
View File
@@ -2,7 +2,7 @@
. $GVM_ROOT/scripts/functions
[[ $gvm_pkgset_name != "" ]] ||
display_error "No Package set selected"
display_fatal "No Package set selected"
rm -rf $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/* ||
display_error "Could not delete package set files"
display_fatal "Could not delete package set files"
+7 -7
View File
@@ -2,21 +2,21 @@
. $GVM_ROOT/scripts/functions
[[ "$1" == "" ]] &&
display_error "Please specifiy the version"
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"` ||
display_error "Invalid version $1"
display_fatal "Invalid version $1"
if [[ -d $GVM_ROOT/gos/$fuzzy_match ]]; then
rm -rf $GVM_ROOT/pkgsets/$fuzzy_match &> /dev/null ||
display_error "Couldn't remove pkgsets"
display_fatal "Couldn't remove pkgsets"
rm -f $GVM_ROOT/environments/$fuzzy_match &> /dev/null ||
display_error "Couldn't remove environment files"
display_fatal "Couldn't remove environment files"
rm -f "$GVM_ROOT/environments/$fuzzy_match@"* &> /dev/null ||
display_error "Couldn't remove pkgset environment files"
display_fatal "Couldn't remove pkgset environment files"
rm -rf $GVM_ROOT/gos/$fuzzy_match &> /dev/null ||
display_error "Couldn't remove Go folder"
display_fatal "Couldn't remove Go folder"
display_message "Uninstalled version $fuzzy_match"
else
display_error "Invalid version"
display_fatal "Invalid version"
fi
+2 -2
View File
@@ -2,8 +2,8 @@
. $GVM_ROOT/scripts/functions
cd $GVM_ROOT/archive/go &> /dev/null ||
display_error "Failed to find local Go source"
display_fatal "Failed to find local Go source"
cd $GVM_ROOT/archive/go && hg pull ||
display_error "Failed to update"
display_fatal "Failed to update"