1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

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

Also remove unnecessary `function`, since it's equal to `()`.
This commit is contained in:
Zetok Zalbavar 2016-09-27 03:15:52 +01:00
parent 610e21169a
commit 0fecb55024
No known key found for this signature in database
GPG Key ID: C953D3880212068A

View File

@ -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 ..." #fcho "Installing x-code Command line tools ..."
#xcode-select --install #xcode-select --install
if [[ -e /usr/local/bin/brew ]]; then if [[ -e /usr/local/bin/brew ]]
fcho "Homebrew already installed!" then
else fcho "Homebrew already installed!"
fcho "Installing homebrew ..." else
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" fcho "Installing homebrew ..."
fi ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
if [[ $TRAVIS != true ]]; then fi
fcho "Updating brew formulas ..." if [[ $TRAVIS != true ]]
brew update then
fi fcho "Updating brew formulas ..."
fcho "Getting home brew formulas ..." brew update
if [[ $TRAVIS != true ]]; then #travis check fi
sleep 3 fcho "Getting home brew formulas ..."
brew install git wget libtool autoconf automake if [[ $TRAVIS != true ]]
fi then
brew install check libvpx opus libsodium sleep 3
brew install git wget libtool autoconf automake
fi
brew install check libvpx opus libsodium
fcho "Starting git repo checks ..." fcho "Starting git repo checks ..."
#cd $MAIN_DIR # just in case #cd $MAIN_DIR # just in case
# Toxcore # Toxcore
if [[ -e $TOX_DIR/.git/index ]]; then # Check if this exists if [[ -e $TOX_DIR/.git/index ]]
fcho "Toxcore git repo already in place !" then
cd $TOX_DIR fcho "Toxcore git repo already in place !"
git pull cd $TOX_DIR
else git pull
fcho "Cloning Toxcore git ... " else
git clone --depth=1 https://github.com/irungentoo/toxcore fcho "Cloning Toxcore git ... "
fi git clone --depth=1 https://github.com/irungentoo/toxcore
# qTox fi
if [[ $TRAVIS = true ]]; then #travis check # qTox
fcho "Travis... You already have qTox..." if [[ $TRAVIS = true ]]
else then
if [[ -e $QTOX_DIR/.git/index ]]; then # Check if this exists fcho "Travis... You already have qTox..."
fcho "qTox git repo already in place !" else
cd $QTOX_DIR if [[ -e $QTOX_DIR/.git/index ]]
git pull then
else fcho "qTox git repo already in place !"
fcho "Cloning qTox git ... " cd $QTOX_DIR
git clone https://github.com/qTox/qTox.git git pull
fi else
fi fcho "Cloning qTox git ... "
git clone https://github.com/qTox/qTox.git
fi
fi
# toxcore build # toxcore build
if [[ $TRAVIS = true ]]; then #travis check if [[ $TRAVIS = true ]]
build_toxcore then
else build_toxcore
fcho "If all went well you should now have all the tools needed to compile qTox!" else
read -r -p "Would you like to install toxcore now? [y/N] " response fcho "If all went well you should now have all the tools needed to compile qTox!"
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then read -r -p "Would you like to install toxcore now? [y/N] " response
build_toxcore if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
else then
fcho "You can simply use the -u command and say [Yes/n] when prompted" build_toxcore
fi else
fi fcho "You can simply use the -u command and say [Yes/n] when prompted"
fi
fi
if [[ $TRAVIS = true ]]; then if [[ $TRAVIS = true ]]
fcho "Updating brew formulas ..." then
brew update > /dev/null fcho "Updating brew formulas ..."
fi brew update > /dev/null
brew install ffmpeg qrencode qt5 sqlcipher 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_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]}" QT_DIR_VER="${QT_DIR}/${QT_VER[1]}"
# put required by qTox libs/headers in `libs/` # put required by qTox libs/headers in `libs/`
cd "${QTOX_DIR}" cd "${QTOX_DIR}"
sudo ./bootstrap-osx.sh 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! #Now let's update qTox!
cd $QTOX_DIR cd $QTOX_DIR
fcho "Now in ${PWD}" fcho "Now in ${PWD}"
fcho "Pulling ..." fcho "Pulling ..."
git pull git pull
read -r -p "Did qTox update from git? [y/N] " response read -r -p "Did qTox update from git? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
fcho "Starting OSX bootstrap ..." then
sudo ./bootstrap-osx.sh fcho "Starting OSX bootstrap ..."
else sudo ./bootstrap-osx.sh
fcho "Moving on!" else
fi 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!"