aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
Maxim Cournoyer | 8bac466 | 2021-05-14 08:45:24 -0400 | [diff] [blame] | 3 | # This is the Jami build helper, it can do these things: |
| 4 | # - Build Jami |
| 5 | # - Install Jami |
| 6 | # - Run Jami |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 7 | # |
| 8 | |
| 9 | import argparse |
| 10 | import os |
| 11 | import subprocess |
| 12 | import sys |
| 13 | import time |
Alexandre Lision | e3d89bc | 2016-03-08 11:24:56 -0500 | [diff] [blame] | 14 | import platform |
Alexandre Lision | e4833b2 | 2016-03-09 23:21:07 -0500 | [diff] [blame] | 15 | import multiprocessing |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 16 | import shlex |
Alexandre Lision | 53048b2 | 2016-04-06 19:34:08 -0400 | [diff] [blame] | 17 | import shutil |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 18 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 19 | IOS_DISTRIBUTION_NAME = "ios" |
| 20 | OSX_DISTRIBUTION_NAME = "osx" |
| 21 | ANDROID_DISTRIBUTION_NAME = "android" |
| 22 | WIN32_DISTRIBUTION_NAME = "win32" |
| 23 | |
Ming Rui Zhang | 8a130e1 | 2020-10-13 13:46:43 -0400 | [diff] [blame] | 24 | QT5_VERSION = "5.15.0" |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 25 | |
| 26 | # vs vars |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 27 | win_sdk_default = '10.0.16299.0' |
Ming Rui Zhang | 8a130e1 | 2020-10-13 13:46:43 -0400 | [diff] [blame] | 28 | win_toolset_default = '142' |
Romain Bertozzi | dca37f0 | 2017-11-07 14:08:02 -0500 | [diff] [blame] | 29 | |
Alexandre Lision | c7336d3 | 2017-11-18 12:19:38 -0500 | [diff] [blame] | 30 | APT_BASED_DISTROS = [ |
Hugo Lefeuvre | b3bb956 | 2018-07-16 13:36:52 -0400 | [diff] [blame] | 31 | 'debian', |
| 32 | 'ubuntu', |
Amin Bandali | 7df8222 | 2020-12-28 11:13:00 -0500 | [diff] [blame] | 33 | 'trisquel', |
Hugo Lefeuvre | b3bb956 | 2018-07-16 13:36:52 -0400 | [diff] [blame] | 34 | 'linuxmint', |
| 35 | 'raspbian', |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 36 | ] |
| 37 | |
Alexandre Lision | c7336d3 | 2017-11-18 12:19:38 -0500 | [diff] [blame] | 38 | DNF_BASED_DISTROS = [ |
Sébastien Blin | 77428f1 | 2019-11-13 17:29:12 -0500 | [diff] [blame] | 39 | 'fedora', 'rhel', |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 40 | ] |
| 41 | |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 42 | PACMAN_BASED_DISTROS = [ |
Hugo Lefeuvre | b3bb956 | 2018-07-16 13:36:52 -0400 | [diff] [blame] | 43 | 'arch', |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 44 | ] |
| 45 | |
Alexandre Lision | c7336d3 | 2017-11-18 12:19:38 -0500 | [diff] [blame] | 46 | ZYPPER_BASED_DISTROS = [ |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 47 | 'opensuse-leap', 'opensuse-tumbleweed', |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 48 | ] |
| 49 | |
Alexander Schlarb | bddc1a2 | 2019-12-13 16:02:46 +0100 | [diff] [blame] | 50 | FLATPAK_BASED_RUNTIMES = [ |
| 51 | 'org.gnome.Platform', |
| 52 | ] |
| 53 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 54 | APT_INSTALL_SCRIPT = [ |
| 55 | 'apt-get update', |
Stepan Salenikovich | 1ffc7fc | 2017-03-22 18:29:44 -0400 | [diff] [blame] | 56 | 'apt-get install -y %(packages)s' |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 57 | ] |
| 58 | |
Alexandre Lision | e656740 | 2016-11-15 09:54:55 -0500 | [diff] [blame] | 59 | BREW_UNLINK_SCRIPT = [ |
| 60 | 'brew unlink %(packages)s' |
| 61 | ] |
| 62 | |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 63 | BREW_INSTALL_SCRIPT = [ |
| 64 | 'brew update', |
Kateryna Kostiuk | 5a0016b | 2019-02-21 10:00:13 -0500 | [diff] [blame] | 65 | 'brew install %(packages)s', |
Alexandre Lision | e656740 | 2016-11-15 09:54:55 -0500 | [diff] [blame] | 66 | 'brew link --force --overwrite %(packages)s' |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 67 | ] |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 68 | |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 69 | RPM_INSTALL_SCRIPT = [ |
philippegorley | 1a3fd04 | 2018-09-24 10:07:17 -0400 | [diff] [blame] | 70 | 'dnf update', |
| 71 | 'dnf install -y %(packages)s' |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 72 | ] |
| 73 | |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 74 | PACMAN_INSTALL_SCRIPT = [ |
philippegorley | 1a3fd04 | 2018-09-24 10:07:17 -0400 | [diff] [blame] | 75 | 'pacman -Sy', |
frisbee-w | 16c581b | 2021-01-09 01:17:15 +0530 | [diff] [blame] | 76 | 'pacman -S --asdeps --needed %(packages)s' |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 77 | ] |
| 78 | |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 79 | ZYPPER_INSTALL_SCRIPT = [ |
philippegorley | 1a3fd04 | 2018-09-24 10:07:17 -0400 | [diff] [blame] | 80 | 'zypper update', |
| 81 | 'zypper install -y %(packages)s' |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 82 | ] |
| 83 | |
Alexandre Lision | c7336d3 | 2017-11-18 12:19:38 -0500 | [diff] [blame] | 84 | ZYPPER_DEPENDENCIES = [ |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 85 | # build system |
Sébastien Blin | 4d94541 | 2020-09-30 14:53:17 -0400 | [diff] [blame] | 86 | 'autoconf', 'autoconf-archive', 'automake', 'cmake', 'make', 'patch', 'gcc-c++', |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 87 | 'libtool', 'which', 'pandoc','nasm', 'doxygen', 'graphviz', |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 88 | # contrib dependencies |
philippegorley | 6d77189 | 2018-09-24 10:45:28 -0400 | [diff] [blame] | 89 | 'curl', 'gzip', 'bzip2', |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 90 | # daemon |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 91 | 'speexdsp-devel', 'speex-devel', 'libdbus-c++-devel', 'jsoncpp-devel', 'yaml-cpp-devel', |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 92 | 'yasm', 'libuuid-devel', 'libnettle-devel', 'libopus-devel', 'libexpat-devel', |
philippegorley | 6d77189 | 2018-09-24 10:45:28 -0400 | [diff] [blame] | 93 | 'libgnutls-devel', 'msgpack-devel', 'libavcodec-devel', 'libavdevice-devel', 'pcre-devel', |
| 94 | 'alsa-devel', 'libpulse-devel', 'libudev-devel', 'libva-devel', 'libvdpau-devel', |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 95 | 'libopenssl-devel', 'libavutil-devel', |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 96 | # lrc |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 97 | 'libQt5Core-devel', 'libQt5DBus-devel', 'libqt5-linguist-devel', |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 98 | # client gnome / qt |
| 99 | 'qrencode-devel', 'NetworkManager-devel' |
| 100 | ] |
| 101 | |
| 102 | ZYPPER_CLIENT_GNOME_DEPENDENCIES = [ |
| 103 | 'gtk3-devel', 'clutter-gtk-devel', 'gettext-tools', 'libnotify-devel', 'libappindicator3-devel', |
| 104 | 'webkit2gtk3-devel', 'libcanberra-gtk3-devel' |
| 105 | ] |
| 106 | |
| 107 | ZYPPER_CLIENT_QT_DEPENDENCIES = [ |
| 108 | 'libqt5-qtsvg-devel', 'libqt5-qtwebengine-devel', 'libqt5-qtmultimedia-devel', |
| 109 | 'libqt5-qtdeclarative-devel', 'libQt5QuickControls2-devel', 'libqt5-qtquickcontrols' |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 110 | ] |
| 111 | |
Alexandre Lision | c7336d3 | 2017-11-18 12:19:38 -0500 | [diff] [blame] | 112 | DNF_DEPENDENCIES = [ |
Sébastien Blin | 4d94541 | 2020-09-30 14:53:17 -0400 | [diff] [blame] | 113 | 'autoconf', 'autoconf-archive', 'automake', 'cmake', 'make', 'speexdsp-devel', 'pulseaudio-libs-devel', |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 114 | 'libtool', 'dbus-devel', 'expat-devel', 'pcre-devel', 'doxygen', 'graphviz', |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 115 | 'yaml-cpp-devel', 'boost-devel', 'dbus-c++-devel', 'dbus-devel', |
philippegorley | 0657218 | 2018-07-30 10:35:15 -0400 | [diff] [blame] | 116 | 'libXext-devel', 'libXfixes-devel', 'yasm', |
Guillaume Roguez | 1c22e9a | 2017-05-31 19:30:19 -0400 | [diff] [blame] | 117 | 'speex-devel', 'chrpath', 'check', 'astyle', 'uuid-c++-devel', 'gettext-devel', |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 118 | 'gcc-c++', 'which', 'alsa-lib-devel', 'systemd-devel', 'libuuid-devel', |
| 119 | 'uuid-devel', 'gnutls-devel', 'nettle-devel', 'opus-devel', 'speexdsp-devel', |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 120 | 'yaml-cpp-devel', 'qt5-qtbase-devel', 'swig', 'jsoncpp-devel', |
| 121 | 'patch', 'libva-devel', 'openssl-devel', 'libvdpau-devel', 'msgpack-devel', |
| 122 | 'sqlite-devel', 'openssl-static', 'pandoc', 'nasm', 'qrencode-devel', 'NetworkManager-libnm-devel', |
| 123 | 'bzip2' |
| 124 | ] |
| 125 | |
| 126 | DNF_CLIENT_GNOME_DEPENDENCIES = [ |
| 127 | 'gtk3-devel', 'clutter-devel', 'clutter-gtk-devel', 'libnotify-devel','libappindicator-gtk3-devel', |
| 128 | 'webkitgtk4-devel', 'libcanberra-devel' |
| 129 | ] |
| 130 | |
| 131 | DNF_CLIENT_QT_DEPENDENCIES = [ |
| 132 | 'qt5-qtsvg-devel', 'qt5-qtwebengine-devel', 'qt5-qtmultimedia-devel', 'qt5-qtdeclarative-devel', |
| 133 | 'qt5-qtquickcontrols2-devel', 'qt5-qtquickcontrols' |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 134 | ] |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 135 | |
Alexandre Lision | c7336d3 | 2017-11-18 12:19:38 -0500 | [diff] [blame] | 136 | APT_DEPENDENCIES = [ |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 137 | 'autoconf', 'autoconf-archive', 'autopoint', 'automake', 'cmake', 'make', 'dbus', 'doxygen', 'graphviz', |
| 138 | 'g++', 'gettext', 'gnome-icon-theme-symbolic', 'libasound2-dev', 'libavcodec-dev', |
Maxim Cournoyer | ffc4019 | 2018-03-05 00:19:22 -0500 | [diff] [blame] | 139 | 'libavdevice-dev', 'libavformat-dev', 'libboost-dev', |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 140 | 'libclutter-gtk-1.0-dev', 'libcppunit-dev', 'libdbus-1-dev', |
David Côté-Tremblay | a81e132 | 2016-10-25 15:29:36 -0400 | [diff] [blame] | 141 | 'libdbus-c++-dev', 'libebook1.2-dev', 'libexpat1-dev', 'libgnutls28-dev', |
philippegorley | 6d77189 | 2018-09-24 10:45:28 -0400 | [diff] [blame] | 142 | 'libgtk-3-dev', 'libjack-dev', 'libnotify-dev', |
philippegorley | ae00a7d | 2018-07-31 11:49:24 -0400 | [diff] [blame] | 143 | 'libopus-dev', 'libpcre3-dev', 'libpulse-dev', 'libssl-dev', |
philippegorley | 0657218 | 2018-07-30 10:35:15 -0400 | [diff] [blame] | 144 | 'libspeex-dev', 'libspeexdsp-dev', 'libswscale-dev', 'libtool', |
Eden Abitbol | 221fee7 | 2019-09-19 14:31:24 -0400 | [diff] [blame] | 145 | 'libudev-dev', 'libyaml-cpp-dev', 'qtbase5-dev', 'libqt5sql5-sqlite', 'sip-tester', 'swig', |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 146 | 'uuid-dev', 'yasm', 'libjsoncpp-dev', 'libva-dev', 'libvdpau-dev', 'libmsgpack-dev', |
| 147 | 'pandoc', 'nasm', 'libqrencode-dev', 'libnm-dev', 'dpkg-dev' |
| 148 | ] |
| 149 | |
| 150 | APT_CLIENT_GNOME_DEPENDENCIES = [ |
Pier-Luc Thériault | 1fd50fa | 2021-10-30 10:03:17 -0400 | [diff] [blame] | 151 | 'libwebkit2gtk-4.0-dev', 'libayatana-appindicator3-dev', 'libcanberra-gtk3-dev' |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 152 | ] |
| 153 | |
| 154 | APT_CLIENT_QT_DEPENDENCIES = [ |
| 155 | 'qtmultimedia5-dev', 'libqt5svg5-dev', 'qtwebengine5-dev', 'qtdeclarative5-dev', |
| 156 | 'qtquickcontrols2-5-dev', 'qml-module-qtquick2', 'qml-module-qtquick-controls', |
| 157 | 'qml-module-qtquick-controls2', 'qml-module-qtquick-dialogs', |
| 158 | 'qml-module-qtquick-layouts', 'qml-module-qtquick-privatewidgets', |
| 159 | 'qml-module-qtquick-shapes', 'qml-module-qtquick-window2', |
| 160 | 'qml-module-qtquick-templates2', 'qml-module-qt-labs-platform', |
| 161 | 'qml-module-qtwebengine', 'qml-module-qtwebchannel' |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 162 | ] |
| 163 | |
Alexandre Lision | c7336d3 | 2017-11-18 12:19:38 -0500 | [diff] [blame] | 164 | PACMAN_DEPENDENCIES = [ |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 165 | 'autoconf', 'autoconf-archive', 'gettext', 'cmake', 'dbus', 'doxygen', 'graphviz', |
| 166 | 'gcc', 'ffmpeg', 'boost', 'cppunit', 'libdbus', 'dbus-c++', 'libe-book', 'expat', |
frisbee-w | d36686e | 2021-01-13 23:45:26 +0530 | [diff] [blame] | 167 | 'jack', 'opus', 'pcre', 'libpulse', 'speex', 'speexdsp', 'libtool', 'yaml-cpp', |
Edouard Denommee | 3f22ac5 | 2020-10-08 15:04:51 -0400 | [diff] [blame] | 168 | 'qt5-base', 'swig', 'yasm', 'qrencode', 'make', 'patch', 'pkg-config', |
frisbee-w | d36686e | 2021-01-13 23:45:26 +0530 | [diff] [blame] | 169 | 'automake', 'libva', 'libnm', 'libvdpau', 'openssl', 'pandoc', 'nasm' |
| 170 | ] |
| 171 | |
| 172 | PACMAN_CLIENT_GNOME_DEPENDENCIES = [ |
| 173 | 'clutter-gtk','gnome-icon-theme-symbolic', 'gtk3', 'libappindicator-gtk3', |
| 174 | 'libcanberra', 'libnotify', 'webkit2gtk' |
| 175 | ] |
| 176 | |
| 177 | PACMAN_CLIENT_QT_DEPENDENCIES = [ |
| 178 | 'qt5-declarative', 'qt5-graphicaleffects', 'qt5-multimedia', 'qt5-quickcontrols', |
| 179 | 'qt5-quickcontrols2', 'qt5-svg', 'qt5-tools', 'qt5-webengine' |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 180 | ] |
| 181 | |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 182 | OSX_DEPENDENCIES = [ |
Alexandre Lision | e656740 | 2016-11-15 09:54:55 -0500 | [diff] [blame] | 183 | 'autoconf', 'cmake', 'gettext', 'pkg-config', 'qt5', |
kkostiuk | eddeb55 | 2021-03-28 15:07:41 -0400 | [diff] [blame] | 184 | 'libtool', 'yasm', 'nasm', 'automake' |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 185 | ] |
| 186 | |
Alexandre Lision | e656740 | 2016-11-15 09:54:55 -0500 | [diff] [blame] | 187 | OSX_DEPENDENCIES_UNLINK = [ |
| 188 | 'autoconf*', 'cmake*', 'gettext*', 'pkg-config*', 'qt*', 'qt@5.*', |
kkostiuk | eddeb55 | 2021-03-28 15:07:41 -0400 | [diff] [blame] | 189 | 'libtool*', 'yasm*', 'nasm*', 'automake*', 'gnutls*', 'nettle*', 'msgpack*' |
Alexandre Lision | e656740 | 2016-11-15 09:54:55 -0500 | [diff] [blame] | 190 | ] |
| 191 | |
Thibault Wittemberg | 3c0d152 | 2017-07-05 11:03:38 -0400 | [diff] [blame] | 192 | IOS_DEPENDENCIES = [ |
Kateryna Kostiuk | 1ee68bb | 2017-08-09 15:57:48 -0400 | [diff] [blame] | 193 | 'autoconf', 'automake', 'cmake', 'yasm', 'libtool', |
kkostiuk | eddeb55 | 2021-03-28 15:07:41 -0400 | [diff] [blame] | 194 | 'pkg-config', 'gettext', 'swiftlint', 'swiftgen' |
Thibault Wittemberg | 3c0d152 | 2017-07-05 11:03:38 -0400 | [diff] [blame] | 195 | ] |
| 196 | |
Kateryna Kostiuk | 2e0422d | 2017-08-07 18:28:32 -0400 | [diff] [blame] | 197 | IOS_DEPENDENCIES_UNLINK = [ |
| 198 | 'autoconf*', 'automake*', 'cmake*', 'yasm*', 'libtool*', |
kkostiuk | eddeb55 | 2021-03-28 15:07:41 -0400 | [diff] [blame] | 199 | 'pkg-config*', 'gettext*', 'swiftlint*', 'swiftgen*' |
Kateryna Kostiuk | 2e0422d | 2017-08-07 18:28:32 -0400 | [diff] [blame] | 200 | ] |
| 201 | |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 202 | UNINSTALL_DAEMON_SCRIPT = [ |
| 203 | 'make -C daemon uninstall' |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 204 | ] |
| 205 | |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 206 | OSX_UNINSTALL_SCRIPT = [ |
| 207 | 'make -C daemon uninstall', |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 208 | 'rm -rf install/client-macosx' |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 209 | ] |
| 210 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 211 | def run_powersell_cmd(cmd): |
| 212 | p = subprocess.Popen(["powershell.exe", cmd], stdout=sys.stdout) |
| 213 | p.communicate() |
| 214 | p.wait() |
| 215 | return |
| 216 | |
| 217 | |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 218 | def write_qt_conf(path, qt5version=QT5_VERSION): |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 219 | # Add a configuration that can be supplied to qmake |
| 220 | # e.g. `qmake -qt=5.15 [mode] [options] [files]` |
Sébastien Blin | e98a5a2 | 2020-11-10 11:19:41 -0500 | [diff] [blame] | 221 | if path == '': |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 222 | return |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 223 | with open('/usr/share/qtchooser/' + qt5version + '.conf', 'w+') as fd: |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 224 | fd.write(path.rstrip('/') + '/bin\n') |
| 225 | fd.write(path.rstrip('/') + '/lib\n') |
| 226 | return |
| 227 | |
| 228 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 229 | def run_dependencies(args): |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 230 | if args.qt is not None: |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 231 | write_qt_conf(args.qt, args.qtver) |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 232 | |
| 233 | if args.distribution == WIN32_DISTRIBUTION_NAME: |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 234 | run_powersell_cmd( |
Andreas Traczyk | da29895 | 2020-08-19 15:44:11 -0400 | [diff] [blame] | 235 | 'Set-ExecutionPolicy Unrestricted; .\\scripts\\install-deps-windows.ps1') |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 236 | |
| 237 | elif args.distribution in APT_BASED_DISTROS: |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 238 | if args.qt is None: |
| 239 | APT_DEPENDENCIES.extend(APT_CLIENT_GNOME_DEPENDENCIES) |
| 240 | else: |
| 241 | APT_DEPENDENCIES.extend(APT_CLIENT_QT_DEPENDENCIES) |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 242 | execute_script( |
| 243 | APT_INSTALL_SCRIPT, |
| 244 | {"packages": ' '.join(map(shlex.quote, APT_DEPENDENCIES))} |
| 245 | ) |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 246 | |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 247 | elif args.distribution in DNF_BASED_DISTROS: |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 248 | if args.qt is None: |
| 249 | DNF_DEPENDENCIES.extend(DNF_CLIENT_GNOME_DEPENDENCIES) |
| 250 | else: |
| 251 | DNF_DEPENDENCIES.extend(DNF_CLIENT_QT_DEPENDENCIES) |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 252 | execute_script( |
| 253 | RPM_INSTALL_SCRIPT, |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 254 | {"packages": ' '.join(map(shlex.quote, DNF_DEPENDENCIES))} |
Alexandre Lision | 6b2ca8b | 2016-03-08 15:18:00 -0500 | [diff] [blame] | 255 | ) |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 256 | |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 257 | elif args.distribution in PACMAN_BASED_DISTROS: |
frisbee-w | d36686e | 2021-01-13 23:45:26 +0530 | [diff] [blame] | 258 | if args.qt is None: |
| 259 | PACMAN_DEPENDENCIES.extend(PACMAN_CLIENT_GNOME_DEPENDENCIES) |
| 260 | else: |
| 261 | PACMAN_DEPENDENCIES.extend(PACMAN_CLIENT_QT_DEPENDENCIES) |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 262 | execute_script( |
| 263 | PACMAN_INSTALL_SCRIPT, |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 264 | {"packages": ' '.join(map(shlex.quote, PACMAN_DEPENDENCIES))} |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 265 | ) |
| 266 | |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 267 | elif args.distribution in ZYPPER_BASED_DISTROS: |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 268 | if args.qt is None: |
| 269 | ZYPPER_DEPENDENCIES.extend(ZYPPER_CLIENT_GNOME_DEPENDENCIES) |
| 270 | else: |
| 271 | ZYPPER_DEPENDENCIES.extend(ZYPPER_CLIENT_QT_DEPENDENCIES) |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 272 | execute_script( |
| 273 | ZYPPER_INSTALL_SCRIPT, |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 274 | {"packages": ' '.join(map(shlex.quote, ZYPPER_DEPENDENCIES))} |
Stepan Salenikovich | a2e1b81 | 2016-07-21 19:04:32 -0400 | [diff] [blame] | 275 | ) |
| 276 | |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 277 | elif args.distribution == OSX_DISTRIBUTION_NAME: |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 278 | execute_script( |
Alexandre Lision | e656740 | 2016-11-15 09:54:55 -0500 | [diff] [blame] | 279 | BREW_UNLINK_SCRIPT, |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 280 | {"packages": ' '.join(map(shlex.quote, OSX_DEPENDENCIES_UNLINK))}, |
Andreas Traczyk | 0a43e01 | 2018-04-16 10:59:30 -0400 | [diff] [blame] | 281 | False |
Alexandre Lision | e656740 | 2016-11-15 09:54:55 -0500 | [diff] [blame] | 282 | ) |
| 283 | execute_script( |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 284 | BREW_INSTALL_SCRIPT, |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 285 | {"packages": ' '.join(map(shlex.quote, OSX_DEPENDENCIES))}, |
Andreas Traczyk | 0fabdf6 | 2018-08-13 11:43:16 -0400 | [diff] [blame] | 286 | False |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 287 | ) |
| 288 | |
Romain Bertozzi | dca37f0 | 2017-11-07 14:08:02 -0500 | [diff] [blame] | 289 | elif args.distribution == IOS_DISTRIBUTION_NAME: |
Thibault Wittemberg | 3c0d152 | 2017-07-05 11:03:38 -0400 | [diff] [blame] | 290 | execute_script( |
Kateryna Kostiuk | 2e0422d | 2017-08-07 18:28:32 -0400 | [diff] [blame] | 291 | BREW_UNLINK_SCRIPT, |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 292 | {"packages": ' '.join(map(shlex.quote, IOS_DEPENDENCIES_UNLINK))}, |
Andreas Traczyk | 0a43e01 | 2018-04-16 10:59:30 -0400 | [diff] [blame] | 293 | False |
Kateryna Kostiuk | 2e0422d | 2017-08-07 18:28:32 -0400 | [diff] [blame] | 294 | ) |
| 295 | execute_script( |
Thibault Wittemberg | 3c0d152 | 2017-07-05 11:03:38 -0400 | [diff] [blame] | 296 | BREW_INSTALL_SCRIPT, |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 297 | {"packages": ' '.join(map(shlex.quote, IOS_DEPENDENCIES))}, |
Andreas Traczyk | 0fabdf6 | 2018-08-13 11:43:16 -0400 | [diff] [blame] | 298 | False |
Thibault Wittemberg | 3c0d152 | 2017-07-05 11:03:38 -0400 | [diff] [blame] | 299 | ) |
| 300 | |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 301 | elif args.distribution == ANDROID_DISTRIBUTION_NAME: |
Romain Bertozzi | b21dc57 | 2016-03-29 15:36:40 -0400 | [diff] [blame] | 302 | print("The Android version does not need more dependencies.\nPlease continue with the --install instruction.") |
| 303 | sys.exit(1) |
| 304 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 305 | elif args.distribution == WIN32_DISTRIBUTION_NAME: |
| 306 | print("The win32 version does not install dependencies with this script.\nPlease continue with the --install instruction.") |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 307 | sys.exit(1) |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 308 | elif args.distribution == 'guix': |
| 309 | print("Building the environment defined in 'guix/manifest.scm'...") |
| 310 | execute_script(['mkdir -p ~/.config/guix/profiles', |
| 311 | ('guix time-machine --channels=guix/channels.scm -- ' |
| 312 | 'package --manifest=guix/manifest.scm ' |
| 313 | '--profile=$HOME/.config/guix/profiles/jami')]) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 314 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 315 | else: |
Sébastien Blin | 46841cf | 2020-12-24 14:01:25 -0500 | [diff] [blame] | 316 | print("Not yet implemented for current distribution (%s). Please continue with the --install instruction. Note: You may need to install some dependencies manually." % |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 317 | args.distribution) |
| 318 | sys.exit(1) |
| 319 | |
| 320 | |
Alexandre Lision | 53048b2 | 2016-04-06 19:34:08 -0400 | [diff] [blame] | 321 | def run_init(): |
Guillaume Roguez | bc7e228 | 2017-06-08 21:28:51 -0400 | [diff] [blame] | 322 | # Extract modules path from '.gitmodules' file |
| 323 | module_names = [] |
| 324 | with open('.gitmodules') as fd: |
| 325 | for line in fd.readlines(): |
| 326 | if line.startswith('[submodule "'): |
| 327 | module_names.append(line[line.find('"')+1:line.rfind('"')]) |
| 328 | |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 329 | subprocess.run(["git", "submodule", "update", "--init"], check=True) |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 330 | subprocess.run(["git", "submodule", "foreach", |
| 331 | "git checkout master && git pull"], check=True) |
Guillaume Roguez | bc7e228 | 2017-06-08 21:28:51 -0400 | [diff] [blame] | 332 | for name in module_names: |
| 333 | copy_file("./scripts/commit-msg", ".git/modules/"+name+"/hooks") |
Alexandre Lision | 53048b2 | 2016-04-06 19:34:08 -0400 | [diff] [blame] | 334 | |
agsantos | 3134d3e | 2020-09-17 10:32:32 -0400 | [diff] [blame] | 335 | module_names_to_format = ['daemon', 'lrc', 'client-qt', 'plugins'] |
Andreas Traczyk | 81c61b6 | 2020-08-18 15:18:22 -0400 | [diff] [blame] | 336 | for name in module_names_to_format: |
| 337 | execute_script( |
| 338 | ['./scripts/format.sh --install %(path)s'], |
| 339 | {"path": ".git/modules/" + name + "/hooks"} |
| 340 | ) |
| 341 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 342 | |
Alexandre Lision | 53048b2 | 2016-04-06 19:34:08 -0400 | [diff] [blame] | 343 | def copy_file(src, dest): |
| 344 | print("Copying:" + src + " to " + dest) |
| 345 | try: |
| 346 | shutil.copy2(src, dest) |
| 347 | # eg. src and dest are the same file |
| 348 | except shutil.Error as e: |
| 349 | print('Error: %s' % e) |
| 350 | # eg. source or destination doesn't exist |
| 351 | except IOError as e: |
| 352 | print('Error: %s' % e.strerror) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 353 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 354 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 355 | def run_install(args): |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 356 | # Platforms with special compilation scripts |
| 357 | if args.distribution == IOS_DISTRIBUTION_NAME: |
| 358 | return subprocess.run(["./compile-ios.sh"], cwd="./client-ios", check=True) |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 359 | elif args.distribution == ANDROID_DISTRIBUTION_NAME: |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 360 | return subprocess.run(["./compile.sh"], cwd="./client-android", check=True) |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 361 | elif args.distribution == WIN32_DISTRIBUTION_NAME: |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 362 | return subprocess.run([ |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 363 | sys.executable, os.path.join( |
| 364 | os.getcwd(), "scripts/build-windows.py"), |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 365 | "--toolset", args.toolset, |
Ming Rui Zhang | 310e7f7 | 2019-12-31 11:11:03 -0500 | [diff] [blame] | 366 | "--sdk", args.sdk, |
| 367 | "--qtver", args.qtver |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 368 | ], check=True) |
| 369 | |
| 370 | # Unix-like platforms |
| 371 | environ = os.environ.copy() |
Ming Rui Zhang | 310e7f7 | 2019-12-31 11:11:03 -0500 | [diff] [blame] | 372 | |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 373 | install_args = ['-p', str(multiprocessing.cpu_count())] |
| 374 | if args.static: |
| 375 | install_args.append('-s') |
| 376 | if args.global_install: |
| 377 | install_args.append('-g') |
Maxim Cournoyer | 2f250c1 | 2021-03-09 11:38:10 -0500 | [diff] [blame] | 378 | if args.prefix: |
Alexander Schlarb | 1a704bb | 2019-12-13 17:13:01 +0100 | [diff] [blame] | 379 | install_args += ('-P', args.prefix) |
Alexander Schlarb | 62004f2 | 2019-12-13 16:50:00 +0100 | [diff] [blame] | 380 | if not args.priv_install: |
| 381 | install_args.append('-u') |
Maxim Cournoyer | 2f250c1 | 2021-03-09 11:38:10 -0500 | [diff] [blame] | 382 | if args.debug: |
| 383 | install_args.append('-d') |
Mohamed Chibani | 3e80a82 | 2021-10-27 10:57:35 -0400 | [diff] [blame] | 384 | if args.no_libwrap: |
| 385 | install_args.append('-W') |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 386 | |
| 387 | if args.distribution == OSX_DISTRIBUTION_NAME: |
| 388 | # The `universal_newlines` parameter has been renamed to `text` in |
| 389 | # Python 3.7+ and triggering automatical binary to text conversion is |
| 390 | # what it actually does |
| 391 | proc = subprocess.run(["brew", "--prefix", "qt5"], |
| 392 | stdout=subprocess.PIPE, check=True, |
| 393 | universal_newlines=True) |
Ming Rui Zhang | 310e7f7 | 2019-12-31 11:11:03 -0500 | [diff] [blame] | 394 | |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 395 | environ['CMAKE_PREFIX_PATH'] = proc.stdout.rstrip("\n") |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 396 | environ['CONFIGURE_FLAGS'] = '--without-dbus' |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 397 | install_args += ("-c", "client-macosx") |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 398 | else: |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 399 | if args.distribution in ZYPPER_BASED_DISTROS: |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 400 | # fix jsoncpp pkg-config bug, remove when jsoncpp package bumped |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 401 | environ['JSONCPP_LIBS'] = "-ljsoncpp" |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 402 | if args.qt is None: |
| 403 | install_args += ("-c", "client-gnome") |
| 404 | else: |
| 405 | install_args += ("-c", "client-qt") |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 406 | install_args += ("-q", args.qtver) |
| 407 | install_args += ("-Q", args.qt) |
Alexander Schlarb | 2d6169b | 2019-12-13 16:38:46 +0100 | [diff] [blame] | 408 | |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 409 | command = ['bash', 'scripts/install.sh'] + install_args |
| 410 | |
| 411 | if args.distribution == 'guix': |
| 412 | if args.global_install: |
| 413 | print('error: global install is not supported when using Guix.') |
| 414 | sys.exit(1) |
| 415 | # Run the build in an isolated container. |
| 416 | share_tarballs_args = [] |
| 417 | if 'TARBALLS' in os.environ: |
| 418 | share_tarballs_args = ['--preserve=TARBALLS', |
| 419 | f'--share={os.environ["TARBALLS"]}'] |
| 420 | # Note: we must expose /gnu/store because /etc/ssl/certs |
| 421 | # contains certs that are symlinks to store items. |
| 422 | command = ['guix', 'time-machine', '-C', 'guix/channels.scm', '--', |
| 423 | 'environment', '--manifest=guix/manifest.scm', |
| 424 | '--expose=/gnu/store', '--expose=/etc/ssl/certs', |
| 425 | '--expose=/usr/bin/env', |
| 426 | '--container', '--network'] + share_tarballs_args \ |
| 427 | + ['--'] + command |
| 428 | |
| 429 | print(f'info: Building/installing using the command: {" ".join(command)}') |
| 430 | return subprocess.run(command, env=environ, check=True) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 431 | |
| 432 | |
| 433 | def run_uninstall(args): |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 434 | if args.distribution == OSX_DISTRIBUTION_NAME: |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 435 | execute_script(OSX_UNINSTALL_SCRIPT) |
| 436 | else: |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 437 | execute_script(UNINSTALL_DAEMON_SCRIPT) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 438 | |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 439 | CLIENT_SUFFIX = 'qt' if (args.qt is not None) else 'gnome' |
| 440 | INSTALL_DIR = '/build-global' if args.global_install else '/build-local' |
| 441 | |
| 442 | # Client needs to be uninstalled first |
| 443 | if (os.path.exists('./client-' + CLIENT_SUFFIX + INSTALL_DIR)): |
| 444 | UNINSTALL_CLIENT = [ |
| 445 | 'make -C client-' + CLIENT_SUFFIX + INSTALL_DIR + ' uninstall', |
| 446 | 'rm -rf ./client-' + CLIENT_SUFFIX + INSTALL_DIR |
| 447 | ] |
| 448 | execute_script(UNINSTALL_CLIENT) |
| 449 | |
| 450 | if (os.path.exists('./lrc' + INSTALL_DIR)): |
| 451 | UNINSTALL_LRC = [ |
| 452 | 'make -C lrc' + INSTALL_DIR + ' uninstall', |
| 453 | 'rm -rf ./lrc' + INSTALL_DIR |
| 454 | ] |
| 455 | execute_script(UNINSTALL_LRC) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 456 | |
Maxim Cournoyer | 6b364a9 | 2021-03-12 16:26:09 -0500 | [diff] [blame] | 457 | |
| 458 | def run_clean(): |
| 459 | execute_script(['git clean -xfdd', |
| 460 | 'git submodule foreach git clean -xfdd']) |
| 461 | |
| 462 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 463 | def run_run(args): |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 464 | if args.distribution == OSX_DISTRIBUTION_NAME: |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 465 | subprocess.Popen( |
| 466 | ["install/client-macosx/Ring.app/Contents/MacOS/Ring"]) |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 467 | return True |
| 468 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 469 | run_env = os.environ |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 470 | run_env['LD_LIBRARY_PATH'] = run_env.get( |
| 471 | 'LD_LIBRARY_PATH', '') + ":install/lrc/lib" |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 472 | |
| 473 | try: |
Maxim Cournoyer | 2827b03 | 2021-06-09 14:21:36 -0400 | [diff] [blame] | 474 | jamid_log = open("daemon.log", 'a') |
| 475 | jamid_log.write('=== Starting daemon (%s) ===' % |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 476 | time.strftime("%d/%m/%Y %H:%M:%S")) |
Maxim Cournoyer | 2827b03 | 2021-06-09 14:21:36 -0400 | [diff] [blame] | 477 | jamid_process = subprocess.Popen( |
Maxim Cournoyer | 5c3c23d | 2021-04-07 13:58:13 -0400 | [diff] [blame] | 478 | ["./install/daemon/libexec/jamid", "-c", "-d"], |
Maxim Cournoyer | 2827b03 | 2021-06-09 14:21:36 -0400 | [diff] [blame] | 479 | stdout=jamid_log, |
| 480 | stderr=jamid_log |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 481 | ) |
| 482 | |
| 483 | with open('daemon.pid', 'w') as f: |
Maxim Cournoyer | 2827b03 | 2021-06-09 14:21:36 -0400 | [diff] [blame] | 484 | f.write(str(jamid_process.pid)+'\n') |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 485 | |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 486 | client_suffix = "" |
| 487 | if args.qt is not None: |
| 488 | client_suffix += "qt" |
| 489 | else: |
| 490 | client_suffix += "gnome" |
| 491 | client_log = open("jami-" + client_suffix + ".log", 'a') |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 492 | client_log.write('=== Starting client (%s) ===' % |
| 493 | time.strftime("%d/%m/%Y %H:%M:%S")) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 494 | client_process = subprocess.Popen( |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 495 | ["./install/client-" + client_suffix + |
| 496 | "/bin/jami-" + client_suffix, "-d"], |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 497 | stdout=client_log, |
| 498 | stderr=client_log, |
| 499 | env=run_env |
| 500 | ) |
| 501 | |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 502 | with open("jami-" + client_suffix + ".pid", 'w') as f: |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 503 | f.write(str(client_process.pid)+'\n') |
| 504 | |
| 505 | if args.debug: |
Maxim Cournoyer | 5c3c23d | 2021-04-07 13:58:13 -0400 | [diff] [blame] | 506 | subprocess.call(['gdb', './install/daemon/libexec/jamid']) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 507 | |
Maxim Cournoyer | d0342d2 | 2021-03-09 10:23:39 -0500 | [diff] [blame] | 508 | if not args.background: |
Maxim Cournoyer | 2827b03 | 2021-06-09 14:21:36 -0400 | [diff] [blame] | 509 | jamid_process.wait() |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 510 | client_process.wait() |
| 511 | |
| 512 | except KeyboardInterrupt: |
| 513 | print("\nCaught KeyboardInterrupt...") |
| 514 | |
| 515 | finally: |
| 516 | if args.background == False: |
| 517 | try: |
| 518 | # Only kill the processes if they are running, as they could |
| 519 | # have been closed by the user. |
| 520 | print("Killing processes...") |
Maxim Cournoyer | 2827b03 | 2021-06-09 14:21:36 -0400 | [diff] [blame] | 521 | jamid_log.close() |
| 522 | if jamid_process.poll() is None: |
| 523 | jamid_process.kill() |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 524 | client_log.close() |
| 525 | if client_process.poll() is None: |
| 526 | client_process.kill() |
| 527 | except UnboundLocalError: |
| 528 | # Its okay! We crashed before we could start a process or open a |
| 529 | # file. All that matters is that we close files and kill processes |
| 530 | # in the right order. |
| 531 | pass |
Alexandre Lision | 6c94929 | 2016-03-04 16:56:17 -0500 | [diff] [blame] | 532 | return True |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 533 | |
| 534 | |
| 535 | def run_stop(args): |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 536 | client_suffix = "qt" if (args.qt is not None) else "gnome" |
| 537 | STOP_SCRIPT = [ |
Maxim Cournoyer | 2f250c1 | 2021-03-09 11:38:10 -0500 | [diff] [blame] | 538 | 'xargs kill < jami-' + client_suffix + '.pid', |
| 539 | 'xargs kill < daemon.pid' |
ababi | 8f4390a | 2021-01-27 11:04:21 +0100 | [diff] [blame] | 540 | ] |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 541 | execute_script(STOP_SCRIPT) |
| 542 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 543 | |
Andreas Traczyk | 0a43e01 | 2018-04-16 10:59:30 -0400 | [diff] [blame] | 544 | def execute_script(script, settings=None, fail=True): |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 545 | if settings == None: |
| 546 | settings = {} |
| 547 | for line in script: |
| 548 | line = line % settings |
| 549 | rv = os.system(line) |
Andreas Traczyk | 0a43e01 | 2018-04-16 10:59:30 -0400 | [diff] [blame] | 550 | if rv != 0 and fail == True: |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 551 | print('Error executing script! Exit code: %s' % |
| 552 | rv, file=sys.stderr) |
Alexandre Lision | 1846722 | 2017-01-11 09:41:54 -0500 | [diff] [blame] | 553 | sys.exit(1) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 554 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 555 | |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 556 | def has_guix(): |
| 557 | """Check whether the 'guix' command is available.""" |
| 558 | with open(os.devnull, 'w') as f: |
| 559 | try: |
| 560 | subprocess.run(["sh", "-c", "command -v guix"], |
| 561 | check=True, stdout=f) |
| 562 | except subprocess.CalledProcessError: |
| 563 | return False |
| 564 | else: |
| 565 | return True |
| 566 | |
| 567 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 568 | def validate_args(parsed_args): |
| 569 | """Validate the args values, exit if error is found""" |
| 570 | |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 571 | # Filter unsupported distributions. |
Alexander Schlarb | bddc1a2 | 2019-12-13 16:02:46 +0100 | [diff] [blame] | 572 | supported_distros = [ |
| 573 | ANDROID_DISTRIBUTION_NAME, OSX_DISTRIBUTION_NAME, IOS_DISTRIBUTION_NAME, |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 574 | WIN32_DISTRIBUTION_NAME, 'guix' |
Alexander Schlarb | bddc1a2 | 2019-12-13 16:02:46 +0100 | [diff] [blame] | 575 | ] + APT_BASED_DISTROS + DNF_BASED_DISTROS + PACMAN_BASED_DISTROS \ |
| 576 | + ZYPPER_BASED_DISTROS + FLATPAK_BASED_RUNTIMES |
Simon Zeni | 11ac349 | 2016-06-15 10:07:27 -0400 | [diff] [blame] | 577 | |
Maxim Cournoyer | f69e9fa | 2021-03-08 15:10:11 -0500 | [diff] [blame] | 578 | if (parsed_args.distribution == 'no-check' |
| 579 | or 'JAMI_BUILD_NO_CHECK' in os.environ): |
| 580 | return |
| 581 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 582 | if parsed_args.distribution not in supported_distros: |
Maxim Cournoyer | f69e9fa | 2021-03-08 15:10:11 -0500 | [diff] [blame] | 583 | print(f'WARNING: Distribution \'{parsed_args.distribution}\' is not ' |
| 584 | f'supported. Choose one of: {", ".join(supported_distros)}. ' |
| 585 | 'Alternatively, you may force execution of this script ' |
| 586 | 'by providing the \'--distribution=no-check\' argument or by ' |
| 587 | 'exporting the JAMI_BUILD_NO_CHECK environment variable.', |
| 588 | file=sys.stderr) |
| 589 | sys.exit(1) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 590 | |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 591 | # The Qt client support will be added incrementally. |
| 592 | if parsed_args.qt is not None: |
| 593 | supported_qt_distros = [ |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 594 | 'guix', |
frisbee-w | d36686e | 2021-01-13 23:45:26 +0530 | [diff] [blame] | 595 | WIN32_DISTRIBUTION_NAME |
| 596 | ] + APT_BASED_DISTROS + DNF_BASED_DISTROS + PACMAN_BASED_DISTROS |
| 597 | |
| 598 | if parsed_args.distribution not in supported_qt_distros: |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 599 | print('Distribution \'{0}\' not supported when building the Qt client.' |
| 600 | '\nChoose one of: {1}'.format( |
| 601 | parsed_args.distribution, ', '.join(supported_qt_distros) |
| 602 | ), file=sys.stderr) |
| 603 | sys.exit(1) |
| 604 | |
| 605 | # The windows client can only be built on a Windows 10 host. |
| 606 | if parsed_args.distribution == WIN32_DISTRIBUTION_NAME: |
| 607 | if platform.release() != '10': |
| 608 | print('Windows version must be built on Windows 10') |
| 609 | sys.exit(1) |
| 610 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 611 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 612 | def parse_args(): |
| 613 | ap = argparse.ArgumentParser(description="Ring build tool") |
| 614 | |
| 615 | ga = ap.add_mutually_exclusive_group(required=True) |
| 616 | ga.add_argument( |
Alexandre Lision | 53048b2 | 2016-04-06 19:34:08 -0400 | [diff] [blame] | 617 | '--init', action='store_true', |
| 618 | help='Init Ring repository') |
| 619 | ga.add_argument( |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 620 | '--dependencies', action='store_true', |
| 621 | help='Install ring build dependencies') |
| 622 | ga.add_argument( |
| 623 | '--install', action='store_true', |
| 624 | help='Build and install Ring') |
| 625 | ga.add_argument( |
Maxim Cournoyer | 6b364a9 | 2021-03-12 16:26:09 -0500 | [diff] [blame] | 626 | '--clean', action='store_true', |
| 627 | help='Call "git clean" on every repository of the project' |
| 628 | ) |
| 629 | ga.add_argument( |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 630 | '--uninstall', action='store_true', |
| 631 | help='Uninstall Ring') |
| 632 | ga.add_argument( |
| 633 | '--run', action='store_true', |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 634 | help='Run the Ring daemon and client') |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 635 | ga.add_argument( |
| 636 | '--stop', action='store_true', |
| 637 | help='Stop the Ring processes') |
| 638 | |
Hugo Lefeuvre | b3bb956 | 2018-07-16 13:36:52 -0400 | [diff] [blame] | 639 | ap.add_argument('--distribution') |
Alexander Schlarb | 1a704bb | 2019-12-13 17:13:01 +0100 | [diff] [blame] | 640 | ap.add_argument('--prefix') |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 641 | ap.add_argument('--static', default=False, action='store_true') |
| 642 | ap.add_argument('--global-install', default=False, action='store_true') |
Maxim Cournoyer | 2f250c1 | 2021-03-09 11:38:10 -0500 | [diff] [blame] | 643 | ap.add_argument('--debug', default=False, action='store_true', |
| 644 | help='Build with debug support; run in GDB') |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 645 | ap.add_argument('--background', default=False, action='store_true') |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 646 | ap.add_argument('--no-priv-install', dest='priv_install', |
| 647 | default=True, action='store_false') |
| 648 | ap.add_argument('--qt', nargs='?', const='', type=str, |
ababi | 3e26f3d | 2020-12-04 15:16:09 +0100 | [diff] [blame] | 649 | help='Build the Qt client with the Qt path supplied') |
| 650 | ap.add_argument('--qtver', default=QT5_VERSION, |
| 651 | help='Sets the Qt version to build with') |
Mohamed Chibani | 3e80a82 | 2021-10-27 10:57:35 -0400 | [diff] [blame] | 652 | ap.add_argument('--no-libwrap', dest='no_libwrap', |
| 653 | default=False, action='store_true', |
| 654 | help='Disable libwrap. Also set --disable-shared option to daemon configure') |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 655 | |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 656 | dist = choose_distribution() |
Maxim Cournoyer | f69e9fa | 2021-03-08 15:10:11 -0500 | [diff] [blame] | 657 | |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 658 | if dist == WIN32_DISTRIBUTION_NAME: |
| 659 | ap.add_argument('--toolset', default=win_toolset_default, type=str, |
| 660 | help='Windows use only, specify Visual Studio toolset version') |
| 661 | ap.add_argument('--sdk', default=win_sdk_default, type=str, |
| 662 | help='Windows use only, specify Windows SDK version') |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 663 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 664 | parsed_args = ap.parse_args() |
Alexandre Lision | e3d89bc | 2016-03-08 11:24:56 -0500 | [diff] [blame] | 665 | |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 666 | if parsed_args.distribution: |
Hugo Lefeuvre | b3bb956 | 2018-07-16 13:36:52 -0400 | [diff] [blame] | 667 | parsed_args.distribution = parsed_args.distribution.lower() |
| 668 | else: |
Andreas Traczyk | 5ec47bc | 2020-08-10 09:32:47 -0400 | [diff] [blame] | 669 | parsed_args.distribution = dist |
Anthony Léonard | 789acd4 | 2016-09-12 15:06:35 -0400 | [diff] [blame] | 670 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 671 | validate_args(parsed_args) |
| 672 | |
| 673 | return parsed_args |
| 674 | |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 675 | |
Alexandre Lision | e3d89bc | 2016-03-08 11:24:56 -0500 | [diff] [blame] | 676 | def choose_distribution(): |
| 677 | system = platform.system().lower() |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 678 | |
Alexandre Lision | e3d89bc | 2016-03-08 11:24:56 -0500 | [diff] [blame] | 679 | if system == "linux" or system == "linux2": |
VietKen | 6c5ed45 | 2016-10-18 17:01:18 -0400 | [diff] [blame] | 680 | if os.path.isfile("/etc/arch-release"): |
Hugo Lefeuvre | b3bb956 | 2018-07-16 13:36:52 -0400 | [diff] [blame] | 681 | return "arch" |
Maxim Cournoyer | f69e9fa | 2021-03-08 15:10:11 -0500 | [diff] [blame] | 682 | try: |
| 683 | with open("/etc/os-release") as f: |
| 684 | for line in f: |
| 685 | k, v = line.split("=") |
| 686 | if k.strip() == 'ID': |
| 687 | return v.strip().replace('"', '').split(' ')[0] |
| 688 | except FileNotFoundError: |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 689 | if has_guix(): |
| 690 | return 'guix' |
Maxim Cournoyer | f69e9fa | 2021-03-08 15:10:11 -0500 | [diff] [blame] | 691 | return 'Unknown' |
Alexandre Lision | e3d89bc | 2016-03-08 11:24:56 -0500 | [diff] [blame] | 692 | elif system == "darwin": |
Alexandre Lision | 2adcfaa | 2017-11-18 11:43:37 -0500 | [diff] [blame] | 693 | return OSX_DISTRIBUTION_NAME |
Andreas Traczyk | 0f0d7ff | 2019-09-02 21:09:17 -0400 | [diff] [blame] | 694 | elif system == "windows": |
| 695 | return WIN32_DISTRIBUTION_NAME |
Alexandre Lision | e3d89bc | 2016-03-08 11:24:56 -0500 | [diff] [blame] | 696 | |
| 697 | return 'Unknown' |
| 698 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 699 | |
| 700 | def main(): |
| 701 | parsed_args = parse_args() |
| 702 | |
| 703 | if parsed_args.dependencies: |
| 704 | run_dependencies(parsed_args) |
| 705 | |
Alexandre Lision | 53048b2 | 2016-04-06 19:34:08 -0400 | [diff] [blame] | 706 | elif parsed_args.init: |
| 707 | run_init() |
Maxim Cournoyer | 6b364a9 | 2021-03-12 16:26:09 -0500 | [diff] [blame] | 708 | elif parsed_args.clean: |
| 709 | run_clean() |
Alexandre Lision | 53048b2 | 2016-04-06 19:34:08 -0400 | [diff] [blame] | 710 | |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 711 | elif parsed_args.install: |
| 712 | run_install(parsed_args) |
| 713 | |
| 714 | elif parsed_args.uninstall: |
| 715 | run_uninstall(parsed_args) |
| 716 | |
| 717 | elif parsed_args.run: |
Maxim Cournoyer | e55531c | 2021-03-08 23:05:48 -0500 | [diff] [blame] | 718 | if (parsed_args.distribution == 'guix' |
| 719 | and 'GUIX_ENVIRONMENT' not in os.environ): |
| 720 | if parsed_args.qt is not None: |
| 721 | print('FIXME: Qt fails loading QML modules due to ' |
| 722 | 'https://issues.guix.gnu.org/47655') |
| 723 | # Relaunch this script, this time in a pure Guix environment. |
| 724 | guix_args = ['time-machine', '--channels=guix/channels.scm', |
| 725 | '--', 'environment', '--pure', |
| 726 | # to allow pulseaudio to connect to an existing server |
| 727 | "-E", "XAUTHORITY", "-E", "XDG_RUNTIME_DIR", |
| 728 | '--manifest=guix/manifest.scm', '--'] |
| 729 | args = sys.argv + ['--distribution=guix'] |
| 730 | print('Running in a guix environment spawned with: guix {}' |
| 731 | .format(str.join(' ', guix_args + args))) |
| 732 | os.execlp('guix', 'guix', *(guix_args + args)) |
| 733 | else: |
| 734 | run_run(parsed_args) |
aviau | 6c85310 | 2016-02-26 14:34:41 -0500 | [diff] [blame] | 735 | |
| 736 | elif parsed_args.stop: |
| 737 | run_stop(parsed_args) |
| 738 | |
| 739 | |
| 740 | if __name__ == "__main__": |
| 741 | main() |