Add some more error checking to shell scripts (#2617)
Exit immediately if a command exits with a non-zero status, and treat unset variables as an error when substituting.
This commit is contained in:
1 parent
352b710754
commit
d80d734190
12 files changed
+64
-40
No files matched your search
@@ -14,7 +14,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
- name: Install dependencies
|
||||
run: ./build/ci/github_actions/macos.sh prepare
|
||||
run: ./build/ci/github_actions/install-macos-dependencies.sh
|
||||
- name: Autogen
|
||||
run: ./build/ci/build.sh -a autogen
|
||||
env:
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
PATH=/usr/local/gnu-autotools/bin/:$PATH
|
||||
export PATH
|
||||
|
||||
# Start from one level above the build directory
|
||||
if [ -f version ]; then
|
||||
@@ -49,7 +49,7 @@ perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' conf
|
||||
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac
|
||||
|
||||
# Remove developer CFLAGS if a release build is being made
|
||||
if [ -n "${MAKE_LIBARCHIVE_RELEASE}" ]; then
|
||||
if [ -n "${MAKE_LIBARCHIVE_RELEASE:-}" ]; then
|
||||
perl -p -i -e "s/^(DEV_CFLAGS.*)/# \$1/" Makefile.am
|
||||
perl -p -i -e 's/CMAKE_BUILD_TYPE "[A-Za-z]*"/CMAKE_BUILD_TYPE "Release"/' CMakeLists.txt
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh +v
|
||||
set -eu
|
||||
|
||||
# Start from the build directory, where the version file is located
|
||||
if [ -f build/version ]; then
|
||||
|
||||
+14
-10
@@ -12,14 +12,18 @@
|
||||
# MAKE_ARGS= # make arguments
|
||||
# DEBUG= # set -g -fsanitize=address flags
|
||||
|
||||
set -eu
|
||||
|
||||
ACTIONS=
|
||||
if [ -n "${BUILD_SYSTEM}" ]; then
|
||||
if [ -n "${BUILD_SYSTEM:-}" ]; then
|
||||
BS="${BUILD_SYSTEM}"
|
||||
fi
|
||||
|
||||
BS="${BS:-autotools}"
|
||||
MAKE="${MAKE:-make}"
|
||||
CMAKE="${CMAKE:-cmake}"
|
||||
CMAKE_ARGS="${CMAKE_ARGS:-}"
|
||||
CONFIGURE_ARGS="${CONFIGURE_ARGS:-}"
|
||||
CURDIR=`pwd`
|
||||
SRCDIR="${SRCDIR:-`pwd`}"
|
||||
RET=0
|
||||
@@ -74,7 +78,7 @@ while getopts a:b:c:d:s: opt; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case "${CRYPTO}" in
|
||||
case "${CRYPTO:-}" in
|
||||
mbedtls)
|
||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPENSSL=OFF -DENABLE_MBEDTLS=ON"
|
||||
CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-mbedtls"
|
||||
@@ -84,7 +88,7 @@ case "${CRYPTO}" in
|
||||
CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-nettle"
|
||||
;;
|
||||
esac
|
||||
if [ -z "${MAKE_ARGS}" ]; then
|
||||
if [ -z "${MAKE_ARGS:-}" ]; then
|
||||
if [ "${BS}" = "autotools" ]; then
|
||||
MAKE_ARGS="V=1"
|
||||
elif [ "${BS}" = "cmake" ]; then
|
||||
@@ -92,13 +96,13 @@ if [ -z "${MAKE_ARGS}" ]; then
|
||||
fi
|
||||
fi
|
||||
if [ -d /opt/homebrew/include ]; then
|
||||
export CFLAGS="${CFLAGS} -I/opt/homebrew/include"
|
||||
export CFLAGS="${CFLAGS:-} -I/opt/homebrew/include"
|
||||
fi
|
||||
if [ -d /opt/homebrew/lib ]; then
|
||||
export LDFLAGS="${LDFLAGS} -L/opt/homebrew/lib"
|
||||
export LDFLAGS="${LDFLAGS:-} -L/opt/homebrew/lib"
|
||||
fi
|
||||
if [ -n "${DEBUG}" ]; then
|
||||
if [ -n "${CFLAGS}" ]; then
|
||||
if [ -n "${DEBUG:-}" ]; then
|
||||
if [ -n "${CFLAGS:-}" ]; then
|
||||
export CFLAGS="${CFLAGS} -g -fsanitize=address"
|
||||
else
|
||||
export CFLAGS="-g -fsanitize=address"
|
||||
@@ -110,7 +114,7 @@ fi
|
||||
if [ -z "${BS}" ]; then
|
||||
inputerror "Missing build system (-b) parameter"
|
||||
fi
|
||||
if [ -z "${BUILDDIR}" ]; then
|
||||
if [ -z "${BUILDDIR:-}" ]; then
|
||||
BUILDDIR="${CURDIR}/build_ci/${BS}"
|
||||
fi
|
||||
mkdir -p "${BUILDDIR}"
|
||||
@@ -147,7 +151,7 @@ for action in ${ACTIONS}; do
|
||||
;;
|
||||
esac
|
||||
RET="$?"
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \;
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \; 2>/dev/null || /bin/true
|
||||
;;
|
||||
install)
|
||||
${MAKE} ${MAKE_ARGS} install DESTDIR="${BUILDDIR}/destdir"
|
||||
@@ -159,7 +163,7 @@ for action in ${ACTIONS}; do
|
||||
${MAKE} ${MAKE_ARGS} distcheck || (
|
||||
RET="$?"
|
||||
find . -name 'test-suite.log' -print -exec cat {} \;
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \;
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \; 2>/dev/null || /bin/true
|
||||
exit "${RET}"
|
||||
)
|
||||
RET="$?"
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if [ $# != 1 ]
|
||||
then
|
||||
echo "Usage: $0 prepare | test"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UNAME=`uname`
|
||||
if [ "$1" = "prepare" ]
|
||||
then
|
||||
@@ -53,6 +61,6 @@ then
|
||||
TMPDIR=/tmp_acl_nfsv4 ${BIN_SUBDIR}/libarchive_test -r "${CURDIR}/libarchive/test" -v test_acl_platform_nfs4
|
||||
fi
|
||||
else
|
||||
echo "Usage $0 prepare | test_nfsv4_acls"
|
||||
echo "Usage: $0 prepare | test"
|
||||
exit 1
|
||||
fi
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -eux
|
||||
|
||||
# Uncommenting these adds a full minute to the CI time
|
||||
#brew update > /dev/null
|
||||
#brew upgrade > /dev/null
|
||||
|
||||
# This does an upgrade if the package is already installed
|
||||
brew install \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
pkg-config \
|
||||
cmake \
|
||||
xz \
|
||||
lz4 \
|
||||
zstd \
|
||||
libxml2 \
|
||||
openssl
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
if [ "$1" = "prepare" ]
|
||||
then
|
||||
set -x -e
|
||||
#Uncommenting these adds a full minute to the CI time
|
||||
#brew update > /dev/null
|
||||
#brew upgrade > /dev/null
|
||||
|
||||
# This does an upgrade if the package is already installed
|
||||
brew install \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
pkg-config \
|
||||
cmake \
|
||||
xz \
|
||||
lz4 \
|
||||
zstd \
|
||||
libxml2 \
|
||||
openssl
|
||||
fi
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
#
|
||||
# Attempt to remove as many generated files as we can.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
#
|
||||
# This script exists primarily to document some of the
|
||||
@@ -8,7 +9,6 @@
|
||||
#
|
||||
|
||||
PATH=/usr/local/gnu-autotools/bin/:$PATH
|
||||
export PATH
|
||||
|
||||
# Start from one level above the build directory
|
||||
if [ -f version ]; then
|
||||
@@ -24,7 +24,7 @@ fi
|
||||
# Makefile. Effectively disable it.
|
||||
export MAKEOBJDIRPREFIX=/junk
|
||||
|
||||
set -ex
|
||||
set -x
|
||||
|
||||
#
|
||||
# Scrub the local tree before running the build tests below.
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
ID=$(docker build -q -f build/release/Dockerfile .)
|
||||
if [ -z "$ID" ]; then
|
||||
echo "Failed to build docker image"
|
||||
exit 1
|
||||
else
|
||||
docker run $ID sh -c "tar -c -f - libarchive-*" | tar -x -f -
|
||||
docker run "$ID" sh -c "tar -c -f - libarchive-*" | tar -x -f -
|
||||
fi
|
||||
@@ -1,4 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if [ $# != 1 ]
|
||||
then
|
||||
echo "Usage: $0 path/to/UnicodeData.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# This needs http://unicode.org/Public/6.0.0/ucd/UnicodeData.txt
|
||||
#
|
||||
|
||||
+4
-2
@@ -1,12 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -eu
|
||||
|
||||
#
|
||||
# Simple script to repopulate the 'doc' tree from
|
||||
# the mdoc man pages stored in each project.
|
||||
#
|
||||
|
||||
script_dir=`dirname $0`
|
||||
cd "$script_dir"
|
||||
|
||||
# Collect list of man pages, relative to my subdirs
|
||||
test -d man || mkdir man
|
||||
cd man
|
||||
|
||||
Reference in new issue
Block a user