Skip to content

Commit a95551c

Browse files
added some -- style script args
also changed wolfProvider to always build, no matter what
1 parent 3e8e7f8 commit a95551c

4 files changed

Lines changed: 160 additions & 85 deletions

File tree

scripts/build-wolfprovider.sh

Lines changed: 102 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,117 @@
22
# This script provides the bare minimum function definitions for compiling
33
# the wolfProvider library
44

5-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
6-
LOG_FILE=${SCRIPT_DIR}/build-release.log
7-
source ${SCRIPT_DIR}/utils-wolfprovider.sh
8-
95
show_help() {
106
echo "Usage: $0"
117
echo ""
8+
echo "Script Arguments:"
9+
echo " --help, -help, -h Display this help menu and exit"
10+
echo " --debug Builds OpenSSL, wolfSSL, and WolfProvider with debugging enabled"
11+
echo " --openssl-ver=VER Which version of OpenSSL to clone"
12+
echo " --wolfssl-ver=VER Which version of wolfSSL to clone"
13+
echo " --enable-fips Build wolfProvider with a cloned FIPS bundle. Cloned FIPS bundle can be changed with --fips-check"
14+
echo " --fips-bundle=DIR Build wolfProvider with a directory containing a wolfSSL FIPS bundle instead of cloning from GitHub. Requires a FIPS version to be given by --fips-version"
15+
echo " --fips-check=TAG Choose a FIPS tag to clone. May require a version to be given by --fips-version"
16+
echo " --fips-version=VER Choose the wolfSSL FIPS version"
17+
echo " --quicktest Disable some tests for a faster testing suite"
18+
echo ""
1219
echo "Environment Variables:"
13-
echo " OPENSSL_TAG OpenSSL tag to use (e.g., openssl-3.5.0)"
14-
echo " WOLFSSL_TAG wolfSSL tag to use (e.g., v5.8.0-stable)"
15-
echo " WOLFPROV_DEBUG If set to 1, builds OpenSSL, wolfSSL, and wolfProvider with debug options enabled"
16-
echo " WOLFSSL_FIPS_BUNDLE Directory containing the wolfSSL FIPS bundle to use instead of cloning from GitHub"
17-
echo " WOLFSSL_FIPS_VERSION Version of wolfSSL FIPS bundle (v5, v6, ready), used as an argument for --enable-fips when configuring wolfSSL"
20+
echo " OPENSSL_TAG OpenSSL tag to use (e.g., openssl-3.5.0)"
21+
echo " WOLFSSL_TAG wolfSSL tag to use (e.g., v5.8.0-stable)"
22+
echo " WOLFPROV_DEBUG If set to 1, builds OpenSSL, wolfSSL, and wolfProvider with debug options enabled"
23+
echo " WOLFSSL_ISFIPS If set to 1, clones a wolfSSL FIPS bundle from GitHub"
24+
echo " WOLFSSL_FIPS_BUNDLE Directory containing the wolfSSL FIPS bundle to use instead of cloning from GitHub"
25+
echo " WOLFSSL_FIPS_VERSION Version of wolfSSL FIPS bundle (v5, v6, ready), used as an argument for --enable-fips when configuring wolfSSL"
26+
echo " WOLFSSL_FIPS_CHECK_TAG Tag for wolfSSL FIPS bundle (linuxv5.2.1, v6.0.0, etc), used as an argument for fips-check.sh when cloning a wolfSSL FIPS version"
27+
echo " WOLFPROV_QUICKTEST If set to 1, disables some tests in the test suite to increase test speed"
1828
echo ""
1929
}
2030

21-
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "-help" ]]; then
22-
show_help
23-
exit 0
31+
args_wrong=""
32+
args=""
33+
for arg in "$@"; do
34+
args+="$arg, "
35+
case "$arg" in
36+
--help | -help | -h)
37+
show_help
38+
exit 0
39+
;;
40+
--debug)
41+
WOLFPROV_DEBUG=1
42+
;;
43+
--openssl-ver=*)
44+
IFS='=' read -r trash ossl_ver <<< "$arg"
45+
if [ -z "$ossl_ver" ]; then
46+
echo "No version given for --openssl-ver"
47+
args_wrong+="$arg, "
48+
fi
49+
OPENSSL_TAG="$ossl_ver"
50+
;;
51+
--wolfssl-ver=*)
52+
IFS='=' read -r trash wolf_ver <<< "$arg"
53+
if [ -z "$wolf_ver" ]; then
54+
echo "No version given for --wolfssl-ver"
55+
args_wrong+="$arg, "
56+
fi
57+
WOLFSSL_TAG="$wolf_ver"
58+
;;
59+
--enable-fips)
60+
unset WOLFSSL_FIPS_BUNDLE
61+
WOLFSSL_ISFIPS=1
62+
;;
63+
--fips-bundle=*)
64+
unset WOLFSSL_ISFIPS
65+
unset WOLFSSL_FIPS_CHECK_TAG
66+
IFS='=' read -r trash fips_bun <<< "$arg"
67+
if [ -z "$fips_bun" ]; then
68+
echo "No directory given for --fips-bundle"
69+
args_wrong+="$arg, "
70+
fi
71+
WOLFSSL_FIPS_BUNDLE="$fips_bun"
72+
;;
73+
--fips-check=*)
74+
unset WOLFSSL_FIPS_BUNDLE
75+
IFS='=' read -r trash fips_tag <<< "$arg"
76+
if [ -z "$fips_tag" ]; then
77+
echo "No tag given for --fips-check"
78+
args_wrong+="$arg, "
79+
fi
80+
WOLFSSL_FIPS_CHECK_TAG="$fips_tag"
81+
;;
82+
--fips-version=*)
83+
IFS='=' read -r trash fips_ver <<< "$arg"
84+
if [ -z "$fips_ver" ]; then
85+
echo "No version given for --fips-version"
86+
args_wrong+="$arg, "
87+
fi
88+
WOLFSSL_FIPS_VERSION="$fips_ver"
89+
;;
90+
--quicktest)
91+
WOLFPROV_QUICKTEST=1
92+
;;
93+
*)
94+
args_wrong+="$arg "
95+
;;
96+
esac
97+
done
98+
99+
if [ -n "$args_wrong" ]; then
100+
args_wrong="`echo $args_wrong | head -c -2 -`"
101+
echo "Unrecognized argument(s) provided: $args_wrong"
102+
echo "Use --help to see a list of arguments"
103+
exit 1
24104
fi
25105

106+
if [ -n "$args" ]; then
107+
args="`echo $args | head -c -2 -`"
108+
echo "Building wolfProvider with: $args"
109+
echo ""
110+
fi
111+
112+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
113+
LOG_FILE=${SCRIPT_DIR}/build-release.log
114+
source ${SCRIPT_DIR}/utils-wolfprovider.sh
115+
26116
echo "Using openssl: $OPENSSL_TAG, wolfssl: $WOLFSSL_TAG"
27117

28118
init_wolfprov

scripts/utils-general.sh

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,6 @@ if [ "$UTILS_GENERAL_LOADED" != "yes" ]; then # only set once
2727
export UTILS_GENERAL_LOADED=yes
2828
fi
2929

30-
check_folder_age() {
31-
folderA=$1
32-
folderB=$2
33-
34-
if [[ "$OSTYPE" == "darwin"* ]]; then
35-
folderA_age=$(find "$folderA" -type f -exec stat -f '%Dm' {} \; | sort -n | tail -n 1)
36-
folderB_age=$(find "$folderB" -type f -exec stat -f '%Dm' {} \; | sort -n | tail -n 1)
37-
else
38-
folderA_age=$(find "$folderA" -type f -printf '%T@' | sort -n | tail -n 1)
39-
folderB_age=$(find "$folderB" -type f -printf '%T@' | sort -n | tail -n 1)
40-
fi
41-
42-
if awk "BEGIN {exit !($folderA_age > $folderB_age)}"; then
43-
echo 1
44-
elif awk "BEGIN {exit !($folderA_age < $folderB_age)}"; then
45-
echo -1
46-
else
47-
echo 0
48-
fi
49-
}
50-
5130
# Usage: check_git_match <target_ref> [<repo_dir>]
5231
check_git_match() {
5332
local target_ref="$1"

scripts/utils-wolfprovider.sh

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -52,57 +52,55 @@ install_wolfprov() {
5252
unset OPENSSL_CONF
5353
printf "LD_LIBRARY_PATH: $LD_LIBRARY_PATH\n"
5454

55-
if [ ! -d ${WOLFPROV_INSTALL_DIR} ] || [ $(check_folder_age "${WOLFPROV_INSTALL_DIR}" "${WOLFSSL_INSTALL_DIR}") -lt 0 ] || [ $(check_folder_age "${WOLFPROV_INSTALL_DIR}" "${OPENSSL_INSTALL_DIR}") -lt 0 ]; then
56-
printf "\tConfigure wolfProvider ... "
57-
if [ ! -e "${WOLFPROV_SOURCE_DIR}/configure" ]; then
58-
./autogen.sh >>$LOG_FILE 2>&1
59-
fi
60-
61-
if [ "$WOLFPROV_DEBUG" = "1" ]; then
62-
WOLFPROV_CONFIG_OPTS+=" --enable-debug"
63-
fi
64-
65-
./configure ${WOLFPROV_CONFIG_OPTS} CFLAGS="${WOLFPROV_CONFIG_CFLAGS}" >>$LOG_FILE 2>&1
66-
RET=$?
67-
68-
if [ $RET != 0 ]; then
69-
printf "\n\n...\n"
70-
tail -n 40 $LOG_FILE
71-
do_cleanup
72-
exit 1
73-
fi
74-
printf "Done.\n"
75-
76-
printf "\tBuild wolfProvider ... "
77-
make -j$NUMCPU >>$LOG_FILE 2>&1
78-
if [ $? != 0 ]; then
79-
printf "\n\n...\n"
80-
tail -n 40 $LOG_FILE
81-
do_cleanup
82-
exit 1
83-
fi
84-
printf "Done.\n"
85-
86-
printf "\tTest wolfProvider ... "
87-
make test >>$LOG_FILE 2>&1
88-
if [ $? != 0 ]; then
89-
printf "\n\n...\n"
90-
tail -n 40 $LOG_FILE
91-
do_cleanup
92-
exit 1
93-
fi
94-
printf "Done.\n"
95-
96-
printf "\tInstall wolfProvider ... "
97-
make install >>$LOG_FILE 2>&1
98-
if [ $? != 0 ]; then
99-
printf "\n\n...\n"
100-
tail -n 40 $LOG_FILE
101-
do_cleanup
102-
exit 1
103-
fi
104-
printf "Done.\n"
55+
printf "\tConfigure wolfProvider ... "
56+
if [ ! -e "${WOLFPROV_SOURCE_DIR}/configure" ]; then
57+
./autogen.sh >>$LOG_FILE 2>&1
10558
fi
59+
60+
if [ "$WOLFPROV_DEBUG" = "1" ]; then
61+
WOLFPROV_CONFIG_OPTS+=" --enable-debug"
62+
fi
63+
64+
./configure ${WOLFPROV_CONFIG_OPTS} CFLAGS="${WOLFPROV_CONFIG_CFLAGS}" >>$LOG_FILE 2>&1
65+
RET=$?
66+
67+
if [ $RET != 0 ]; then
68+
printf "\n\n...\n"
69+
tail -n 40 $LOG_FILE
70+
do_cleanup
71+
exit 1
72+
fi
73+
printf "Done.\n"
74+
75+
printf "\tBuild wolfProvider ... "
76+
make -j$NUMCPU >>$LOG_FILE 2>&1
77+
if [ $? != 0 ]; then
78+
printf "\n\n...\n"
79+
tail -n 40 $LOG_FILE
80+
do_cleanup
81+
exit 1
82+
fi
83+
printf "Done.\n"
84+
85+
printf "\tTest wolfProvider ... "
86+
make test >>$LOG_FILE 2>&1
87+
if [ $? != 0 ]; then
88+
printf "\n\n...\n"
89+
tail -n 40 $LOG_FILE
90+
do_cleanup
91+
exit 1
92+
fi
93+
printf "Done.\n"
94+
95+
printf "\tInstall wolfProvider ... "
96+
make install >>$LOG_FILE 2>&1
97+
if [ $? != 0 ]; then
98+
printf "\n\n...\n"
99+
tail -n 40 $LOG_FILE
100+
do_cleanup
101+
exit 1
102+
fi
103+
printf "Done.\n"
106104
}
107105

108106
init_wolfprov() {

scripts/utils-wolfssl.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,20 @@ install_wolfssl() {
104104
WOLFSSL_CONFIG_CFLAGS=$WOLFSSL_FIPS_CONFIG_CFLAGS
105105
elif [ "$WOLFSSL_ISFIPS" = "1" ]; then
106106
printf "with FIPS ... "
107-
CONF_ARGS+=" --enable-fips=v5"
107+
if [ -n "$WOLFSSL_FIPS_VERSION" ]; then
108+
CONF_ARGS+=" --enable-fips=$WOLFSSL_FIPS_VERSION"
109+
else
110+
CONF_ARGS+=" --enable-fips=v5"
111+
fi
108112
WOLFSSL_CONFIG_OPTS=$WOLFSSL_FIPS_CONFIG_OPTS
109113
WOLFSSL_CONFIG_CFLAGS=$WOLFSSL_FIPS_CONFIG_CFLAGS
110114
if [ ! -e "XXX-fips-test" ]; then
111115
# Sometimes the system OpenSSL is different than the one we're using. So for the 'git' commands, we'll just use whatever the system comes with
112-
LD_LIBRARY_PATH="" ./fips-check.sh linuxv5.2.1 keep nomakecheck >>$LOG_FILE 2>&1
116+
if [ -n "$WOLFSSL_FIPS_CHECK_TAG" ]; then
117+
LD_LIBRARY_PATH="" ./fips-check.sh "$WOLFSSL_FIPS_CHECK_TAG" keep nomakecheck >>$LOG_FILE 2>&1
118+
else
119+
LD_LIBRARY_PATH="" ./fips-check.sh linuxv5.2.1 keep nomakecheck >>$LOG_FILE 2>&1
120+
fi
113121
if [ $? != 0 ]; then
114122
printf "ERROR checking out FIPS\n"
115123
rm -rf ${WOLFSSL_INSTALL_DIR}

0 commit comments

Comments
 (0)