Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
close #10 - allow flag to set installation directory
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed May 24, 2017
1 parent 30722be commit 0685c70
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 62 deletions.
38 changes: 23 additions & 15 deletions samples/godownloader-goreleaser.sh
Expand Up @@ -8,14 +8,17 @@ usage() {
cat <<EOF
$this: download go binaries for goreleaser/goreleaser
Usage: $this [version]
where [version] is 'latest' or a version number from
https://github.com/goreleaser/goreleaser/releases
Usage: $this [-b] bindir [version]
-b sets bindir or installation directory, default "./bin"
[version] is a version number from
https://github.com/goreleaser/goreleaser/releases
If version is missing, then an attempt to find the latest will be found.
Generated by godownloader
https://github.com/goreleaser/godownloader
EOF
exit 2
}


Expand Down Expand Up @@ -173,7 +176,7 @@ hash_sha256_verify() {
return 1
fi
BASENAME=${TARGET##*/}
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | cut -d ' ' -f 1)
if [ -z "$want" ]; then
echo "hash_sha256_verify: unable to find checksum for '${TARGET}' in '${checksums}'"
return 1
Expand Down Expand Up @@ -210,22 +213,27 @@ is_supported_platform() {
return $found
}

parse_args() {
#BINDIR is ./bin unless set be ENV
# over-ridden by flag below

BINDIR=${BINDIR:-./bin}
while getopts "b:" arg; do
case "$arg" in
b) BINDIR="$OPTARG";;
\?) usage "$0" ;;
esac
done
shift $((OPTIND - 1))
VERSION=$1
}

OWNER=goreleaser
REPO=goreleaser
BINARY=goreleaser
FORMAT=tar.gz
BINDIR=${BINDIR:-./bin}

VERSION=$1
case "${VERSION}" in
latest)
VERSION=""
;;
-h|-?|*help*)
usage "$0"
exit 1
;;
esac
parse_args "$@"

uname_os_check
uname_arch_check
Expand Down
38 changes: 23 additions & 15 deletions samples/godownloader-hugo.sh
Expand Up @@ -8,14 +8,17 @@ usage() {
cat <<EOF
$this: download go binaries for spf13/hugo
Usage: $this [version]
where [version] is 'latest' or a version number from
https://github.com/spf13/hugo/releases
Usage: $this [-b] bindir [version]
-b sets bindir or installation directory, default "./bin"
[version] is a version number from
https://github.com/spf13/hugo/releases
If version is missing, then an attempt to find the latest will be found.
Generated by godownloader
https://github.com/goreleaser/godownloader
EOF
exit 2
}


Expand Down Expand Up @@ -173,7 +176,7 @@ hash_sha256_verify() {
return 1
fi
BASENAME=${TARGET##*/}
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | cut -d ' ' -f 1)
if [ -z "$want" ]; then
echo "hash_sha256_verify: unable to find checksum for '${TARGET}' in '${checksums}'"
return 1
Expand Down Expand Up @@ -226,22 +229,27 @@ is_supported_platform() {
return $found
}

parse_args() {
#BINDIR is ./bin unless set be ENV
# over-ridden by flag below

BINDIR=${BINDIR:-./bin}
while getopts "b:" arg; do
case "$arg" in
b) BINDIR="$OPTARG";;
\?) usage "$0" ;;
esac
done
shift $((OPTIND - 1))
VERSION=$1
}

OWNER=spf13
REPO=hugo
BINARY=hugo
FORMAT=tar.gz
BINDIR=${BINDIR:-./bin}

VERSION=$1
case "${VERSION}" in
latest)
VERSION=""
;;
-h|-?|*help*)
usage "$0"
exit 1
;;
esac
parse_args "$@"

uname_os_check
uname_arch_check
Expand Down
2 changes: 1 addition & 1 deletion samples/godownloader-minify.sh
Expand Up @@ -172,7 +172,7 @@ hash_sha256_verify() {
return 1
fi
BASENAME=${TARGET##*/}
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | cut -d ' ' -f 1)
if [ -z "$want" ]; then
echo "hash_sha256_verify: unable to find checksum for '${TARGET}' in '${checksums}'"
return 1
Expand Down
38 changes: 23 additions & 15 deletions samples/godownloader-misspell.sh
Expand Up @@ -8,14 +8,17 @@ usage() {
cat <<EOF
$this: download go binaries for client9/misspell
Usage: $this [version]
where [version] is 'latest' or a version number from
https://github.com/client9/misspell/releases
Usage: $this [-b] bindir [version]
-b sets bindir or installation directory, default "./bin"
[version] is a version number from
https://github.com/client9/misspell/releases
If version is missing, then an attempt to find the latest will be found.
Generated by godownloader
https://github.com/goreleaser/godownloader
EOF
exit 2
}


Expand Down Expand Up @@ -173,7 +176,7 @@ hash_sha256_verify() {
return 1
fi
BASENAME=${TARGET##*/}
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | cut -d ' ' -f 1)
if [ -z "$want" ]; then
echo "hash_sha256_verify: unable to find checksum for '${TARGET}' in '${checksums}'"
return 1
Expand Down Expand Up @@ -202,22 +205,27 @@ is_supported_platform() {
return $found
}

parse_args() {
#BINDIR is ./bin unless set be ENV
# over-ridden by flag below

BINDIR=${BINDIR:-./bin}
while getopts "b:" arg; do
case "$arg" in
b) BINDIR="$OPTARG";;
\?) usage "$0" ;;
esac
done
shift $((OPTIND - 1))
VERSION=$1
}

OWNER=client9
REPO=misspell
BINARY=misspell
FORMAT=tar.gz
BINDIR=${BINDIR:-./bin}

VERSION=$1
case "${VERSION}" in
latest)
VERSION=""
;;
-h|-?|*help*)
usage "$0"
exit 1
;;
esac
parse_args "$@"

uname_os_check
uname_arch_check
Expand Down
38 changes: 23 additions & 15 deletions shell_godownloader.go
Expand Up @@ -10,14 +10,17 @@ usage() {
cat <<EOF
$this: download go binaries for {{ $.Release.GitHub.Owner }}/{{ $.Release.GitHub.Name }}
Usage: $this [version]
where [version] is 'latest' or a version number from
https://github.com/{{ $.Release.GitHub.Owner }}/{{ $.Release.GitHub.Name }}/releases
Usage: $this [-b] bindir [version]
-b sets bindir or installation directory, default "./bin"
[version] is a version number from
https://github.com/{{ $.Release.GitHub.Owner }}/{{ $.Release.GitHub.Name }}/releases
If version is missing, then an attempt to find the latest will be found.
Generated by godownloader
https://github.com/goreleaser/godownloader
EOF
exit 2
}
` + shellfn + `
is_supported_platform() {
Expand All @@ -44,22 +47,27 @@ is_supported_platform() {
return $found
}
parse_args() {
#BINDIR is ./bin unless set be ENV
# over-ridden by flag below
BINDIR=${BINDIR:-./bin}
while getopts "b:" arg; do
case "$arg" in
b) BINDIR="$OPTARG";;
\?) usage "$0" ;;
esac
done
shift $((OPTIND - 1))
VERSION=$1
}
OWNER={{ $.Release.GitHub.Owner }}
REPO={{ $.Release.GitHub.Name }}
BINARY={{ .Build.Binary }}
FORMAT={{ .Archive.Format }}
BINDIR=${BINDIR:-./bin}
VERSION=$1
case "${VERSION}" in
latest)
VERSION=""
;;
-h|-?|*help*)
usage "$0"
exit 1
;;
esac
parse_args "$@"
uname_os_check
uname_arch_check
Expand Down
2 changes: 1 addition & 1 deletion shellfn.go
Expand Up @@ -156,7 +156,7 @@ hash_sha256_verify() {
return 1
fi
BASENAME=${TARGET##*/}
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
want=$(grep "${BASENAME}" "${checksums}" 2> /dev/null | cut -d ' ' -f 1)
if [ -z "$want" ]; then
echo "hash_sha256_verify: unable to find checksum for '${TARGET}' in '${checksums}'"
return 1
Expand Down

0 comments on commit 0685c70

Please sign in to comment.