Shellcheck on build.sh (#1534)

This commit is contained in:
optizone 2019-05-15 11:02:48 +03:00 committed by xarkes
parent 2ba9e170c5
commit d35bed54a3

View File

@ -6,9 +6,9 @@
ERR=0 ERR=0
#### User variables #### #### User variables ####
BUILD="`pwd`/build" BUILD="$(pwd)/build"
QMAKE_CONF=$* QMAKE_CONF=$*
ROOT_DIR=`pwd` ROOT_DIR=$(pwd)
check_r2() { check_r2() {
r2 -v >/dev/null 2>&1 r2 -v >/dev/null 2>&1
@ -23,9 +23,9 @@ check_r2() {
} }
find_qmake() { find_qmake() {
qmakepath=$(which qmake-qt5) qmakepath=$(command -v qmake-qt5)
if [ -z "$qmakepath" ]; then if [ -z "$qmakepath" ]; then
qmakepath=$(which qmake) qmakepath=$(command -v qmake)
fi fi
if [ -z "$qmakepath" ]; then if [ -z "$qmakepath" ]; then
echo "You need qmake to build Cutter." echo "You need qmake to build Cutter."
@ -36,9 +36,9 @@ find_qmake() {
} }
find_lrelease() { find_lrelease() {
lreleasepath=$(which lrelease-qt5) lreleasepath=$(command -v lrelease-qt5)
if [ -z "$lreleasepath" ]; then if [ -z "$lreleasepath" ]; then
lreleasepath=$(which lrelease) lreleasepath=$(command -v lrelease)
fi fi
if [ -z "$lreleasepath" ]; then if [ -z "$lreleasepath" ]; then
echo "You need lrelease to build Cutter." echo "You need lrelease to build Cutter."
@ -49,9 +49,9 @@ find_lrelease() {
} }
find_gmake() { find_gmake() {
gmakepath=$(which gmake) gmakepath=$(command -v gmake)
if [ -z "$gmakepath" ]; then if [ -z "$gmakepath" ]; then
gmakepath=$(which make) gmakepath=$(command -v make)
fi fi
${gmakepath} --help 2>&1 | grep -q gnu ${gmakepath} --help 2>&1 | grep -q gnu
@ -64,15 +64,16 @@ find_gmake() {
} }
prepare_breakpad() { prepare_breakpad() {
if [ -z $OSTYPE ]; then OS="$(uname -s)"
if [ -z "$OS" ]; then
echo "Could not identify OS, OSTYPE var is empty. You can try to disable breakpad to avoid this error." echo "Could not identify OS, OSTYPE var is empty. You can try to disable breakpad to avoid this error."
exit 1 exit 1
fi fi
if [ $OSTYPE = "linux-gnu" ]; then if [ "$OS" = "Linux" ]; then
. $ROOT_DIR/scripts/prepare_breakpad_linux.sh . $ROOT_DIR/scripts/prepare_breakpad_linux.sh
export PKG_CONFIG_PATH="$CUSTOM_BREAKPAD_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" export PKG_CONFIG_PATH="$CUSTOM_BREAKPAD_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
elif [ $OSTYPE = "darwin" ]; then elif [ "$OS" = "Darwin" ]; then
. $ROOT_DIR/scripts/prepare_breakpad_macos.sh . $ROOT_DIR/scripts/prepare_breakpad_macos.sh
fi fi
} }
@ -81,8 +82,8 @@ prepare_breakpad() {
check_r2 check_r2
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
printf "A (new?) version of radare2 will be installed. Do you agree? [Y/n] " printf "A (new?) version of radare2 will be installed. Do you agree? [Y/n] "
read answer read -r answer
if [ -z "$answer" -o "$answer" = "Y" -o "$answer" = "y" ]; then if [ -z "$answer" ] || [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then
R2PREFIX=${1:-"/usr"} R2PREFIX=${1:-"/usr"}
git submodule init && git submodule update git submodule init && git submodule update
cd radare2 || exit 1 cd radare2 || exit 1
@ -100,19 +101,19 @@ fi
$(find_lrelease) ./src/Cutter.pro $(find_lrelease) ./src/Cutter.pro
# Build # Build
if [ "${QMAKE_CONF/CUTTER_ENABLE_CRASH_REPORTS=true/something}" != $QMAKE_CONF ]; then if [ "${QMAKE_CONF#*CUTTER_ENABLE_CRASH_REPORTS=true}" != "$QMAKE_CONF" ]; then
prepare_breakpad prepare_breakpad
fi fi
mkdir -p "$BUILD" mkdir -p "$BUILD"
cd "$BUILD" || exit 1 cd "$BUILD" || exit 1
$(find_qmake) ../src/Cutter.pro $QMAKE_CONF $(find_qmake) ../src/Cutter.pro "$QMAKE_CONF"
$(find_gmake) -j4 $(find_gmake) -j4
ERR=$((ERR+$?)) ERR=$((ERR+$?))
# Move translations # Move translations
mkdir -p "`pwd`/translations" mkdir -p "$(pwd)/translations"
find "$ROOT_DIR/src/translations" -maxdepth 1 -type f | grep "cutter_..\.qm" | while read SRC_FILE; do find "$ROOT_DIR/src/translations" -maxdepth 1 -type f | grep "cutter_..\.qm" | while read -r SRC_FILE; do
mv $SRC_FILE "`pwd`/translations" mv "$SRC_FILE" "$(pwd)/translations"
done done
# Finish # Finish
@ -121,8 +122,8 @@ if [ ${ERR} -gt 0 ]; then
else else
echo "Build complete." echo "Build complete."
printf "This build of Cutter will be installed. Do you agree? [Y/n] " printf "This build of Cutter will be installed. Do you agree? [Y/n] "
read answer read -r answer
if [ -z "$answer" -o "$answer" = "Y" -o "$answer" = "y" ]; then if [ -z "$answer" ] || [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then
$(find_gmake) install $(find_gmake) install
else else
echo "Binary available at $BUILD/Cutter" echo "Binary available at $BUILD/Cutter"