2016-01-26 19:52:15 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-01-26 19:55:28 +08:00
|
|
|
#
|
|
|
|
# Copyright © 2015 by RowenStipe
|
|
|
|
# Copyright © 2016 by The qTox Project
|
|
|
|
#
|
|
|
|
# This program is libre software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-01-26 19:52:15 +08:00
|
|
|
# This uses the same process as doing it manually but with a few varients
|
|
|
|
|
2016-01-26 19:55:28 +08:00
|
|
|
# Use: ./qTox-Mac-Deployer-ULTIMATE.sh -h
|
2016-01-26 19:52:15 +08:00
|
|
|
|
2016-07-30 01:57:42 +08:00
|
|
|
set -e
|
|
|
|
|
2016-01-26 19:52:15 +08:00
|
|
|
# Your home DIR really (Most of this happens in it) {DONT USE: ~ }
|
2016-05-29 07:21:53 +08:00
|
|
|
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
|
|
|
|
|
2016-01-26 19:52:15 +08:00
|
|
|
if [[ $TRAVIS = true ]]; then #travis check
|
2016-01-26 15:46:35 +08:00
|
|
|
MAIN_DIR="${TRAVIS_BUILD_DIR}"
|
2016-02-19 03:28:46 +08:00
|
|
|
QTOX_DIR="${MAIN_DIR}"
|
2016-01-26 19:52:15 +08:00
|
|
|
else
|
|
|
|
MAIN_DIR="/Users/${USER}"
|
2016-05-29 07:21:53 +08:00
|
|
|
QTOX_DIR="${MAIN_DIR}/qTox${SUBGIT}"
|
2016-01-26 19:52:15 +08:00
|
|
|
fi
|
|
|
|
QT_DIR="/usr/local/Cellar/qt5" # Folder name of QT install
|
2016-03-23 01:52:38 +08:00
|
|
|
# Figure out latest version
|
|
|
|
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]}"
|
|
|
|
|
|
|
|
QMAKE="${QT_DIR_VER}/bin/qmake" # Don't change
|
|
|
|
MACDEPLOYQT="${QT_DIR_VER}/bin/macdeployqt" # Don't change
|
2016-01-26 19:52:15 +08:00
|
|
|
|
|
|
|
TOXCORE_DIR="${MAIN_DIR}/toxcore" # Change to Git location
|
|
|
|
|
2016-01-27 00:49:10 +08:00
|
|
|
LIB_INSTALL_PREFIX="${QTOX_DIR}/libs"
|
2016-01-26 19:52:15 +08:00
|
|
|
|
2016-01-27 09:22:04 +08:00
|
|
|
if [[ ! -e "${LIB_INSTALL_PREFIX}" ]]; then
|
|
|
|
mkdir -p "${LIB_INSTALL_PREFIX}"
|
|
|
|
fi
|
|
|
|
|
2016-05-29 07:21:53 +08:00
|
|
|
BUILD_DIR="${MAIN_DIR}/qTox-Mac_Build${SUBGIT}"
|
|
|
|
DEPLOY_DIR="${MAIN_DIR}/qTox-Mac_Deployed${SUBGIT}"
|
2016-01-26 19:52:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
function fcho() {
|
|
|
|
local msg="$1"; shift
|
|
|
|
printf "\n$msg\n" "$@"
|
|
|
|
}
|
|
|
|
|
2016-02-01 00:25:38 +08:00
|
|
|
function build_toxcore() {
|
2016-01-26 19:52:15 +08:00
|
|
|
echo "Starting Toxcore build and install"
|
|
|
|
cd $TOXCORE_DIR
|
|
|
|
echo "Now working in: ${PWD}"
|
2016-07-30 01:57:42 +08:00
|
|
|
|
2016-03-23 01:52:38 +08:00
|
|
|
local LS_DIR="/usr/local/Cellar/libsodium/"
|
|
|
|
#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_DIR_VER="${LS_DIR}/${LS_VER[1]}"
|
2016-07-30 01:57:42 +08:00
|
|
|
|
|
|
|
if [[ $TRAVIS != true ]]; then
|
|
|
|
sleep 3
|
|
|
|
fi
|
|
|
|
|
2016-01-27 09:22:04 +08:00
|
|
|
autoreconf -if
|
2016-07-30 01:57:42 +08:00
|
|
|
|
2016-01-26 19:52:15 +08:00
|
|
|
#Make sure the correct version of libsodium is used
|
2016-03-23 01:52:38 +08:00
|
|
|
./configure --with-libsodium-headers="${LS_DIR_VER}/include/" --with-libsodium-libs="${LS_DIR_VER}/lib/" --prefix="${LIB_INSTALL_PREFIX}"
|
2016-07-30 01:57:42 +08:00
|
|
|
|
2016-01-27 09:22:04 +08:00
|
|
|
make clean &> /dev/null
|
|
|
|
fcho "Compiling toxcore."
|
|
|
|
make > /dev/null || exit 1
|
|
|
|
fcho "Installing toxcore."
|
2016-02-25 14:48:36 +08:00
|
|
|
make install > /dev/null || exit 1
|
2016-01-26 19:52:15 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 20:28:07 +08:00
|
|
|
function install() {
|
2016-01-26 19:52:15 +08:00
|
|
|
fcho "=============================="
|
2016-02-01 00:25:38 +08:00
|
|
|
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."
|
2016-01-26 19:52:15 +08:00
|
|
|
if [[ $TRAVIS = true ]]; then #travis check
|
|
|
|
echo "Oh... It's just Travis...."
|
|
|
|
else
|
2016-07-30 01:57:42 +08:00
|
|
|
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'
|
2016-01-26 19:52:15 +08:00
|
|
|
fi
|
2016-07-30 01:57:42 +08:00
|
|
|
|
|
|
|
#fcho "Installing x-code Command line tools ..."
|
|
|
|
#xcode-select --install
|
|
|
|
|
2016-01-26 23:48:21 +08:00
|
|
|
if [[ -e /usr/local/bin/brew ]]; then
|
2016-01-26 19:52:15 +08:00
|
|
|
fcho "Homebrew already installed!"
|
|
|
|
else
|
|
|
|
fcho "Installing homebrew ..."
|
|
|
|
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
|
|
fi
|
2016-07-30 01:57:42 +08:00
|
|
|
if [[ $TRAVIS != true ]]; then
|
|
|
|
fcho "Updating brew formulas ..."
|
2016-03-23 01:52:38 +08:00
|
|
|
brew update
|
|
|
|
fi
|
2016-01-26 19:52:15 +08:00
|
|
|
fcho "Getting home brew formulas ..."
|
2016-01-27 01:36:03 +08:00
|
|
|
if [[ $TRAVIS != true ]]; then #travis check
|
2016-07-30 01:57:42 +08:00
|
|
|
sleep 3
|
|
|
|
brew install git wget libtool autoconf automake
|
2016-01-27 01:36:03 +08:00
|
|
|
fi
|
2016-07-30 01:57:42 +08:00
|
|
|
brew install check libvpx opus libsodium
|
|
|
|
|
2016-01-26 19:52:15 +08:00
|
|
|
fcho "Starting git repo checks ..."
|
2016-07-30 01:57:42 +08:00
|
|
|
|
|
|
|
#cd $MAIN_DIR # just in case
|
2016-02-01 00:25:38 +08:00
|
|
|
# Toxcore
|
2016-01-26 23:48:21 +08:00
|
|
|
if [[ -e $TOX_DIR/.git/index ]]; then # Check if this exists
|
2016-02-01 00:25:38 +08:00
|
|
|
fcho "Toxcore git repo already in place !"
|
2016-01-26 19:52:15 +08:00
|
|
|
cd $TOX_DIR
|
|
|
|
git pull
|
|
|
|
else
|
|
|
|
fcho "Cloning Toxcore git ... "
|
2016-07-30 01:57:42 +08:00
|
|
|
git clone --depth=1 https://github.com/irungentoo/toxcore
|
2016-01-26 19:52:15 +08:00
|
|
|
fi
|
2016-02-01 00:25:38 +08:00
|
|
|
# qTox
|
2016-02-01 01:16:19 +08:00
|
|
|
if [[ $TRAVIS = true ]]; then #travis check
|
|
|
|
fcho "Travis... You already have qTox..."
|
2016-01-26 19:52:15 +08:00
|
|
|
else
|
2016-02-01 01:16:19 +08:00
|
|
|
if [[ -e $QTOX_DIR/.git/index ]]; then # Check if this exists
|
|
|
|
fcho "qTox git repo already in place !"
|
|
|
|
cd $QTOX_DIR
|
|
|
|
git pull
|
|
|
|
else
|
|
|
|
fcho "Cloning qTox git ... "
|
|
|
|
git clone https://github.com/tux3/qTox.git
|
|
|
|
fi
|
2016-01-26 19:52:15 +08:00
|
|
|
fi
|
2016-07-30 01:57:42 +08:00
|
|
|
|
2016-02-01 00:25:38 +08:00
|
|
|
# toxcore build
|
2016-01-26 19:52:15 +08:00
|
|
|
if [[ $TRAVIS = true ]]; then #travis check
|
2016-02-01 00:25:38 +08:00
|
|
|
build_toxcore
|
2016-01-26 19:52:15 +08:00
|
|
|
else
|
|
|
|
fcho "If all went well you should now have all the tools needed to compile qTox!"
|
|
|
|
read -r -p "Would you like to install toxcore now? [y/N] " response
|
|
|
|
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
|
2016-01-26 23:48:21 +08:00
|
|
|
build_toxcore
|
2016-01-26 19:52:15 +08:00
|
|
|
else
|
2016-07-30 01:57:42 +08:00
|
|
|
fcho "You can simply use the -u command and say [Yes/n] when prompted"
|
2016-01-26 19:52:15 +08:00
|
|
|
fi
|
|
|
|
fi
|
2016-07-30 01:57:42 +08:00
|
|
|
|
|
|
|
if [[ $TRAVIS = true ]]; then
|
|
|
|
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]}"
|
|
|
|
|
2016-01-27 09:22:04 +08:00
|
|
|
# put required by qTox libs/headers in `libs/`
|
|
|
|
cd "${QTOX_DIR}"
|
2016-02-01 00:25:38 +08:00
|
|
|
sudo ./bootstrap-osx.sh
|
2016-01-26 19:52:15 +08:00
|
|
|
}
|
|
|
|
|
2016-01-26 20:28:07 +08:00
|
|
|
function update() {
|
2016-01-26 19:52:15 +08:00
|
|
|
fcho "------------------------------"
|
2016-07-30 01:57:42 +08:00
|
|
|
fcho "Starting update process ..."
|
2016-01-26 19:52:15 +08:00
|
|
|
#First update Toxcore from git
|
|
|
|
cd $TOXCORE_DIR
|
|
|
|
fcho "Now in ${PWD}"
|
|
|
|
fcho "Pulling ..."
|
|
|
|
git pull
|
|
|
|
read -r -p "Did Toxcore update from git? [y/N] " response
|
|
|
|
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
|
2016-02-20 19:24:56 +08:00
|
|
|
build_toxcore
|
2016-01-26 19:52:15 +08:00
|
|
|
else
|
2016-07-30 01:57:42 +08:00
|
|
|
fcho "Moving on!"
|
2016-01-26 19:52:15 +08:00
|
|
|
fi
|
2016-07-30 01:57:42 +08:00
|
|
|
|
2016-01-26 19:52:15 +08:00
|
|
|
#Now let's update qTox!
|
|
|
|
cd $QTOX_DIR
|
|
|
|
fcho "Now in ${PWD}"
|
|
|
|
fcho "Pulling ..."
|
|
|
|
git pull
|
|
|
|
read -r -p "Did qTox update from git? [y/N] " response
|
|
|
|
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
|
|
|
|
fcho "Starting OSX bootstrap ..."
|
2016-02-01 00:25:38 +08:00
|
|
|
sudo ./bootstrap-osx.sh
|
2016-01-26 19:52:15 +08:00
|
|
|
else
|
2016-07-30 01:57:42 +08:00
|
|
|
fcho "Moving on!"
|
2016-01-26 19:52:15 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-01-26 20:28:07 +08:00
|
|
|
function build() {
|
2016-01-26 19:52:15 +08:00
|
|
|
fcho "------------------------------"
|
|
|
|
fcho "Starting build process ..."
|
2016-07-30 01:57:42 +08:00
|
|
|
rm -rf $BUILD_DIR
|
|
|
|
rm -rf $DEPLOY_DIR
|
2016-01-26 19:52:15 +08:00
|
|
|
mkdir $BUILD_DIR
|
|
|
|
cd $BUILD_DIR
|
|
|
|
fcho "Now working in ${PWD}"
|
|
|
|
fcho "Starting qmake ... "
|
|
|
|
$QMAKE $QTOX_DIR/qtox.pro
|
|
|
|
make
|
|
|
|
}
|
|
|
|
|
2016-01-26 20:28:07 +08:00
|
|
|
function deploy() {
|
2016-01-26 19:52:15 +08:00
|
|
|
fcho "------------------------------"
|
|
|
|
fcho "starting deployment process ..."
|
|
|
|
cd $BUILD_DIR
|
|
|
|
if [ ! -d $BUILD_DIR ]; then
|
|
|
|
fcho "Error: Build directory not detected, please run -ubd, or -b before deploying"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
mkdir $DEPLOY_DIR
|
|
|
|
cp -r $BUILD_DIR/qTox.app $DEPLOY_DIR/qTox.app
|
|
|
|
cd $DEPLOY_DIR
|
|
|
|
fcho "Now working in ${PWD}"
|
|
|
|
$MACDEPLOYQT qTox.app
|
|
|
|
}
|
|
|
|
|
2016-03-23 01:52:38 +08:00
|
|
|
function bootstrap() {
|
|
|
|
fcho "------------------------------"
|
|
|
|
fcho "starting bootstrap process ..."
|
2016-07-30 01:57:42 +08:00
|
|
|
|
2016-03-23 01:52:38 +08:00
|
|
|
#Toxcore
|
|
|
|
build_toxcore
|
2016-07-30 01:57:42 +08:00
|
|
|
|
2016-03-23 01:52:38 +08:00
|
|
|
#Boot Strap
|
|
|
|
fcho "Running: sudo ${QTOX_DIR_VER}/bootstrap-osx.sh"
|
|
|
|
cd $QTOX_DIR
|
|
|
|
sudo ./bootstrap-osx.sh
|
|
|
|
}
|
|
|
|
|
2016-05-29 07:21:53 +08:00
|
|
|
function dmgmake() {
|
|
|
|
fcho "------------------------------"
|
|
|
|
fcho "Starting DMG creation"
|
|
|
|
cd $DEPLOY_DIR
|
|
|
|
ln -s /Applications "./Install to Applications"
|
|
|
|
cp -r -f $QTOX_DIR/osx/background-DMG ./.background
|
|
|
|
cp -f $QTOX_DIR/osx/DS_Store-DMG ./.DS_Store
|
|
|
|
cp -f $QTOX_DIR/LICENSE ./LICENSE
|
|
|
|
cp -f $QTOX_DIR/README.md ./README.md
|
|
|
|
cd $QTOX_DIR
|
|
|
|
hdiutil create -volname qTox${SUBGIT} -srcfolder $DEPLOY_DIR -format UDZO qTox${SUBGIT}.dmg
|
|
|
|
}
|
|
|
|
|
|
|
|
function helpme() {
|
|
|
|
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 "-h | --help -- This help text."
|
|
|
|
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 "-b | --build -- Builds qTox in: ${BUILD_DIR}"
|
|
|
|
echo "-d | --deploy -- Makes a distributable qTox.app file in: ${DEPLOY_DIR}"
|
|
|
|
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/tux3/qTox"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
-h | --help)
|
|
|
|
helpme
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
-i | --install)
|
2016-01-26 19:52:15 +08:00
|
|
|
install
|
2016-01-26 23:48:21 +08:00
|
|
|
exit
|
2016-05-29 07:21:53 +08:00
|
|
|
;;
|
|
|
|
-u | --update)
|
2016-01-26 19:52:15 +08:00
|
|
|
update
|
2016-01-26 23:48:21 +08:00
|
|
|
exit
|
2016-05-29 07:21:53 +08:00
|
|
|
;;
|
|
|
|
-b | --build)
|
2016-01-26 19:52:15 +08:00
|
|
|
build
|
2016-01-26 23:48:21 +08:00
|
|
|
exit
|
2016-05-29 07:21:53 +08:00
|
|
|
;;
|
|
|
|
-d | --deploy)
|
2016-01-26 19:52:15 +08:00
|
|
|
deploy
|
2016-01-26 23:48:21 +08:00
|
|
|
exit
|
2016-05-29 07:21:53 +08:00
|
|
|
;;
|
|
|
|
-bs | --bootstrap)
|
|
|
|
bootstrap
|
2016-01-26 23:48:21 +08:00
|
|
|
exit
|
2016-05-29 07:21:53 +08:00
|
|
|
;;
|
|
|
|
-dmg)
|
|
|
|
dmgmake
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
2016-01-26 19:52:15 +08:00
|
|
|
|
2016-02-01 00:25:38 +08:00
|
|
|
fcho "Oh dear! You seemed to of started this script improperly! Use -h to get available commands and information!"
|
|
|
|
echo " "
|
|
|
|
say -v Kathy -r 255 "Oh dear! You seemed to of started this script improperly! Use -h to get available commands and information!"
|
2016-01-26 15:46:35 +08:00
|
|
|
exit 0
|