Created
October 21, 2014 16:55
-
-
Save thelinuxkid/c57ddaf9ddbdce2f30b9 to your computer and use it in GitHub Desktop.
Revisions
-
thelinuxkid created this gist
Oct 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ !/bin/sh # WARNING: this script is unfinished. # With this script you don't have to keep third-packages in your repo. # You just run it when you need to install, update or remove dependencies. # Call it like: # dependencies install < packages.dep # where packages.deb is a file that looks like: # github.com/mattbaird/http-digest-auth-client:8db792bc5f8e1df7594e777a78d7ec26cec3d583 # github.com/abbot/go-http-auth:c0ef4539dfab4d21c8ef20ba2924f9fc6f186d35 # github.com/gorilla/websocket:a6f041ac33b84488bb44137d6866cd3c8706d792 # ... # If you add a new package to packages.deb and run install, only the new package will be installed. # If you use the 'clean' command all dependencies will be removed. # Maybe in the future you will be able to specify which dependencies to remove. # GUSER is your github username which contains the repo you want to ignore, i.e., your source code. # Maybe in the future you will be able to specify multiple repos to ignore. # You should have this script at the root of your repo. If so, the GOPATH, set below, looks like: # ./src/github.com/<packages> # and one of those packages is yours. # Maybe in the future you will be able to set GOPATH yourself. # If you don't want to type a long path to change into your source code directory, # you can create a soft link to it at the root of your repo like this: # ln -s ./src/github.com/$GUSER/<source-code> ./<source-code> # Feel free to change this script to your liking. GUSER=<your-github-username> GOPATH=$(realpath $(dirname ${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]})/) install_one () { PKG=$(echo $1 | cut -d \: -f 1) PKGVER=$(echo $1 | cut -d \: -f 2) if [ "$PKG" == "$PKGVER" ] || [ -z "$PKGVER" ]; then echo You must specify a version for $PKG return fi PKGPATH=src/$PKG if [ ! -d ${PKGPATH} ]; then git clone -q https://$PKG $PKGPATH cd $PKGPATH git checkout -q $PKGVER cd $GOPATH fi go install $PKG } install_all() { while read -r PKG || [[ -n $PKG ]]; do install_one $PKG done } clean_all() { CODE=$GOPATH/src/github.com/$GUSER SAVE=$GOPATH/$GUSER.save if [ -d ${CODE} ]; then mv $CODE $SAVE fi rm -rf $GOPATH/src/* if [ -d ${SAVE} ]; then mkdir -p $GOPATH/src/github.com mv $SAVE $CODE fi } case "$1" in install) install_all ;; clean) clean_all ;; *) echo "Usage: $0 {install|clean}" >&2 exit 1 esac