Skip to content

Commit

Permalink
build: make scripts sh-compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Portnov <me@progrm-jarvis.ru>
  • Loading branch information
JarvisCraft committed Jul 8, 2024
1 parent 3646265 commit b0a37d2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
36 changes: 18 additions & 18 deletions deps/mbedtls/build-mbedtls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

set -e
if [ -z "$O3" ]; then
Expand All @@ -20,11 +20,11 @@ if [ -z "$TARGET" ]; then
fi

# source vars
. $O3/core/vars/vars-${TARGET}
. $O3/core/deps/lib-versions
. "$O3/core/vars/vars-${TARGET}"
. "$O3/core/deps/lib-versions"

# source helper functions
. $O3/core/deps/functions.sh
. "$O3/core/deps/functions.sh"

FNAME=${MBEDTLS_VERSION}.tar.gz
PN=${MBEDTLS_VERSION#*-}
Expand All @@ -35,29 +35,29 @@ download

# put build targets here
DIST=$(pwd)/mbedtls/mbedtls-$PLATFORM
rm -rf $DIST
mkdir -p $DIST
rm -rf "$DIST"
mkdir -p "$DIST"

if [ "$NO_WIPE" = "1" ]; then
echo RETAIN existing source
cd $MBEDTLS_VERSION
cd "$MBEDTLS_VERSION"
else
echo WIPE and reunzip source
rm -rf $MBEDTLS_VERSION
rm -rf "$MBEDTLS_VERSION"
[ -z "$DL" ] && DL=~/Downloads
tar xfz $DL/$MBEDTLS_VERSION.tar.gz
cd $MBEDTLS_VERSION
tar xfz "$DL/$MBEDTLS_VERSION.tar.gz"
cd "$MBEDTLS_VERSION"

# enable MD4 (needed for NTLM auth)
perl -pi -e 's/^\/\/// if /#define MBEDTLS_MD4_C/' include/mbedtls/config.h
fi

if [ "x$NO_BUILD" == x1 ]; then
if [ "$NO_BUILD" = 1 ]; then
echo "Not building"
exit 0
fi

if [[ "x$TARGET" == xlinux* || "x$TARGET" == xosx* ]]; then
if echo "$TARGET" | grep -q '^linux.*$' || echo "$TARGET" | grep -q '^osx.*$'; then
# run unit tests and then clean
echo RUNNING CHECK
make check
Expand All @@ -80,21 +80,21 @@ RANLIB=ranlib
# build it
SRC=$(pwd)
cd library
rm -f *.o
rm -f ./*.o
for c in *.c ; do
CMD="$CC -I../include -DMBEDTLS_RELAXED_X509_DATE \
$PLATFORM_FLAGS $(lto_flags $c) $OTHER_COMPILER_FLAGS $LIB_OPT_LEVEL $LIB_FPIC -c $c"
echo $CMD
$PLATFORM_FLAGS $(lto_flags "$c") $OTHER_COMPILER_FLAGS $LIB_OPT_LEVEL $LIB_FPIC -c $c"
echo "$CMD"
$CMD
done

# create archive
cd $DIST
cd "$DIST"
mkdir library
$AR library/libmbedtls.a $SRC/library/*.o
$AR library/libmbedtls.a "$SRC/library/"*.o
$RANLIB library/libmbedtls.a 2>&1 | grep -v "has no symbols" || true

# copy headers
mkdir -p include/mbedtls
cp $SRC/include/mbedtls/*.h include/mbedtls/
cp "$SRC/include/mbedtls/"*.h include/mbedtls/
exit 0
5 changes: 3 additions & 2 deletions scripts/version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# OpenVPN -- An application to securely tunnel IP networks
# over a single port, with support for SSL/TLS-based
Expand All @@ -25,7 +25,8 @@ set -eu

# ensure this script works even when core is used as submodule, by setting
# O3/core/.git as git folder
export GIT_DIR=$(dirname $0)/../.git
GIT_DIR=$(dirname "$0")/../.git
export GIT_DIR

MAJOR=3
BRANCH="$(git rev-parse --symbolic-full-name HEAD | cut -d/ -f3- | tr / _)"
Expand Down
17 changes: 10 additions & 7 deletions test/ovpncli/go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Options:
# OSSL=1 -- build using OpenSSL
Expand All @@ -14,27 +14,30 @@ GCC_EXTRA="$GCC_EXTRA -DOPENVPN_SHOW_SESSION_TOKEN"
[ "$DEX" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_DISABLE_EXPLICIT_EXIT"
[ "$BS64" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_BS64_DATA_LIMIT=2500000"
[ "$ROVER" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_REMOTE_OVERRIDE"
# shellcheck disable=SC2153
[ "$TLS" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_TLS_LINK"
[ "$SITNL" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_USE_SITNL"
[ "$MDNC" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DMBEDTLS_DISABLE_NAME_CONSTRAINTS"
[ "$DAT" = "1" ] && GCC_EXTRA="$GCC_EXTRA -DOPENVPN_DISABLE_AUTH_TOKEN"
if [ "$AGENT" = "1" ]; then
GCC_EXTRA="$GCC_EXTRA -DOPENVPN_COMMAND_AGENT"
fi
GCC_EXTRA="$GCC_EXTRA -DOPENVPN_VERSION=\"$($(dirname $0)/../../scripts/version)\""
# shellcheck disable=SC2046,SC2089
GCC_EXTRA="$GCC_EXTRA -DOPENVPN_VERSION=\"$($(dirname "$0")/../../scripts/version)\""
# shellcheck disable=SC2090
export GCC_EXTRA

# determine platform
if [ "$(uname)" == "Darwin" ]; then
export PROF=${PROF:-osx64}
elif [ "$(uname)" == "Linux" ]; then
export PROF=${PROF:-linux}
if [ "$(uname)" = "Darwin" ]; then
export PROF="${PROF:-osx64}"
elif [ "$(uname)" = "Linux" ]; then
export PROF="${PROF:-linux}"
else
echo this script only knows how to build on Mac OS or Linux
fi

# use mbedTLS by default
[[ -z "$OSSL" && -z "$MTLS" ]] && export MTLS=1
[ -z "$OSSL" ] && [ -z "$MTLS" ] && export MTLS=1

# don't link with OpenSSL if mbedTLS is specified
if [ "$MTLS" = "1" ]; then
Expand Down

0 comments on commit b0a37d2

Please sign in to comment.