From 595531b7fc5964779d258ad76b36288bd4222e76 Mon Sep 17 00:00:00 2001 From: Joshua Bussdieker Date: Sun, 4 Mar 2012 22:54:05 -0800 Subject: [PATCH] Taken over by gpkg --- scripts/pkg | 36 ------- scripts/pkg-install | 218 ------------------------------------------ scripts/pkg-list | 39 -------- scripts/pkg-uninstall | 31 ------ scripts/pkg-update | 20 ---- 5 files changed, 344 deletions(-) delete mode 100755 scripts/pkg delete mode 100755 scripts/pkg-install delete mode 100755 scripts/pkg-list delete mode 100755 scripts/pkg-uninstall delete mode 100755 scripts/pkg-update diff --git a/scripts/pkg b/scripts/pkg deleted file mode 100755 index 7a9799a..0000000 --- a/scripts/pkg +++ /dev/null @@ -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 - diff --git a/scripts/pkg-install b/scripts/pkg-install deleted file mode 100755 index 8a96323..0000000 --- a/scripts/pkg-install +++ /dev/null @@ -1,218 +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 - 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]*=//'` - sources=`echo $i | sed 's/[-a-zA-Z0-9]*=//' && echo $sources` - ;; - -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 - 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() { - 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 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 - 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 - 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` - fi - - if [[ -n $BUILD_NUMBER ]]; then - BUILD_NUMBER="$SOURCE_VERSION.$BUILD_NUMBER" - else - 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" - 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" -} - -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 `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 - done - fi - echo ":complete" >> $build_dir/manifest -} - -function copy_source() { - 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-$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 -} - -function install_package() { - 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 || - 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 $tmp_dir || - display_error "Failed to remove $tmp_dir in cleanup()" -} - -read_command_line $@ -download_package -setup_build_env -check_deps -copy_source -build_package -install_package -cleanup - diff --git a/scripts/pkg-list b/scripts/pkg-list deleted file mode 100755 index ec3e8c5..0000000 --- a/scripts/pkg-list +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -. $GVM_ROOT/scripts/functions - -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")" - - echo $output -done -if [ -f $package_folder/goinstall.log ]; then - echo - display_message "Installing via goinstall" - echo - cat $package_folder/goinstall.log -fi -echo - diff --git a/scripts/pkg-uninstall b/scripts/pkg-uninstall deleted file mode 100755 index 1e63590..0000000 --- a/scripts/pkg-uninstall +++ /dev/null @@ -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 - diff --git a/scripts/pkg-update b/scripts/pkg-update deleted file mode 100755 index aaf2f37..0000000 --- a/scripts/pkg-update +++ /dev/null @@ -1,20 +0,0 @@ -#!/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 -