Browse Source

style(OSX build): change tabs to spaces and adjust style to existing one

Also remove unnecessary `function`, since it's equal to `()`.
pull/3749/head
Zetok Zalbavar 9 years ago
parent
commit
0fecb55024
No known key found for this signature in database
GPG Key ID: C953D3880212068A
  1. 461
      osx/qTox-Mac-Deployer-ULTIMATE.sh

461
osx/qTox-Mac-Deployer-ULTIMATE.sh

@ -25,14 +25,15 @@ set -e
# Your home DIR really (Most of this happens in it) {DONT USE: ~ } # Your home DIR really (Most of this happens in it) {DONT USE: ~ }
SUBGIT="" #Change this to define a 'sub' git folder e.g. "-Patch" SUBGIT="" #Change this to define a 'sub' git folder e.g. "-Patch"
#Applys to $QTOX_DIR, $BUILD_DIR, and $DEPLOY_DIR folders for organization puropses #Applies to $QTOX_DIR, $BUILD_DIR, and $DEPLOY_DIR folders for organization puropses
if [[ $TRAVIS = true ]]; then #travis check if [[ $TRAVIS = true ]]
MAIN_DIR="${TRAVIS_BUILD_DIR}" then
QTOX_DIR="${MAIN_DIR}" MAIN_DIR="${TRAVIS_BUILD_DIR}"
QTOX_DIR="${MAIN_DIR}"
else else
MAIN_DIR="/Users/${USER}" MAIN_DIR="/Users/${USER}"
QTOX_DIR="${MAIN_DIR}/qTox${SUBGIT}" QTOX_DIR="${MAIN_DIR}/qTox${SUBGIT}"
fi fi
QT_DIR="/usr/local/Cellar/qt5" # Folder name of QT install QT_DIR="/usr/local/Cellar/qt5" # Folder name of QT install
# Figure out latest version # Figure out latest version
@ -46,255 +47,267 @@ TOXCORE_DIR="${MAIN_DIR}/toxcore" # Change to Git location
LIB_INSTALL_PREFIX="${QTOX_DIR}/libs" LIB_INSTALL_PREFIX="${QTOX_DIR}/libs"
if [[ ! -e "${LIB_INSTALL_PREFIX}" ]]; then [[ ! -e "${LIB_INSTALL_PREFIX}" ]] \
mkdir -p "${LIB_INSTALL_PREFIX}" && mkdir -p "${LIB_INSTALL_PREFIX}"
fi
BUILD_DIR="${MAIN_DIR}/qTox-Mac_Build${SUBGIT}" BUILD_DIR="${MAIN_DIR}/qTox-Mac_Build${SUBGIT}"
DEPLOY_DIR="${MAIN_DIR}/qTox-Mac_Deployed${SUBGIT}" DEPLOY_DIR="${MAIN_DIR}/qTox-Mac_Deployed${SUBGIT}"
function fcho() { # helper function to "pretty-print"
local msg="$1"; shift fcho() {
printf "\n$msg\n" "$@" local msg="$1"; shift
printf "\n$msg\n" "$@"
} }
function build_toxcore() { build_toxcore() {
echo "Starting Toxcore build and install" echo "Starting Toxcore build and install"
cd $TOXCORE_DIR cd $TOXCORE_DIR
echo "Now working in: ${PWD}" echo "Now working in: ${PWD}"
local LS_DIR="/usr/local/Cellar/libsodium/" local LS_DIR="/usr/local/Cellar/libsodium/"
#Figure out latest version #Figure out latest version
local LS_VER=($(ls ${LS_DIR} | sed -n -e 's/^\([0-9]*\.([0-9]*\.([0-9]*\).*/\1/' -e '1p;$p')) local LS_VER=($(ls ${LS_DIR} | sed -n -e 's/^\([0-9]*\.([0-9]*\.([0-9]*\).*/\1/' -e '1p;$p'))
local LS_DIR_VER="${LS_DIR}/${LS_VER[1]}" local LS_DIR_VER="${LS_DIR}/${LS_VER[1]}"
if [[ $TRAVIS != true ]]; then [[ $TRAVIS != true ]] \
sleep 3 && sleep 3
fi
autoreconf -if autoreconf -if
#Make sure the correct version of libsodium is used #Make sure the correct version of libsodium is used
./configure --with-libsodium-headers="${LS_DIR_VER}/include/" --with-libsodium-libs="${LS_DIR_VER}/lib/" --prefix="${LIB_INSTALL_PREFIX}" ./configure --with-libsodium-headers="${LS_DIR_VER}/include/" --with-libsodium-libs="${LS_DIR_VER}/lib/" --prefix="${LIB_INSTALL_PREFIX}"
make clean &> /dev/null make clean &> /dev/null
fcho "Compiling toxcore." fcho "Compiling toxcore."
make > /dev/null || exit 1 make > /dev/null || exit 1
fcho "Installing toxcore." fcho "Installing toxcore."
make install > /dev/null || exit 1 make install > /dev/null || exit 1
} }
function install() { install() {
fcho "==============================" fcho "=============================="
fcho "This script will install the necessary applications and libraries needed to compile qTox properly." fcho "This script will install the necessary applications and libraries needed to compile qTox properly."
fcho "Note that this is not a 100 percent automated install it just helps simplify the process for less experienced or lazy users." fcho "Note that this is not a 100 percent automated install it just helps simplify the process for less experienced or lazy users."
if [[ $TRAVIS = true ]]; then #travis check if [[ $TRAVIS = true ]]
echo "Oh... It's just Travis...." then
else echo "Oh... It's just Travis...."
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n' else
fi read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'
fi
#fcho "Installing x-code Command line tools ..."
#xcode-select --install #fcho "Installing x-code Command line tools ..."
#xcode-select --install
if [[ -e /usr/local/bin/brew ]]; then
fcho "Homebrew already installed!" if [[ -e /usr/local/bin/brew ]]
else then
fcho "Installing homebrew ..." fcho "Homebrew already installed!"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" else
fi fcho "Installing homebrew ..."
if [[ $TRAVIS != true ]]; then ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fcho "Updating brew formulas ..." fi
brew update if [[ $TRAVIS != true ]]
fi then
fcho "Getting home brew formulas ..." fcho "Updating brew formulas ..."
if [[ $TRAVIS != true ]]; then #travis check brew update
sleep 3 fi
brew install git wget libtool autoconf automake fcho "Getting home brew formulas ..."
fi if [[ $TRAVIS != true ]]
brew install check libvpx opus libsodium then
sleep 3
fcho "Starting git repo checks ..." brew install git wget libtool autoconf automake
fi
#cd $MAIN_DIR # just in case brew install check libvpx opus libsodium
# Toxcore
if [[ -e $TOX_DIR/.git/index ]]; then # Check if this exists fcho "Starting git repo checks ..."
fcho "Toxcore git repo already in place !"
cd $TOX_DIR #cd $MAIN_DIR # just in case
git pull # Toxcore
else if [[ -e $TOX_DIR/.git/index ]]
fcho "Cloning Toxcore git ... " then
git clone --depth=1 https://github.com/irungentoo/toxcore fcho "Toxcore git repo already in place !"
fi cd $TOX_DIR
# qTox git pull
if [[ $TRAVIS = true ]]; then #travis check else
fcho "Travis... You already have qTox..." fcho "Cloning Toxcore git ... "
else git clone --depth=1 https://github.com/irungentoo/toxcore
if [[ -e $QTOX_DIR/.git/index ]]; then # Check if this exists fi
fcho "qTox git repo already in place !" # qTox
cd $QTOX_DIR if [[ $TRAVIS = true ]]
git pull then
else fcho "Travis... You already have qTox..."
fcho "Cloning qTox git ... " else
git clone https://github.com/qTox/qTox.git if [[ -e $QTOX_DIR/.git/index ]]
fi then
fi fcho "qTox git repo already in place !"
cd $QTOX_DIR
# toxcore build git pull
if [[ $TRAVIS = true ]]; then #travis check else
build_toxcore fcho "Cloning qTox git ... "
else git clone https://github.com/qTox/qTox.git
fcho "If all went well you should now have all the tools needed to compile qTox!" fi
read -r -p "Would you like to install toxcore now? [y/N] " response fi
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
build_toxcore # toxcore build
else if [[ $TRAVIS = true ]]
fcho "You can simply use the -u command and say [Yes/n] when prompted" then
fi build_toxcore
fi else
fcho "If all went well you should now have all the tools needed to compile qTox!"
if [[ $TRAVIS = true ]]; then read -r -p "Would you like to install toxcore now? [y/N] " response
fcho "Updating brew formulas ..." if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
brew update > /dev/null then
fi build_toxcore
brew install ffmpeg qrencode qt5 sqlcipher else
fcho "You can simply use the -u command and say [Yes/n] when prompted"
QT_VER=($(ls ${QT_DIR} | sed -n -e 's/^\([0-9]*\.([0-9]*\.([0-9]*\).*/\1/' -e '1p;$p')) fi
QT_DIR_VER="${QT_DIR}/${QT_VER[1]}" fi
# put required by qTox libs/headers in `libs/` if [[ $TRAVIS = true ]]
cd "${QTOX_DIR}" then
sudo ./bootstrap-osx.sh fcho "Updating brew formulas ..."
brew update > /dev/null
fi
brew install ffmpeg qrencode qt5 sqlcipher
QT_VER=($(ls ${QT_DIR} | sed -n -e 's/^\([0-9]*\.([0-9]*\.([0-9]*\).*/\1/' -e '1p;$p'))
QT_DIR_VER="${QT_DIR}/${QT_VER[1]}"
# put required by qTox libs/headers in `libs/`
cd "${QTOX_DIR}"
sudo ./bootstrap-osx.sh
} }
function update() { update() {
fcho "------------------------------" fcho "------------------------------"
fcho "Starting update process ..." fcho "Starting update process ..."
#First update Toxcore from git #First update Toxcore from git
cd $TOXCORE_DIR cd $TOXCORE_DIR
fcho "Now in ${PWD}" fcho "Now in ${PWD}"
fcho "Pulling ..." fcho "Pulling ..."
git pull git pull
read -r -p "Did Toxcore update from git? [y/N] " response read -r -p "Did Toxcore update from git? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
build_toxcore then
else build_toxcore
fcho "Moving on!" else
fi fcho "Moving on!"
fi
#Now let's update qTox!
cd $QTOX_DIR #Now let's update qTox!
fcho "Now in ${PWD}" cd $QTOX_DIR
fcho "Pulling ..." fcho "Now in ${PWD}"
git pull fcho "Pulling ..."
read -r -p "Did qTox update from git? [y/N] " response git pull
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then read -r -p "Did qTox update from git? [y/N] " response
fcho "Starting OSX bootstrap ..." if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
sudo ./bootstrap-osx.sh then
else fcho "Starting OSX bootstrap ..."
fcho "Moving on!" sudo ./bootstrap-osx.sh
fi else
fcho "Moving on!"
fi
} }
function build() { build() {
fcho "------------------------------" fcho "------------------------------"
fcho "Starting build process ..." fcho "Starting build process ..."
rm -rf $BUILD_DIR rm -rf $BUILD_DIR
rm -rf $DEPLOY_DIR rm -rf $DEPLOY_DIR
mkdir $BUILD_DIR mkdir $BUILD_DIR
cd $BUILD_DIR cd $BUILD_DIR
fcho "Now working in ${PWD}" fcho "Now working in ${PWD}"
fcho "Starting qmake ... " fcho "Starting qmake ... "
$QMAKE $QTOX_DIR/qtox.pro $QMAKE $QTOX_DIR/qtox.pro
make make
} }
function deploy() { deploy() {
fcho "------------------------------" fcho "------------------------------"
fcho "starting deployment process ..." fcho "starting deployment process ..."
cd $BUILD_DIR cd $BUILD_DIR
if [ ! -d $BUILD_DIR ]; then if [ ! -d $BUILD_DIR ]
fcho "Error: Build directory not detected, please run -ubd, or -b before deploying" then
exit 0 fcho "Error: Build directory not detected, please run -ubd, or -b before deploying"
fi exit 0
mkdir $DEPLOY_DIR fi
cp -r $BUILD_DIR/qTox.app $DEPLOY_DIR/qTox.app mkdir $DEPLOY_DIR
cd $DEPLOY_DIR cp -r $BUILD_DIR/qTox.app $DEPLOY_DIR/qTox.app
fcho "Now working in ${PWD}" cd $DEPLOY_DIR
$MACDEPLOYQT qTox.app fcho "Now working in ${PWD}"
$MACDEPLOYQT qTox.app
} }
function bootstrap() { bootstrap() {
fcho "------------------------------" fcho "------------------------------"
fcho "starting bootstrap process ..." fcho "starting bootstrap process ..."
#Toxcore #Toxcore
build_toxcore build_toxcore
#Boot Strap #Boot Strap
fcho "Running: sudo ${QTOX_DIR_VER}/bootstrap-osx.sh" fcho "Running: sudo ${QTOX_DIR_VER}/bootstrap-osx.sh"
cd $QTOX_DIR cd $QTOX_DIR
sudo ./bootstrap-osx.sh sudo ./bootstrap-osx.sh
} }
function dmgmake() { dmgmake() {
fcho "------------------------------" fcho "------------------------------"
fcho "Starting DMG creation" fcho "Starting DMG creation"
cd $DEPLOY_DIR cd $DEPLOY_DIR
ln -s /Applications "./Install to Applications" ln -s /Applications "./Install to Applications"
cp -r -f $QTOX_DIR/osx/background-DMG ./.background cp -r -f $QTOX_DIR/osx/background-DMG ./.background
cp -f $QTOX_DIR/osx/DS_Store-DMG ./.DS_Store cp -f $QTOX_DIR/osx/DS_Store-DMG ./.DS_Store
cp -f $QTOX_DIR/LICENSE ./LICENSE cp -f $QTOX_DIR/LICENSE ./LICENSE
cp -f $QTOX_DIR/README.md ./README.md cp -f $QTOX_DIR/README.md ./README.md
cd $QTOX_DIR cd $QTOX_DIR
hdiutil create -volname qTox${SUBGIT} -srcfolder $DEPLOY_DIR -format UDZO qTox${SUBGIT}.dmg hdiutil create -volname qTox${SUBGIT} -srcfolder $DEPLOY_DIR -format UDZO qTox${SUBGIT}.dmg
} }
function helpme() { helpme() {
echo "This script was created to help ease the process of compiling and creating a distributable qTox package for OSX systems." echo "This script was created to help ease the process of compiling and creating a distributable qTox package for OSX systems."
echo "The available commands are:" echo "The available commands are:"
echo "-h | --help -- This help text." echo "-h | --help -- This help text."
echo "-i | --instal -- A slightly automated process for getting an OSX machine ready to build Toxcore and qTox." echo "-i | --instal -- A slightly automated process for getting an OSX machine ready to build Toxcore and qTox."
echo "-u | --update -- Check for updates and build Toxcore from git & update qTox from git." echo "-u | --update -- Check for updates and build Toxcore from git & update qTox from git."
echo "-b | --build -- Builds qTox in: ${BUILD_DIR}" echo "-b | --build -- Builds qTox in: ${BUILD_DIR}"
echo "-d | --deploy -- Makes a distributable qTox.app file in: ${DEPLOY_DIR}" echo "-d | --deploy -- Makes a distributable qTox.app file in: ${DEPLOY_DIR}"
echo "-bs | --bootstrap -- Performs bootstrap steps." echo "-bs | --bootstrap -- Performs bootstrap steps."
fcho "Issues with Toxcore or qTox should be reported to their respective repos: https://github.com/irungentoo/toxcore | https://github.com/qTox/qTox" fcho "Issues with Toxcore or qTox should be reported to their respective repos: https://github.com/irungentoo/toxcore | https://github.com/qTox/qTox"
exit 0 exit 0
} }
case "$1" in case "$1" in
-h | --help) -h | --help)
helpme helpme
exit exit
;; ;;
-i | --install) -i | --install)
install install
exit exit
;; ;;
-u | --update) -u | --update)
update update
exit exit
;; ;;
-b | --build) -b | --build)
build build
exit exit
;; ;;
-d | --deploy) -d | --deploy)
deploy deploy
exit exit
;; ;;
-bs | --bootstrap) -bs | --bootstrap)
bootstrap bootstrap
exit exit
;; ;;
-dmg) -dmg)
dmgmake dmgmake
exit exit
;; ;;
*) *)
;; ;;
esac esac
fcho "Oh dear! You seemed to of started this script improperly! Use -h to get available commands and information!" fcho "Oh dear! You seemed to of started this script improperly! Use -h to get available commands and information!"

Loading…
Cancel
Save