[Android] compile.sh: refactor checkfail
Simon Latapie
git at videolan.org
Tue Aug 27 13:01:46 CEST 2019
vlc-android | branch: 3.2.x | Simon Latapie <garf at videolan.org> | Fri Jul 26 17:56:39 2019 +0200| [5b1edaad12fe455096f9b775d50bf45d935bb3bc] | committer: Nicolas Pomepuy
compile.sh: refactor checkfail
checkfail function cannot work with `set -e` at the beginning of the
script: every command that will return != 0 will stop the script.
This commit replaces checkfail with a || fail "..." function (to keep
error explanations)
(cherry picked from commit 9a7eeebabd25a411ddf4fc34ed09f8da40af9a9f)
> https://code.videolan.org/videolan/vlc-android/commit/5b1edaad12fe455096f9b775d50bf45d935bb3bc
---
compile.sh | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/compile.sh b/compile.sh
index 2eaa4e0cb..4f88ce59a 100755
--- a/compile.sh
+++ b/compile.sh
@@ -10,12 +10,10 @@ diagnostic()
echo "$@" 1>&2;
}
-checkfail()
+fail()
{
- if [ ! $? -eq 0 ];then
- diagnostic "$1"
- exit 1
- fi
+ diagnostic "$1"
+ exit 1
}
# Try to check whether a patch file has already been applied to the current directory tree
@@ -248,17 +246,13 @@ if [ ! -d "gradle/wrapper" ]; then
diagnostic "Downloading gradle"
GRADLE_VERSION=5.1.1
GRADLE_URL=https://download.videolan.org/pub/contrib/gradle/gradle-${GRADLE_VERSION}-bin.zip
- wget ${GRADLE_URL} 2>/dev/null || curl -O ${GRADLE_URL}
- checkfail "gradle: download failed"
+ wget ${GRADLE_URL} 2>/dev/null || curl -O ${GRADLE_URL} || fail "gradle: download failed"
- unzip -o gradle-${GRADLE_VERSION}-bin.zip
- checkfail "gradle: unzip failed"
+ unzip -o gradle-${GRADLE_VERSION}-bin.zip || fail "gradle: unzip failed"
- ./gradle-${GRADLE_VERSION}/bin/gradle wrapper
- checkfail "gradle: wrapper failed"
+ ./gradle-${GRADLE_VERSION}/bin/gradle wrapper || fail "gradle: wrapper failed"
- ./gradlew -version
- checkfail "gradle: wrapper failed"
+ ./gradlew -version || fail "gradle: wrapper failed"
chmod a+x gradlew
rm -rf gradle-${GRADLE_VERSION}-bin.zip
fi
@@ -274,16 +268,13 @@ TESTED_HASH=f3047d4
VLC_REPOSITORY=https://git.videolan.org/git/vlc/vlc-3.0.git
if [ ! -d "vlc" ]; then
diagnostic "VLC sources: not found, cloning"
- git clone "${VLC_REPOSITORY}" vlc
- checkfail "VLC sources: git clone failed"
+ git clone "${VLC_REPOSITORY}" vlc || fail "VLC sources: git clone failed"
cd vlc
diagnostic "VLC sources: resetting to the TESTED_HASH commit (${TESTED_HASH})"
- git reset --hard ${TESTED_HASH}
- checkfail "VLC sources: TESTED_HASH ${TESTED_HASH} not found"
+ git reset --hard ${TESTED_HASH} || fail "VLC sources: TESTED_HASH ${TESTED_HASH} not found"
diagnostic "VLC sources: applying custom patches"
# Keep Message-Id inside commits description to track them afterwards
- git am --message-id ../libvlc/patches/vlc3/*.patch
- checkfail "VLC sources: cannot apply custom patches"
+ git am --message-id ../libvlc/patches/vlc3/*.patch || fail "VLC sources: cannot apply custom patches"
cd ..
else
diagnostic "VLC source: found sources, leaving untouched"
@@ -294,8 +285,8 @@ else
diagnostic "VLC sources: Checking TESTED_HASH and patches presence"
diagnostic "NOTE: checks can be bypass by adding '-b' option to this script."
cd vlc
- git cat-file -e ${TESTED_HASH} 2> /dev/null
- checkfail "Error: Your vlc checkout does not contain the latest tested commit: ${TESTED_HASH}"
+ git cat-file -e ${TESTED_HASH} 2> /dev/null || \
+ fail "Error: Your vlc checkout does not contain the latest tested commit: ${TESTED_HASH}"
for patch_file in ../libvlc/patches/vlc3/*.patch; do
check_patch_is_applied "$patch_file"
done
More information about the Android
mailing list