Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Acme Downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Geant DevOps
Acme Downloader
Commits
4949fa52
Unverified
Commit
4949fa52
authored
4 years ago
by
Massimiliano Adamo
Browse files
Options
Downloads
Patches
Plain Diff
minor
parent
35410207
No related branches found
No related tags found
No related merge requests found
Pipeline
#968
passed
4 years ago
Stage: sonarqube
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build.sh
+17
-12
17 additions, 12 deletions
build.sh
with
17 additions
and
12 deletions
build.sh
+
17
−
12
View file @
4949fa52
...
...
@@ -2,6 +2,11 @@
#
# 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
PATH
=
$PATH
:
$(
go
env
GOPATH
)
/bin
GOPATH
=
$(
go
env
GOPATH
)
...
...
@@ -21,14 +26,14 @@ usage() {
echo
"Usage:
$(
basename
$0
)
"
echo
" -h | --help [Print this help and exit]"
echo
" --os=OS (Compile binary for this OS)"
echo
" --arch=ARCH (Compile binary for this
a
rchitecture)"
echo
" --arch=ARCH (Compile binary for this
A
rchitecture)"
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
=======
,
=======
exit
}
OPTS
=
$(
getopt
-o
"h"
--longoptions
"help,
platform
:,arch:"
--
"
$@
"
)
OPTS
=
$(
getopt
-o
"h"
--longoptions
"help,
os
:,arch:"
--
"
$@
"
)
eval set
--
"
$OPTS
"
while
true
;
do
...
...
@@ -36,9 +41,9 @@ while true; do
-h
|
--help
)
usage
;;
--
platform
)
--
os
)
shift
PLATFORM
=
"
$1
"
OS
=
"
$1
"
;;
--arch
)
shift
...
...
@@ -52,28 +57,28 @@ while true; do
shift
done
if
[
-z
$
PLATFORM
-o
-z
$ARCH
]
;
then
echo
-e
"
\n
You need to supply
platform
and
a
rchitecture
\n
"
if
[
-z
$
OS
]
||
[
-z
$ARCH
]
;
then
echo
-e
"
\n
You need to supply
OS
and
A
rchitecture
\n
"
usage
fi
if
[
"
$
PLATFORM
"
==
"windows"
]
;
then
if
[
"
$
OS
"
==
"windows"
]
;
then
BIN_NAME
=
"
${
BIN_NAME
}
.exe"
fi
# 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
echo
-e
"
\n
there was an error while compiling the code
\n
"
exit
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
}
"
run_upx
()
{
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"
exit
fi
...
...
@@ -82,7 +87,7 @@ run_upx() {
while
true
;
do
echo
-e
"
\n
UPX 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
case
$yn
in
[
Yy]
*
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment