Skip to content

Commit

Permalink
Update package
Browse files Browse the repository at this point in the history
  • Loading branch information
jancajthaml authored Jul 30, 2020
1 parent 939e960 commit eec05b0
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions dev/lifecycle/package
Original file line number Diff line number Diff line change
Expand Up @@ -31,38 +31,45 @@ if [ -z "${OUTPUT}" ] ; then
exit 1
fi

if [ -d ${OUTPUT} ] ; then
rm -rf ${OUTPUT}/*
fi

OUTPUT_FILE=${OUTPUT}/$(basename ${SOURCE})-${PLATFORM}-${ARCH}

################################################################################

lifecycle::go::build() {
local dir="$1"
if [ -z ${dir} -o ! -d ${dir} ] ; then
lifecycle::go::clean() {
local source="$1"
if [ -z ${source} -o ! -d ${source} ] ; then
return
fi

local output="$2"
if [ -z ${output} ] ; then
if [ -z ${output} -o ! -d ${output} ] ; then
return
fi

if [ -f ${output} ] ; then
rm -f ${output}
find "${output}" -name "$(basename ${source})*${ARCH}*" -exec rm -f {} \;
echo "[info] ${output} cleaned"

cd ${source} && go clean
echo "[info] ${source} cleaned"
}

lifecycle::go::build() {
local source="$1"
if [ -z ${source} -o ! -d ${source} ] ; then
return
fi

cd ${dir}
local output="$2"
if [ -z ${output} ] ; then
return
fi

go clean

echo "[info] ${output} cleaned"

case ${ARCH} in

armhf)
cd ${source} && \
\
GOOS=${PLATFORM} \
GOARM=7 \
GOARCH=arm \
Expand All @@ -77,6 +84,8 @@ lifecycle::go::build() {
;;

arm64)
cd ${source} && \
\
GOOS=${PLATFORM} \
GOARCH=arm64 \
CGO_ENABLED=1 \
Expand All @@ -90,6 +99,8 @@ lifecycle::go::build() {
;;

amd64)
cd ${source} && \
\
GOOS=${PLATFORM} \
GOARCH=amd64 \
CGO_ENABLED=1 \
Expand All @@ -112,8 +123,6 @@ lifecycle::go::build() {
chmod +x ${output}

echo "[info] ${output} compiled"

du -hs ${output}
}

lifecycle::go::strip() {
Expand Down Expand Up @@ -142,15 +151,19 @@ lifecycle::go::strip() {
esac

echo "[info] ${output} stripped"

du -hs ${output}
}

################################################################################

lifecycle::go::clean \
${SOURCE} \
${OUTPUT}

lifecycle::go::build \
${SOURCE} \
${OUTPUT_FILE}

lifecycle::go::strip \
${OUTPUT_FILE}

du -hs ${OUTPUT_FILE}

0 comments on commit eec05b0

Please sign in to comment.