1 Commits
Author SHA1 Message Date
Joshua Bussdieker 91b3c0b950 Testing goinstall branches 2012-02-29 20:12:37 -08:00
13 changed files with 118 additions and 106 deletions
+1
View File
@@ -1,6 +1,7 @@
*~
go
gos/
pkgs
pkgsets/
archive/
environments/
+5
View File
@@ -1,3 +1,8 @@
Version: 0.0.8
State: Development
CHANGES:
Version: 0.0.7
State: Stable
-4
View File
@@ -1,7 +1,3 @@
# gvm
GVM provides an interface to manage Go versions.
Installing
==========
+1 -1
View File
@@ -1 +1 @@
0.0.7
0.0.8-dev
+12
View File
@@ -0,0 +1,12 @@
package main
import "os"
func main() {
gvm_root := os.Getenv("GVM_ROOT")
if gvm_root == "" {
println("ERROR: gpkg requires gvm to run (http://github.com/moovweb/gvm)")
} else {
println("GVM Package Manager for release.r60.3!")
}
}
+2 -2
View File
@@ -13,10 +13,10 @@ function gvm_pkgset_use() {
[[ "$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 $GVM_ROOT/environments | sort | grep "$gvm_go_name@" | head -n 1 | grep "$1"` ||
display_error "Invalid package set" || return 1
. "$GVM_ROOT/environments/$fuzzy_match" ||
. "$GVM_ROOT/environments/$gvm_go_name@$1" ||
display_error "Failed to source the package set environment" || return 1
echo "Now using version $fuzzy_match"
-1
View File
@@ -20,7 +20,6 @@ function gvm_use() {
fuzzy_match=`ls $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
if [[ "$2" == "--default" ]]; then
cp $GVM_ROOT/environments/$fuzzy_match $GVM_ROOT/environments/default
-1
View File
@@ -15,7 +15,6 @@ 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
+26 -57
View File
@@ -1,36 +1,9 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
function show_usage() {
echo "Usage: gvm install [version] [options]"
echo " -s, --source=SOURCE Install Go from specified source."
echo " -h, --help Display this message."
}
read_command_line() {
VERSION=$1
shift
GO_SOURCE_URL=https://go.googlecode.com/hg/
for i in $*; do
case $i in
-s=*|--source=*)
GO_SOURCE_URL=$i
;;
-h|--help*)
show_usage
exit 0
;;
*)
echo "Invalid option $i"
show_usage
exit 65 # Bad arguments
;;
esac
done
}
download_source() {
GO_CACHE_PATH=$GVM_ROOT/archive/go
GO_SOURCE_URL=https://go.googlecode.com/hg/
[ -d $GO_CACHE_PATH ] && return
echo "Downloading Go source..."
hg clone $GO_SOURCE_URL $GO_CACHE_PATH >> $GVM_ROOT/logs/go-download.log 2>&1 ||
@@ -59,8 +32,7 @@ compile_go() {
export GOBIN=$GO_INSTALL_ROOT/bin &&
export PATH=$GOBIN:$PATH &&
export GOROOT=$GO_INSTALL_ROOT &&
#cd $GO_INSTALL_ROOT/src && ./all.bash &> $GVM_ROOT/logs/go-$version-compile.log ||
cd $GO_INSTALL_ROOT/src && ./make.bash &> $GVM_ROOT/logs/go-$version-compile.log ||
cd $GO_INSTALL_ROOT/src && ./all.bash &> $GVM_ROOT/logs/go-$version-compile.log ||
(rm -rf $GO_INSTALL_ROOT && display_error "Failed to compile")
}
@@ -73,9 +45,10 @@ create_enviroment() {
echo "export GOPATH; GOPATH=\"\$GVM_ROOT/pkgsets/$version/global\"" >> $new_env_file
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"
gvm_use $version &> /dev/null
gvm pkgset create global
. $GVM_ROOT/scripts/env/pkgset-use
gvm_pkgset_use global &> /dev/null
unset GOPATH
}
@@ -100,7 +73,7 @@ install_go() {
install_gpkg() {
echo " * Installing gpkg..."
$GVM_GOINSTALL github.com/moovweb/gpkg > $GVM_ROOT/logs/$version-gpkg.log 2>&1
goinstall github.com/moovweb/gvm/gpkg > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install gpkg"
return 1
@@ -108,34 +81,36 @@ install_gpkg() {
}
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
if [[ "$version" == "release.r60.3" ]]; then
echo " * Installing gb..."
goinstall github.com/skelterjohn/go-gb/gb > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install gb"
return 1
fi
fi
}
install_goprotobuf() {
echo " * 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"
return 1
fi
#if [[ $version == "release.r60.3" ]]; then
if [[ "$version" == "release.r60.3" ]]; then
echo " * Installing goprotobuf..."
goinstall goprotobuf.googlecode.com/hg/proto > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install goprotobuf"
return 1
fi
cd $GVM_ROOT/gos/$version/src/pkg/goprotobuf.googlecode.com/hg/compiler
make install >> $GVM_ROOT/logs/$version-pb-compiler.log 2>&1
make install > $GVM_ROOT/logs/$version-pb-compiler.log 2>&1
if [[ $? -ne 0 ]]; then
echo "Failed to install goprotobuf compiler"
return 1
fi
#fi
fi
}
main() {
VERSION=$1
trap 'display_error "Canceled!"' INT
read_command_line $@
# GREEN!
tput sgr0
tput setaf 2
@@ -143,15 +118,9 @@ main() {
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
fi
install_gpkg
install_gb
install_goprotobuf
cd $GO_INSTALL_ROOT && find . > manifest
tput sgr0
}
+51 -27
View File
@@ -16,7 +16,7 @@ function read_command_line() {
# Get package name
package_name=$1
source="git@github.com:moovweb/$1"
sources=`cat $GVM_ROOT/config/sources`
shift
for i in $*; do
@@ -25,7 +25,7 @@ function read_command_line() {
version=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
-s=*|--source=*)
source=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
sources=`echo $i | sed 's/[-a-zA-Z0-9]*=//' && echo $sources`
;;
-a|--all)
all_deps="true"
@@ -46,45 +46,70 @@ function read_command_line() {
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
cache_dir=$GVM_ROOT/archive/package/$package_name
tmp_dir=$GVM_ROOT/tmp/$$
source_dir=$tmp_dir/$package_name/src/$package_name
build_dir=$tmp_dir/$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"
[ -d $cache_dir ] && return
#echo "Downloading $package_name..."
for source in $sources; do
git clone $source/$package_name $cache_dir > /dev/null 2>&1
if [ "$?" == "0" ]; then
echo $source > $cache_dir/GVM_SOURCE
return
fi
fi
done
display_error "Could not find $package_name in any sources"
}
function select_version() {
function update_package_cache() {
cd $cache_dir && git pull > /dev/null 2>&1 ||
display_error "Failed to update source"
}
function copy_tmp_source() {
rm -rf $source_dir
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
git clone $cache_dir $source_dir > /dev/null 2>&1
cd $source_dir && git checkout $version > /dev/null 2>&1 ||
return 1
else
git clone $cache_dir $source_dir > /dev/null 2>&1
cd $source_dir
git describe --exact-match > /dev/null 2>&1
if [ "$?" == "0" ]; then
git_tag=`git describe --exact-match`
git_version=`echo $git_tag | awk '{ n=split($1,path,"_"); print path[n] }'`
if [ "$BUILD_NUMBER" == "" ]; then
BUILD_NUMBER=$git_version
fi
fi
fi
}
function setup_build_env() {
rm -rf $build_dir && mkdir -p $build_dir
select_version
copy_tmp_source
if [ "$?" != "0" ]; then
update_package_cache
copy_tmp_source ||
display_error "Invalid version"
fi
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"
if [[ "$SOURCE_VERSION" != "" ]]; then
BUILD_NUMBER="$SOURCE_VERSION.src"
else
BUILD_NUMBER="src"
fi
fi
}
@@ -113,7 +138,7 @@ function load_dep() {
function check_deps() {
export GOPATH=$build_dir
echo ":source $source" >> $build_dir/manifest
echo ":source `cat $cache_dir/GVM_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
@@ -128,7 +153,7 @@ function copy_source() {
}
function build_package() {
echo "Installing $package_name..."
echo "Installing $package_name-$BUILD_NUMBER..."
echo "$BUILD_NUMBER" > $build_dir/BUILD_VERSION
cd $source_dir && gvmake > $build_dir/build.log 2>&1
if [ $? -ne 0 ]; then
@@ -156,8 +181,7 @@ function install_package() {
}
function cleanup() {
rm -rf $build_dir
rm -rf $source_dir
rm -rf $tmp_dir
}
read_command_line $@
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
[[ "$1" == "" ]] &&
display_error "Please specify package name"
[[ ! -d $GVM_ROOT/archive/package/$1 ]] &&
display_error "Invalid package"
cd $GVM_ROOT/archive/package/$1
git pull &> /dev/null
if [ "$?" == "1" ]; then
echo "Changes!"
else
echo "No changes"
fi
#cd git pull
#gvm_go_path=$GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name
-9
View File
@@ -1,9 +0,0 @@
#!/bin/bash
. $GVM_ROOT/scripts/functions
cd $GVM_ROOT/archive/go ||
display_error "Failed to find local Go source"
cd $GVM_ROOT/archive/go && hg pull ||
display_error "Failed to update"
-4
View File
@@ -1,4 +0,0 @@
#!/bin/bash -ex
TEST_OUTPUT=`gvm version`
[ "$TEST_OUTPUT" != "" ]
echo "Success!"