From cce4cd627c1b951a746cebf725e55e1c6e165a5f Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 12 Jul 2013 00:16:33 -0400 Subject: [PATCH] adding go2dist here at least to have some place to track it --- go2dist/go2dist | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 go2dist/go2dist diff --git a/go2dist/go2dist b/go2dist/go2dist new file mode 100755 index 0000000..18b15ba --- /dev/null +++ b/go2dist/go2dist @@ -0,0 +1,43 @@ +#!/bin/sh + +set -e + +ts=$(date +"%Y%m%d%H%M%S") + +if [ "${#GOROOT}" -eq 0 ] ;then + echo "ERROR: required GOROOT env is not set" + exit 2 +fi +if [ "${#1}" -eq 0 ] ;then + echo "ERROR: need an argument" + exit 2 +fi + +gr=${GOROOT} + +export GOPATH="/tmp/go2dist-${ts}/" +go get ${1} || exit 2 + +mkdir -p $GOPATH/$GOROOT/src/pkg +mv $GOPATH/src/* $GOPATH/$GOROOT/src/pkg/ +rm -rf $GOPATH/src +if [ -d ${GOPATH}/pkg ] ; then + mv $GOPATH/pkg $GOPATH/$GOROOT/ +fi +if [ -d ${GOPATH}/bin ] ; then + mv $GOPATH/bin $GOPATH/$GOROOT/ + pushd $GOPATH >/dev/null + mkdir -p usr/bin + if [ "${GOROOT:0:1}" == "/" ] ; then + GOROOT=${GOROOT:1} + fi + for file in $GOROOT/bin/* ; do + ln -sf ${file} usr/bin/ + done + popd >/dev/null +fi + +echo $GOPATH + + +# vim:set sts=2 sw=2 et ai: