Skip to content

Commit

Permalink
add more architechtures and change and improve logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hboetes committed Feb 2, 2023
1 parent 5f89b7c commit 38abe2c
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions mg-static/generate-mg-static
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,36 @@ usage() {
name=${0##*/}
cat << EOF >&2
This script can build a static binary for mg, like this:
./$name tag -- build the latest tagged 64-bit version
./$name latest -- build the latest 64-bit version
./$name tag32 -- build the latest tagged 32-bit version
./$name latest32 -- build the latest 32-bit version
./$name [amd64|i386|arm64v8|arm32v7] [tag|latest]
Make sure your architecture is compatible.
EOF
exit 1
}

case $1 in
latest|latest64)
ext=_64
TCMD='date +latest%Y%m%d'
IMPTH=library
amd64)
ext=$1
;;
tag|tag64)
ext=_64
TCMD='git tag|tail -n 1'
IMPTH=library
arm64v8)
ext=41
;;
arm32v7)
ext=$1
;;
latest32)
ext=
i386)
ext=$1
;;
*)
usage
;;
esac

case $2 in
latest)
TCMD='date +latest%Y%m%d'
IMPTH=i386
;;
tag32)
ext=
tag)
TCMD='git tag|tail -n 1'
IMPTH=i386
;;
*)
usage
Expand All @@ -58,7 +60,7 @@ esac

# Create the Containerfile
cat << EOF > Containerfile
FROM docker.io/$IMPTH/alpine
FROM docker.io/$ext/alpine
RUN apk upgrade
RUN apk add git libbsd-static libbsd-dev ncurses-dev musl-dev ncurses-static gcc make
RUN git clone https://github.com/hboetes/mg.git
Expand All @@ -67,14 +69,14 @@ RUN TAG=\$($TCMD); \
git checkout \$TAG; \
make STATIC=1; \
strip mg; \
ln mg mg-\$TAG-static-x86$ext
ln mg mg-\$TAG-static-$ext
EOF


cat << EOF > ./helper-script
#!/bin/sh
mnt=\$(podman image mount localhost/mg-static)
cp \$mnt/mg/mg-*static-x86* .
cp \$mnt/mg/mg-*static-* .
EOF
chmod 755 ./helper-script

Expand Down

0 comments on commit 38abe2c

Please sign in to comment.