From e90bc630fabb3e8c2e815250594204578931066a Mon Sep 17 00:00:00 2001 From: zapashcanon Date: Mon, 26 Jun 2017 19:52:39 +0200 Subject: [PATCH 1/2] Fix scripts --- .travis/script.sh | 3 +++ cmake/msys/msys_helper.sh | 46 ++++++++++++++------------------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/.travis/script.sh b/.travis/script.sh index c4219fe18ae..4367f942e9c 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -4,6 +4,9 @@ set -e if [ "$TYPE" = 'style' ]; then + # SC2185 is disabled because of: https://github.com/koalaman/shellcheck/issues/942 + # once it's fixed, it should be enabled again + # shellcheck disable=SC2185 # shellcheck disable=SC2046 shellcheck $(find -O3 "$TRAVIS_BUILD_DIR/.travis/" "$TRAVIS_BUILD_DIR/cmake/" -type f -name '*.sh' -o -name "*.sh.in") diff --git a/cmake/msys/msys_helper.sh b/cmake/msys/msys_helper.sh index 92b86825505..7037f526a26 100644 --- a/cmake/msys/msys_helper.sh +++ b/cmake/msys/msys_helper.sh @@ -15,8 +15,8 @@ function warn() { echo -e "\n${yellow}$1${plain}"; } function err() { echo -e "\n${red}$1${plain}"; exit 1;} info "Checking for mingw environment" -env |grep MINGW -if [ $? -ne 0 ]; then + +if ! env | grep MINGW; then err " - Failed. Please relaunch using MinGW shell" fi @@ -52,9 +52,8 @@ chmod u+w /mingw64/include/qt4 -R chmod u+w /mingw32/include/qt4 -R info "Merging mingw headers and libraries from ppa over existing system libraries..." -find /mingw64 |grep sndfile.h -if [ $? -ne 0 ]; then +if ! find /mingw64 | grep sndfile.h; then command cp -r "$HOME/ppa/opt/mingw"* / else warn " - Skipping, sndfile.h has already been merged" @@ -70,10 +69,8 @@ stkver="4.5.1" info "Downloading and building fltk $fltkver" mingw_root="/$(echo "$MSYSTEM"|tr '[:upper:]' '[:lower:]')" -which fluid -if [ $? -ne 0 ]; then - wget http://fltk.org/pub/fltk/$fltkver/fltk-$fltkver-source.tar.gz -O "$HOME/fltk-source.tar.gz" - if [ $? -ne 0 ]; then +if ! which fluid; then + if ! wget http://fltk.org/pub/fltk/$fltkver/fltk-$fltkver-source.tar.gz -O "$HOME/fltk-source.tar.gz"; then err "ERROR: Could not download fltk. Exiting." fi tar zxf "$HOME/fltk-source.tar.gz" -C "$HOME/" @@ -85,9 +82,8 @@ if [ $? -ne 0 ]; then make info " - Installing fltk..." - make install - if [ $? -ne 0 ]; then + if ! make install; then err "ERROR: Could not build/install fltk -- Zyn needs this. Exiting." fi @@ -100,8 +96,7 @@ fi info "Downloading and building libogg $oggver" if [ ! -e "$mingw_root/lib/libogg.dll.a" ]; then - wget http://downloads.xiph.org/releases/ogg/libogg-$oggver.tar.xz -O "$HOME/libogg-source.tar.xz" - if [ $? -ne 0 ]; then + if ! wget http://downloads.xiph.org/releases/ogg/libogg-$oggver.tar.xz -O "$HOME/libogg-source.tar.xz"; then err "ERROR: Could not download libogg. Exiting." fi tar xf "$HOME/libogg-source.tar.xz" -C "$HOME/" @@ -121,9 +116,8 @@ if [ ! -e "$mingw_root/lib/libogg.dll.a" ]; then make info " - Installing libogg..." - make install - if [ $? -ne 0 ]; then + if ! make install; then err "ERROR: Could not build/install fltk -- lmms needs this. Exiting." fi @@ -136,8 +130,7 @@ fi info "Downloading and building libvorbis $vorbisver" if [ ! -e "$mingw_root/lib/libvorbis.dll.a" ]; then - wget http://downloads.xiph.org/releases/vorbis/libvorbis-$vorbisver.tar.xz -O "$HOME/libvorbis-source.tar.xz" - if [ $? -ne 0 ]; then + if ! wget http://downloads.xiph.org/releases/vorbis/libvorbis-$vorbisver.tar.xz -O "$HOME/libvorbis-source.tar.xz"; then err "ERROR: Could not download libogg. Exiting." fi tar xf "$HOME/libvorbis-source.tar.xz" -C "$HOME/" @@ -157,9 +150,8 @@ if [ ! -e "$mingw_root/lib/libvorbis.dll.a" ]; then make info " - Installing libvorbis..." - make install - if [ $? -ne 0 ]; then + if ! make install; then err "ERROR: Could not build/install libvorbis -- lmms needs this. Exiting." fi @@ -171,8 +163,7 @@ fi info "Downloading and building flac $flacver" if [ ! -e "$mingw_root/lib/libFLAC.dll.a" ]; then - wget http://downloads.xiph.org/releases/flac/flac-$flacver.tar.xz -O "$HOME/flac-source.tar.xz" - if [ $? -ne 0 ]; then + if ! wget http://downloads.xiph.org/releases/flac/flac-$flacver.tar.xz -O "$HOME/flac-source.tar.xz"; then err "ERROR: Could not download flac. Exiting." fi tar xf "$HOME/flac-source.tar.xz" -C "$HOME/" @@ -192,9 +183,8 @@ if [ ! -e "$mingw_root/lib/libFLAC.dll.a" ]; then make info " - Installing flac..." - make install - if [ $? -ne 0 ]; then + if ! make install; then err "ERROR: Could not build/install flac -- lmms needs this. Exiting." fi @@ -206,8 +196,7 @@ fi info "Downloading and building libgig $gigver" if [ ! -e "$mingw_root/lib/libgig/libgig.dll.a" ]; then - wget http://download.linuxsampler.org/packages/libgig-$gigver.tar.bz2 -O "$HOME/gig-source.tar.xz" - if [ $? -ne 0 ]; then + if ! wget http://download.linuxsampler.org/packages/libgig-$gigver.tar.bz2 -O "$HOME/gig-source.tar.xz"; then err "ERROR: Could not download libgig. Exiting." fi tar xf "$HOME/gig-source.tar.xz" -C "$HOME/" @@ -222,9 +211,8 @@ if [ ! -e "$mingw_root/lib/libgig/libgig.dll.a" ]; then make install mv "$mingw_root/lib/bin/libakai-0.dll" "$mingw_root/bin" - mv "$mingw_root/lib/bin/libgig-7.dll" "$mingw_root/bin" - if [ $? -ne 0 ]; then + if ! mv "$mingw_root/lib/bin/libgig-7.dll" "$mingw_root/bin"; then err "ERROR: Could not build/install libgig -- gigplayer needs this. Exiting." fi @@ -236,8 +224,7 @@ fi info "Downloading and building stk $stkver" if [ ! -e "$mingw_root/lib/libstk.dll" ]; then - wget http://ccrma.stanford.edu/software/stk/release/stk-$stkver.tar.gz -O "$HOME/stk-source.tar.xz" - if [ $? -ne 0 ]; then + if ! wget http://ccrma.stanford.edu/software/stk/release/stk-$stkver.tar.gz -O "$HOME/stk-source.tar.xz"; then err "ERROR: Could not download stk. Exiting." fi tar xf "$HOME/stk-source.tar.xz" -C "$HOME/" @@ -249,9 +236,8 @@ if [ ! -e "$mingw_root/lib/libstk.dll" ]; then make info " - Installing stk..." - make install - if [ $? -ne 0 ]; then + if ! make install; then err "ERROR: Could not build/install stk -- mallotstk needs this. Exiting." fi From 060c012b1026a26d31bdb1fd48e6331db349bfa4 Mon Sep 17 00:00:00 2001 From: zapashcanon Date: Tue, 27 Jun 2017 17:42:27 +0200 Subject: [PATCH 2/2] Clean code --- cmake/msys/msys_helper.sh | 87 +++++++++------------------------------ 1 file changed, 20 insertions(+), 67 deletions(-) diff --git a/cmake/msys/msys_helper.sh b/cmake/msys/msys_helper.sh index 7037f526a26..af7fb67934f 100644 --- a/cmake/msys/msys_helper.sh +++ b/cmake/msys/msys_helper.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -eu + # Git repo information fork="lmms" # i.e. "lmms" or "tobydox" branch="master" # i.e. "master" or "stable-1.2" @@ -15,7 +17,6 @@ function warn() { echo -e "\n${yellow}$1${plain}"; } function err() { echo -e "\n${red}$1${plain}"; exit 1;} info "Checking for mingw environment" - if ! env | grep MINGW; then err " - Failed. Please relaunch using MinGW shell" fi @@ -31,20 +32,18 @@ else git clone -b $branch https://github.com/$fork/lmms.git fi - info "Fetching ppa using cmake/msys/fetch_ppas.sh..." if [ -d "$HOME/ppa" ]; then warn " - Skipping, $HOME/ppa already exists" else - ./lmms/cmake/msys/fetch_ppa.sh + lmms/cmake/msys/fetch_ppa.sh fi - info "Extracting debs to $HOME/ppa/opt/, etc..." if [ -d "$HOME/ppa/opt" ]; then warn " - Skipping, $HOME/ppa/opt already exists" else - ./lmms/cmake/msys/extract_debs.sh + lmms/cmake/msys/extract_debs.sh fi info "Preparing library merge, making all qt headers writable..." @@ -52,7 +51,6 @@ chmod u+w /mingw64/include/qt4 -R chmod u+w /mingw32/include/qt4 -R info "Merging mingw headers and libraries from ppa over existing system libraries..." - if ! find /mingw64 | grep sndfile.h; then command cp -r "$HOME/ppa/opt/mingw"* / else @@ -66,26 +64,20 @@ flacver="1.3.2" gigver="4.0.0" stkver="4.5.1" -info "Downloading and building fltk $fltkver" - mingw_root="/$(echo "$MSYSTEM"|tr '[:upper:]' '[:lower:]')" + +info "Downloading and building fltk $fltkver" if ! which fluid; then - if ! wget http://fltk.org/pub/fltk/$fltkver/fltk-$fltkver-source.tar.gz -O "$HOME/fltk-source.tar.gz"; then - err "ERROR: Could not download fltk. Exiting." - fi + wget http://fltk.org/pub/fltk/$fltkver/fltk-$fltkver-source.tar.gz -O "$HOME/fltk-source.tar.gz" tar zxf "$HOME/fltk-source.tar.gz" -C "$HOME/" pushd "$HOME/fltk-$fltkver" info " - Compiling fltk $fltkver..." ./configure --prefix="$mingw_root" --enable-shared - make info " - Installing fltk..." - - if ! make install; then - err "ERROR: Could not build/install fltk -- Zyn needs this. Exiting." - fi + make install # ln -s $mingw_root/usr/local/bin/fluid.exe $mingw_root/bin/fluid.exe popd @@ -94,51 +86,37 @@ else fi info "Downloading and building libogg $oggver" - if [ ! -e "$mingw_root/lib/libogg.dll.a" ]; then - if ! wget http://downloads.xiph.org/releases/ogg/libogg-$oggver.tar.xz -O "$HOME/libogg-source.tar.xz"; then - err "ERROR: Could not download libogg. Exiting." - fi + wget http://downloads.xiph.org/releases/ogg/libogg-$oggver.tar.xz -O "$HOME/libogg-source.tar.xz" tar xf "$HOME/libogg-source.tar.xz" -C "$HOME/" pushd "$HOME/libogg-$oggver" info " - Compiling libogg $oggver..." ./configure --prefix="$mingw_root" - make info " - Installing libogg..." make install - # for some reason libgig needs this ./configure --prefix="/opt$mingw_root" - make info " - Installing libogg..." - - if ! make install; then - err "ERROR: Could not build/install fltk -- lmms needs this. Exiting." - fi + make install popd else warn " - Skipping, libogg binary already exists" fi - info "Downloading and building libvorbis $vorbisver" - if [ ! -e "$mingw_root/lib/libvorbis.dll.a" ]; then - if ! wget http://downloads.xiph.org/releases/vorbis/libvorbis-$vorbisver.tar.xz -O "$HOME/libvorbis-source.tar.xz"; then - err "ERROR: Could not download libogg. Exiting." - fi + wget http://downloads.xiph.org/releases/vorbis/libvorbis-$vorbisver.tar.xz -O "$HOME/libvorbis-source.tar.xz" tar xf "$HOME/libvorbis-source.tar.xz" -C "$HOME/" pushd "$HOME/libvorbis-$vorbisver" info " - Compiling libvorbis $vorbisver..." ./configure --prefix="$mingw_root" - make info " - Installing libvorbis..." @@ -146,14 +124,9 @@ if [ ! -e "$mingw_root/lib/libvorbis.dll.a" ]; then # for some reason libgig needs this ./configure --prefix="/opt$mingw_root" - make - info " - Installing libvorbis..." - - if ! make install; then - err "ERROR: Could not build/install libvorbis -- lmms needs this. Exiting." - fi + make install popd else @@ -163,15 +136,13 @@ fi info "Downloading and building flac $flacver" if [ ! -e "$mingw_root/lib/libFLAC.dll.a" ]; then - if ! wget http://downloads.xiph.org/releases/flac/flac-$flacver.tar.xz -O "$HOME/flac-source.tar.xz"; then - err "ERROR: Could not download flac. Exiting." - fi + + wget http://downloads.xiph.org/releases/flac/flac-$flacver.tar.xz -O "$HOME/flac-source.tar.xz" tar xf "$HOME/flac-source.tar.xz" -C "$HOME/" pushd "$HOME/flac-$flacver" info " - Compiling flac $flacver..." ./configure --prefix="$mingw_root" - make info " - Installing flac..." @@ -179,14 +150,10 @@ if [ ! -e "$mingw_root/lib/libFLAC.dll.a" ]; then # for some reason libgig needs this ./configure --prefix="/opt$mingw_root" - make info " - Installing flac..." - - if ! make install; then - err "ERROR: Could not build/install flac -- lmms needs this. Exiting." - fi + make install popd else @@ -196,25 +163,19 @@ fi info "Downloading and building libgig $gigver" if [ ! -e "$mingw_root/lib/libgig/libgig.dll.a" ]; then - if ! wget http://download.linuxsampler.org/packages/libgig-$gigver.tar.bz2 -O "$HOME/gig-source.tar.xz"; then - err "ERROR: Could not download libgig. Exiting." - fi + wget http://download.linuxsampler.org/packages/libgig-$gigver.tar.bz2 -O "$HOME/gig-source.tar.xz" tar xf "$HOME/gig-source.tar.xz" -C "$HOME/" pushd "$HOME/libgig-$gigver" info " - Compiling libgig $gigver..." ./configure --prefix="$mingw_root" - make info " - Installing libgig..." make install mv "$mingw_root/lib/bin/libakai-0.dll" "$mingw_root/bin" - - if ! mv "$mingw_root/lib/bin/libgig-7.dll" "$mingw_root/bin"; then - err "ERROR: Could not build/install libgig -- gigplayer needs this. Exiting." - fi + mv "$mingw_root/lib/bin/libgig-7.dll" "$mingw_root/bin" popd else @@ -224,22 +185,16 @@ fi info "Downloading and building stk $stkver" if [ ! -e "$mingw_root/lib/libstk.dll" ]; then - if ! wget http://ccrma.stanford.edu/software/stk/release/stk-$stkver.tar.gz -O "$HOME/stk-source.tar.xz"; then - err "ERROR: Could not download stk. Exiting." - fi + wget http://ccrma.stanford.edu/software/stk/release/stk-$stkver.tar.gz -O "$HOME/stk-source.tar.xz" tar xf "$HOME/stk-source.tar.xz" -C "$HOME/" pushd "$HOME/stk-$stkver" info " - Compiling stk $stkver..." ./configure --prefix="$mingw_root" - make info " - Installing stk..." - - if ! make install; then - err "ERROR: Could not build/install stk -- mallotstk needs this. Exiting." - fi + make install mv "$mingw_root/lib/libstk.so" "$mingw_root/lib/libstk.dll" mv "$mingw_root/lib/libstk-$stkver.so" "$mingw_root/lib/libstk-$stkver.dll" @@ -254,9 +209,7 @@ if [ "$mingw_root" = "/mingw64" ]; then if [ ! -e /opt/mingw64/bin/x86_64-w64-mingw32-pkg-config ]; then ln -s /usr/bin/pkg-config /opt/mingw64/bin/x86_64-w64-mingw32-pkg-config fi -fi -if [ "$mingw_root" = "/mingw32" ]; then - +elif [ "$mingw_root" = "/mingw32" ]; then if [ ! -e /opt/mingw32/bin/i686-w64-mingw32-pkg-config ]; then ln -s /usr/bin/pkg-config /opt/mingw32/bin/i686-w64-mingw32-pkg-config fi