Created
April 8, 2014 16:53
-
-
Save takumakei/10155224 to your computer and use it in GitHub Desktop.
Homebrew formula for the Deploygate cli
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 characters
require 'formula' | |
class Dgate < Formula | |
homepage 'https://deploygate.com/docs/cli' | |
url 'https://deploygate.com/client/dgate.tar.gz' | |
sha1 '23e3723bf01f6fbca0a097fc895ca9812a8c9de3' | |
version '0.0.1' | |
patch :DATA | |
def install | |
rm Dir['bin/*'] | |
libexec.install Dir['*'] | |
bin.install_symlink Dir["#{libexec}/dgate"] | |
end | |
end | |
__END__ | |
diff --git a/dgate b/dgate | |
index aee2843..ec36bc8 100755 | |
--- a/dgate | |
+++ b/dgate | |
@@ -1,9 +1,16 @@ | |
#!/bin/sh | |
ORIG_DIR=$(pwd) | |
-cd $(dirname "$0") | |
-if [ -L "$(basename $0)" ] ; then | |
- cd $(dirname $(readlink $(basename "$0") ) ) | |
-fi | |
-SCRIPT_DIR=$(pwd -P) | |
+PRG="$0" | |
+# resolve relative/absolute symlinks | |
+while [ -h "$PRG" ] ; do | |
+ ls=`ls -ld "$PRG"` | |
+ link=`expr "$ls" : '.*-> \(.*\)$'` | |
+ if expr "$link" : '/.*' > /dev/null; then | |
+ PRG="$link" | |
+ else | |
+ PRG="`dirname "$PRG"`/$link" | |
+ fi | |
+done | |
+SCRIPT_DIR=`dirname $PRG` | |
cd "$ORIG_DIR" | |
ruby -I $SCRIPT_DIR/lib $SCRIPT_DIR/dgate.rb "$@" |
Author
takumakei
commented
Apr 8, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment