Skip to content
Snippets Groups Projects
Unverified Commit 4949fa52 authored by Massimiliano Adamo's avatar Massimiliano Adamo
Browse files

minor

parent 35410207
No related branches found
No related tags found
No related merge requests found
Pipeline #968 passed
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
# #
# for windows and Mac check the README # for windows and Mac check the README
# #
if ! which go &>/dev/null; then
echo "Go is not installed or is not in \$PATH"
echo "giving up..."
exit
fi
BIN_NAME=acme-downloader BIN_NAME=acme-downloader
PATH=$PATH:$(go env GOPATH)/bin PATH=$PATH:$(go env GOPATH)/bin
GOPATH=$(go env GOPATH) GOPATH=$(go env GOPATH)
...@@ -21,14 +26,14 @@ usage() { ...@@ -21,14 +26,14 @@ usage() {
echo "Usage: $(basename $0)" echo "Usage: $(basename $0)"
echo " -h | --help [Print this help and exit]" echo " -h | --help [Print this help and exit]"
echo " --os=OS (Compile binary for this OS)" echo " --os=OS (Compile binary for this OS)"
echo " --arch=ARCH (Compile binary for this architecture)" echo " --arch=ARCH (Compile binary for this Architecture)"
echo "" echo ""
echo " Below is a list of supported combinations (1st column: OS / 2nd column: Arch):" echo " Below is a list of supported OS/Arch combinations:"
echo "OS ARCH"; go tool dist list | column -t -s '/' --table-columns =======,======= echo "OS ARCH"; go tool dist list | column -t -s '/' --table-columns =======,=======
exit exit
} }
OPTS=$(getopt -o "h" --longoptions "help,platform:,arch:" -- "$@") OPTS=$(getopt -o "h" --longoptions "help,os:,arch:" -- "$@")
eval set -- "$OPTS" eval set -- "$OPTS"
while true; do while true; do
...@@ -36,9 +41,9 @@ while true; do ...@@ -36,9 +41,9 @@ while true; do
-h | --help) -h | --help)
usage usage
;; ;;
--platform) --os)
shift shift
PLATFORM="$1" OS="$1"
;; ;;
--arch) --arch)
shift shift
...@@ -52,28 +57,28 @@ while true; do ...@@ -52,28 +57,28 @@ while true; do
shift shift
done done
if [ -z $PLATFORM -o -z $ARCH ]; then if [ -z $OS ] || [ -z $ARCH ]; then
echo -e "\nYou need to supply platform and architecture\n" echo -e "\nYou need to supply OS and Architecture\n"
usage usage
fi fi
if [ "$PLATFORM" == "windows" ]; then if [ "$OS" == "windows" ]; then
BIN_NAME="${BIN_NAME}.exe" BIN_NAME="${BIN_NAME}.exe"
fi fi
# env GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" . # env GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" .
env GOOS=$PLATFORM GOARCH=$ARCH go get -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" . env GOOS=$OS GOARCH=$ARCH go get -ldflags "-s -w -X main.appVersion=${PROG_VERSION} -X main.buildTime=${BUILDTIME}" .
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo -e "\nthere was an error while compiling the code\n" echo -e "\nthere was an error while compiling the code\n"
exit exit
fi fi
EXECUTABLE_PATH="${GOPATH}/bin/${PLATFORM}_${ARCH}/${BIN_NAME}" EXECUTABLE_PATH="${GOPATH}/bin/${OS}_${ARCH}/${BIN_NAME}"
[ -f $EXECUTABLE_PATH ] || EXECUTABLE_PATH="${GOPATH}/bin/${BIN_NAME}" [ -f $EXECUTABLE_PATH ] || EXECUTABLE_PATH="${GOPATH}/bin/${BIN_NAME}"
run_upx() { run_upx() {
if ! which upx &>/dev/null; then if ! which upx &>/dev/null; then
echo "please download upx here https://github.com/upx/upx/releases" echo "please download upx here: https://github.com/upx/upx/releases"
echo "and store the executable within your \$PATH" echo "and store the executable within your \$PATH"
exit exit
fi fi
...@@ -82,7 +87,7 @@ run_upx() { ...@@ -82,7 +87,7 @@ run_upx() {
while true; do while true; do
echo -e "\nUPX degrades performances but in the case of acme-downloader it is not noticeable" echo -e "\nUPX degrades performances but in the case of acme-downloader it is not noticeable"
echo -e "UPX may or may not work for a specific platform (I haven't tried all the combinations)\n" echo -e "UPX does not work on some OS/Arch combination (I haven't tried them all)\n"
read -p "Do you wish to run upx against ${BIN_NAME}? (y/n) " yn read -p "Do you wish to run upx against ${BIN_NAME}? (y/n) " yn
case $yn in case $yn in
[Yy]*) [Yy]*)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment