Skip to content

Commit

Permalink
Build script: format the code.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeov committed Jul 4, 2024
1 parent 1173366 commit c25cf56
Showing 1 changed file with 45 additions and 58 deletions.
103 changes: 45 additions & 58 deletions travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ MYQFSHADOOP_VERSIONS_CENTOS5='0.23.4 0.23.11 1.0.4 1.1.2 2.5.1'

MYBUILD_TYPE='release'

set_sudo()
{
set_sudo() {
if [ x"$(id -u)" = x'0' ]; then
MYSUDO=
MYUSER=
Expand All @@ -88,34 +87,32 @@ set_sudo()
fi
}

cores_show_stack_traces()
{
gdb -version > /dev/null || return 0
MYGDBCMDS=`mktemp`
cat > "$MYGDBCMDS" << EOF
cores_show_stack_traces() {
gdb -version >/dev/null || return 0
MYGDBCMDS=$(mktemp)
cat >"$MYGDBCMDS" <<EOF
bt
thread apply all bt
EOF
find ${1+"$@"} -type f -name core\* -print \
| while read MYCORE; do
MYEXECUTABLE=$(gdb -batch -c "$MYCORE" 2>/dev/null \
| sed -ne 's/^Core was generated by `\([^ ]*\).*$/\1/p')
echo "================== $MYEXECUTABLE $MYCORE ===="
gdb -batch "$MYEXECUTABLE" -c "$MYCORE" -x "$MYGDBCMDS" \
2>/dev/null || true
echo "------------------ $MYEXECUTABLE $MYCORE ----"
done
find ${1+"$@"} -type f -name core\* -print |
while read MYCORE; do
MYEXECUTABLE=$(gdb -batch -c "$MYCORE" 2>/dev/null |
sed -ne 's/^Core was generated by `\([^ ]*\).*$/\1/p')
echo "================== $MYEXECUTABLE $MYCORE ===="
gdb -batch "$MYEXECUTABLE" -c "$MYCORE" -x "$MYGDBCMDS" \
2>/dev/null || true
echo "------------------ $MYEXECUTABLE $MYCORE ----"
done
rm "$MYGDBCMDS"
return 0
}

tail_logs_and_exit()
{
tail_logs_and_exit() {
MYQFSTEST_DIR="build/$MYBUILD_TYPE/qfstest"
if [ -d "$MYQFSTEST_DIR" ]; then
cores_show_stack_traces "$MYQFSTEST_DIR"
find "$MYQFSTEST_DIR" -type f -name '*.log' -print0 \
| xargs -0 tail -n 100
find "$MYQFSTEST_DIR" -type f -name '*.log' -print0 |
xargs -0 tail -n 100
fi
while [ -e "$MYDOCKERBUILDDEBUGFILENAME" ]; do
echo 'sleeping for 10 sec.'
Expand All @@ -124,8 +121,7 @@ tail_logs_and_exit()
exit 1
}

do_build()
{
do_build() {
if [ x"$MYBUILD_TYPE" = x'debug' ]; then
MYCMAKE_OPTIONS=$MYCMAKE_OPTIONS' -D CMAKE_BUILD_TYPE=Debug'
else
Expand All @@ -137,16 +133,15 @@ do_build()
CMAKE="$MYCMAKE" \
CMAKE_OPTIONS="$MYCMAKE_OPTIONS" \
JAVA_BUILD_OPTIONS='-r 5' \
test tarball \
|| tail_logs_and_exit
test tarball ||
tail_logs_and_exit
}

do_build_linux()
{
do_build_linux() {
MYMAKEOPT='-j 2'
if [ -r /proc/cpuinfo ]; then
cat /proc/cpuinfo
MYCCNT=`grep -c -w processor /proc/cpuinfo`
MYCCNT=$(grep -c -w processor /proc/cpuinfo)
if [ $MYCCNT -gt 2 ]; then
MYMAKEOPT="-j $MYCCNT"
fi
Expand All @@ -162,23 +157,21 @@ do_build_linux()
fi
}

init_codecov()
{
init_codecov() {
# Run code coverage in docker
# Pass travis env vars to code coverage.
mkdir -p "$MYTMPDIR"
mkdir -p "$MYTMPDIR"
{
env | grep -E '^(TRAVIS|CI|GITHUB)' | sed \
-e "s/'/'\\\''/g" \
-e "s/'/'\\\''/g" \
-e "s/=/=\'/" \
-e 's/$/'"'/" \
-e 's/^/export /'
echo 'curl -s https://codecov.io/bash | /bin/bash'
} > "$MYCODECOV"
} >"$MYCODECOV"
}

install_maven()
{
install_maven() {
if [ -f "$MYMVNTAR" ]; then
$MYSUDO tar -xf "$MYMVNTAR" -C '/usr/local'
# Set up PATH and links
Expand All @@ -191,8 +184,7 @@ install_maven()
fi
}

build_ubuntu()
{
build_ubuntu() {
if [ x"$1" = x'22.04' ]; then
MYDEPS=$DEPS_UBUNTU22
elif [ x"$1" = x'14.04' -o x"$1" = x'16.04' ]; then
Expand Down Expand Up @@ -220,13 +212,11 @@ build_ubuntu()
${QFSHADOOP_VERSIONS+QFSHADOOP_VERSIONS="$QFSHADOOP_VERSIONS"}
}

build_ubuntu32()
{
build_ubuntu32() {
build_ubuntu
}

build_debian()
{
build_debian() {
if [ x"$1" = x'9' ]; then
true
else
Expand All @@ -235,8 +225,7 @@ build_debian()
build_ubuntu
}

build_centos()
{
build_centos() {
if [ x"$1" = x'5' ]; then
# Centos 5 EOL, use vault for now.
$MYSUDO sed -i 's/enabled=1/enabled=0/' \
Expand Down Expand Up @@ -289,7 +278,7 @@ build_centos()
MYBINDIR='/usr/local/openssl101e/bin'
fi
mkdir -p "$MYBINDIR"
ln -snf "`which openssl101e`" "$MYBINDIR/openssl"
ln -snf "$(which openssl101e)" "$MYBINDIR/openssl"
MYPATH="$MYBINDIR:$MYPATH:/usr/kerberos/bin"
MYCMAKE_OPTIONS=$MYCMAKE_OPTIONS_CENTOS5
MYCMAKE=$MYCMAKE_CENTOS5
Expand All @@ -314,8 +303,7 @@ build_centos()
${QFS_MSTRESS_ON+QFS_MSTRESS_ON="$QFS_MSTRESS_ON"}
}

set_build_type()
{
set_build_type() {
if [ x"$1" = x ]; then
true
else
Expand Down Expand Up @@ -353,11 +341,11 @@ if [ x"$BUILD_OS_NAME" = x'linux' ]; then
init_codecov
fi
if [ x"$DOCKER_BUILD_DEBUG" = x'yes' ]; then
mkdir -p "$MYTMPDIR"
mkdir -p "$MYTMPDIR"
touch "$MYDOCKERBUILDDEBUGFILENAME"
fi
if [ x"$DISTRO" = x'centos' -o x"$DISTRO $VER" = x'ubuntu 14.04' ]; then
mkdir -p "$MYTMPDIR"
mkdir -p "$MYTMPDIR"
curl --retry 3 -S -o "$MYMVNTAR" "$MYMVN_URL"
if [ x"$DISTRO $VER" = x'centos 5' ]; then
# Download here as curl/openssl and root certs are dated on centos5,
Expand Down Expand Up @@ -385,21 +373,20 @@ if [ x"$BUILD_OS_NAME" = x'linux' ]; then
elif [ x"$BUILD_OS_NAME" = x'osx' ]; then
set_build_type "$BTYPE"
for pkg_name in \
'openssl' \
'openssl@3' \
'openssl@1.1' \
; do
MYSSLD=$(brew list "$pkg_name" \
| sed -ne 's/^\(.*\)\/bin\/[^\/]*$/\1/p' \
| sort -ru | head -1)
'openssl' \
'openssl@3' \
'openssl@1.1'; do
MYSSLD=$(brew list "$pkg_name" |
sed -ne 's/^\(.*\)\/bin\/[^\/]*$/\1/p' |
sort -ru | head -1)
[ -d "$MYSSLD" ] && break
done
if [ -d "$MYSSLD" ]; then
MYCMAKE_OPTIONS="$MYCMAKE_OPTIONS -D OPENSSL_ROOT_DIR=${MYSSLD}"
MYSSLBIND="$MYSSLD/bin"
if [ -f "$MYSSLBIND/openssl" ] && \
PATH="$MYSSLBIND:$PATH" \
openssl version > /dev/null 2>&1; then
if [ -f "$MYSSLBIND/openssl" ] &&
PATH="$MYSSLBIND:$PATH" \
openssl version >/dev/null 2>&1; then
PATH="$MYSSLBIND:$PATH"
export PATH
fi
Expand All @@ -408,7 +395,7 @@ elif [ x"$BUILD_OS_NAME" = x'osx' ]; then
sysctl machdep.cpu || true
df -h || true
cpu_count=$(sysctl -n hw.ncpu)
expr "$cpu_count" : '^[0-9]*$' > /dev/null || cpu_count=2
expr "$cpu_count" : '^[0-9]*$' >/dev/null 2>&1 || cpu_count=2
do_build -j "$cpu_count"
else
echo "OS: $BUILD_OS_NAME not yet supported"
Expand Down

0 comments on commit c25cf56

Please sign in to comment.