mirror of
https://github.com/wahyd4/gvm.git
synced 2026-08-10 05:16:13 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19ae86559a | ||
|
|
c6533ce424 | ||
|
|
018a9552df | ||
|
|
045b88de76 | ||
|
|
d7179e0350 | ||
|
|
211491990c | ||
|
|
b9e6b02e38 | ||
|
|
b1e504374a | ||
|
|
3a45cde1aa | ||
|
|
bdc0eb2fda | ||
|
|
2f562e6d3c | ||
|
|
99f4c5035c | ||
|
|
503ec01aaa | ||
|
|
d4fa2d8bdb | ||
|
|
9711c445d8 | ||
|
|
6d5e3ec8d5 | ||
|
|
1b5197c450 |
@@ -1,3 +1,4 @@
|
||||
pkgs/
|
||||
*~
|
||||
go
|
||||
gos/
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
Version: 0.0.8
|
||||
State: Development
|
||||
|
||||
CHANGES:
|
||||
|
||||
Version: 0.0.7
|
||||
State: Stable
|
||||
|
||||
|
||||
+26
-25
@@ -59,7 +59,8 @@ 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 && ./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")
|
||||
}
|
||||
|
||||
@@ -72,10 +73,9 @@ 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
|
||||
gvm_use $version &> /dev/null ||
|
||||
display_error "Failed to use installed version"
|
||||
gvm pkgset create global
|
||||
. $GVM_ROOT/scripts/env/pkgset-use
|
||||
gvm_pkgset_use global &> /dev/null
|
||||
unset GOPATH
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ install_go() {
|
||||
|
||||
install_gpkg() {
|
||||
echo " * Installing gpkg..."
|
||||
$GVM_GOINSTALL github.com/moovweb/gpkg > /dev/null 2>&1
|
||||
$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
|
||||
@@ -108,31 +108,29 @@ install_gpkg() {
|
||||
}
|
||||
|
||||
install_gb() {
|
||||
if [[ "$version" == "release.r60.3" ]]; then
|
||||
echo " * Installing gb..."
|
||||
$GVM_GOINSTALL github.com/skelterjohn/go-gb/gb > /dev/null 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Failed to install gb"
|
||||
return 1
|
||||
fi
|
||||
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
|
||||
}
|
||||
|
||||
install_goprotobuf() {
|
||||
if [[ "$version" == "release.r60.3" ]]; then
|
||||
echo " * Installing goprotobuf..."
|
||||
$GVM_GOINSTALL goprotobuf.googlecode.com/hg/proto > /dev/null 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Failed to install goprotobuf"
|
||||
return 1
|
||||
fi
|
||||
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
|
||||
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() {
|
||||
@@ -147,10 +145,13 @@ main() {
|
||||
install_go
|
||||
GVM_GOINSTALL="goinstall"
|
||||
which goinstall &> /dev/null ||
|
||||
GVM_GOINSTALL="go install"
|
||||
install_gpkg
|
||||
install_gb
|
||||
install_goprotobuf
|
||||
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
|
||||
cd $GO_INSTALL_ROOT && find . > manifest
|
||||
tput sgr0
|
||||
}
|
||||
|
||||
+113
-65
@@ -1,4 +1,14 @@
|
||||
#!/bin/bash
|
||||
gpkg build $1 || exit 1
|
||||
VERSION=`cat VERSION`
|
||||
if [ "$VERSION" == "" ]; then
|
||||
VERSION=0.0
|
||||
fi
|
||||
BUILD=$VERSION.$BUILD_NUMBER
|
||||
mkdir -p $GVM_ROOT/pkgs/pkg.gvm/$1/current
|
||||
cp $GVM_ROOT/pkgsets/$gvm_go_name/$gvm_pkgset_name/pkg.gvm/$1/$BUILD/manifest $GVM_ROOT/pkgs/pkg.gvm/$1/current/manifest
|
||||
exit 0
|
||||
|
||||
. $GVM_ROOT/scripts/functions
|
||||
|
||||
show_usage() {
|
||||
@@ -16,83 +26,91 @@ 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
|
||||
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
|
||||
|
||||
version=$1
|
||||
strict="true"
|
||||
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
|
||||
# TODO: Remove hack after change to gvm_build
|
||||
mkdir -p $GVM_ROOT/pkgs/pkg.gvm/$package_name/current
|
||||
}
|
||||
|
||||
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
|
||||
if [ -d $cache_dir ]; then
|
||||
cd $cache_dir && git pull &> /dev/null
|
||||
return
|
||||
fi
|
||||
echo "Downloading $package_name..."
|
||||
for source in $sources; do
|
||||
echo "Trying $source"
|
||||
git clone $source/$package_name $cache_dir > /dev/null 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
echo $source > $cache_dir/GVM_SOURCE
|
||||
return
|
||||
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"
|
||||
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
|
||||
fi
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
function install_dep() {
|
||||
[[ "$strict" == "true" ]] && display_error "Missing dependancy ($1) and strict mode is set"
|
||||
[[ "$source" == "." ]] && passthrough_options="--source=. "$passthrough_options
|
||||
passthrough_options=""
|
||||
[[ "$source" != "" ]] && passthrough_options="--source=$source "$passthrough_options
|
||||
[[ "$all_deps" == "true" ]] && passthrough_options="--all "$passthrough_options
|
||||
|
||||
gvm pkg install $1 $passthrough_options ||
|
||||
display_error "Failed to install dependency $1"
|
||||
}
|
||||
@@ -113,7 +131,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
|
||||
@@ -123,41 +141,64 @@ function check_deps() {
|
||||
}
|
||||
|
||||
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/
|
||||
git clone $source_dir $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER/ &> /dev/null
|
||||
#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 "Installing $package_name-$BUILD_NUMBER..."
|
||||
echo "$BUILD_NUMBER" > $build_dir/BUILD_VERSION
|
||||
export BUILD_NUMBER
|
||||
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
|
||||
echo "Running tests..."
|
||||
cd $source_dir && gvmake test >> $build_dir/build.log 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Failed tests"
|
||||
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
|
||||
mkdir -p $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER ||
|
||||
display_error "Failed to create $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER"
|
||||
cp -r $build_dir/* $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER ||
|
||||
display_error "Failed to copy from build folder to install destination"
|
||||
rm -f $gvm_go_path/pkg.gvm/$package_name/current ||
|
||||
display_error "Failed to remove symlink to 'current' before recreating it"
|
||||
ln -s $gvm_go_path/pkg.gvm/$package_name/$BUILD_NUMBER $gvm_go_path/pkg.gvm/$package_name/current ||
|
||||
display_error "Failed to create new symlink to 'current'"
|
||||
|
||||
if [ -d $build_dir/bin ]; then
|
||||
echo " * Installing binaries"
|
||||
mkdir -p $gvm_go_path/bin &&
|
||||
cp -f $build_dir/bin/* $gvm_go_path/bin/
|
||||
mkdir -p $gvm_go_path/bin ||
|
||||
display_error "Failed to create $gvm_go_path/bin"
|
||||
for binary in $build_dir/bin/*; do
|
||||
binary_name=`echo "$binary" | awk '{ n=split($1,path,"/"); print path[n] }'`
|
||||
rm -f $gvm_go_path/bin/$binary_name ||
|
||||
display_error "Failed to remove old binary"
|
||||
|
||||
IFS=$'\n'
|
||||
lines=`cat $GVM_ROOT/scripts/templates/binary`
|
||||
for line in $lines; do
|
||||
echo "$line" | sed 's/{{package_name}}/'$package_name'/g' | sed 's/{{binary_name}}/'$binary_name'/g' >> $gvm_go_path/bin/$binary_name
|
||||
done
|
||||
|
||||
chmod +x $gvm_go_path/bin/$binary_name ||
|
||||
display_error "Failed to mark binary executable"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
rm -rf $build_dir
|
||||
rm -rf $source_dir
|
||||
rm -rf $tmp_dir ||
|
||||
display_error "Failed to remove $tmp_dir in cleanup()"
|
||||
}
|
||||
|
||||
read_command_line $@
|
||||
@@ -167,5 +208,12 @@ check_deps
|
||||
copy_source
|
||||
build_package
|
||||
install_package
|
||||
if [ "$GPKG_PUSH_TAG" == "true" ]; then
|
||||
echo "Pushing tag $BUILD_NUMBER"
|
||||
cd $WORKSPACE && git tag $BUILD_NUMBER && git push origin $BUILD_NUMBER ||
|
||||
display_error "Failed to push version tag"
|
||||
fi
|
||||
# TODO: Remove after change to gvm_build
|
||||
cp $build_dir/manifest $GVM_ROOT/pkgs/pkg.gvm/$package_name/current
|
||||
cleanup
|
||||
|
||||
|
||||
+23
-23
@@ -1,37 +1,37 @@
|
||||
#!/bin/bash
|
||||
. $GVM_ROOT/scripts/functions
|
||||
|
||||
echo "
|
||||
gvm packages $gvm_go_name@$gvm_pkgset_name"
|
||||
echo
|
||||
display_message "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")"
|
||||
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
|
||||
echo $output
|
||||
done
|
||||
if [ -f $package_folder/goinstall.log ]; then
|
||||
echo
|
||||
echo "Installing via goinstall"
|
||||
display_message "Installing via goinstall"
|
||||
echo
|
||||
cat $package_folder/goinstall.log
|
||||
fi
|
||||
|
||||
Executable
+20
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/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"
|
||||
|
||||
Reference in New Issue
Block a user