Skip to content

Commit

Permalink
add openbsd support to masher
Browse files Browse the repository at this point in the history
  • Loading branch information
puellanivis committed Jun 3, 2020
1 parent faa8991 commit 9e9d363
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion masher/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# However, I don’t think it makes sense to use older version, better to be able to advance as it releases outselves.
RUN mkdir -p /usr/bin && \
cd /usr && \
curl -sS -L https://github.com/google/protobuf/releases/download/v3.11.4/protoc-3.11.4-linux-x86_64.zip | \
curl -sS -L https://github.com/google/protobuf/releases/download/v3.12.3/protoc-3.12.3-linux-x86_64.zip | \
bsdtar -xvf- --exclude=readme.txt && \
chmod 755 /usr/bin/protoc

Expand Down
14 changes: 12 additions & 2 deletions masher/mash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ while [[ "$#" -gt 0 ]]; do
--darwin)
DARWIN="true"
;;
--openbsd)
OPENBSD="true"
;;
--windows)
WINDOWS="true"
;;
Expand Down Expand Up @@ -84,15 +87,15 @@ if [[ $ESCAPE == "true" ]]; then
exit 1
fi

case "${LINUX}${DARWIN}${WINDOWS}" in
case "${LINUX}${DARWIN}${OPENBSD}${WINDOWS}" in
"")
[[ $DEB == "" ]] && LINUX="true"
;;
truetrue*)
TESTING="true"
esac

[[ "${LINUX}${DARWIN}${WINDOWS}" == "" ]] && NOCOMPILE="true"
[[ "${LINUX}${DARWIN}${OPENBSD}${WINDOWS}" == "" ]] && NOCOMPILE="true"

if which go > /dev/null 2>&1 ; then
GO_VERSION="$(go version)"
Expand Down Expand Up @@ -222,6 +225,13 @@ if [[ $DARWIN == "true" ]]; then
GOOS=darwin GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1
fi

if [[ $OPENBSD == "true" ]]; then
OUT="bin/openbsd.x86_64"
echo Compiling ${OUT}/${PROJECT}
[ -d "$OUT" ] || mkdir -p $OUT || exit 1
GOOS=openbsd GOARCH=amd64 go build -o "${OUT}/${PROJECT}" "${LDFLAGS}" || exit 1
fi

if [[ $WINDOWS == "true" ]]; then
OUT="bin/windows.x86_64"
echo Compiling ${OUT}/${PROJECT}.exe
Expand Down
38 changes: 27 additions & 11 deletions masher/masher
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,33 @@ if [[ -n ${DOCKER_MACHINE_NAME} ]]; then
RUNAS=1000
fi

LINUX=""
DARWIN=""
LINUX=""
OPENBSD=""
WINDOWS=""
if [[ -n "${MASHALL}" ]]; then
DARWIN="--darwin"
LINUX="--linux"
WINDOWS="--windows"
OPENBSD="--openbsd"
else
case ${OSTYPE} in
darwin*)
DARWIN="--darwin"
;;
linux*)
LINUX="--linux"
;;
darwin*)
DARWIN="--darwin"
openbsd*)
OPENBSD="--openbsd"
;;
cygwin*|msys*)
WINDOWS="--windows"
;;
*) #I don't know, just make them all
DARWIN="--darwin"
LINUX="--linux"
OPENSBD="--openbsd"
WINDOWS="--windows"
;;
esac
Expand All @@ -66,24 +72,29 @@ while [[ $# -gt 0 ]]; do
REGISTRY="$val"
;;

--darwin)
DARWINFLAG="--darwin"
;;
--linux)
LINUXFLAG="--linux"
;;
--darwin)
DARWINFLAG="--darwin"
--openbsd)
OPENBSDFLAG="--openbsd"
;;
--windows)
WINDOWSFLAG="--windows"
;;
--all)
LINUXFLAG="--linux"
DARWINFLAG="--darwin"
LINUXFLAG="--linux"
OPENBSDFLAG="--openbsd"
WINDOWSFLAG="--windows"
;;

--pkgonly)
LINUXFLAG="--deb"
DARWINFLAG=""
LINUXFLAG="--deb"
OPENBSDFLAG=""
WINDOWSFLAG=""
;;

Expand All @@ -93,6 +104,7 @@ while [[ $# -gt 0 ]]; do
--proto)
DARWIN=""
LINUX=""
OPENBSD=""
WINDOWS=""
NODOCKER="true"
PROTO="--proto"
Expand Down Expand Up @@ -144,8 +156,9 @@ while [[ $# -gt 0 ]]; do
done

if [[ -n ${PROD} ]]; then
LINUXFLAG="--linux"
DARWINFLAG="--darwin"
LINUXFLAG="--linux"
OPENBSDFLAG="--openbsd"
WINDOWSFLAG="--windows"
PROTO="--allprotos"
TEST="--notest"
Expand Down Expand Up @@ -182,9 +195,10 @@ if [[ -z $IMAGE ]]; then
IMAGE="${IMAGE}:latest"
fi

if [[ (-n "$LINUXFLAG") || (-n "$DARWINFLAG") || (-n "$WINDOWSFLAG") ]]; then
if [[ (-n "$DARWINFLAG") || (-n "$LINUXFLAG") || (-n "$OPENBSDFLAG") || (-n "$WINDOWSFLAG") ]]; then
LINUX="$LINUXFLAG"
DARWIN="$DARWINFLAG"
OPENBSD="$OPENBSDFLAG"
WINDOWS="$WINDOWSFLAG"
fi

Expand All @@ -194,6 +208,7 @@ if [[ (-n "$PROD") && ( $BRANCH = "testing" ) ]]; then
# if that works, then it will move up the branches, which will
# then compile the additional binaries.
DARWIN=""
OPENBSD=""
WINDOWS=""
fi

Expand Down Expand Up @@ -237,6 +252,7 @@ if [[ -z ${ESCAPE} ]]; then
NAME="${NAME}-"
[[ ${DARWIN} != "" ]] && NAME="${NAME}d"
[[ ${LINUX} != "" ]] && NAME="${NAME}l"
[[ ${OPENBSD} != "" ]] && NAME="${NAME}o"
[[ ${WINDOWS} != "" ]] && NAME="${NAME}w"
NAME=${NAME%-}
fi
Expand All @@ -259,7 +275,7 @@ fi
TIMESTAMP=$(date -u +"%Y%m%d.%H%M%S")

echo Using image: $IMAGE
echo /bin/mash.sh $ESCAPE $DARWIN $LINUX $WINDOWS $TEST $PROTO $BUILD $CACHE $PRIVATE $BUILD_VERSION --timestamp=$TIMESTAMP --id=$HASHID $@
echo /bin/mash.sh $ESCAPE $DARWIN $LINUX $OPENBSD $WINDOWS $TEST $PROTO $BUILD $CACHE $PRIVATE $BUILD_VERSION --timestamp=$TIMESTAMP --id=$HASHID $@

DOCKER_VERSION="$(docker --version)"
DOCKER_VERSION=${DOCKER_VERSION%%,*}
Expand Down Expand Up @@ -359,7 +375,7 @@ ${EXEC} docker run ${FLAGS} --rm \
$LIBS \
--workdir "${SRCROOT}/${PRJPATH}" \
${IMAGE} \
/bin/mash.sh $ESCAPE $DARWIN $LINUX $WINDOWS $TEST $PROTO $BUILD $CACHE $PRIVATE $BUILD_VERSION --timestamp=$TIMESTAMP --id=$HASHID "$@" || exit 1
/bin/mash.sh $ESCAPE $DARWIN $LINUX $OPENBSD $WINDOWS $TEST $PROTO $BUILD $CACHE $PRIVATE $BUILD_VERSION --timestamp=$TIMESTAMP --id=$HASHID "$@" || exit 1

if [[ $PROD == "true" ]]; then
make push || exit 1
Expand Down

0 comments on commit 9e9d363

Please sign in to comment.