File indexing completed on 2024-04-14 04:37:59

0001 #!/usr/bin/env bash
0002 
0003 # exit on any error
0004 set -Ee
0005 
0006 # Enter the directory that contains this script file
0007 cd $(dirname $0)
0008 TOP=$( pwd -L )
0009 
0010 if [ $(id -u) -eq 0 ] ; then
0011     echo "This script should not be run as root or with sudo."
0012     return 1
0013 fi
0014 
0015 # function to display menus
0016 show_menus() {
0017     clear
0018     echo "                     "
0019     echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
0020     echo " WELCOME TO LIBQMYCROFT INSTALLATION SCRIPT "
0021     echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
0022     echo "                     "
0023     echo "Please Note: This is an Interactive script that will take you through a series of installation choices, where you might be required to provide your administrative password to successfully install system dependencies and Libqmycroft on your system."
0024     echo "                     "
0025     echo "~~~~~~~~~~~~~~~~~~~~~"
0026     echo " SELECT - DISTRIBUTION "
0027     echo "~~~~~~~~~~~~~~~~~~~~~"
0028     echo "1. KDE NEON BIONIC"
0029     echo "2. K/UBUNTU 20.04+ / KDE NEON FOCAL"
0030     echo "3. MANJARO/ARCH"
0031     echo "4. ALPINE LINUX"
0032     echo "5. openSUSE Leap 15.x"
0033     echo "6. OTHERS"
0034     echo "7. UPDATE INSTALLATION"
0035     echo "8. EXIT"
0036 }
0037 
0038 read_options() {
0039     echo " "
0040         local choice
0041         read -p "Enter choice [ 1 - 8 ] " choice
0042         case $choice in
0043                 1) neon ;;
0044                 2) kubuntu ;;
0045                 3) manjaro ;;
0046                 4) alpine ;;
0047                 5) opensuse ;;
0048                 6) others ;;
0049                 7) updateinstall;;
0050                 8) exit 0;;
0051                 *) echo -e "${RED}Error...${STD}" && sleep 2
0052         esac
0053 }
0054 
0055 #trap '' SIGINT SIGQUIT SIGTSTP
0056 
0057 function found_exe() {
0058    hash "$1" 2>/dev/null
0059 }
0060 
0061 neon() {
0062     echo "Starting Installation For KDE NEON"
0063     echo ""
0064     echo "Following Packages Will Be Installed: git-core g++ cmake extra-cmake-modules gettext pkg-config pkg-kde-tools qtbase5-dev qtdeclarative5-dev libqt5websockets5-dev qtmultimedia5-dev"
0065     echo ""
0066     echo "Please Enter Authentication For Installing System Dependencies"
0067     sudo apt-get install -y git-core g++ cmake extra-cmake-modules gettext pkg-config pkg-kde-tools qtbase5-dev qtdeclarative5-dev libqt5websockets5-dev qtmultimedia5-dev
0068     build_lib
0069 }
0070 
0071 kubuntu() {
0072     echo "Starting Installation For K/Ubuntu 20.04 +"
0073     echo ""
0074     echo "Following Packages Will Be Installed: git-core g++ cmake extra-cmake-modules gettext pkg-config pkg-kde-tools qtbase5-dev qtdeclarative5-dev libqt5websockets5-dev qtmultimedia5-dev"
0075     echo ""
0076     echo "Please Enter Authentication For Installing System Dependencies"
0077     sudo apt-get install -y git-core g++ cmake extra-cmake-modules gettext pkg-config pkg-kde-tools qtbase5-dev qtdeclarative5-dev libqt5websockets5-dev qtmultimedia5-dev
0078     build_lib
0079 }
0080 
0081 manjaro() {
0082     echo "Starting Installation For Manjaro / Arch"
0083     echo ""
0084     echo "Following Packages Will Be Installed: cmake extra-cmake-modules qt5-websockets qt5-declarative qt5-quickcontrols2 qt5-base qt5-multimedia"
0085     echo ""
0086     echo "Please Enter Authentication For Installing System Dependencies"
0087     yes | sudo pacman -S git cmake extra-cmake-modules qt5-websockets qt5-declarative qt5-quickcontrols2 qt5-base qt5-multimedia
0088     build_lib   
0089 }
0090 
0091 alpine() {
0092     echo "Starting Installation For Alpine Linux"
0093     echo ""
0094     echo "The development headers for the following packages will be installed: alpine-sdk cmake extra-cmake-modules qt5-qtwebsockets-dev qt5-qtdeclarative-dev qt5-qtquickcontrols2-dev qt5-qtbase-dev qt5-qtmultimedia-dev"
0095     echo "They can easily be uninstalled later on by running 'apk del makedeps-libqmycroft'"
0096     echo ""
0097     echo "Please Enter Authentication For Installing System Dependencies"
0098     sudo apk add --virtual makedeps-libqmycroft alpine-sdk cmake extra-cmake-modules qt5-qtwebsockets-dev qt5-qtdeclarative-dev qt5-qtquickcontrols2-dev qt5-qtbase-dev qt5-qtmultimedia-dev
0099     build_lib
0100 }
0101 
0102 opensuse() {
0103     echo "Starting Installation For openSUSE Leap 15.x"
0104     echo ""
0105     echo "The development headers for the following packages will be installed: cmake extra-cmake-modules libqt5-qtwebsockets-devel libqt5-qtdeclarative-devel libQt5QuickControls2-devel libqt5-qtbase-devel libqt5-qtmultimedia-devel"
0106     echo ""
0107     echo "Please Enter Authentication For Installing System Dependencies"
0108     sudo zypper --non-interactive install cmake extra-cmake-modules libqt5-qtwebsockets-devel libqt5-qtwebview-devel libqt5-qtdeclarative-devel libQt5QuickControls2-devel libqt5-qtbase-devel libqt5-qtmultimedia-devel
0109     build_lib
0110 }
0111 
0112 updateinstall() {
0113     echo "Pulling Latest Changes From Master"
0114     git pull origin master
0115     echo "Update Completed"
0116     exit 0
0117     build_lib
0118 }
0119 
0120 continue_unknown() {
0121     echo "Starting Installation For Unknown Platform, Builds Will Fail If Required Packages Are Not Found"
0122     build_lib
0123 }
0124 
0125 return_previous() {
0126     show_menus
0127 }
0128 
0129 others() {
0130       clear
0131       echo "You must manually install the following packages for this platform"
0132       echo "cmake extra-cmake-modules qt5-websockets qt5-declarative qt5-quickcontrols2 qt5-base"
0133       echo "Consider contributing support for your platform by adding it to this script"
0134       
0135       echo "1. Continue Installation"
0136       echo "2. Return To Previous Menu"
0137       echo "3. Exit"
0138       
0139       local additional_choice
0140       read -p "Enter choice [ 1 - 3 ] " additional_choice
0141       case $additional_choice in
0142           1) continue_unknown;;
0143           2) return_previous;;
0144           3) exit 0;;
0145       esac
0146 }
0147 
0148 function build_lib() {
0149     echo " "
0150     echo "Building Libqmycroft"
0151     if [[ ! -d build-testing ]] ; then
0152     mkdir build-testing
0153     fi
0154     cd build-testing
0155     cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release   -DKDE_INSTALL_LIBDIR=lib -DKDE_INSTALL_USE_QT_SYS_PATHS=ON
0156     make -j4
0157     sudo make install
0158     install_libqmycroft_mock
0159 }
0160 
0161 function install_libqmycroft_mock() {
0162     echo " "
0163     echo "Installing Libqmycroft Mock Interface"
0164     cd ..
0165     mkdir -p /opt/mycroft/skills/libqmycroft-mock-interface 
0166     cp -R libqmycroft-mock-interface/* /opt/mycroft/skills/libqmycroft-mock-interface
0167     complete_installer
0168 }   
0169 
0170 function complete_installer() {
0171     echo " "
0172     echo "Installation complete!"
0173     exit 0
0174 }
0175 
0176 while true
0177 do
0178 
0179         show_menus
0180         read_options
0181 done