File indexing completed on 2025-01-19 03:59:49

0001 #!/bin/bash
0002 
0003 # Rules to prepare Ubuntu 18.04 and later Linux host.
0004 #
0005 # Copyright (c) 2015-2024 by Gilles Caulier  <caulier dot gilles at gmail dot com>
0006 #
0007 # Redistribution and use is allowed according to the terms of the BSD license.
0008 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0009 #
0010 
0011 #################################################################################################
0012 
0013 echo -e "---------- Update Linux Ubuntu Host\n"
0014 
0015 # for downloading package information from all configured sources.'
0016 
0017 sudo apt-get update
0018 sudo apt-get upgrade
0019 
0020 # benefit from a higher version of certain software , update the key
0021 
0022 sudo apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com
0023 sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
0024 
0025 # To fix GPP key error with some reporsitories
0026 # See: https://www.skyminds.net/linux-resoudre-les-erreurs-communes-de-cle-gpg-dans-apt/
0027 
0028 sudo apt-get update 2>&1 | \
0029     sed -ne 's?^.*NO_PUBKEY ??p' | \
0030     xargs -r -- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys
0031 
0032 echo -e "---------- Install New Development Packages\n"
0033 
0034 # Install dependencies to Checkout Source Code
0035 
0036 sudo apt-get install -y git
0037 sudo apt-get install -y perl
0038 
0039 required_packages=("cmake"                   # To Compile Source Code
0040                    "ninja-build"             # To Compile Source Code
0041                    "build-essential"         # To Compile Source Code
0042                    "libpthread-stubs0-dev"   # Development files for pthread
0043                    "libtiff-dev"             # Tag image file format library
0044                    "libpng-dev"              # PNG library
0045                    "libjpeg-dev"             # JPEG library
0046                    "liblcms2-dev"            # Little CMS 2 color management library
0047                    "libexpat1-dev"           # XML parsing C library
0048                    "libssl-dev"              # For MXE build
0049                     )
0050 
0051 
0052 for pkg in ${required_packages[@]}; do
0053 
0054     sudo apt-get install -y ${pkg}
0055 
0056     current_version=$(dpkg-query --showformat='${Version}' --show ${pkg})
0057 
0058     case "${pkg}" in
0059     "cmake")
0060         required_version=3.3.2
0061         ;;
0062     "build-essential")
0063         required_version=11.0.0
0064         ;;
0065     "libpthread-stubs0-dev")
0066         required_version=2.0.0
0067         ;;
0068     "libtiff-dev")
0069         required_version=4.0.0
0070         ;;
0071     "libpng-dev")
0072         required_version=1.6.0
0073         ;;
0074     "libjpeg-dev")
0075         required_version=6b
0076         ;;
0077     "liblcms2-dev")
0078         required_version=2.0.0
0079         ;;
0080     "libexpat1-dev")
0081         required_version=2.1.0
0082         ;;
0083     esac
0084 
0085     echo $current_version
0086 
0087     if $(dpkg --compare-versions "$current_version" "lt" "$required_version"); then
0088             echo "less than $required_version";
0089             echo "please upgrade newer version or another packages";
0090     else
0091             echo "greater than $required_version ............. accepted";
0092     fi
0093 
0094     echo "-------------------------------------------------------------------"
0095 
0096 done
0097 
0098 # Install optional dependencies to Compile And Link Source Code
0099 
0100 optional_packages=("ruby"                               # For i18n extraction
0101                    "subversion"                         # For i18n extraction
0102                    "hunspell"                           # For check spelling
0103                    "keychain"                           # For git-ssh
0104                    "ssh-askpass"                        # For git-ssh
0105                    "ccache"                             # For compiling
0106                    "bison"                              # For Qt build (>= 2.5.0)
0107                    "flex"                               # For compiling (>= 2.5.0)
0108                    "mysql-server"                       # Run-time: mysql internal server init
0109                    "libeigen3-dev"                      # >= 3.2
0110                    "libgomp1"                           # For Libraw compilation
0111                    "libxslt-dev"                        # >= 1.1.0
0112                    "libxml2-dev"                        # >= 2.7.0
0113                    "libfftw3-dev"                       # For GMic-Qt compilation
0114                    "libx265-dev"                        # >= 2.2
0115                    "wget"
0116                    "tar"
0117                    "bzip2"
0118                    "gettext"
0119                    "libtool"
0120                    "fuse"
0121                    "automake"
0122                    "ccache"
0123                    "yasm"
0124                    "patch"
0125                    "libdrm-dev"
0126                    "libxcb*-dev"
0127                    "libx11-keyboard-perl"
0128                    "xscreensaver"
0129                    "gperf"
0130                    "zlib1g-dev"
0131                    "libfuse-dev"
0132                    "libc6-dev"
0133                    "default-libmysqlclient-dev"
0134                    "libcppunit-dev"
0135                    "libc++-dev"
0136                    "libudev-dev"
0137                    "libsqlite3-dev"
0138                    "libexif-dev"
0139                    "liblzma-dev"
0140                    "liblz-dev"
0141                    "libinotifytools0-dev"
0142                    "libcups2-dev"
0143                    "libopenal-dev"
0144                    "libpulse-dev"
0145                    "libical-dev"
0146                    "libcap-dev"
0147                    "libfontconfig1-dev"
0148                    "patchelf"
0149                    "dpkg"
0150                    "clang"
0151                    "python2"
0152                    "python3"
0153                    "python3-lxml"
0154                    "python-is-python2"
0155                    "libboost-all-dev"
0156                    "libgphoto2-dev"
0157                    "libsane-dev"
0158                    "libssl-dev"
0159                    "appstream"
0160                    "libnss3-dev"
0161                    "libxkbcommon-dev"
0162                    "libxkbcommon-x11-dev"
0163                    "libxkbfile-dev"
0164                    "libxinerama-dev"
0165                    "libxi-dev"
0166                    "libxtst-dev"
0167                    "libxrandr-dev"
0168                    "libxcursor-dev"
0169                    "libxcomposite-dev"
0170                    "libxrender-dev"
0171                    "libxdamage-dev"
0172                    "libx11-xcb-dev"
0173                    "libltdl-dev"
0174                    "libglib2.0-dev"
0175                    "libusb-1.0-0-dev"
0176                    "libclang-dev"
0177                    "libsm-dev"
0178                    "freeglut3-dev"
0179                    "libinput-dev"
0180                    "libfdk-aac-dev"
0181                    "libx264-dev"
0182                    "libx265-dev"
0183                    "libxvidcore-dev"
0184                    "libvpx-dev"
0185                    "libtheora-dev"
0186                    "libvorbis-dev"
0187                    "libopencore-amrnb-dev"
0188                    "libopencore-amrwb-dev"
0189                    "librtmp-dev"
0190                    "libopus-dev"
0191                    "libspeex-dev"
0192                    "libmp3lame-dev"
0193                    "libfreetype6-dev"
0194                    "libass-dev"
0195                    "libegl1-mesa-dev"
0196                    "libgl1-mesa-dev"
0197                    "libgles2-mesa-dev"
0198                    "libglu1-mesa-dev"
0199                    "libdbus-1-dev"
0200                    "libmount-dev"
0201                    "curl"
0202                    "libicu-dev"
0203                    "icu-devtools"
0204                    "flite1-dev"
0205                    "libxshmfence-dev"
0206                    "libcanberra-dev"
0207                    "libgcrypt11-dev"
0208                    "libasound2-dev"
0209                   )
0210 
0211 
0212 for pkg in ${optional_packages[@]}; do
0213     sudo apt-get install -y ${pkg}
0214     echo "-------------------------------------------------------------------"
0215 done
0216 
0217 # Install more recent version of NodeJs for QtWebEngine.
0218 # https://learnubuntu.com/update-node-js/
0219 
0220 curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
0221 sudo apt-get install nodejs
0222 
0223 echo -e "---------- Clean-up Old Packages\n"
0224 
0225 # Remove system based devel package to prevent conflict with new one.
0226 sudo apt remove -y libqt5core5a  || true
0227 sudo apt remove -y libavfilter6  || true
0228 sudo apt remove -y libjasper-dev || true
0229 
0230 echo -e "---------- Install more recent version of compiler\n"
0231 
0232 # https://askubuntu.com/questions/1140183/install-gcc-9-on-ubuntu-18-04
0233 # https://www.followchain.org/install-gcc-11-on-ubuntu/
0234 # https://linuxconfig.org/how-to-switch-between-multiple-gcc-and-g-compiler-versions-on-ubuntu-20-04-lts-focal-fossa
0235 
0236 sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
0237 sudo apt install -y gcc-11
0238 sudo apt install -y g++-11
0239 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11
0240 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11
0241