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