Skip to content

Instantly share code, notes, and snippets.

@timsueberkrueb
Last active November 28, 2016 16:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timsueberkrueb/bc60f3318878d6889622237cd19fc9db to your computer and use it in GitHub Desktop.
Save timsueberkrueb/bc60f3318878d6889622237cd19fc9db to your computer and use it in GitHub Desktop.
Setup Fluid on Ubuntu (https://github.com/lirios/fluid)
#!/bin/bash
# Setup Fluid on Ubuntu (https://github.com/lirios/fluid)
# Tested on Ubuntu 16.04 and Ubuntu 16.10 with Qt 5.7
#
# You may use this script freely if you find it useful. Please note
# that it comes with absolutely no warranty though.
#
# MIT License
#
# Copyright (C) 2016 by Tim Süberkrüb
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
info(){
tput setaf 3
tput bold
echo $1
tput sgr0
}
error() {
tput setaf 1
tput bold
echo "$1"
tput sgr0
}
prompt(){
tput setaf 3
echo -n "$1"
tput sgr0
}
info "Welcome to Fluid Installer for Ubuntu"
info "This script helps you to setup Fluid (https://github.com/lirios/fluid)"
prompt "Do you wish to continue (Y/n)? "
read -n 1 continue_installation
echo
if [[ $continue_installation != "y"* ]] && [[ $continue_installation != "Y"* ]] && [ ! -z "$continue_installation" ]; then
error "Exiting."
exit
fi
info "Installing dependencies ..."
sudo apt update && sudo apt upgrade
sudo apt install git cmake extra-cmake-modules
sudo apt install mesa-common-dev # Required for android-cmake
info "Please enter the path of your clone of the Fluid repository "
info "or where it should get cloned:"
info "[1] /tmp/fluid-install/"
info "[2] Custom ..."
prompt "Choose (default: 1): "
read -n 1 installation_mode
echo
data_path="/tmp/fluid-install/"
if [ ! -d "$data_path" ]; then
mkdir $data_path
fi
cd $data_path
if [ -z "$installation_mode" ]; then
installation_mode="1"
fi
if [ "$installation_mode" == "1" ]; then
info "Temporary installation data is written to /tmp/fluid-install"
fluid_source_path="/tmp/fluid-install/source"
if [ ! -d "$fluid_source_path" ]; then
mkdir -p "$fluid_source_path"
info "Cloning Fluid git repository ..."
git clone https://github.com/liros/fluid "$fluid_source_path"
else
info "Updating Fluid git repository ..."
cd "$fluid_source_path"
git checkout develop
git pull
fi
elif [ "$installation_mode" == "2" ]; then
info "Enter the path to your clone of the Fluid repository."
info "If you don't have one, enter the path where it should be cloned to."
prompt "Path to Fluid source: "
read fluid_source_path
echo
if [ ! -d "$fluid_source_path" ]; then
error "Invalid path."
exit
elif [ ! -d "$fluid_source_path/.git" ]; then # Naive.
info "Not a git repository. "
info "Cloning fluid source to '$fluid_source_path/fluid'..."
fluid_source_path="$fluid_source_path/fluid"
info "Cloning Fluid git repository ..."
git clone https://github.com/lirios/fluid "$fluid_source_path"
else
info "Updating Fluid git repository ..."
cd "$fluid_source_path"
git checkout develop
git pull
cd "$data_path"
fi
else
error "Invalid option."
exit
fi
info "Fluid requires Qt >= 5.7"
user_name=$(whoami)
default_qt_install_dir="/home/$user_name/Qt/5.7"
prompt "Please enter the path where you installed Qt 5.7 (default: $default_qt_install_dir): "
read qt_install_dir
echo
if [ -z "$qt_install_dir" ]; then
qt_install_dir=$default_qt_install_dir
fi
if [ ! -d "$qt_install_dir" ]
then
error "The given path '$qt_install_dir' doesn't seem to exist."
exit
fi
info "Please choose the target platform: "
ls $qt_install_dir
prompt "Choose (default: gcc_64): "
read qt_platform
echo
if [ -z "$qt_platform" ]; then
qt_platform="gcc_64"
fi
if [ ! -d "$qt_install_dir/$qt_platform" ]; then
error "The given target platform '$qt_platform' doesn't seem to be installed."
exit
fi
is_android_platform=false
if [[ $qt_platform == *"android"* ]]; then
info "Android platform detected."
is_android_platform=true
info "Checking for android cmake toolchain ..."
if [ ! -d "android-cmake" ]; then
info "Not found. Cloning android-cmake ..."
git clone https://github.com/taka-no-me/android-cmake
else
info "Found. Updating ..."
cd android-cmake
git pull
cd ..
fi
info "In order to build Fluid for Android you need to have the Android NDK installed."
prompt "NDK Installation path: "
read ndk_path
echo
if [ ! -d "$ndk_path" ]; then
error "Invalid path."
exit
fi
prompt "Please enter the Android ABI (default: armeabi-v7a): "
read android_abi
echo
if [ -z "$android_abi" ]; then
android_abi="armeabi-v7a"
fi
file_to_be_patched="$qt_install_dir/$qt_platform/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake"
if [ ! -d "patch" ]; then
mkdir patch
fi
if [ ! -e "patch/cmake_android.patch" ]; then
touch "patch/cmake_android.patch"
echo "@@ -98,7 +98,7 @@ set(Qt5_DISABLED_FEATURES" >> "patch/cmake_android.patch"
echo " " >> "patch/cmake_android.patch"
echo " set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)" >> "patch/cmake_android.patch"
echo " " >> "patch/cmake_android.patch"
echo "-set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)" >> "patch/cmake_android.patch"
echo "+#set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)" >> "patch/cmake_android.patch"
echo " " >> "patch/cmake_android.patch"
echo ' set(QT_VISIBILITY_AVAILABLE "True")' >> "patch/cmake_android.patch"
echo " " >> "patch/cmake_android.patch"
fi
info "Because of a bug in Qt (https://bugreports.qt.io/browse/QTBUG-54666)"
info " CMake fails to configure an Android build in Qt 5.7."
patch -p0 -N --dry-run $file_to_be_patched < patch/cmake_android.patch 2>/dev/null
if [ $? -eq 0 ]; then
prompt "Do you want to patch your installation (y/N):"
read -n 1 patch_install
echo
if [[ $patch_install == "n"* ]] || [[ $patch_install == "N"* ]] || [ -z "$patch_install" ]; then
error "Exiting."
exit
else
info "Patching Qt for Android ..."
patch $file_to_be_patched patch/cmake_android.patch
info "Patch applied."
fi
else
info "Patch has already been applied."
fi
fi
cd "$fluid_source_path"
release_tag=$(git describe --abbrev=0)
info "Please select the version you want to install:"
info "[1] Latest release ($release_tag)"
info "[2] Development branch"
prompt "Choose (default: 1): "
read -n 1 option_num
echo
if [ -z "$option_num" ]; then
option_num="1"
fi
if [ "$option_num" == "1" ]; then
git checkout -q tags/$release_tag
info "Installing release $release_tag."
elif [ "$option_num" == "2" ]; then
info "Installing latest development state."
else
error "Invalid option."
exit
fi
info "Fetching icons ..."
./scripts/fetch_icons.sh
info "What type of build to you wish to perform?"
info "[1] Debug"
info "[2] Release"
prompt "Choose (default: 1): "
read -n 1 build_type
echo
if [ -z "$build_type" ]; then
option_num="1"
fi
if [ "$build_type" == "1" ]; then
build_type="Debug"
elif [ "$build_type" == "2" ]; then
build_type="Release"
else
error "Invalid option."
exit
fi
info "Performing $build_type build."
cd "$data_path"
if [ ! -d "build" ]; then
info "Creating build directory ..."
mkdir build/
else
info "Cleaning build directory ..."
rm -rf build && mkdir build/
fi
cd build/
info "Running cmake ..."
if $is_android_platform; then
cmake -DCMAKE_TOOLCHAIN_FILE=../android-cmake/android.toolchain.cmake \
-DANDROID_NDK="$ndk_path" \
-DANDROID_ABI="$android_abi" \
-DCMAKE_PREFIX_PATH=$qt_install_dir/$qt_platform/lib/cmake \
-DCMAKE_BUILD_TYPE=$build_type \
-DKDE_INSTALL_QMLDIR=$qt_install_dir/$qt_platform/qml \
"$fluid_source_path"
else
cmake -DCMAKE_PREFIX_PATH=$qt_install_dir/$qt_platform/lib/cmake \
-DCMAKE_BUILD_TYPE=$build_type \
-DKDE_INSTALL_QMLDIR=$qt_install_dir/$qt_platform/qml \
"$fluid_source_path"
fi
info "Running make ..."
make
info "Running make install ..."
sudo make install
cd ../../
info "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment