├── .gitignore ├── README.md ├── buildicu.sh ├── buildifw_qt5.sh ├── buildlinguist.sh ├── buildllvm.sh ├── buildmaster.sh ├── buildqmllive.sh ├── buildqt5.sh ├── buildqtc.sh ├── copy.sh ├── defaults.sh ├── file-information.sh ├── hack-snapshots-cow.sh ├── make-archive-meta.sh ├── make-sb2-image-meta.sh ├── patches ├── qtdeclarative-windows-python-under-program-files.patch └── qttools-lupdate-Process-mjs-files.patch ├── prune-shared.sh ├── refresh-sdk-repos.sh ├── sdk-setup-qa.sh ├── seccomp.json ├── setup-buildengine.sh ├── setup-buildenv.py ├── setup-documentation.sh ├── setup-emulator.sh ├── setup-sb2-images.sh └── utils.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## SDK Build Scripts 2 | 3 | ### Overview 4 | 5 | The scripts in this project are used to build Sailfish SDK in its 6 | production environment. They have some assumptions about the host 7 | environment, but may offer command line options for changing the 8 | default values. The scripts can act as a starting point for adapting 9 | them for personal use if so desired. 10 | 11 | Building Qt is only necessary once and whenever patches are 12 | applied, otherwise they can be left in the built state and utilized in 13 | subsequent Qt Creator builds. 14 | 15 | Static Qt build is required for Installer Framework, dynamic Qt build is 16 | required for Qt Creator and other tools coming with the SDK. 17 | 18 | ### Scripts 19 | 20 | Most of the scripts offer a `--help` option. 21 | 22 | * `buildqt5.sh` - builds Qt 23 | * `buildqtc.sh` - builds Qt Creator and cross-gdb for *i486* and *armv7hl* architectures 24 | * `buildicu.sh` - builds the ICU library for Linux and Windows (required for Webkit) 25 | * `buildifw.sh` - builds the Qt Installer Framework binaries 26 | * `buildmaster.sh` - start one or more build tasks in a build host 27 | 28 | The other scripts are various helper scripts mostly to package files 29 | into a format suitable for the Installer FW. 30 | 31 | ### Build hosts 32 | 33 | The SDK builds are made in the following host environments: 34 | 35 | * Mac: OS X 10.10 36 | * Linux: Ubuntu 16.04 32/64 bit 37 | * Windows: Windows 7 32 bit 38 | 39 | `These are also the oldest host operating system versions the SDK is supported in.` 40 | 41 | ### Qt versions required for build 42 | 43 | * Qt5 from `http://download.qt.io/archive/qt/5.6/5.6.2/single/` 44 | * Qt Installer FW from `https://github.com/sailfishos/qt-installer-framework` branch `master` 45 | 46 | ### ICU version 47 | 48 | ICU library is required for building Webkit in Linux and in Windows. 49 | 50 | For Linux build from sources using the `buildicu.sh` script: 51 | 52 | * http://download.icu-project.org/files/icu4c/4.2.1/icu4c-4_2_1-src.tgz 53 | 54 | For Windows use a pre-built package: 55 | 56 | * http://download.icu-project.org/files/icu4c/4.8.1.1/icu4c-4_8_1_1-Win32-msvc10.zip 57 | 58 | ### Linux 59 | 60 | The following additional packages are required in Ubuntu 16.04 61 | 62 | * `build-essential` `p7zip-full` `git` `libgtk2.0-dev` `chrpath` `libncurses5-dev` `libdbus-1-dev` 63 | `ruby` `libgl1-mesa-dev` `"^libxcb.*"` `libx11-xcb-dev` `libxrender-dev` `libxi-dev` `flex` 64 | `bison` `gperf` `patchelf` 65 | 66 | ### Mac 67 | 68 | The following additional software is required in the build Mac: 69 | 70 | * [Xcode 6 or 7][9], available on the Mac App Store 71 | * `p7zip` and `wget` installed via [MacPorts][1] 72 | 73 | [9]: https://itunes.apple.com/fi/app/xcode/id497799835?mt=12 74 | [1]: https://www.macports.org/ 75 | 76 | The build Mac should be prepared for command line development. To make sure 77 | this is the case, please refer to [Technical Note TN2339][11] "Building from 78 | the Command Line with Xcode FAQ", available in the Apple Mac Developer Library. 79 | 80 | [11]: https://developer.apple.com/library/mac/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588 81 | 82 | By default, the build scripts use Qt 5.6.2. To build a different version of Qt, 83 | set the `DEF_QT_VER` variable in the `defaults.sh` script to another version, e.g.: 84 | 85 | ``` 86 | DEF_QT_VER=5.8.0 87 | ``` 88 | 89 | When building p7zip, follow the BUILD instructions in the accompanying README 90 | file. However, to build p7zip (as of writing version 9.38.1) on OS X 10.10 with 91 | Xcode 6, the architecture-specific makefile needs to be modified to use the 92 | correct path for the command line tools. After preparing the makefile with: 93 | 94 | ``` 95 | $ cp makefile.macosx_llvm_64bits makefile.machine 96 | ``` 97 | 98 | change the compiler paths in `makefile.machine` from: 99 | 100 | ``` 101 | CXX=/Developer/usr/bin/llvm-g++ 102 | CC=/Developer/usr/bin/llvm-gcc 103 | ``` 104 | 105 | to the paths used by Xcode 6 command line tool shims: 106 | 107 | ``` 108 | CXX=/usr/bin/llvm-g++ 109 | CC=/usr/bin/llvm-gcc 110 | ``` 111 | 112 | ### Windows 113 | 114 | Windows build uses [Visual Studio Express 2015 for Windows Desktop][2] and [MinGW][4] compilers in a bash 115 | shell provided by a combination of [msysgit][3] and MinGW environments. Also [7-Zip][5] is required on the command line. 116 | 117 | Other build requirements include `perl`, `python` and `ruby` and they are documented [here][7]. 118 | 119 | pkg-config and its dependencies (check buildqtc.sh) can be downloaded from locations mentioned [here][8]. 120 | 121 | [2]: http://www.visualstudio.com/en-us/downloads 122 | [3]: http://code.google.com/p/msysgit/ 123 | [4]: http://sourceforge.net/projects/mingw/files/Installer/ 124 | [5]: http://www.7-zip.org/ 125 | [6]: https://bugreports.qt-project.org/browse/QTBUG-26844 126 | [7]: http://qt-project.org/doc/qt-5/windows-requirements.html 127 | [8]: https://stackoverflow.com/questions/1710922/how-to-install-pkg-config-in-windows 128 | -------------------------------------------------------------------------------- /buildicu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # On Linux this script builds ICU library into subdirectories in 4 | # the $HOME/invariant dir. ICU sources must be found from the current user's 5 | # home directory $HOME/invariant/icu. 6 | # 7 | # On Windows this script downloads the ICU library and extracts it into 8 | # the $HOME/invariant dir. 9 | # 10 | # 11 | # Copyright (C) 2014 Jolla Oy 12 | # Contact: Juha Kallioinen 13 | # All rights reserved. 14 | # 15 | # You may use this file under the terms of BSD license as follows: 16 | # 17 | # Redistribution and use in source and binary forms, with or without 18 | # modification, are permitted provided that the following conditions are met: 19 | # * Redistributions of source code must retain the above copyright 20 | # notice, this list of conditions and the following disclaimer. 21 | # * Redistributions in binary form must reproduce the above copyright 22 | # notice, this list of conditions and the following disclaimer in the 23 | # documentation and/or other materials provided with the distribution. 24 | # * Neither the name of the Jolla Ltd nor the 25 | # names of its contributors may be used to endorse or promote products 26 | # derived from this software without specific prior written permission. 27 | # 28 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 29 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 30 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 32 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 33 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 35 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | # 39 | 40 | export LC_ALL=C 41 | 42 | . $(dirname $0)/defaults.sh 43 | . $(dirname $0)/utils.sh 44 | 45 | configure_icu() { 46 | export CC=gcc-9 CXX=g++-9 47 | # According to $DEF_ICU_SRC_DIR/source/runConfigureICU 48 | export CFLAGS=-O3 CXXFLAGS=-O 49 | 50 | $DEF_ICU_SRC_DIR/source/configure --disable-draft --disable-extras --disable-debug --disable-icuio --disable-layout --disable-tests --disable-samples --enable-release --prefix=$DEF_ICU_INSTALL_DIR 51 | } 52 | 53 | build_icu() { 54 | rm -rf $DEF_ICU_BUILD_DIR 55 | mkdir -p $DEF_ICU_BUILD_DIR 56 | pushd $DEF_ICU_BUILD_DIR 57 | configure_icu 58 | make -j$(nproc) 59 | rm -rf $DEF_ICU_INSTALL_DIR 60 | make install 61 | popd 62 | } 63 | 64 | download_icu_win() { 65 | local download_dest=$DEF_ICU_DOWNLOAD_DIR/${DEF_WIN_ICU_DOWNLOAD_URL##*/} 66 | curl -o $download_dest $DEF_WIN_ICU_DOWNLOAD_URL 67 | rm -rf $DEF_ICU_INSTALL_DIR 68 | 7z -y -o$DEF_ICU_INSTALL_DIR x $download_dest 69 | [[ -d $DEF_ICU_INSTALL_DIR ]] || fail "Fixme: Name of the ICU archive root directory has changed" 70 | } 71 | 72 | build_arch() { 73 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 74 | echo "linux" 75 | elif [[ $UNAME_SYSTEM == "Darwin" ]]; then 76 | echo "mac" 77 | else 78 | echo "windows" 79 | fi 80 | } 81 | 82 | fail() { 83 | echo "FAIL: $@" 84 | exit 1 85 | } 86 | 87 | usage() { 88 | if [[ $(build_arch) == "linux" ]]; then 89 | cat < 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | . $(dirname $0)/utils.sh 36 | 37 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 38 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 39 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 40 | 41 | OPT_QTDIR=$DEF_QT_STATIC_BUILD_DIR 42 | OPT_IFW_SRC_DIR=$DEF_IFW_SRC_DIR 43 | IFW_BUILD_DIR=$DEF_IFW_BUILD_DIR 44 | 45 | fail() { 46 | echo "FAIL: $@" 47 | exit 1 48 | } 49 | 50 | usage() { 51 | cat < Installer FW source directory [$OPT_IFW_SRC_DIR] 62 | -qt | --qt-dir Static Qt (install) directory [$OPT_QTDIR] 63 | -u | --upload upload local build result to [$OPT_UPLOAD_HOST] as user [$OPT_UPLOAD_USER] 64 | the uploaded build will be copied to [$OPT_UPLOAD_PATH/] 65 | the upload directory will be created if it is not there 66 | -uh | --uhost override default upload host 67 | -up | --upath override default upload path 68 | -uu | --uuser override default upload user 69 | -y | --non-interactive answer yes to all questions presented by the script 70 | -h | --help this help 71 | 72 | EOF 73 | 74 | # exit if any argument is given 75 | [[ -n "$1" ]] && exit 1 76 | } 77 | 78 | # handle commandline options 79 | while [[ ${1:-} ]]; do 80 | case "$1" in 81 | -ifw | --ifw-src ) shift 82 | OPT_IFW_SRC_DIR=$1; shift 83 | IFW_BUILD_DIR=$OPT_IFW_SRC_DIR$DEF_IFW_BUILD_SUFFIX 84 | ;; 85 | -qt | --qt-dir ) shift 86 | OPT_QTDIR=$1; shift 87 | ;; 88 | -u | --upload ) shift 89 | OPT_UPLOAD=1 90 | OPT_UL_DIR=$1; shift 91 | if [[ -z $OPT_UL_DIR ]]; then 92 | fail "upload option requires a directory name" 93 | fi 94 | ;; 95 | -uh | --uhost ) shift; 96 | OPT_UPLOAD_HOST=$1; shift 97 | ;; 98 | -up | --upath ) shift; 99 | OPT_UPLOAD_PATH=$1; shift 100 | ;; 101 | -uu | --uuser ) shift; 102 | OPT_UPLOAD_USER=$1; shift 103 | ;; 104 | -y | --non-interactive ) shift 105 | OPT_YES=1 106 | ;; 107 | -h | --help ) shift 108 | usage quit 109 | ;; 110 | * ) 111 | usage quit 112 | ;; 113 | esac 114 | done 115 | 116 | if [[ ! -d $OPT_QTDIR ]]; then 117 | fail "Qt directory [$OPT_QTDIR] not found" 118 | fi 119 | 120 | if [[ ! -d $OPT_IFW_SRC_DIR ]]; then 121 | fail "Installer framework source directory [$OPT_IFW_SRC_DIR] not found" 122 | fi 123 | 124 | # summary 125 | cat < build-windows.bat 179 | @echo off 180 | 181 | if DEFINED ProgramFiles(x86) set _programs=%ProgramFiles(x86)% 182 | if Not DEFINED ProgramFiles(x86) set _programs=%ProgramFiles% 183 | 184 | set QTDIR=$(win_path $OPT_QTDIR) 185 | set QMAKESPEC=$DEF_MSVC_SPEC 186 | set PATH=$(win_path $DEF_PREFIX)\invariant\bin;%PATH% 187 | 188 | call "%_programs%\Microsoft Visual Studio\\$DEF_MSVC_VER\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 189 | 190 | call %QTDIR%\qtbase\bin\qmake -r $(win_path $OPT_IFW_SRC_DIR)\installerfw.pro || exit 1 191 | call jom || exit 1 192 | EOF 193 | 194 | # execute the bat 195 | cmd //c build-windows.bat 196 | 197 | popd 198 | } 199 | 200 | # if any step below fails, exit 201 | set -e 202 | 203 | # record start time 204 | BUILD_START=$(date +%s) 205 | 206 | if [[ $UNAME_SYSTEM == "Linux" ]] || [[ $UNAME_SYSTEM == "Darwin" ]]; then 207 | build_unix 208 | else 209 | build_windows 210 | fi 211 | 212 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 213 | if [[ $UNAME_ARCH == "x86_64" ]]; then 214 | BUILD_ARCH="linux-64" 215 | else 216 | BUILD_ARCH="linux-32" 217 | fi 218 | elif [[ $UNAME_SYSTEM == "Darwin" ]]; then 219 | BUILD_ARCH="mac" 220 | else 221 | BUILD_ARCH="windows" 222 | fi 223 | 224 | pushd $IFW_BUILD_DIR 225 | 226 | # install results 227 | mkdir -p ifw 228 | cp -a bin ifw 229 | 7z a -mx=9 $DEF_IFW_PACKAGE_NAME ifw 230 | 231 | # record end time 232 | BUILD_END=$(date +%s) 233 | 234 | time=$(( BUILD_END - BUILD_START )) 235 | hour=$(( $time / 3600 )) 236 | mins=$(( $time / 60 - 60*$hour )) 237 | secs=$(( $time - 3600*$hour - 60*$mins )) 238 | 239 | echo Time used for IFW build: $(printf "%02d:%02d:%02d" $hour $mins $secs) 240 | 241 | if [[ -n "$OPT_UPLOAD" ]]; then 242 | echo "Uploading $IFW_PACKAGE_NAME ..." 243 | # create upload dir 244 | ssh $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST mkdir -p $OPT_UPLOAD_PATH/$OPT_UL_DIR/$BUILD_ARCH 245 | scp $DEF_IFW_PACKAGE_NAME $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/$BUILD_ARCH/ 246 | fi 247 | 248 | popd 249 | 250 | # For Emacs: 251 | # Local Variables: 252 | # indent-tabs-mode:nil 253 | # tab-width:8 254 | # sh-basic-offset:4 255 | # End: 256 | # For VIM: 257 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 258 | -------------------------------------------------------------------------------- /buildlinguist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Builds Qt Linguist and optionally uploads it to a server 4 | # 5 | # Copyright (C) 2018 Jolla Ltd. 6 | # Contact: Jarkko Lehtoranta 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | 36 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 37 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 38 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 39 | 40 | OPT_QTDIR=$DEF_QT_DYN_BUILD_DIR 41 | LINGUIST_INSTALL_ROOT=$DEF_LINGUIST_INSTALL_ROOT 42 | 43 | fail() { 44 | echo "FAIL: $@" 45 | exit 1 46 | } 47 | 48 | usage() { 49 | cat < Qt Linguist install directory [$LINGUIST_INSTALL_ROOT] 60 | -qt | --qt-dir Qt (install) directory [$OPT_QTDIR] 61 | -u | --upload upload local build result to [$OPT_UPLOAD_HOST] as user [$OPT_UPLOAD_USER] 62 | the uploaded build will be copied to [$OPT_UPLOAD_PATH/] 63 | the upload directory will be created if it is not there 64 | -uh | --uhost override default upload host 65 | -up | --upath override default upload path 66 | -uu | --uuser override default upload user 67 | -y | --non-interactive answer yes to all questions presented by the script 68 | -h | --help this help 69 | 70 | EOF 71 | 72 | # exit if any argument is given 73 | [[ -n "$1" ]] && exit 1 74 | } 75 | 76 | # handle commandline options 77 | while [[ ${1:-} ]]; do 78 | case "$1" in 79 | -ling | --linguist-install ) shift 80 | LINGUIST_INSTALL_ROOT=$1; shift 81 | ;; 82 | -qt | --qt-dir ) shift 83 | OPT_QTDIR=$1; shift 84 | ;; 85 | -u | --upload ) shift 86 | OPT_UPLOAD=1 87 | OPT_UL_DIR=$1; shift 88 | if [[ -z $OPT_UL_DIR ]]; then 89 | fail "upload option requires a directory name" 90 | fi 91 | ;; 92 | -uh | --uhost ) shift; 93 | OPT_UPLOAD_HOST=$1; shift 94 | ;; 95 | -up | --upath ) shift; 96 | OPT_UPLOAD_PATH=$1; shift 97 | ;; 98 | -uu | --uuser ) shift; 99 | OPT_UPLOAD_USER=$1; shift 100 | ;; 101 | -y | --non-interactive ) shift 102 | OPT_YES=1 103 | ;; 104 | -h | --help ) shift 105 | usage quit 106 | ;; 107 | * ) 108 | usage quit 109 | ;; 110 | esac 111 | done 112 | 113 | if [[ ! -d $OPT_QTDIR ]]; then 114 | fail "Qt directory [$OPT_QTDIR] not found" 115 | fi 116 | 117 | if [[ ! -d $LINGUIST_INSTALL_ROOT ]]; then 118 | mkdir -p $LINGUIST_INSTALL_ROOT 119 | fi 120 | 121 | # summary 122 | echo "Summary of chosen actions:" 123 | cat < "$LINGUIST_INSTALL_ROOT/bin/Linguist.app/Contents/Resources/qt.conf" 202 | else 203 | RPATH='INSTALL_ROOT/lib:INSTALL_ROOT/lib/Qt/lib:INSTALL_ROOT/lib/qtcreator' 204 | find $LINGUIST_INSTALL_ROOT/bin/* -maxdepth 0 -type f | xargs -n1 patchelf --remove-rpath 205 | find $LINGUIST_INSTALL_ROOT/bin/* -maxdepth 0 -type f | xargs -n1 patchelf --force-rpath --set-rpath "${RPATH//INSTALL_ROOT/\$ORIGIN/..}" 206 | fi 207 | 208 | popd 209 | } 210 | 211 | build_windows_linguist() { 212 | # clear build workspace 213 | rm -rf $LINGUIST_INSTALL_ROOT/* 214 | pushd $LINGUIST_INSTALL_ROOT 215 | 216 | mkdir bin 217 | 218 | # no more errors allowed 219 | set -e 220 | 221 | # Copy Linguist binary from the Qt build directory 222 | cp $OPT_QTDIR/qtbase/bin/linguist.exe bin/ 223 | 224 | popd 225 | } 226 | 227 | # if any step below fails, exit 228 | set -e 229 | 230 | # record start time 231 | BUILD_START=$(date +%s) 232 | 233 | if [[ $(build_arch) == "windows" ]]; then 234 | build_windows_linguist 235 | else 236 | build_unix_linguist 237 | fi 238 | 239 | # create package 240 | SAILFISH_LINGUIST_PACKAGE="sailfish-linguist-$(build_arch).7z" 241 | rm -f $LINGUIST_INSTALL_ROOT/$SAILFISH_LINGUIST_PACKAGE 242 | 7z a $LINGUIST_INSTALL_ROOT/$SAILFISH_LINGUIST_PACKAGE $LINGUIST_INSTALL_ROOT/* 243 | 244 | # record end time 245 | BUILD_END=$(date +%s) 246 | 247 | time=$(( BUILD_END - BUILD_START )) 248 | hour=$(( $time / 3600 )) 249 | mins=$(( $time / 60 - 60*$hour )) 250 | secs=$(( $time - 3600*$hour - 60*$mins )) 251 | 252 | echo Time used for Qt Linguist build: $(printf "%02d:%02d:%02d" $hour $mins $secs) 253 | 254 | if [[ -n "$OPT_UPLOAD" ]]; then 255 | # create upload dir 256 | ssh $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST mkdir -p $OPT_UPLOAD_PATH/$OPT_UL_DIR/$(build_arch) 257 | 258 | echo "Uploading $SAILFISH_LINGUIST_PACKAGE ..." 259 | scp $LINGUIST_INSTALL_ROOT/$SAILFISH_LINGUIST_PACKAGE $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/$(build_arch)/ 260 | fi 261 | 262 | # For Emacs: 263 | # Local Variables: 264 | # indent-tabs-mode:nil 265 | # tab-width:8 266 | # sh-basic-offset:4 267 | # End: 268 | # For VIM: 269 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 270 | -------------------------------------------------------------------------------- /buildllvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # On Linux this script builds LLVM/Clang libraries into subdirectories in 4 | # the $HOME/invariant dir. LLVM sources must be found from the current user's 5 | # home directory $HOME/invariant/llvm. 6 | # 7 | # On Windows and macOS this script downloads the LLVM/Clang libraries and 8 | # extracts it into the $HOME/invariant dir. 9 | # 10 | # 11 | # Copyright (C) 2014-2019 Jolla Ltd. 12 | # Copyright (C) 2020 Open Mobile Platform LLC. 13 | # Contact: http://jolla.com/ 14 | # All rights reserved. 15 | # 16 | # You may use this file under the terms of BSD license as follows: 17 | # 18 | # Redistribution and use in source and binary forms, with or without 19 | # modification, are permitted provided that the following conditions are met: 20 | # * Redistributions of source code must retain the above copyright 21 | # notice, this list of conditions and the following disclaimer. 22 | # * Redistributions in binary form must reproduce the above copyright 23 | # notice, this list of conditions and the following disclaimer in the 24 | # documentation and/or other materials provided with the distribution. 25 | # * Neither the name of the Jolla Ltd nor the 26 | # names of its contributors may be used to endorse or promote products 27 | # derived from this software without specific prior written permission. 28 | # 29 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 30 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 31 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 33 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 35 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 36 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | # 40 | 41 | export LC_ALL=C 42 | 43 | . $(dirname $0)/defaults.sh 44 | . $(dirname $0)/utils.sh 45 | 46 | configure_llvm() { 47 | export CC=gcc-9 CXX=g++-9 48 | # See Qt Creator's README 49 | cmake \ 50 | -D CMAKE_BUILD_TYPE=Release \ 51 | -D LLVM_ENABLE_RTTI=ON \ 52 | -D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \ 53 | -D CMAKE_INSTALL_PREFIX=$DEF_LLVM_INSTALL_DIR \ 54 | $DEF_LLVM_SRC_DIR/llvm 55 | } 56 | 57 | build_llvm() { 58 | rm -rf $DEF_LLVM_BUILD_DIR 59 | mkdir -p $DEF_LLVM_BUILD_DIR 60 | pushd $DEF_LLVM_BUILD_DIR 61 | configure_llvm 62 | make -j$(nproc) 63 | rm -rf $DEF_LLVM_INSTALL_DIR 64 | make install 65 | popd 66 | } 67 | 68 | download_llvm_windows() { 69 | local download_dest=$DEF_LLVM_DOWNLOAD_DIR/${DEF_WIN_LLVM_DOWNLOAD_URL##*/} 70 | curl -o $download_dest $DEF_WIN_LLVM_DOWNLOAD_URL 71 | rm -rf $DEF_LLVM_INSTALL_DIR 72 | 7z -y -o$(dirname $DEF_LLVM_INSTALL_DIR) x $download_dest 73 | [[ -d $DEF_LLVM_INSTALL_DIR ]] || fail "Fixme: Name of the LLVM/Clang archive root directory has changed" 74 | } 75 | 76 | download_llvm_mac() { 77 | local download_dest=$DEF_LLVM_DOWNLOAD_DIR/${DEF_MAC_LLVM_DOWNLOAD_URL##*/} 78 | curl -o $download_dest $DEF_MAC_LLVM_DOWNLOAD_URL 79 | rm -rf $DEF_LLVM_INSTALL_DIR 80 | 7z -y -o$(dirname $DEF_LLVM_INSTALL_DIR) x $download_dest 81 | [[ -d $DEF_LLVM_INSTALL_DIR ]] || fail "Fixme: Name of the LLVM/Clang archive root directory has changed" 82 | } 83 | 84 | build_arch() { 85 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 86 | echo "linux" 87 | elif [[ $UNAME_SYSTEM == "Darwin" ]]; then 88 | echo "mac" 89 | else 90 | echo "windows" 91 | fi 92 | } 93 | 94 | fail() { 95 | echo "FAIL: $@" 96 | exit 1 97 | } 98 | 99 | usage() { 100 | if [[ $(build_arch) == "linux" ]]; then 101 | cat < 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | 36 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 37 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 38 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 39 | OPT_REPO_URL='' 40 | 41 | OPT_VARIANT=$DEF_VARIANT 42 | OPT_VARIANT_PRETTY=$DEF_VARIANT_PRETTY 43 | OPT_COPY_FROM_VARIANT=$DEF_COPY_FROM_VARIANT 44 | OPT_RELEASE=$DEF_RELEASE 45 | OPT_RELCYCLE=$DEF_RELCYCLE 46 | OPT_INSTALLER_PROFILE=offline 47 | 48 | REQUIRED_SRC_DIRS=($DEF_QTC_SRC_DIR $DEF_QMLLIVE_SRC_DIR $DEF_INSTALLER_SRC_DIR $DEF_IFW_SRC_DIR) 49 | 50 | DEFAULT_REMOTE='origin' 51 | INSTALLER_BUILD_OPTIONS='' 52 | 53 | build_arch() { 54 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 55 | if [[ $UNAME_ARCH == "x86_64" ]]; then 56 | echo "linux-64" 57 | else 58 | echo "linux-32" 59 | fi 60 | elif [[ $UNAME_SYSTEM == "Darwin" ]]; then 61 | echo "mac" 62 | else 63 | echo "windows" 64 | fi 65 | } 66 | 67 | fail() { 68 | echo "FAIL: $@" 69 | exit 1 70 | } 71 | 72 | usage() { 73 | cat < Use as the build variant [$OPT_VARIANT] 96 | -vp | --variant-pretty SDK pretty variant [$OPT_VARIANT_PRETTY] (appears 97 | in the installer name and in braces after Qt Creator 98 | or QmlLive version in Qt Creator/QmlLive About dialog) 99 | --copy-from-variant Copy settings from the older variant 100 | if found [$OPT_COPY_FROM_VARIANT] 101 | | --branch Build the given branch instead of "master" if it exists. 102 | Multiple branches can be given, separated with spaces. 103 | Tags and remote tracking branches are also accepted. 104 | | --release SDK release version [$OPT_RELEASE] 105 | | --rel-cycle SDK release cycle [$OPT_RELCYCLE] 106 | | --repourl Update repo location, if set overrides the public repo URL 107 | -gd | --gdb-default Use default download URLs for gdb build deps 108 | -P | --installer-profile Choose a profile when building installer. 109 | can be one of "online", "offline" or "full". 110 | Multiple values may be passed too, separated with comma. 111 | [$OPT_INSTALLER_PROFILE] 112 | -d | --download Use to download artifacts 113 | -D | --dload-def Create download URL using as the source dir 114 | -u | --upload upload build results 115 | -uh | --uhost override default upload host 116 | -up | --upath override default upload path 117 | -uu | --uuser override default upload user 118 | -y | --non-interactive answer yes to all questions from this script 119 | -z | --dry-run do nothing, just print out what would happen 120 | -h | --help this help 121 | 122 | EOF 123 | 124 | # exit if any argument is given 125 | [[ -n "$1" ]] && exit 1 126 | } 127 | 128 | # handle commandline options 129 | while [[ ${1:-} ]]; do 130 | # Keep it during the transition to not break Jenkins config 131 | case "$1" in 132 | -qt4 ) echo "The switch '-qt4' is deprecated. Use '--qt-static' instead";; 133 | -qt5 ) echo "The switch '-qt5' is deprecated. Use '--qt-dynamic' instead";; 134 | esac 135 | 136 | case "$1" in 137 | -q | --qtc ) shift 138 | OPT_BUILD_QTC=1 139 | let numtasks++ 140 | ;; 141 | -qd | --qtc-docs ) shift 142 | OPT_BUILD_QTC_DOCS=1 143 | ;; 144 | -g | --gdb ) shift 145 | OPT_BUILD_GDB=1 146 | let numtasks++ 147 | ;; 148 | -I | --ifw ) shift 149 | OPT_BUILD_IFW=1 150 | let numtasks++ 151 | ;; 152 | -i | --installer ) shift 153 | OPT_BUILD_INSTALLER=1 154 | let numtasks++ 155 | ;; 156 | -r | --repogen ) shift 157 | OPT_BUILD_REPO=1 158 | let numtasks++ 159 | ;; 160 | -icu | --icu-build ) shift 161 | OPT_BUILD_ICU=1 162 | let numtasks++ 163 | ;; 164 | -qt4 | --qt-static ) shift 165 | OPT_BUILD_QT_STATIC=1 166 | let numtasks++ 167 | ;; 168 | -qt5 | --qt-dynamic ) shift 169 | OPT_BUILD_QT_DYNAMIC=1 170 | let numtasks++ 171 | ;; 172 | --llvm ) shift 173 | OPT_BUILD_LLVM=1 174 | let numtasks++ 175 | ;; 176 | --linguist ) shift 177 | OPT_BUILD_LINGUIST=1 178 | let numtasks++ 179 | ;; 180 | --qmllive ) shift 181 | OPT_BUILD_QMLLIVE=1 182 | let numtasks++ 183 | ;; 184 | -p | --git-pull ) shift 185 | OPT_GIT_PULL=1 186 | let numtasks++ 187 | ;; 188 | -v | --variant ) shift 189 | OPT_VARIANT=$1; shift 190 | ;; 191 | --copy-from-variant ) shift 192 | OPT_COPY_FROM_VARIANT=$1; shift 193 | ;; 194 | --branch ) shift 195 | OPT_BRANCH=$1; shift 196 | ;; 197 | --release ) shift 198 | OPT_RELEASE=$1; shift 199 | ;; 200 | --rel-cycle ) shift 201 | OPT_RELCYCLE=$1; shift 202 | ;; 203 | --repourl ) shift 204 | OPT_REPO_URL=$1; shift 205 | ;; 206 | -vp | --variant-pretty ) shift 207 | OPT_VARIANT_PRETTY=$1; shift 208 | ;; 209 | -e | --extra ) shift 210 | OPT_VERSION_EXTRA=$1; shift 211 | ;; 212 | -d | --download ) shift 213 | OPT_DOWNLOAD_URL=$1; shift 214 | if [[ -z $OPT_DOWNLOAD_URL ]]; then 215 | fail "download option requires a valid URL" 216 | fi 217 | ;; 218 | -D | --dload-def ) shift 219 | OPT_DL_DIR=$1; shift 220 | if [[ -z $OPT_DL_DIR ]]; then 221 | fail "download option requires a directory name" 222 | fi 223 | ;; 224 | -gd | --gdb-default ) shift 225 | OPT_GDB_DEFAULT=1 226 | ;; 227 | -P | --installer-profile ) shift 228 | OPT_INSTALLER_PROFILE=$1; shift 229 | if [[ -z $OPT_UL_DIR ]]; then 230 | fail "installer profile option requires a profile name" 231 | fi 232 | ;; 233 | -u | --upload ) shift 234 | OPT_UPLOAD=1 235 | OPT_UL_DIR=$1; shift 236 | if [[ -z $OPT_UL_DIR ]]; then 237 | fail "upload option requires a directory name" 238 | fi 239 | ;; 240 | -uh | --uhost ) shift; 241 | OPT_UPLOAD_HOST=$1; shift 242 | ;; 243 | -up | --upath ) shift; 244 | OPT_UPLOAD_PATH=$1; shift 245 | ;; 246 | -uu | --uuser ) shift; 247 | OPT_UPLOAD_USER=$1; shift 248 | ;; 249 | -y | --non-interactive ) shift 250 | OPT_YES=1 251 | ;; 252 | -z | --dry-run ) shift 253 | OPT_DRY_RUN=1 254 | ;; 255 | -h | --help ) shift 256 | usage quit 257 | ;; 258 | * ) 259 | usage quit 260 | ;; 261 | esac 262 | done 263 | 264 | # is there anything to do? 265 | [[ $numtasks -eq 0 ]] && usage quit 266 | 267 | # some basic requirement checks 268 | for src in ${REQUIRED_SRC_DIRS[*]}; do 269 | [[ ! -d $src ]] && fail "Directory [$src] does not exist" 270 | done 271 | 272 | if [[ -n $OPT_DL_DIR ]]; then 273 | OPT_DOWNLOAD_URL=$DEF_URL_PREFIX/$OPT_DL_DIR 274 | fi 275 | 276 | if [[ -n $OPT_BUILD_INSTALLER ]] || [[ -n $OPT_BUILD_REPO ]] && [[ -z $OPT_DOWNLOAD_URL ]]; then 277 | fail "Building the installer requires a download url [-d or -D]" 278 | fi 279 | 280 | # dry run function 281 | _() { 282 | [[ -n $OPT_DRY_RUN ]] && echo "$@" || eval $@ 283 | } 284 | 285 | # helper 286 | get_option() { 287 | [[ -z $1 ]] && echo " " || echo "X" 288 | } 289 | 290 | # summary 291 | cat < 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | . $(dirname $0)/utils.sh 36 | 37 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 38 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 39 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 40 | 41 | OPT_QTDIR=$DEF_QT_DYN_BUILD_DIR 42 | OPT_QMLLIVE_SRC_DIR=$DEF_QMLLIVE_SRC_DIR 43 | QMLLIVE_BUILD_DIR=$DEF_QMLLIVE_BUILD_DIR 44 | QMLLIVE_INSTALL_ROOT=$DEF_QMLLIVE_INSTALL_ROOT 45 | OPT_ICU_PATH=$DEF_ICU_INSTALL_DIR 46 | OPT_VARIANT=$DEF_VARIANT 47 | 48 | fail() { 49 | echo "FAIL: $@" 50 | exit 1 51 | } 52 | 53 | usage() { 54 | cat < Qt QmlLive source directory [$OPT_QMLLIVE_SRC_DIR] 65 | -qt | --qt-dir Qt (install) directory [$OPT_QTDIR] 66 | -v | --variant Use as the build variant [$OPT_VARIANT] 67 | -vp | --variant-pretty Use as the pretty variant (appears in braces 68 | after Qt QmlLive version in About dialog) 69 | -r | --revision Use as the build revision [git sha] 70 | | --quick Do not run configure or clean build dir 71 | -u | --upload upload local build result to [$OPT_UPLOAD_HOST] as user [$OPT_UPLOAD_USER] 72 | the uploaded build will be copied to [$OPT_UPLOAD_PATH/] 73 | the upload directory will be created if it is not there 74 | -uh | --uhost override default upload host 75 | -up | --upath override default upload path 76 | -uu | --uuser override default upload user 77 | -y | --non-interactive answer yes to all questions presented by the script 78 | -h | --help this help 79 | 80 | EOF 81 | 82 | # exit if any argument is given 83 | [[ -n "$1" ]] && exit 1 84 | } 85 | 86 | # handle commandline options 87 | while [[ ${1:-} ]]; do 88 | case "$1" in 89 | -v | --variant ) shift 90 | OPT_VARIANT=$1; shift 91 | ;; 92 | -r | --revision ) shift 93 | OPT_REVISION=$1; shift 94 | ;; 95 | -vp | --variant-pretty ) shift 96 | OPT_VARIANT_PRETTY=$1; shift 97 | ;; 98 | -qmllive | --qmllive-src ) shift 99 | OPT_QMLLIVE_SRC_DIR=$1; shift 100 | QMLLIVE_BUILD_DIR=$OPT_QMLLIVE_SRC_DIR$DEF_QMLLIVE_BUILD_SUFFIX 101 | QMLLIVE_INSTALL_ROOT=$OPT_QMLLIVE_SRC_DIR$DEF_QMLLIVE_INSTALL_SUFFIX 102 | ;; 103 | -qt | --qt-dir ) shift 104 | OPT_QTDIR=$1; shift 105 | ;; 106 | -u | --upload ) shift 107 | OPT_UPLOAD=1 108 | OPT_UL_DIR=$1; shift 109 | if [[ -z $OPT_UL_DIR ]]; then 110 | fail "upload option requires a directory name" 111 | fi 112 | ;; 113 | -uh | --uhost ) shift; 114 | OPT_UPLOAD_HOST=$1; shift 115 | ;; 116 | -up | --upath ) shift; 117 | OPT_UPLOAD_PATH=$1; shift 118 | ;; 119 | -uu | --uuser ) shift; 120 | OPT_UPLOAD_USER=$1; shift 121 | ;; 122 | -y | --non-interactive ) shift 123 | OPT_YES=1 124 | ;; 125 | --quick ) shift 126 | OPT_QUICK=1 127 | ;; 128 | -h | --help ) shift 129 | usage quit 130 | ;; 131 | * ) 132 | usage quit 133 | ;; 134 | esac 135 | done 136 | 137 | if [[ ! -d $OPT_QTDIR ]]; then 138 | fail "Qt directory [$OPT_QTDIR] not found" 139 | fi 140 | 141 | if [[ ! -d $OPT_QMLLIVE_SRC_DIR ]]; then 142 | fail "Qt QmlLive source directory [$OPT_QMLLIVE_SRC_DIR] not found" 143 | fi 144 | 145 | if [[ ! -d $QMLLIVE_INSTALL_ROOT ]]; then 146 | mkdir -p $QMLLIVE_INSTALL_ROOT 147 | fi 148 | 149 | # the default revision is the git hash of Qt QmlLive src directory 150 | if [[ -z $OPT_REVISION ]]; then 151 | OPT_REVISION=$(git --git-dir=$OPT_QMLLIVE_SRC_DIR/.git rev-parse --short HEAD 2>/dev/null) 152 | fi 153 | 154 | if [[ -z $OPT_REVISION ]]; then 155 | OPT_REVISION="unknown" 156 | fi 157 | 158 | # summary 159 | echo "Summary of chosen actions:" 160 | cat < "$QMLLIVE_INSTALL_ROOT/bin/QmlLive Bench.app/Contents/Resources/qt.conf" 280 | printf "$QT_CONF_TEMPLATE" '' > "$QMLLIVE_INSTALL_ROOT/bin/qt.conf" 281 | printf "$QT_CONF_TEMPLATE" '../../bin/' > "$QMLLIVE_INSTALL_ROOT/libexec/qmllive/qt.conf" 282 | else 283 | RPATH='INSTALL_ROOT/lib:INSTALL_ROOT/lib/Qt/lib:INSTALL_ROOT/lib/qtcreator' 284 | chrpath --replace "${RPATH//INSTALL_ROOT/\$ORIGIN/..}" $QMLLIVE_INSTALL_ROOT/bin/* 285 | chrpath --replace "${RPATH//INSTALL_ROOT/\$ORIGIN/../..}" $QMLLIVE_INSTALL_ROOT/libexec/qmllive/* 286 | fi 287 | 288 | popd 289 | } 290 | 291 | build_windows_qmllive() { 292 | # clear build workspace 293 | [[ $OPT_QUICK ]] || rm -rf $QMLLIVE_BUILD_DIR 294 | mkdir -p $QMLLIVE_BUILD_DIR 295 | pushd $QMLLIVE_BUILD_DIR 296 | 297 | # no more errors allowed 298 | set -e 299 | # create the build script for windows 300 | cat < build-windows.bat 301 | @echo off 302 | 303 | if DEFINED ProgramFiles(x86) ( 304 | set "_programs=%ProgramFiles(x86)%" 305 | set _systemdir=%windir%\system 306 | ) 307 | if Not DEFINED ProgramFiles(x86) ( 308 | set _programs=%ProgramFiles% 309 | set _systemdir=%windir%\system32 310 | ) 311 | 312 | set INSTALL_ROOT=$(win_path $QMLLIVE_INSTALL_ROOT) 313 | set QTDIR=$(win_path $OPT_QTDIR)\qtbase 314 | set QMAKESPEC=$DEF_MSVC_SPEC 315 | set PATH=%QTDIR%\bin;$(win_path $DEF_PREFIX)\invariant\bin;$(win_path $OPT_ICU_PATH)\bin64;%PATH% 316 | set INSTALLER_ARCHIVE=$SAILFISH_QMLLIVE_BASENAME$(build_arch).7z 317 | 318 | call rmdir /s /q $(win_path $QMLLIVE_INSTALL_ROOT) 319 | 320 | call "%_programs%\Microsoft Visual Studio\\$DEF_MSVC_VER\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 321 | 322 | call %QTDIR%\bin\qmake $(win_path $OPT_QMLLIVE_SRC_DIR)\qmllive.pro -r CONFIG+=release ^ 323 | QMLLIVE_SETTINGS_VARIANT="$OPT_VARIANT" QMLLIVE_REVISION="$OPT_REVISION" ^ 324 | QMLLIVE_VERSION_EXTRA="$OPT_VARIANT_PRETTY" ^ 325 | PREFIX=\. EXAMPLES_PREFIX=\qmllive-examples CONFIG+=no_testcase_installs || exit 1 326 | 327 | call jom || exit 1 328 | call nmake install || exit 1 329 | EOF 330 | 331 | # execute the bat 332 | cmd //c build-windows.bat 333 | 334 | # Remove development files 335 | rm -rf $QMLLIVE_INSTALL_ROOT/include $QMLLIVE_INSTALL_ROOT/bin/qmllive0.lib 336 | 337 | popd 338 | } 339 | 340 | # if any step below fails, exit 341 | set -e 342 | 343 | # record start time 344 | BUILD_START=$(date +%s) 345 | 346 | if [[ $(build_arch) == "windows" ]]; then 347 | build_windows_qmllive 348 | else 349 | build_unix_qmllive 350 | fi 351 | 352 | # create package 353 | SAILFISH_QMLLIVE_PACKAGE="sailfish-qmllive-$(build_arch).7z" 354 | rm -f $QMLLIVE_BUILD_DIR/$SAILFISH_QMLLIVE_PACKAGE 355 | 7z a $QMLLIVE_BUILD_DIR/$SAILFISH_QMLLIVE_PACKAGE $QMLLIVE_INSTALL_ROOT/* 356 | 357 | # record end time 358 | BUILD_END=$(date +%s) 359 | 360 | time=$(( BUILD_END - BUILD_START )) 361 | hour=$(( $time / 3600 )) 362 | mins=$(( $time / 60 - 60*$hour )) 363 | secs=$(( $time - 3600*$hour - 60*$mins )) 364 | 365 | echo Time used for Qt QmlLive build: $(printf "%02d:%02d:%02d" $hour $mins $secs) 366 | 367 | if [[ -n "$OPT_UPLOAD" ]]; then 368 | # create upload dir 369 | ssh $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST mkdir -p $OPT_UPLOAD_PATH/$OPT_UL_DIR/$(build_arch) 370 | 371 | echo "Uploading $SAILFISH_QMLLIVE_PACKAGE ..." 372 | scp $QMLLIVE_BUILD_DIR/$SAILFISH_QMLLIVE_PACKAGE $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/$(build_arch)/ 373 | fi 374 | 375 | # For Emacs: 376 | # Local Variables: 377 | # indent-tabs-mode:nil 378 | # tab-width:8 379 | # sh-basic-offset:4 380 | # End: 381 | # For VIM: 382 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 383 | -------------------------------------------------------------------------------- /buildqt5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script builds dynamic and static versions of Qt5 into 4 | # subdirectories in the parent directory of the Qt source directory. 5 | # 6 | # Qt5 sources must be found from the current user's home directory. Pass 7 | # --help to display the exact path. 8 | # 9 | # Copyright (C) 2014-2019 Jolla Oy 10 | # Copyright (C) 2020 Open Mobile Platform LLC. 11 | # 12 | # Contact: Juha Kallioinen 13 | # All rights reserved. 14 | # 15 | # You may use this file under the terms of BSD license as follows: 16 | # 17 | # Redistribution and use in source and binary forms, with or without 18 | # modification, are permitted provided that the following conditions are met: 19 | # * Redistributions of source code must retain the above copyright 20 | # notice, this list of conditions and the following disclaimer. 21 | # * Redistributions in binary form must reproduce the above copyright 22 | # notice, this list of conditions and the following disclaimer in the 23 | # documentation and/or other materials provided with the distribution. 24 | # * Neither the name of the Jolla Ltd nor the 25 | # names of its contributors may be used to endorse or promote products 26 | # derived from this software without specific prior written permission. 27 | # 28 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 29 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 30 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 31 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 32 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 33 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 34 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 35 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | # 39 | 40 | export LC_ALL=C 41 | 42 | . $(dirname $0)/defaults.sh 43 | . $(dirname $0)/utils.sh 44 | 45 | # common options for unix/windows dynamic build 46 | # the dynamic build is used when building Qt Creator 47 | COMMON_CONFIG_OPTIONS="-release -nomake examples -nomake tests -no-qml-debug -qt-zlib -qt-libpng -qt-libjpeg -qt-pcre -no-sql-mysql -no-sql-odbc -developer-build -confirm-license -opensource -skip qtandroidextras -skip qtconnectivity -skip qtlocation" 48 | 49 | LINUX_CONFIG_OPTIONS="-no-eglfs -no-linuxfb -no-kms -bundled-xcb-xinput" 50 | 51 | # add these to the COMMON_CONFIG_OPTIONS for static build 52 | # the static build is required to build Qt Installer Framework 53 | COMMON_STATIC_OPTIONS="-static -skip qtxmlpatterns -no-dbus -skip qt3d -skip qtquick3d -skip qtwebengine -skip qtconnectivity" 54 | 55 | WEBENGINE_OPTIONS="\ 56 | -no-feature-webengine-alsa \ 57 | -no-feature-webengine-extensions \ 58 | -no-feature-webengine-geolocation \ 59 | -no-feature-webengine-kerberos \ 60 | -no-feature-webengine-pepper-plugins \ 61 | -no-feature-webengine-printing-and-pdf \ 62 | -no-feature-webengine-proprietary-codecs \ 63 | -no-feature-webengine-pulseaudio \ 64 | -no-feature-webengine-spellchecker \ 65 | -no-feature-webengine-system-ffmpeg \ 66 | -no-feature-webengine-system-libwebp \ 67 | -no-feature-webengine-system-libxml2 \ 68 | -no-feature-webengine-system-opus \ 69 | -no-feature-webengine-webchannel \ 70 | -no-feature-webengine-webrtc \ 71 | " 72 | 73 | build_dynamic_qt_windows() { 74 | [[ -z $OPT_DYNAMIC ]] && return 75 | 76 | rm -rf $DEF_QT_DYN_BUILD_DIR 77 | mkdir -p $DEF_QT_DYN_BUILD_DIR 78 | pushd $DEF_QT_DYN_BUILD_DIR 79 | 80 | cat < build-dyn.bat 81 | @echo off 82 | if DEFINED ProgramFiles(x86) set _programs=%ProgramFiles(x86)% 83 | if Not DEFINED ProgramFiles(x86) set _programs=%ProgramFiles% 84 | 85 | set PATH=$(win_path $DEF_PREFIX)\invariant\bin;$(win_path $DEF_ICU_INSTALL_DIR)\bin64;$(win_path $DEF_QT_SRC_DIR)\gnuwin32\bin;$(win_path $DEF_PREFIX)\invariant\bin;%PATH% 86 | call "%_programs%\Microsoft Visual Studio\\$DEF_MSVC_VER\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 || exit 1 87 | 88 | set MAKE=jom 89 | REM NINJAFLAGS is handled by qtwebengine/src/core/gn_run.pro (at least) 90 | set NINJAFLAGS=-j1 91 | call $(win_path $DEF_QT_SRC_DIR)\configure.bat -make-tool jom $COMMON_CONFIG_OPTIONS -skip qtwebengine -icu -I $(win_path $DEF_ICU_INSTALL_DIR)\include -L $(win_path $DEF_ICU_INSTALL_DIR)\lib64 -opengl dynamic -platform $DEF_MSVC_SPEC -prefix "%CD%/qtbase" || exit 1 92 | 93 | call jom /j 1 || exit 1 94 | EOF 95 | 96 | cmd //c build-dyn.bat 97 | popd 98 | } 99 | 100 | configure_static_qt5() { 101 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 102 | $DEF_QT_SRC_DIR/configure $COMMON_CONFIG_OPTIONS $LINUX_CONFIG_OPTIONS $COMMON_STATIC_OPTIONS -xcb -xkbcommon -no-gstreamer -no-icu -skip qtsvg -no-warnings-are-errors -no-compile-examples 103 | else 104 | $DEF_QT_SRC_DIR/configure $COMMON_CONFIG_OPTIONS $COMMON_STATIC_OPTIONS -no-gstreamer -no-warnings-are-errors 105 | fi 106 | } 107 | 108 | configure_dynamic_qt5() { 109 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 110 | $DEF_QT_SRC_DIR/configure $COMMON_CONFIG_OPTIONS $LINUX_CONFIG_OPTIONS $WEBENGINE_OPTIONS -xcb -xkbcommon -no-gstreamer -I $DEF_ICU_INSTALL_DIR/include -L $DEF_ICU_INSTALL_DIR/lib -icu -no-warnings-are-errors -no-compile-examples 111 | else 112 | $DEF_QT_SRC_DIR/configure $COMMON_CONFIG_OPTIONS -no-gstreamer 113 | fi 114 | } 115 | 116 | build_dynamic_qt() { 117 | [[ -z $OPT_DYNAMIC ]] && return 118 | 119 | rm -rf $DEF_QT_DYN_BUILD_DIR 120 | mkdir -p $DEF_QT_DYN_BUILD_DIR 121 | pushd $DEF_QT_DYN_BUILD_DIR 122 | # NINJAFLAGS is handled by qtwebengine/src/core/gn_run.pro (at least) 123 | export NINJAFLAGS=-j$(nproc) 124 | # qtwebengine assumes python 2 is the default 125 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 126 | mkdir select-python-2 127 | python2=$(which python2) 128 | ln -s "$python2" select-python-2/python 129 | export PATH=$PWD/select-python-2:$PATH 130 | fi 131 | configure_dynamic_qt5 132 | make -j$(nproc) 133 | # no need to make install with -developer-build option 134 | # make install 135 | popd 136 | } 137 | 138 | build_static_qt_windows() { 139 | [[ -z $OPT_STATIC ]] && return 140 | 141 | rm -rf $DEF_QT_STATIC_BUILD_DIR 142 | mkdir -p $DEF_QT_STATIC_BUILD_DIR 143 | pushd $DEF_QT_STATIC_BUILD_DIR 144 | 145 | cat < build-dyn.bat 146 | @echo off 147 | if DEFINED ProgramFiles(x86) set _programs=%ProgramFiles(x86)% 148 | if Not DEFINED ProgramFiles(x86) set _programs=%ProgramFiles% 149 | 150 | set PATH=$(win_path $DEF_PREFIX)\invariant\bin;$(win_path $DEF_ICU_INSTALL_DIR)\bin64;$(win_path $DEF_QT_SRC_DIR)\gnuwin32\bin;$(win_path $DEF_PREFIX)\invariant\bin;%PATH% 151 | call "%_programs%\Microsoft Visual Studio\\$DEF_MSVC_VER\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 || exit 1 152 | 153 | set MAKE=jom 154 | call $(win_path $DEF_QT_SRC_DIR)\configure.bat -make-tool jom $COMMON_CONFIG_OPTIONS $COMMON_STATIC_OPTIONS -angle -platform $DEF_MSVC_SPEC -static-runtime -prefix "%CD%/qtbase" || exit 1 155 | 156 | call jom /j 1 || exit 1 157 | EOF 158 | 159 | cmd //c build-dyn.bat 160 | popd 161 | } 162 | 163 | build_static_qt() { 164 | [[ -z $OPT_STATIC ]] && return 165 | 166 | rm -rf $DEF_QT_STATIC_BUILD_DIR 167 | mkdir -p $DEF_QT_STATIC_BUILD_DIR 168 | pushd $DEF_QT_STATIC_BUILD_DIR 169 | configure_static_qt5 170 | make -j$(nproc) 171 | # no need to make install with -developer-build option 172 | # make install 173 | popd 174 | } 175 | 176 | fail() { 177 | echo "FAIL: $@" 178 | exit 1 179 | } 180 | 181 | usage() { 182 | cat < Qt Creator source directory [$OPT_QTC_SRC_DIR] 71 | -qt | --qt-dir Qt (install) directory [$OPT_QTDIR] 72 | -v | --variant Use as the build variant [$OPT_VARIANT] 73 | -vp | --variant-pretty Use as the pretty variant (appears in braces 74 | after Qt Creator version in About dialog) 75 | --copy-from-variant Copy settings from the older variant 76 | if found [$OPT_COPY_FROM_VARIANT] 77 | -r | --revision Use as the build revision [git sha] 78 | -d | --docs Build Qt Creator documentation 79 | | --sfdk-docs Build sfdk documentation (implied on Linux) 80 | -g | --gdb Build also gdb 81 | -go | --gdb-only Build only gdb 82 | -gd | --gdb-download Use to download gdb build deps 83 | -k | --keep-template Keep the Sailfish template code in the package 84 | | --quick Do not run configure or clean build dir 85 | -u | --upload upload local build result to [$OPT_UPLOAD_HOST] as user [$OPT_UPLOAD_USER] 86 | the uploaded build will be copied to [$OPT_UPLOAD_PATH/] 87 | the upload directory will be created if it is not there 88 | -uh | --uhost override default upload host 89 | -up | --upath override default upload path 90 | -uu | --uuser override default upload user 91 | -y | --non-interactive answer yes to all questions presented by the script 92 | -h | --help this help 93 | 94 | EOF 95 | 96 | # exit if any argument is given 97 | [[ -n "$1" ]] && exit 1 98 | } 99 | 100 | # handle commandline options 101 | while [[ ${1:-} ]]; do 102 | case "$1" in 103 | -v | --variant ) shift 104 | OPT_VARIANT=$1; shift 105 | ;; 106 | --copy-from-variant ) shift 107 | OPT_COPY_FROM_VARIANT=$1; shift 108 | ;; 109 | -r | --revision ) shift 110 | OPT_REVISION=$1; shift 111 | ;; 112 | -vp | --variant-pretty ) shift 113 | OPT_VARIANT_PRETTY=$1; shift 114 | ;; 115 | -qtc | --qtc-src ) shift 116 | OPT_QTC_SRC_DIR=$1; shift 117 | QTC_BUILD_DIR=$OPT_QTC_SRC_DIR$DEF_QTC_BUILD_SUFFIX 118 | QTC_INSTALL_ROOT=$OPT_QTC_SRC_DIR$DEF_QTC_INSTALL_SUFFIX 119 | ;; 120 | -qt | --qt-dir ) shift 121 | OPT_QTDIR=$1; shift 122 | ;; 123 | -d | --docs ) shift 124 | OPT_DOCUMENTATION=1 125 | ;; 126 | --sfdk-docs ) shift 127 | OPT_SFDK_DOCUMENTATION=1 128 | ;; 129 | -g | --gdb ) shift 130 | OPT_GDB=1 131 | ;; 132 | -go | --gdb-only ) shift 133 | OPT_GDB=1 134 | OPT_GDB_ONLY=1 135 | ;; 136 | -gd | --gdb-download ) shift 137 | OPT_GDB_URL=$1; shift 138 | if [[ -z $OPT_GDB_URL ]]; then 139 | fail "gdb download option requires a URL" 140 | fi 141 | ;; 142 | -u | --upload ) shift 143 | OPT_UPLOAD=1 144 | OPT_UL_DIR=$1; shift 145 | if [[ -z $OPT_UL_DIR ]]; then 146 | fail "upload option requires a directory name" 147 | fi 148 | ;; 149 | -uh | --uhost ) shift; 150 | OPT_UPLOAD_HOST=$1; shift 151 | ;; 152 | -up | --upath ) shift; 153 | OPT_UPLOAD_PATH=$1; shift 154 | ;; 155 | -uu | --uuser ) shift; 156 | OPT_UPLOAD_USER=$1; shift 157 | ;; 158 | -k | --keep-template ) shift 159 | OPT_KEEP_TEMPLATE=1 160 | ;; 161 | -y | --non-interactive ) shift 162 | OPT_YES=1 163 | ;; 164 | --quick ) shift 165 | OPT_QUICK=1 166 | ;; 167 | -h | --help ) shift 168 | usage quit 169 | ;; 170 | * ) 171 | usage quit 172 | ;; 173 | esac 174 | done 175 | 176 | if [[ ! -d $OPT_QTDIR ]]; then 177 | fail "Qt directory [$OPT_QTDIR] not found" 178 | fi 179 | 180 | if [[ ! -d $OPT_QTC_SRC_DIR ]]; then 181 | fail "Qt Creator source directory [$OPT_QTC_SRC_DIR] not found" 182 | fi 183 | 184 | if [[ ! -d $QTC_INSTALL_ROOT ]]; then 185 | mkdir -p $QTC_INSTALL_ROOT 186 | fi 187 | 188 | # the default revision is the git hash of Qt Creator src directory 189 | if [[ -z $OPT_REVISION ]]; then 190 | OPT_REVISION=$(git --git-dir=$OPT_QTC_SRC_DIR/.git rev-parse --short HEAD 2>/dev/null) 191 | fi 192 | 193 | if [[ -z $OPT_REVISION ]]; then 194 | OPT_REVISION="unknown" 195 | fi 196 | 197 | # summary 198 | echo "Summary of chosen actions:" 199 | cat < bin/sfdk 350 | chmod +x bin/sfdk 351 | fi 352 | 353 | make deployqt 354 | 355 | # Deploy QtWebEngine 356 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 357 | mkdir -p "$QTC_INSTALL_ROOT/lib/Qt/libexec" 358 | cp "$OPT_QTDIR/qtbase/libexec/QtWebEngineProcess" "$QTC_INSTALL_ROOT/lib/Qt/libexec/" 359 | 360 | patchelf --remove-rpath "$QTC_INSTALL_ROOT/lib/Qt/libexec/QtWebEngineProcess" 361 | patchelf --set-rpath '$ORIGIN/../lib:$ORIGIN/../../qtcreator' --force-rpath \ 362 | "$QTC_INSTALL_ROOT/lib/Qt/libexec/QtWebEngineProcess" 363 | 364 | mkdir -p "$QTC_INSTALL_ROOT/lib/Qt/resources" 365 | cp "$OPT_QTDIR/qtbase/resources"/*.pak "$QTC_INSTALL_ROOT/lib/Qt/resources/" 366 | # TODO The docs say this shouldn't be needed when custom ICU is used 367 | cp "$OPT_QTDIR/qtbase/resources"/icudtl.dat "$QTC_INSTALL_ROOT/lib/Qt/resources/" 368 | 369 | mkdir -p "$QTC_INSTALL_ROOT/lib/Qt/translations" 370 | cp -r "$OPT_QTDIR/qtbase/translations/qtwebengine_locales" "$QTC_INSTALL_ROOT/lib/Qt/translations/" 371 | fi 372 | 373 | if [[ $UNAME_SYSTEM == "Darwin" ]]; then 374 | local dbus_libs= 375 | dbus_libs=$(brew list dbus |grep 'libdbus-1.*\.dylib') 376 | mkdir -p "$QTC_INSTALL_ROOT/bin/Qt Creator.app/Contents/Frameworks/" 377 | cp $dbus_libs "$QTC_INSTALL_ROOT/bin/Qt Creator.app/Contents/Frameworks/" 378 | fi 379 | 380 | # Add icu library 381 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 382 | cp $OPT_ICU_PATH/lib/lib*.so* $QTC_INSTALL_ROOT/lib/qtcreator 383 | fi 384 | 385 | make bindist_installer 386 | 387 | if [[ -z $OPT_KEEP_TEMPLATE ]]; then 388 | # remove the sailfish template project from the 389 | # archive. it will be reinstalled by the installer. 390 | if [[ $UNAME_SYSTEM == "Darwin" ]]; then 391 | 7z d $SAILFISH_QTC_BASENAME$(build_arch).7z "bin/Qt Creator.app/Contents/Resources/templates/wizards/sailfishos-qtquick2app" 392 | else 393 | 7z d $SAILFISH_QTC_BASENAME$(build_arch).7z share/qtcreator/templates/wizards/sailfishos-qtquick2app 394 | fi 395 | fi 396 | 397 | if [[ -n $OPT_DOCUMENTATION ]]; then 398 | make docs 399 | make install_docs 400 | fi 401 | 402 | popd 403 | fi 404 | } 405 | 406 | build_windows_gdb() { 407 | if [[ -n $OPT_GDB ]]; then 408 | rm -f $SAILFISH_GDB_BASENAME*.7z 409 | [[ $OPT_QUICK ]] || rm -rf gdb-build 410 | mkdir -p gdb-build 411 | pushd gdb-build 412 | 413 | GDB_MAKEFILE=Makefile.mingw 414 | 415 | local downloads 416 | if [[ -n $OPT_GDB_URL ]]; then 417 | downloads="DOWNLOAD_URL=$OPT_GDB_URL" 418 | fi 419 | 420 | # dirty hax to build gdb in another mingw session, which has 421 | # the compiler available 422 | 423 | cat < build-gdb.bat 424 | @echo off 425 | call C:\msys64\usr\bin\env -u PATH MSYSTEM=UCRT64 C:\msys64\usr\bin\bash.exe --login -c "cd $PWD; make -f $OPT_QTC_SRC_DIR/dist/gdb/Makefile.mingw PATCHDIR=$OPT_QTC_SRC_DIR/dist/gdb/patches $downloads" || exit 1 426 | EOF 427 | cmd //c build-gdb.bat 428 | 429 | # move the completed package to the parent dir 430 | mv $SAILFISH_GDB_BASENAME*.7z .. 431 | popd 432 | fi 433 | } 434 | 435 | build_windows_qtc() { 436 | if [[ -z $OPT_GDB_ONLY ]]; then 437 | # clear build workspace 438 | [[ $OPT_QUICK ]] || rm -rf $QTC_BUILD_DIR 439 | mkdir -p $QTC_BUILD_DIR 440 | pushd $QTC_BUILD_DIR 441 | 442 | # fetch the binary artifacts if they can be found 443 | # 444 | # https://git.gitorious.org/qt-creator/binary-artifacts.git 445 | # 446 | local binary_artifacts="qtc-win32-binary-artifacts.7z" 447 | echo "Downloading binary artifacts ..." 448 | # Allow error code from curl 449 | set +e 450 | curl -s -f -o $binary_artifacts http://$OPT_UPLOAD_HOST/sailfishos/win32-binary-artifacts/$binary_artifacts 451 | [[ $? -ne 0 ]] && echo "NOTE! Downloading binary artifacts failed [ignoring]" 452 | 453 | # no more errors allowed 454 | set -e 455 | 456 | local opengl32sw_lib="opengl32sw-64-mesa_11_2_2-signed.7z" 457 | curl -s -f -o $opengl32sw_lib http://$OPT_UPLOAD_HOST/sailfishos/win32-binary-artifacts/opengl/$opengl32sw_lib 458 | 459 | local pkg_config_libs="pkg-config_0.26-1_win32.zip \ 460 | gettext-runtime_0.18.1.1-2_win32.zip \ 461 | glib_2.28.8-1_win32.zip" 462 | for lib in $pkg_config_libs; do 463 | curl -s -f -O http://$OPT_UPLOAD_HOST/sailfishos/win32-binary-artifacts/pkg-config/$lib 464 | done 465 | 466 | local mingw_dbus="mingw-w64-x86_64-dbus-1.12.20-1-any.pkg.tar" 467 | local mingw_dbus_lib="libdbus-1-3.dll" 468 | curl -s -f -o $mingw_dbus http://$OPT_UPLOAD_HOST/sailfishos/win32-binary-artifacts/dbus/$mingw_dbus 469 | tar -xf $mingw_dbus --strip-components=2 mingw64/bin/$mingw_dbus_lib 470 | 471 | # create the build script for windows 472 | cat < build-windows.bat 473 | @echo off 474 | 475 | if DEFINED ProgramFiles(x86) ( 476 | set "_programs=%ProgramFiles(x86)%" 477 | set _systemdir=%windir%\syswow64 478 | ) 479 | 480 | if Not DEFINED ProgramFiles(x86) ( 481 | set _programs=%ProgramFiles% 482 | set _systemdir=%windir%\system32 483 | ) 484 | 485 | 486 | set INSTALL_ROOT=$(win_path $QTC_INSTALL_ROOT) 487 | set QTDIR=$(win_path $OPT_QTDIR)\qtbase 488 | set QMAKESPEC=$DEF_MSVC_SPEC 489 | set PATH=%QTDIR%\bin;$(win_path $DEF_PREFIX)\invariant\bin;$(win_path $OPT_ICU_PATH)\bin64;%PATH% 490 | set LLVM_INSTALL_DIR=$(win_path $OPT_LLVM_INSTALL_DIR) 491 | set INSTALLER_ARCHIVE=$SAILFISH_QTC_BASENAME$(build_arch).7z 492 | 493 | call rmdir /s /q $(win_path $QTC_INSTALL_ROOT) 494 | 495 | if exist $binary_artifacts ( 496 | call 7z x -o$(win_path $QTC_INSTALL_ROOT) $binary_artifacts 497 | ) 498 | 499 | call "%_programs%\Microsoft Visual Studio\\$DEF_MSVC_VER\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 500 | 501 | call %QTDIR%\bin\qmake $(win_path $OPT_QTC_SRC_DIR)\qtcreator.pro ^ 502 | CONFIG+=release CONFIG-=debug_and_release -r ^ 503 | QTC_SHOW_BUILD_DATE=1 ^ 504 | -after "DEFINES+=IDE_REVISION=$OPT_REVISION" ^ 505 | ${OPT_COPY_FROM_VARIANT:+"'DEFINES+=IDE_COPY_SETTINGS_FROM_VARIANT=$OPT_COPY_FROM_VARIANT'"} ^ 506 | "DEFINES+=IDE_SETTINGSVARIANT=$OPT_VARIANT" ^ 507 | "QTCREATOR_DISPLAY_VERSION='$OPT_VARIANT_PRETTY'" ^ 508 | QTC_PREFIX= || exit 1 509 | 510 | call jom || exit 1 511 | call nmake install || exit 1 512 | call nmake deployqt || exit 1 513 | 514 | rem copy all the necessary libraries to the install directory 515 | copy %QTDIR%\bin\libEGL.dll %INSTALL_ROOT%\bin || exit 1 516 | copy %QTDIR%\bin\libGLESv2*.dll %INSTALL_ROOT%\bin || exit 1 517 | call 7z x -o%INSTALL_ROOT%\bin $opengl32sw_lib 518 | for %%i in ($pkg_config_libs) do ( 519 | call 7z x -o%INSTALL_ROOT% %%i < NUL || exit 1 520 | ) 521 | copy $mingw_dbus_lib %INSTALL_ROOT%\bin || exit 1 522 | copy "%VCToolsInstallDir%\bin\Hostx64\x64\d3dcompiler_*.dll" %INSTALL_ROOT%\bin || exit 1 523 | pushd "%VCToolsRedistDir%\x64\Microsoft.VC*.CRT" ^ 524 | && copy "*.dll" %INSTALL_ROOT%\bin ^ 525 | && popd || exit 1 526 | copy "%_systemdir%\msvc*100.dll" %INSTALL_ROOT%\bin || exit 1 527 | copy $(win_path $OPT_ICU_PATH)\bin64\*.dll %INSTALL_ROOT%\bin || exit 1 528 | # Required by libpython.dll packaged with gdb 529 | copy "%UniversalCRTSdkDir%\Redist\ucrt\DLLs\x64\*.dll" %INSTALL_ROOT%\bin || exit 1 530 | 531 | call nmake bindist_installer || exit 1 532 | EOF 533 | 534 | # execute the bat 535 | cmd //c build-windows.bat 536 | 537 | if [[ -z $OPT_KEEP_TEMPLATE ]]; then 538 | # remove the template project from the archive. it will be 539 | # reinstalled by the installer. 540 | 7z d $SAILFISH_QTC_BASENAME$(build_arch).7z share/qtcreator/templates/wizards/sailfishos-qtquick2app 541 | fi 542 | 543 | popd 544 | fi 545 | } 546 | 547 | # if any step below fails, exit 548 | set -e 549 | 550 | # build result files 551 | SAILFISH_QTC_BASENAME="sailfish-qt-creator-" 552 | SAILFISH_GDB_BASENAME="sailfish-gdb-" 553 | 554 | # record start time 555 | BUILD_START=$(date +%s) 556 | 557 | if [[ $(build_arch) == "windows" ]]; then 558 | build_windows_qtc 559 | build_windows_gdb 560 | else 561 | build_unix_qtc 562 | build_unix_gdb 563 | fi 564 | 565 | if [[ $OPT_SFDK_DOCUMENTATION && ! $OPT_GDB_ONLY ]]; then 566 | rm -f $SFDK_DOC_NAME 567 | mkdir -p $QTC_INSTALL_ROOT/$SFDK_DOC_DIR 568 | PATH=$QTC_INSTALL_ROOT/bin:$PATH \ 569 | $QTC_INSTALL_ROOT/share/qtcreator/sfdk/gendoc.sh $QTC_INSTALL_ROOT/$SFDK_DOC_DIR 570 | (cd $QTC_INSTALL_ROOT && 7z a $OLDPWD/$SFDK_DOC_NAME $SFDK_DOC_DIR) 571 | fi 572 | 573 | # record end time 574 | BUILD_END=$(date +%s) 575 | 576 | time=$(( BUILD_END - BUILD_START )) 577 | hour=$(( $time / 3600 )) 578 | mins=$(( $time / 60 - 60*$hour )) 579 | secs=$(( $time - 3600*$hour - 60*$mins )) 580 | 581 | echo Time used for QtC build: $(printf "%02d:%02d:%02d" $hour $mins $secs) 582 | 583 | if [[ -n "$OPT_UPLOAD" ]]; then 584 | # create upload dir 585 | ssh $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST mkdir -p $OPT_UPLOAD_PATH/$OPT_UL_DIR/$(build_arch) 586 | 587 | if [[ -z $OPT_GDB_ONLY ]]; then 588 | echo "Uploading $SAILFISH_QTC_BASENAME$(build_arch).7z ..." 589 | scp $QTC_BUILD_DIR/$SAILFISH_QTC_BASENAME$(build_arch).7z $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/$(build_arch)/ 590 | 591 | if [[ $OPT_SFDK_DOCUMENTATION ]]; then 592 | echo "Uploading $SFDK_DOC_NAME ..." 593 | scp $SFDK_DOC_NAME $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/ 594 | fi 595 | fi 596 | 597 | if [[ -n $OPT_GDB ]]; then 598 | echo "Uploading GDB ..." 599 | scp $SAILFISH_GDB_BASENAME*.7z $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/$(build_arch)/ 600 | fi 601 | fi 602 | 603 | # For Emacs: 604 | # Local Variables: 605 | # indent-tabs-mode:nil 606 | # tab-width:8 607 | # sh-basic-offset:4 608 | # End: 609 | # For VIM: 610 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 611 | -------------------------------------------------------------------------------- /copy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $# -ne 2 ]]; then 4 | cat < 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | # The address of the build host 35 | # Note: This can also be configured dynamically by using the -uh/--uhost 36 | # option in buildmaster.sh 37 | : ${DEF_UPLOAD_HOST:=10.21.0.20} 38 | # The username on the build host 39 | # Note: This can also be configured dynamically by using the -uu/--uuser 40 | # option in buildmaster.sh 41 | : ${DEF_UPLOAD_USER:=sdkinstaller} 42 | # The upload root on the build host 43 | # Note: This can also be configured dynamically by using the -up/--upath 44 | # option in buildmaster.sh 45 | : ${DEF_UPLOAD_PATH:=/var/www/sailfishos} 46 | # The URL pointing to the upload root on the build host 47 | : ${DEF_URL_PREFIX:=http://$DEF_UPLOAD_HOST/sailfishos} 48 | 49 | # The download URL for the Windows ICU binaries 50 | DEF_WIN_ICU_DOWNLOAD_URL="$DEF_URL_PREFIX/win32-binary-artifacts/icu/icu4c-68_2-Win64-MSVC2019.zip" 51 | 52 | # The download URL for the Windows LLVM/Clang binaries 53 | DEF_WIN_LLVM_DOWNLOAD_URL="$DEF_URL_PREFIX/win32-binary-artifacts/llvm/libclang-release_110-based-windows-vs2019_64.7z" 54 | 55 | # The download URL for the macOS LLVM/Clang binaries 56 | DEF_MAC_LLVM_DOWNLOAD_URL="$DEF_URL_PREFIX/mac-binary-artifacts/llvm/libclang-release_110-based-mac.7z" 57 | 58 | # The Qt version to use 59 | DEF_QT_VER=5.15.14 60 | 61 | # The Microsoft Visual C++ version to use 62 | DEF_MSVC_VER=2019 63 | DEF_MSVC_VER_ALT=16.7.1 64 | DEF_MSVC_SPEC=win32-msvc 65 | 66 | # The default release version 67 | # Note: This can also be configured dynamically by using the --release 68 | # option in buildmaster.sh 69 | DEF_RELEASE="x.y" 70 | 71 | # SDK release cycle 72 | # Note: This can also be configured dynamically by using the --rel-cycle 73 | # option in buildmaster.sh 74 | DEF_RELCYCLE="Stable" 75 | 76 | # SDK variant 77 | # Sets the default settings folder name for the Qt Creator and Qt QmlLive 78 | # Note: This can also be configured dynamically by using the -v/--variant 79 | # option in buildmaster.sh 80 | DEF_VARIANT="SailfishSDK" 81 | 82 | # Older SDK variant to copy settings from 83 | # See also DEF_VARIANT 84 | # Note: This can also be configured dynamically by using the --copy-from-variant 85 | # option in buildmaster.sh 86 | DEF_COPY_FROM_VARIANT= 87 | 88 | # SDK pretty variant 89 | # Sets the default base name for the installers and the SDK release name shown 90 | # in the Qt Creator and QmlLive About dialogs 91 | # Note: This can also be configured dynamically by using the -vp/--variant-pretty 92 | # option in buildmaster.sh 93 | DEF_VARIANT_PRETTY="Sailfish SDK" 94 | 95 | # --------------------------------------------------------------------- 96 | # General 97 | 98 | UNAME_SYSTEM=$(uname -s) 99 | UNAME_ARCH=$(uname -m) 100 | 101 | if [[ $UNAME_SYSTEM == "Linux" ]] || [[ $UNAME_SYSTEM == "Darwin" ]]; then 102 | : ${DEF_PREFIX:=$HOME} 103 | else 104 | : ${DEF_PREFIX:=/c} 105 | fi 106 | 107 | win_path() { 108 | sed -e 's,^/c$,c:,' -e 's,^/c/,c:\\,' -e 's,/,\\,g' <<<"$1" 109 | } 110 | 111 | # no `readlink -f` on macOS 112 | BUILD_TOOLS_SRC=$(cd "$(dirname "$0")" && pwd) 113 | 114 | # --------------------------------------------------------------------- 115 | # Qt 116 | 117 | # Source directory 118 | DEF_QT_SOURCE_PACKAGE=qt-everywhere-src-$DEF_QT_VER 119 | DEF_QT_SRC_DIR=$DEF_PREFIX/invariant/$DEF_QT_SOURCE_PACKAGE 120 | 121 | if [[ $UNAME_SYSTEM == "Linux" ]] || [[ $UNAME_SYSTEM == "Darwin" ]]; then 122 | # Dynamic Qt build directory on Linux and MacOS 123 | DEF_QT_DYN_BUILD_DIR=$DEF_PREFIX/invariant/$DEF_QT_SOURCE_PACKAGE-build-rpathpadrpathpad 124 | # Static Qt build directory on Linux and MacOS 125 | DEF_QT_STATIC_BUILD_DIR=$DEF_PREFIX/invariant/$DEF_QT_SOURCE_PACKAGE-static-build 126 | else 127 | # Dynamic Qt build directory on Windows 128 | DEF_QT_DYN_BUILD_DIR=$DEF_PREFIX/invariant/$DEF_QT_SOURCE_PACKAGE-build 129 | # Static Qt build directory on Windows 130 | DEF_QT_STATIC_BUILD_DIR=$DEF_PREFIX/invariant/$DEF_QT_SOURCE_PACKAGE-static-build 131 | fi 132 | 133 | # --------------------------------------------------------------------- 134 | # ICU 135 | 136 | if [[ $UNAME_SYSTEM == "Linux" ]] || [[ $UNAME_SYSTEM == "Darwin" ]]; then 137 | # ICU build configuration on Linux 138 | DEF_ICU_SRC_DIR=$DEF_PREFIX/invariant/icu 139 | DEF_ICU_BUILD_DIR=$DEF_PREFIX/invariant/icu-build 140 | DEF_ICU_INSTALL_DIR=$DEF_PREFIX/invariant/icu-install 141 | else 142 | # On Windows upstream ICU binaries are downloaded 143 | DEF_ICU_DOWNLOAD_DIR=$DEF_PREFIX/invariant 144 | DEF_ICU_INSTALL_DIR=$DEF_PREFIX/invariant/icu 145 | fi 146 | 147 | # --------------------------------------------------------------------- 148 | # LLVM/Clang 149 | 150 | if [[ $UNAME_SYSTEM == "Linux" ]]; then 151 | DEF_LLVM_SRC_DIR=$DEF_PREFIX/invariant/llvm 152 | DEF_LLVM_BUILD_DIR=$DEF_PREFIX/invariant/llvm-build 153 | DEF_LLVM_INSTALL_DIR=$DEF_PREFIX/invariant/llvm-install 154 | else 155 | # On Windows and macOS prebuilt binaries supplied by Qt project are downloaded 156 | DEF_LLVM_DOWNLOAD_DIR=$DEF_PREFIX/invariant 157 | DEF_LLVM_INSTALL_DIR=$DEF_PREFIX/invariant/libclang 158 | fi 159 | 160 | # --------------------------------------------------------------------- 161 | # Qt Creator 162 | 163 | # Source directory 164 | DEF_QTC_SRC_DIR=$DEF_PREFIX/build/sailfish-qtcreator 165 | # Build directory 166 | DEF_QTC_BUILD_SUFFIX=-build 167 | DEF_QTC_BUILD_DIR=$DEF_QTC_SRC_DIR$DEF_QTC_BUILD_SUFFIX 168 | # Install directory 169 | DEF_QTC_INSTALL_SUFFIX=-install 170 | DEF_QTC_INSTALL_ROOT=$DEF_QTC_SRC_DIR$DEF_QTC_INSTALL_SUFFIX 171 | 172 | # --------------------------------------------------------------------- 173 | # Qt Linguist 174 | 175 | # Install directory 176 | DEF_LINGUIST_INSTALL_ROOT=$DEF_PREFIX/build/linguist-install 177 | 178 | # --------------------------------------------------------------------- 179 | # Qt QmlLive 180 | 181 | # Source directory 182 | DEF_QMLLIVE_SRC_DIR=$DEF_PREFIX/build/qmllive 183 | # Build directory 184 | DEF_QMLLIVE_BUILD_SUFFIX=-build 185 | DEF_QMLLIVE_BUILD_DIR=$DEF_QMLLIVE_SRC_DIR$DEF_QMLLIVE_BUILD_SUFFIX 186 | # Install directory 187 | DEF_QMLLIVE_INSTALL_SUFFIX=-install 188 | DEF_QMLLIVE_INSTALL_ROOT=$DEF_QMLLIVE_SRC_DIR$DEF_QMLLIVE_INSTALL_SUFFIX 189 | 190 | # --------------------------------------------------------------------- 191 | # Installer Framework 192 | 193 | # Source directory 194 | DEF_IFW_SRC_DIR=$DEF_PREFIX/invariant/qt-installer-framework 195 | # Build directory 196 | DEF_IFW_BUILD_SUFFIX=-build 197 | DEF_IFW_BUILD_DIR=$DEF_IFW_SRC_DIR$DEF_IFW_BUILD_SUFFIX 198 | 199 | # The default name for the Installer Framework package 200 | DEF_IFW_PACKAGE_NAME="InstallerFW.7z" 201 | 202 | # --------------------------------------------------------------------- 203 | # Installer 204 | 205 | # Source directory 206 | DEF_INSTALLER_SRC_DIR=$DEF_PREFIX/build/sailfish-sdk-installer 207 | 208 | # --------------------------------------------------------------------- 209 | # Documentation 210 | 211 | # The documentation filter attribute to add to the *.qch files 212 | DEF_DOCS_FILTER_ATTRIBUTE="sailfishos" 213 | # The documentation filter name to add to the *.qch files 214 | # Note: This will show up in the Qt Creator Help section 215 | DEF_DOCS_FILTER_NAME="Sailfish OS" 216 | 217 | # --------------------------------------------------------------------- 218 | # Build Engine 219 | 220 | # The default base name for the SDK targets. The '--target-basename' option to setup-buildengine.sh 221 | # overrides this. 222 | # Note: This will result to targets and kits named as e.g. SailfishOS-- 223 | DEF_TARGET_BASENAME="SailfishOS" 224 | 225 | # --------------------------------------------------------------------- 226 | # Scratchbox2 Images 227 | 228 | # The default path to shared location for sb2 images. The '--shared-path' option to 229 | # setup-sb2-images.sh overrides this. 230 | DEF_SHARED_SB2_IMAGES_PATH="targets" 231 | 232 | # --------------------------------------------------------------------- 233 | # Emulator 234 | 235 | # The default path to shared location for emulator images. The '--shared-path' option to 236 | # setup-emulator.sh overides this. 237 | DEF_SHARED_EMULATORS_PATH="emulators" 238 | 239 | # The default base name for emulator images. The '--basename' option to setup-emulator.sh 240 | # overrides this. 241 | DEF_EMULATOR_BASENAME="Sailfish_OS" 242 | -------------------------------------------------------------------------------- /file-information.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Create file information page for SDK release 4 | # 5 | # Copyright (C) 2017 Jolla Oy 6 | # Contact: Jarkko Lehtoranta 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | RELEASE="2.0" 35 | CHECK="md5" 36 | PLATFORMS="linux-64 mac windows" 37 | URL_BASE="https://releases.sailfishos.org/sdk/installers" 38 | NBSP=$'\xC2\xA0' 39 | 40 | fatal() { 41 | echo "FAIL: $@" 42 | exit 1 43 | } 44 | 45 | rename_installers() { 46 | echo "Renaming installers ..." 47 | for installer in SailfishSDK*; do 48 | local new_name=$(sed \ 49 | -e "s/\(SailfishSDK\)-\(.*\)-\(offline\|online\)-\(.*\)\.\(.*$\)/\1-$RELEASE-\2-\3.\5/" \ 50 | -e "s/linux-/linux/" <<< $installer) 51 | mv "$installer" "$new_name" || fatal "error renaming $installer" 52 | done 53 | } 54 | 55 | # Some obscure handling is needed to support the old 'column' on builder 56 | format_table() { 57 | column -t -n \ 58 | |sed "2 { s/[ $NBSP]/-/g; s/|--/| /g; s/--|/ |/g }" \ 59 | |sed 's/ \?| \?/|/g' 60 | } 61 | 62 | usage() { 63 | cat < $FNAME.$CHECK 135 | FSIZE=$(stat -c %s $FNAME) 136 | FSIZE_MIB=$(ls -lh $FNAME | cut -f 5 -d ' ') 137 | MD5=$(cut -f 1 -d ' ' $FNAME.$CHECK) 138 | 139 | cat < Create them but purge and reset on first boot. 37 | 38 | set -e 39 | 40 | systemctl stop sdk-freespace 41 | 42 | rm -rf /srv/mer/targets/*.default/* 43 | 44 | # host side copy is preserved - no need to sync after the initial reset 45 | sed -i -e '/sync-to-host/s/1/0/' /srv/mer/targets/*.default/.sdk-manage.conf 46 | 47 | cat > /usr/lib/oneshot.d/500-sdk-reset-snapshots.sh <<'EOF' 48 | #!/bin/bash 49 | # Script created by setup-buildengine.sh 50 | 51 | sdk-manage() { sudo -u mersdk sdk-manage "$@"; } 52 | 53 | targets=$(sdk-manage target list --long |awk '($4 == "-") { print $1 }') 54 | for target in $targets; do 55 | sdk-manage target snapshot --reset=force $target{,.default} 56 | sed -i -e '/sync-to-host/s/0/1/' /srv/mer/targets/$target.default/.sdk-manage.conf 57 | done 58 | EOF 59 | 60 | chmod +x /usr/lib/oneshot.d/500-sdk-reset-snapshots.sh 61 | add-oneshot --late 500-sdk-reset-snapshots.sh 62 | -------------------------------------------------------------------------------- /make-archive-meta.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Creates meta data files for the given 7z archive files 4 | # 5 | # Copyright (C) 2018-2019 Jolla Ltd. 6 | # Contact: Martin Kampas 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | set -o nounset 35 | set -o pipefail 36 | 37 | synopsis() 38 | { 39 | cat < [--] [key=value]... 41 | END 42 | } 43 | 44 | short_usage() 45 | { 46 | cat < file a corresponding meta data file will be created in the 63 | current working directory, with the same base name but the ".meta" suffix 64 | added. 65 | 66 | Package-specific meta data can be specified with optional "key=value" arguments 67 | after the <7z-archive> file name, where "key" must meet the requirements for 68 | a valid shell variable name. 69 | END 70 | } 71 | 72 | fatal() 73 | { 74 | echo "make-archive-meta.sh: fatal: $*" >&2 75 | } 76 | 77 | bad_usage() 78 | { 79 | fatal "$*" 80 | short_usage >&2 81 | } 82 | 83 | with_tmp_file() 84 | { 85 | local file=$1 cmd=("${@:2}") 86 | local tmp_file= 87 | 88 | with_tmp_file_cleanup() 89 | ( 90 | trap 'echo cleaning up...' INT TERM HUP 91 | if [[ $tmp_file ]]; then 92 | rm -f "$tmp_file" 93 | fi 94 | ) 95 | trap 'with_tmp_file_cleanup; trap - RETURN' RETURN 96 | trap 'return 1' INT TERM HUP 97 | 98 | tmp_file=$(mktemp "$file.XXX") || return 99 | 100 | if "${cmd[@]}" <&3 >"$tmp_file"; then 101 | cat <"$tmp_file" >"$file" || return 102 | else 103 | return $? 104 | fi 105 | } 3<&0 <&- 106 | 107 | get_sha1() 108 | { 109 | local archive=$1 110 | sha1sum <"$archive" |cut -d' ' -f1 111 | } 112 | 113 | get_uncompressed_size() 114 | { 115 | local archive=$1 116 | 117 | local sizes= 118 | sizes=$(7z l -slt "$archive" |sed -n 's/^Size = \([0-9]\+\)$/\1/p') || return 119 | 120 | if [[ ! $sizes ]]; then 121 | fatal "Empty archive '$archive'?" 122 | return 1 123 | fi 124 | 125 | local size= total_size=0 126 | for size in $sizes; do 127 | let total_size+=size 128 | done 129 | 130 | echo "$total_size" 131 | } 132 | 133 | get_compressed_size() 134 | { 135 | local archive=$1 136 | 137 | stat -c "%s" "$archive" || return 138 | } 139 | 140 | get_meta_data() 141 | { 142 | local archive=$1 143 | local extra_data=("${@:2}") 144 | 145 | local basename= 146 | basename=$(basename "$archive") || return 147 | 148 | local sha1= 149 | sha1=$(get_sha1 "$archive") || return 150 | 151 | local uncompressed_size= 152 | uncompressed_size=$(get_uncompressed_size "$archive") || return 153 | 154 | local compressed_size= 155 | compressed_size=$(get_compressed_size "$archive") || return 156 | 157 | printf '%s %s %s %s' "$basename" "$sha1" "$uncompressed_size" "$compressed_size" 158 | if [[ ${extra_data[@]+"${extra_data[@]}"} ]]; then 159 | printf ' %q' ${extra_data[@]+"${extra_data[@]}"} 160 | fi 161 | printf '\n' 162 | } 163 | 164 | main() 165 | { 166 | local opt_archive= 167 | local opt_extra_data=() 168 | 169 | while (( $# > 0 )); do 170 | case $1 in 171 | -h) 172 | short_usage 173 | return 174 | ;; 175 | --help) 176 | usage 177 | return 178 | ;; 179 | --) 180 | shift 181 | break 182 | ;; 183 | -*) 184 | bad_usage "Unexpected argument: $1" 185 | return 1 186 | ;; 187 | *) 188 | if [[ ! $opt_archive ]]; then 189 | opt_archive=$1 190 | else 191 | if ! [[ $1 == *?=* ]]; then 192 | bad_usage "Unexpected argument: $1" 193 | return 1 194 | fi 195 | if ! [[ $1 =~ ^[a-zA-Z_][a-zA-Z0-9_]*= ]]; then 196 | bad_usage "Key must be a valid shell variable identifier: $1" 197 | return 1 198 | fi 199 | opt_extra_data+=("$1") 200 | fi 201 | ;; 202 | esac 203 | shift 204 | done 205 | 206 | opt_extra_data+=("$@") 207 | 208 | if [[ ! $opt_archive ]]; then 209 | bad_usage "Argument expected" 210 | return 1 211 | fi 212 | 213 | local meta="$(basename "$opt_archive").meta" 214 | with_tmp_file "$meta" get_meta_data "$opt_archive" ${opt_extra_data[@]+"${opt_extra_data[@]}"} || return 215 | } 216 | 217 | main "$@" 218 | -------------------------------------------------------------------------------- /make-sb2-image-meta.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Creates meta data file for the given sb2 image file 4 | # 5 | # Copyright (C) 2022 Jolla Ltd. 6 | # All rights reserved. 7 | # 8 | # You may use this file under the terms of BSD license as follows: 9 | # 10 | # Redistribution and use in source and binary forms, with or without 11 | # modification, are permitted provided that the following conditions are met: 12 | # * Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # * Redistributions in binary form must reproduce the above copyright 15 | # notice, this list of conditions and the following disclaimer in the 16 | # documentation and/or other materials provided with the distribution. 17 | # * Neither the name of the Jolla Ltd nor the 18 | # names of its contributors may be used to endorse or promote products 19 | # derived from this software without specific prior written permission. 20 | # 21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 25 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | # 32 | 33 | set -o nounset 34 | set -o pipefail 35 | 36 | synopsis() 37 | { 38 | cat < 40 | END 41 | } 42 | 43 | short_usage() 44 | { 45 | cat < file a corresponding meta data file will be created in the 62 | current working directory, with the same base name but the ".meta" suffix 63 | added. 64 | END 65 | } 66 | 67 | fatal() 68 | { 69 | echo "make-sb2-image-meta.sh: fatal: $*" >&2 70 | } 71 | 72 | bad_usage() 73 | { 74 | fatal "$*" 75 | short_usage >&2 76 | } 77 | 78 | with_tmp_file() 79 | { 80 | local file=$1 cmd=("${@:2}") 81 | local tmp_file= 82 | 83 | with_tmp_file_cleanup() 84 | ( 85 | trap 'echo cleaning up...' INT TERM HUP 86 | if [[ $tmp_file ]]; then 87 | rm -f "$tmp_file" 88 | fi 89 | ) 90 | trap 'with_tmp_file_cleanup; trap - RETURN' RETURN 91 | trap 'return 1' INT TERM HUP 92 | 93 | tmp_file=$(mktemp "$file.XXX") || return 94 | 95 | if "${cmd[@]}" <&3 >"$tmp_file"; then 96 | cat <"$tmp_file" >"$file" || return 97 | else 98 | return $? 99 | fi 100 | } 3<&0 <&- 101 | 102 | get_meta_data() 103 | { 104 | local archive=$1 105 | 106 | local ssu_ini= 107 | ssu_ini=$(tar -x --to-stdout -f "$archive" ./etc/ssu/ssu.ini) || return 108 | 109 | local brand= 110 | brand=$(sed -n 's/^brand=//p' <<<"$ssu_ini") || return 111 | [[ $brand ]] || { fatal "Failed to determine Brand name"; return 1; } 112 | 113 | local release= 114 | release=$(sed -n 's/^release=//p' <<<"$ssu_ini") || return 115 | [[ $release ]] || { fatal "Failed to determine Release version"; return 1; } 116 | 117 | cat < 0 )); do 130 | case $1 in 131 | -h) 132 | short_usage 133 | return 134 | ;; 135 | --help) 136 | usage 137 | return 138 | ;; 139 | -*) 140 | bad_usage "Unexpected argument: $1" 141 | return 1 142 | ;; 143 | *) 144 | if [[ ! $opt_archive ]]; then 145 | opt_archive=$1 146 | else 147 | bad_usage "Unexpected argument: $1" 148 | return 1 149 | fi 150 | ;; 151 | esac 152 | shift 153 | done 154 | 155 | if [[ ! $opt_archive ]]; then 156 | bad_usage "Argument expected" 157 | return 1 158 | fi 159 | 160 | local meta="$(basename "$opt_archive").meta" 161 | with_tmp_file "$meta" get_meta_data "$opt_archive" || return 162 | } 163 | 164 | main "$@" 165 | -------------------------------------------------------------------------------- /patches/qtdeclarative-windows-python-under-program-files.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/qml/configure.pri b/src/qml/configure.pri 2 | index fcd2eac..4506a57 100644 3 | --- a/src/qml/configure.pri 4 | +++ b/src/qml/configure.pri 5 | @@ -13,7 +13,7 @@ defineTest(qtConfTest_detectPython) { 6 | } 7 | 8 | # Make tests.python.location available in configure.json. 9 | - $${1}.location = $$shell_path($$python_path) 10 | + $${1}.location = $$shell_quote($$shell_path($$python_path)) 11 | export($${1}.location) 12 | $${1}.cache += location 13 | export($${1}.cache) 14 | -------------------------------------------------------------------------------- /patches/qttools-lupdate-Process-mjs-files.patch: -------------------------------------------------------------------------------- 1 | From 0f6439532b6d4ef4eff0ba61ba5110cc6ce3ea16 Mon Sep 17 00:00:00 2001 2 | From: Martin Kampas 3 | Date: Thu, 21 Nov 2019 10:57:32 +0100 4 | Subject: [PATCH] lupdate: Process .mjs files 5 | 6 | --- 7 | src/linguist/lupdate/lupdate.h | 1 + 8 | src/linguist/lupdate/main.cpp | 4 +++- 9 | src/linguist/lupdate/qdeclarative.cpp | 14 ++++++++++---- 10 | 3 files changed, 14 insertions(+), 5 deletions(-) 11 | 12 | diff --git a/src/linguist/lupdate/lupdate.h b/src/linguist/lupdate/lupdate.h 13 | index 5dbd0e21..f8eda621 100644 14 | --- a/src/linguist/lupdate/lupdate.h 15 | +++ b/src/linguist/lupdate/lupdate.h 16 | @@ -74,6 +74,7 @@ bool loadUI(Translator &translator, const QString &filename, ConversionData &cd) 17 | 18 | #ifndef QT_NO_QML 19 | bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd); 20 | +bool loadQScriptModule(Translator &translator, const QString &filename, ConversionData &cd); 21 | bool loadQml(Translator &translator, const QString &filename, ConversionData &cd); 22 | #endif 23 | 24 | diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp 25 | index 6c4e3db9..fd085b69 100644 26 | --- a/src/linguist/lupdate/main.cpp 27 | +++ b/src/linguist/lupdate/main.cpp 28 | @@ -510,6 +510,8 @@ static void processSources(Translator &fetchedTor, 29 | else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive) 30 | || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive)) 31 | loadQScript(fetchedTor, *it, cd); 32 | + else if (it->endsWith(QLatin1String(".mjs"), Qt::CaseInsensitive)) 33 | + loadQScriptModule(fetchedTor, *it, cd); 34 | else if (it->endsWith(QLatin1String(".qml"), Qt::CaseInsensitive)) 35 | loadQml(fetchedTor, *it, cd); 36 | #else 37 | @@ -669,7 +671,7 @@ int main(int argc, char **argv) 38 | #endif // Q_OS_WIN32 39 | #endif 40 | 41 | - m_defaultExtensions = QLatin1String("java,jui,ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx,js,qs,qml,qrc"); 42 | + m_defaultExtensions = QLatin1String("java,jui,ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx,js,mjs,qs,qml,qrc"); 43 | 44 | QStringList args = app.arguments(); 45 | QStringList tsFileNames; 46 | diff --git a/src/linguist/lupdate/qdeclarative.cpp b/src/linguist/lupdate/qdeclarative.cpp 47 | index 7a453aa3..90215daa 100644 48 | --- a/src/linguist/lupdate/qdeclarative.cpp 49 | +++ b/src/linguist/lupdate/qdeclarative.cpp 50 | @@ -448,7 +448,8 @@ private: 51 | int lastOffset; 52 | }; 53 | 54 | -static bool load(Translator &translator, const QString &filename, ConversionData &cd, bool qmlMode) 55 | +static bool load(Translator &translator, const QString &filename, ConversionData &cd, bool qmlMode, 56 | + bool mjsMode) 57 | { 58 | cd.m_sourceFileName = filename; 59 | QFile file(filename); 60 | @@ -474,7 +475,7 @@ static bool load(Translator &translator, const QString &filename, ConversionData 61 | lexer.setCode(code, /*line = */ 1, qmlMode); 62 | driver.setLexer(&lexer); 63 | 64 | - if (qmlMode ? parser.parse() : parser.parseProgram()) { 65 | + if (qmlMode ? parser.parse() : mjsMode ? parser.parseModule() : parser.parseProgram()) { 66 | FindTrCalls trCalls(&driver, cd); 67 | 68 | //find all tr calls in the code 69 | @@ -489,12 +490,17 @@ static bool load(Translator &translator, const QString &filename, ConversionData 70 | 71 | bool loadQml(Translator &translator, const QString &filename, ConversionData &cd) 72 | { 73 | - return load(translator, filename, cd, /*qmlMode=*/ true); 74 | + return load(translator, filename, cd, /*qmlMode=*/ true, /*mjsMode=*/ false); 75 | } 76 | 77 | bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd) 78 | { 79 | - return load(translator, filename, cd, /*qmlMode=*/ false); 80 | + return load(translator, filename, cd, /*qmlMode=*/ false, /*mjsMode=*/ false); 81 | +} 82 | + 83 | +bool loadQScriptModule(Translator &translator, const QString &filename, ConversionData &cd) 84 | +{ 85 | + return load(translator, filename, cd, /*qmlMode=*/ false, /*mjsMode=*/ true); 86 | } 87 | 88 | QT_END_NAMESPACE 89 | -- 90 | 2.24.0 91 | 92 | -------------------------------------------------------------------------------- /prune-shared.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Remove unused shared images from upload host 4 | # 5 | # Copyright (C) 2019 Jolla Ltd. 6 | # Contact: Martin Kampas 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | . $(dirname $0)/utils.sh 36 | 37 | set -o nounset 38 | set -o pipefail 39 | 40 | synopsis() 41 | { 42 | cat <] 44 | [--uuser ] [--upath ] 45 | [--keep <7zfile>...] 46 | END 47 | } 48 | 49 | short_usage() 50 | { 51 | cat < at upload host. Relative will 64 | be resolved against '--upath'. Works equally for images uploaded by 65 | setup-sb2-images.sh and setup-emulator.sh. In case of the former it also 66 | updates the 'targets.json' if it exists in . 67 | 68 | This tool does not remove unused files permanently. A directory at 69 | .TRASH will be created to hold the files (re)moved from - it needs 70 | to be cleared manually in order to free the disk space. 71 | 72 | OPTIONS 73 | -y, --non-interactive 74 | Assume yes to all questions 75 | 76 | --keep <7zfile>... 77 | Do not remove the <7zfile> and the accompanying meta data files. 78 | Multiple files may be specified, separated with comma. 79 | 80 | --uhost 81 | Override the default upload host [$DEF_UPLOAD_HOST] 82 | 83 | --uuser 84 | Override the default upload user [$DEF_UPLOAD_USER] 85 | 86 | --upath 87 | Override the default global upload path [$DEF_UPLOAD_PATH] 88 | END 89 | } 90 | 91 | fatal() 92 | { 93 | echo "prune-shared.sh: fatal: $*" >&2 94 | } 95 | 96 | bad_usage() 97 | { 98 | fatal "$*" 99 | short_usage >&2 100 | } 101 | 102 | set_defaults() 103 | { 104 | OPT_H= 105 | OPT_HELP= 106 | OPT_INTERACTIVE=1 107 | OPT_KEEP= 108 | OPT_SHARED_PATH= 109 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 110 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 111 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 112 | } 113 | 114 | parse_opts() 115 | { 116 | local positional=() 117 | while (( $# > 0 )); do 118 | case $1 in 119 | -h) 120 | OPT_H=1 121 | return 122 | ;; 123 | --help) 124 | OPT_HELP=1 125 | return 126 | ;; 127 | -y|--non-interactive) 128 | OPT_INTERACTIVE= 129 | ;; 130 | --keep) 131 | if [[ ! ${2:-} ]]; then 132 | bad_usage "Argument expected: $1" 133 | return 1 134 | fi 135 | OPT_KEEP=${2//,/$'\n'} 136 | shift 137 | ;; 138 | --uhost) 139 | if [[ ! ${2:-} ]]; then 140 | bad_usage "Argument expected: $1" 141 | return 1 142 | fi 143 | OPT_UPLOAD_HOST=$2 144 | shift 145 | ;; 146 | --upath) 147 | if [[ ! ${2:-} ]]; then 148 | bad_usage "Argument expected: $1" 149 | return 1 150 | fi 151 | OPT_UPLOAD_PATH=$2 152 | shift 153 | ;; 154 | --uuser) 155 | if [[ ! ${2:-} ]]; then 156 | bad_usage "Argument expected: $1" 157 | return 1 158 | fi 159 | OPT_UPLOAD_USER=$2 160 | shift 161 | ;; 162 | --) 163 | shift 164 | break 165 | ;; 166 | -*) 167 | bad_usage "Unexpected argument: $1" 168 | return 1 169 | ;; 170 | *) 171 | positional+=("$1") 172 | ;; 173 | esac 174 | shift 175 | done 176 | 177 | positional+=("$@") 178 | 179 | if [[ ${#positional[@]} -ne 1 ]]; then 180 | bad_usage "Exactly one positional argument expected" 181 | return 1 182 | fi 183 | 184 | OPT_SHARED_PATH=${positional[0]} 185 | 186 | if [[ $OPT_SHARED_PATH && $OPT_SHARED_PATH != /* ]]; then 187 | OPT_SHARED_PATH=$OPT_UPLOAD_PATH/$OPT_SHARED_PATH 188 | fi 189 | OPT_SHARED_PATH=$(ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" \ 190 | "realpath --canonicalize-missing $OPT_SHARED_PATH") || return 191 | } 192 | 193 | main() 194 | { 195 | set_defaults || return 196 | parse_opts "$@" || return 197 | 198 | if [[ $OPT_H ]]; then 199 | short_usage 200 | return 201 | fi 202 | 203 | if [[ $OPT_HELP ]]; then 204 | usage 205 | return 206 | fi 207 | 208 | local used_images= 209 | used_images=$(ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" \ 210 | "find $OPT_UPLOAD_PATH -type l -exec readlink -f {} \\;" \ 211 | |sort -u |sed -n "s,^$OPT_SHARED_PATH/,,p") || return 212 | local all_images= 213 | all_images=$(ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" "cd $OPT_SHARED_PATH && ls *.7z" |sort) || return 214 | 215 | local unused_images= 216 | unused_images=$(join -v 1 <(cat <<<"$all_images") <(cat <<<"$used_images")) || return 217 | 218 | local to_remove=() 219 | to_remove=($(join -v 1 <(cat <<<"$unused_images") <(cat <<<"$OPT_KEEP"))) || return 220 | 221 | if [[ ${#to_remove[*]} -eq 0 ]]; then 222 | echo "Nothing to be removed" >&2 223 | else 224 | to_remove+=("${to_remove[@]/%/.meta}" "${to_remove[@]/%/.md5sum}") 225 | 226 | if [[ $OPT_INTERACTIVE ]]; then 227 | echo "The following images (and the accompanying files) would be removed from the upload host:" 228 | echo 229 | (IFS=$'\n'; sed 's/^/\t/' <<<"${to_remove[*]}" |sort) 230 | echo 231 | local YN= 232 | read -p "Continue? [Y/n] " YN 233 | [[ $YN && $YN != y ]] && return 234 | fi 235 | 236 | local trash=$OPT_SHARED_PATH.TRASH 237 | ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" \ 238 | "mkdir -p $trash \ 239 | && cd $OPT_SHARED_PATH \ 240 | && mv -v --target-directory=$trash ${to_remove[*]}" 241 | fi 242 | 243 | if ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" "test -e $OPT_SHARED_PATH/targets.json"; then 244 | echo "Updating targets.json..." >&2 245 | update_remote_targets_json "$OPT_SHARED_PATH" || return 246 | fi 247 | } 248 | 249 | main "$@" 250 | -------------------------------------------------------------------------------- /refresh-sdk-repos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Refresh MerSDK zypper repositories for SDK release 4 | # 5 | # Copyright (C) 2014-2023 Jolla Oy 6 | # Contact: http://jolla.com/ 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | # default is to use public repositories, which means no domain changes 35 | # are necessary 36 | OPT_PUBLIC_REPOS=1 37 | 38 | SSU_RELEASE=latest 39 | SSU_DOMAIN=sdkinstaller 40 | 41 | SSU_RELEASE_ORIG=latest 42 | # mersdk and emulator are on sailfish domain 43 | SSU_DOMAIN_ORIG=sailfish 44 | # targets are on sales domain 45 | SSU_DOMAIN_ORIG_TARGET=sales 46 | 47 | SSU_REFRESH_DOMAIN=10.21.0.20 48 | 49 | SSU_INIFILE=/usr/share/ssu/repos.ini 50 | 51 | # list here files that are to be removed after refresh has been run 52 | CLEANUP_FILES=/var/log/zypper.log 53 | 54 | TOOLINGS_DIR=/srv/mer/toolings 55 | 56 | sdk_user=mersdk 57 | 58 | if [[ $(hostname) != "SailfishSDK" ]]; then 59 | echo "You must run this script in the MerSDK build engine." 60 | exit 1 61 | fi 62 | 63 | if [[ $EUID -ne 0 ]]; then 64 | exec sudo $0 "$@" 65 | echo "$0 must be run as root and sudo failed; exiting" 66 | exit 1 67 | fi 68 | 69 | usage() 70 | { 71 | cat <$repoini 161 | 162 | [$SSU_DOMAIN-domain] 163 | _ca-certificate=/etc/ssl/certs/sailfish-ca.pem 164 | releaseProtocol=http 165 | releaseDomain=$SSU_REFRESH_DOMAIN 166 | releasePath=sdk 167 | secureDomain=%(releaseDomain) 168 | ssuRegDomain=ssu.sailfishos.org 169 | EOF 170 | 171 | check_target_visible() { 172 | local tgt=$1 173 | local sbox2dir=/home/$sdk_user/.scratchbox2 174 | . $sbox2dir/$tgt/sb2.config 2>/dev/null 175 | if [[ ! -d "$SBOX_TARGET_ROOT" ]]; then 176 | echo "no" 177 | return 178 | fi 179 | echo "yes" 180 | } 181 | 182 | get_targets() { 183 | local tgts=$(sudo -i -u $sdk_user sdk-manage target list --long \ 184 | |awk '$4 == "-" { print $1 }') # skip snapshots 185 | [[ $? -ne 0 ]] && return 186 | 187 | for t in $tgts; do 188 | if [[ $(check_target_visible $t) == "yes" ]]; then 189 | echo $t 190 | fi 191 | done 192 | } 193 | 194 | print_object() { 195 | local type=${1%:*} object=${1#*:} 196 | 197 | case $type in 198 | sdk) echo -n "SDK";; 199 | *) echo -n "$type '$object'";; 200 | esac 201 | } 202 | 203 | enter() { 204 | local type=${1%:*} object=${1#*:} 205 | shift 206 | 207 | case $type in 208 | sdk) 209 | "$@" 210 | ;; 211 | tooling) 212 | $TOOLINGS_DIR/$object/mer-tooling-chroot "$@" 213 | ;; 214 | target) 215 | sudo -i -u $sdk_user sb2 -t $object -m sdk-install -R "$@" 216 | ;; 217 | esac 218 | } 219 | 220 | refresh() { 221 | local object=$1 222 | 223 | local reposbackup=$SSU_INIFILE~ 224 | 225 | echo "#### Refresh $(print_object $object) repos" 226 | 227 | if [[ $OPT_PUBLIC_REPOS -eq 1 ]]; then 228 | # refresh repos 229 | enter $object zypper --non-interactive ref 230 | else 231 | # save the original ini file 232 | enter $object cp -a $SSU_INIFILE $reposbackup 233 | 234 | # append contents of $repoini file to ssu repos.ini 235 | enter $object tee --append $SSU_INIFILE <$repoini >/dev/null 236 | enter $object ssu domain $SSU_DOMAIN 237 | enter $object ssu release $SSU_RELEASE 238 | 239 | # refresh repos 240 | enter $object zypper --non-interactive ref 241 | 242 | if [[ -z $OPT_KEEP_TEST_DOMAIN ]]; then 243 | # restore the original ssu status 244 | enter $object mv $reposbackup $SSU_INIFILE 245 | enter $object ssu domain $SSU_DOMAIN_ORIG_TARGET 246 | enter $object ssu release $SSU_RELEASE_ORIG 247 | else 248 | enter $object rm -f $reposbackup 249 | fi 250 | fi 251 | 252 | # clean up remaining stuff here 253 | enter $object rm -f $CLEANUP_FILES 254 | } 255 | 256 | ###### 257 | # 258 | # Do it 259 | refresh sdk 260 | 261 | toolings=$(sdk-manage --tooling --list) 262 | for tooling in $toolings; do 263 | refresh tooling:$tooling 264 | done 265 | 266 | targets=$(get_targets) 267 | for target in $targets; do 268 | refresh target:$target 269 | done 270 | 271 | echo "#### Done" 272 | 273 | # For Emacs: 274 | # Local Variables: 275 | # indent-tabs-mode:nil 276 | # tab-width:8 277 | # sh-basic-offset:4 278 | # End: 279 | # For VIM: 280 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 281 | -------------------------------------------------------------------------------- /sdk-setup-qa.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2013-2023 Jolla Ltd. 4 | # Contact: Juha Kallioinen 5 | # 6 | # Change the ssu domain and release for SDK QA purposes 7 | # 8 | # The ssu domain and release will be changed for the build engine, sdk 9 | # emulator and all scratchbox2 targets found in the build engine. 10 | # 11 | # Run this script on the build engine. 12 | # 13 | ################################################################ 14 | 15 | SSU_RELEASE=latest 16 | SSU_DOMAIN=sailfishqa 17 | SSU_REGDOMAIN=10.21.0.20 18 | 19 | ################################################################ 20 | # 21 | sdk_user=mersdk 22 | ssh_keys=/etc/$sdk_user/share/ssh/private_keys/SailfishOS_Emulator/ 23 | emu_ip=10.220.220.1 24 | 25 | if [[ $(hostname) != "SailfishSDK" ]]; then 26 | echo "You must run this script in the SailfishSDK build engine." 27 | exit 1 28 | fi 29 | 30 | if [[ $EUID -ne 0 ]]; then 31 | exec sudo $0 "$@" 32 | echo "$0 must be run as root and sudo failed; exiting" 33 | exit 1 34 | fi 35 | 36 | usage() 37 | { 38 | cat < use hostname or ip address as the reg domain 53 | -r use as the release 54 | -y answer 'yes' to all questions from this script 55 | 56 | EOF 57 | [[ -n $1 ]] && exit 1 58 | } 59 | 60 | OPT_ASK_USER=1 61 | OPT_IGNORE_EMULATOR=0 62 | 63 | while [[ ${1:-} ]]; do 64 | case "$1" in 65 | -y) shift 66 | OPT_ASK_USER=0 67 | ;; 68 | -i) shift 69 | OPT_IGNORE_EMULATOR=1 70 | ;; 71 | -d) shift 72 | SSU_REGDOMAIN=$1; shift 73 | [[ -z $SSU_REGDOMAIN ]] && usage quit 74 | ;; 75 | -r) shift 76 | SSU_RELEASE=$1; shift 77 | [[ -z $SSU_RELEASE ]] && usage quit 78 | ;; 79 | -h|--help|-*) 80 | usage quit 81 | ;; 82 | *) 83 | usage quit 84 | ;; 85 | esac 86 | done 87 | 88 | if [[ $OPT_IGNORE_EMULATOR -eq 0 ]]; then 89 | echo "Testing connection to the Emulator ..." 90 | ssh -F /etc/ssh/ssh_config.sdk -i $ssh_keys/root root@$emu_ip true 91 | if [[ $? -ne 0 ]]; then 92 | echo "Could not connect to the Emulator. Please start it or use -i option to ignore this." 93 | exit 1 94 | fi 95 | fi 96 | 97 | cat <$repoini <&1) 161 | [[ $? -ne 0 ]] && return 0 162 | 163 | for t in $tgts; do 164 | if [[ $(check_target_visible $t) == "yes" ]]; then 165 | echo $t 166 | fi 167 | done 168 | } 169 | 170 | target_change_domain() 171 | { 172 | local tgt 173 | [[ -z ${1:-} ]] && return 0 174 | 175 | tgt=$1 176 | echo "#### Changing $tgt domain" 177 | # use sed to append contents of $repoini file to ssu repos.ini 178 | sudo -i -u $sdk_user bash -c "sb2 -t $tgt -m sdk-install -R sed -i '$ r $repoini' /usr/share/ssu/repos.ini" 2>/dev/null 179 | sudo -i -u $sdk_user bash -c "sb2 -t $tgt -m sdk-install -R ssu domain $SSU_DOMAIN" 2>/dev/null 180 | sudo -i -u $sdk_user bash -c "sb2 -t $tgt -m sdk-install -R ssu release $SSU_RELEASE" 2>/dev/null 181 | } 182 | 183 | ###### 184 | # 185 | # Build engine 186 | echo "#### Changing BE ssu domain" 187 | cat $repoini >> /usr/share/ssu/repos.ini 188 | ssu domain $SSU_DOMAIN 189 | ssu release $SSU_RELEASE 190 | 191 | ###### 192 | # 193 | # Emulator 194 | if [[ $OPT_IGNORE_EMULATOR -eq 0 ]]; then 195 | echo "#### Changing Emulator ssu domain" 196 | cat $repoini | ssh -F /etc/ssh/ssh_config.sdk -i $ssh_keys/root root@$emu_ip "cat >> /usr/share/ssu/repos.ini" 197 | ssh -F /etc/ssh/ssh_config.sdk -i $ssh_keys/root root@$emu_ip ssu domain $SSU_DOMAIN 198 | ssh -F /etc/ssh/ssh_config.sdk -i $ssh_keys/root root@$emu_ip ssu release $SSU_RELEASE 199 | else 200 | echo "#### Ignoring the Emulator" 201 | fi 202 | 203 | ###### 204 | # 205 | # Targets 206 | targets=$(get_targets) 207 | for target in $targets; do 208 | target_change_domain $target 209 | done 210 | 211 | echo "#### Done" 212 | 213 | # For Emacs: 214 | # Local Variables: 215 | # indent-tabs-mode:nil 216 | # tab-width:8 217 | # sh-basic-offset:4 218 | # End: 219 | # For VIM: 220 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 221 | -------------------------------------------------------------------------------- /seccomp.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultAction": "SCMP_ACT_ALLOW", 3 | "archMap": [ 4 | { 5 | "architecture": "SCMP_ARCH_X86_64", 6 | "subArchitectures": [ 7 | "SCMP_ARCH_X86", 8 | "SCMP_ARCH_X32" 9 | ] 10 | } 11 | ], 12 | "syscalls": [ 13 | { 14 | "names": [ 15 | "keyctl", 16 | "keyctl_chown" 17 | ], 18 | "action": "SCMP_ACT_ERRNO", 19 | "errnoRet": 38, 20 | "comment": "Workaround for https://github.com/systemd/systemd/issues/6281" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /setup-buildengine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- mode: sh;flycheck-sh-bash-args: ("-O" "extglob"); -*- 3 | # 4 | # SDK build engine creation script 5 | # 6 | # Copyright (C) 2014-2023 Jolla Oy 7 | # Copyright (C) 2019-2020 Open Mobile Platform LLC. 8 | # All rights reserved. 9 | # 10 | # You may use this file under the terms of BSD license as follows: 11 | # 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions are met: 14 | # * Redistributions of source code must retain the above copyright 15 | # notice, this list of conditions and the following disclaimer. 16 | # * Redistributions in binary form must reproduce the above copyright 17 | # notice, this list of conditions and the following disclaimer in the 18 | # documentation and/or other materials provided with the distribution. 19 | # * Neither the name of the Jolla Ltd nor the 20 | # names of its contributors may be used to endorse or promote products 21 | # derived from this software without specific prior written permission. 22 | # 23 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 24 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 27 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | # 34 | 35 | . $(dirname $0)/defaults.sh 36 | . $(dirname $0)/utils.sh 37 | 38 | shopt -s extglob 39 | 40 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 41 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 42 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 43 | 44 | # ultra compression by default 45 | OPT_COMPRESSION=9 46 | OPT_RELEASE="latest" 47 | OPT_TOOLING= 48 | declare -A OPT_TARGETS=() 49 | OPT_VM="MerSDK.build" 50 | OPT_VDI= 51 | OPT_TARGET_BASENAME=${DEF_TARGET_BASENAME} 52 | 53 | # some static settings for the VM 54 | SSH_PORT=2222 55 | HTTP_PORT=8080 56 | 57 | # wrap it all up into these files 58 | PACKAGE_NAME=buildengine-vbox.7z 59 | DOCKER_PACKAGE_NAME=buildengine-docker.7z 60 | 61 | fatal() { 62 | echo "FAIL: $@" 63 | exit 1 64 | } 65 | 66 | # silent 7z a bit 67 | 7z() { 68 | stdbuf -o0 7z "$@" |gawk '/^Compressing / { printf "Compressing...\r"; next } { print $0 }' 69 | return ${PIPESTATUS[0]} 70 | } 71 | 72 | vboxmanage_wrapper() { 73 | echo "VBoxManage $@" 74 | VBoxManage "$@" 75 | [[ $? -ne 0 ]] && fatal "VBoxManage failed" 76 | } 77 | 78 | unregisterVm() { 79 | echo "Unregistering $OPT_VM" 80 | # make sure the VM is not running 81 | VBoxManage controlvm "$OPT_VM" poweroff 2>/dev/null 82 | VBoxManage unregistervm "$OPT_VM" --delete 2>/dev/null 83 | } 84 | 85 | createVM() { 86 | vboxmanage_wrapper createvm --basefolder=$VM_BASEFOLDER --name "$OPT_VM" --ostype Linux26 --register 87 | vboxmanage_wrapper modifyvm "$OPT_VM" --memory 1024 --vram 128 --accelerate3d off 88 | vboxmanage_wrapper storagectl "$OPT_VM" --name "SATA" --add sata --controller IntelAHCI $SATACOMMAND 1 89 | vboxmanage_wrapper storageattach "$OPT_VM" --storagectl SATA --port 0 --type hdd --mtype normal --medium $OPT_VDI 90 | vboxmanage_wrapper modifyvm "$OPT_VM" --nic1 nat --nictype1 virtio 91 | vboxmanage_wrapper modifyvm "$OPT_VM" --nic2 intnet --intnet2 sailfishsdk --nictype2 virtio --macaddress2 08005A11F155 92 | vboxmanage_wrapper modifyvm "$OPT_VM" --bioslogodisplaytime 1 93 | vboxmanage_wrapper modifyvm "$OPT_VM" --natpf1 "guestssh,tcp,127.0.0.1,${SSH_PORT},,22" 94 | vboxmanage_wrapper modifyvm "$OPT_VM" --natpf1 "guestwww,tcp,127.0.0.1,${HTTP_PORT},,9292" 95 | vboxmanage_wrapper modifyvm "$OPT_VM" --natdnshostresolver1 on 96 | } 97 | 98 | createShares() { 99 | # put 'ssh' and 'vmshare' into $SSHCONFIG_PATH 100 | mkdir -p $SSHCONFIG_PATH/ssh/mersdk 101 | vboxmanage_wrapper sharedfolder add "$OPT_VM" --name ssh --hostpath $SSHCONFIG_PATH/ssh 102 | 103 | mkdir -p $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine 104 | pushd $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine 105 | ssh-keygen -t rsa -N "" -f mersdk 106 | cp mersdk.pub $SSHCONFIG_PATH/ssh/mersdk/authorized_keys 107 | popd 108 | 109 | # required for the MerSDK network config 110 | cat < $SSHCONFIG_PATH/vmshare/devices.xml 111 | 112 | 113 | 114 | 10.220.220 115 | 116 | 117 | EOF 118 | vboxmanage_wrapper sharedfolder add "$OPT_VM" --name config --hostpath $SSHCONFIG_PATH/vmshare 119 | 120 | # and then 'targets' and 'home' for $INSTALL_PATH 121 | mkdir -p $INSTALL_PATH/targets 122 | vboxmanage_wrapper sharedfolder add "$OPT_VM" --name targets --hostpath $INSTALL_PATH/targets 123 | vboxmanage_wrapper sharedfolder add "$OPT_VM" --name home --hostpath $INSTALL_PATH 124 | } 125 | 126 | startVM() { 127 | vboxmanage_wrapper startvm --type headless "$OPT_VM" 128 | 129 | # wait a few seconds 130 | sleep 2 131 | } 132 | 133 | installTooling() { 134 | local tooling=$1 135 | local file=$2 136 | 137 | echo "Installing tooling $tooling to $OPT_VM" 138 | 139 | if [[ ! -f $OPT_TOOLING ]]; then 140 | fatal "$OPT_TOOLING does not exist!" 141 | fi 142 | 143 | ln $OPT_TOOLING $INSTALL_PATH/ 144 | 145 | echo "Creating tooling ..." 146 | ssh -o UserKnownHostsFile=/dev/null \ 147 | -o StrictHostKeyChecking=no \ 148 | -p $SSH_PORT \ 149 | -i $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine/mersdk \ 150 | mersdk@localhost "sdk-manage --mode installer --tooling --install $tooling file:///host_home/$file" 151 | } 152 | 153 | installTarget() { 154 | local tgt=$1 155 | local file=$2 156 | 157 | echo "Installing target $tgt to $OPT_VM" 158 | 159 | if [[ ! -f $file ]]; then 160 | fatal "$file does not exist!" 161 | fi 162 | 163 | ln $file $INSTALL_PATH/ 164 | 165 | echo "Creating target ..." 166 | ssh -o UserKnownHostsFile=/dev/null \ 167 | -o StrictHostKeyChecking=no \ 168 | -p $SSH_PORT \ 169 | -i $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine/mersdk \ 170 | mersdk@localhost "sdk-manage --mode installer --target --install --jfdi $tgt file:///host_home/$file" 171 | } 172 | 173 | createTar() { 174 | echo "Mounting vdi ..." 175 | sudo modprobe nbd max_part=16 176 | sudo qemu-nbd -c /dev/nbd0 mersdk/mer.vdi 177 | sleep 1 178 | if [[ ! -e /dev/nbd0p1 ]]; then 179 | fatal "/dev/nbd0p1 does not exist!" 180 | fi 181 | mkdir -p mer.d 182 | sudo mount /dev/nbd0p1 mer.d 183 | 184 | echo "Changing permissions of /srv/mer ..." 185 | sudo chmod -R a+rwX mer.d/srv/mer 186 | 187 | echo "Compressing filesystem ..." 188 | sudo tar -C mer.d --exclude './srv/mer/*' -cf mersdk/sailfish.tar --one-file-system --numeric-owner . 189 | sudo tar -C mer.d/srv/mer -cf mersdk/sailfish-tools.tar --numeric-owner . 190 | sudo umount mer.d 191 | sudo qemu-nbd -d /dev/nbd0 192 | 193 | sudo chown "$USER:$USER" -- mersdk/sailfish*.tar 194 | } 195 | 196 | checkVBox() { 197 | # check that VBox is 4.3 or newer - affects the sataport count. 198 | VBOX_TOCHECK="4.3" 199 | echo "Using VirtualBox v$VBOX_VERSION" 200 | if [[ $(bc <<< "$VBOX_VERSION >= $VBOX_TOCHECK") -eq 1 ]]; then 201 | SATACOMMAND="--portcount" 202 | else 203 | SATACOMMAND="--sataportcount" 204 | fi 205 | } 206 | 207 | initPaths() { 208 | # anything under this directory will end up in the package 209 | RELATIVE_INSTALL_PATH=mersdk 210 | INSTALL_PATH=$PWD/$RELATIVE_INSTALL_PATH 211 | rm -rf $INSTALL_PATH 212 | mkdir -p $INSTALL_PATH 213 | # anything under this directory will end up in the docker package 214 | DOCKER_PREFIX=$PWD/docker 215 | DOCKER_INSTALL_PATH=$DOCKER_PREFIX/$RELATIVE_INSTALL_PATH 216 | rm -rf $DOCKER_INSTALL_PATH 217 | mkdir -p $DOCKER_INSTALL_PATH 218 | # copy refresh script to an accessible path, this needs to be 219 | # removed later 220 | cp -a $BUILD_TOOLS_SRC/refresh-sdk-repos.sh $INSTALL_PATH 221 | cp -a $BUILD_TOOLS_SRC/hack-snapshots-cow.sh $INSTALL_PATH 222 | 223 | # this is not going to end up inside the package 224 | SSHCONFIG_PATH=$PWD/sshconfig 225 | rm -rf $SSHCONFIG_PATH 226 | mkdir -p $SSHCONFIG_PATH 227 | 228 | # this is not going to end up inside the package 229 | VM_BASEFOLDER=$PWD/basefolder 230 | rm -rf $VM_BASEFOLDER 231 | mkdir -p $VM_BASEFOLDER 232 | } 233 | 234 | checkIfVMexists() { 235 | if [[ -n $(VBoxManage list vms 2>&1 | grep $OPT_VM) ]]; then 236 | fatal "$OPT_VM already exists. Please unregister it from VirtualBox before proceeding." 237 | fi 238 | } 239 | 240 | checkForRequiredFiles() { 241 | if [[ ! -f $OPT_VDI ]]; then 242 | fatal "VDI file [$OPT_VDI] not found in the current directory." 243 | fi 244 | 245 | if [[ ! -f $OPT_TOOLING ]]; then 246 | fatal "Tooling file [$OPT_TOOLING] not found in the current directory." 247 | fi 248 | 249 | for target_filename in "${OPT_TARGETS[@]}"; do 250 | if [ ! -e "$target_filename" ] ; then 251 | fatal "Target file [$target_filename] not found in the current directory." 252 | fi 253 | done 254 | } 255 | 256 | packVM() { 257 | echo "Creating 7z package ..." 258 | # Shut down the VM so it won't interfere (and make sure it's down). This 259 | # will probably fail because sdk-shutdown has already done its job, so 260 | # ignore any error output. 261 | VBoxManage controlvm "$OPT_VM" poweroff 2>/dev/null 262 | 263 | # remove target archive files 264 | rm -f $INSTALL_PATH/$OPT_TOOLING 265 | for target_filename in "${OPT_TARGETS[@]}"; do 266 | rm -f "$INSTALL_PATH/$target_filename" 267 | done 268 | 269 | # remove stuff that is not meant to end up in the package 270 | rm -f $INSTALL_PATH/.bash_history $INSTALL_PATH/refresh-sdk-repos.sh 271 | rm -f $INSTALL_PATH/hack-snapshots-cow.sh 272 | 273 | # copy the used VDI file: 274 | echo "Hard linking $PWD/$OPT_VDI => $INSTALL_PATH/mer.vdi" 275 | ln $PWD/$OPT_VDI $INSTALL_PATH/mer.vdi 276 | 277 | mkdir -p vmshare 278 | cp $SSHCONFIG_PATH/vmshare/df.cache vmshare/ 279 | 280 | if [[ ! $OPT_NO_COMPRESSION ]]; then 281 | # and 7z the mersdk with chosen compression 282 | 7z a -mx=$OPT_COMPRESSION $PACKAGE_NAME $INSTALL_PATH/ vmshare/ 283 | fi 284 | } 285 | 286 | packDocker() { 287 | echo "Creating Docker 7z package..." 288 | # move the docker tarball to docker directory 289 | mv $INSTALL_PATH/sailfish*.tar $DOCKER_INSTALL_PATH/ 290 | 291 | if [[ ! $OPT_NO_COMPRESSION ]]; then 292 | local threads=$(nproc) 293 | (( threads > 1 )) && let threads-- # be nice 294 | xz -$OPT_COMPRESSION -T $threads $DOCKER_INSTALL_PATH/sailfish*.tar 295 | fi 296 | 297 | echo "copying $INSTALL_PATH/targets => $DOCKER_INSTALL_PATH/targets" 298 | cp -R $INSTALL_PATH/targets $DOCKER_INSTALL_PATH/targets 299 | 300 | cp $(dirname $0)/seccomp.json $DOCKER_INSTALL_PATH/ 301 | 302 | if [[ ! $OPT_NO_COMPRESSION ]]; then 303 | # and 7z the mersdk with chosen compression 304 | pushd $DOCKER_PREFIX 305 | 7z a -mx=$OPT_COMPRESSION $DOCKER_PACKAGE_NAME $RELATIVE_INSTALL_PATH/!(sailfish*.tar.xz) 306 | 7z a -mx=0 $DOCKER_PACKAGE_NAME $RELATIVE_INSTALL_PATH/sailfish*.tar.xz 307 | popd 308 | mv $DOCKER_PREFIX/$DOCKER_PACKAGE_NAME . 309 | fi 310 | } 311 | 312 | checkForRunningVms() { 313 | local running=$(VBoxManage list runningvms 2>/dev/null) 314 | 315 | if [[ -n $running ]]; then 316 | echo -n "These virtual machines are running " 317 | 318 | if [[ -n $OPT_IGNORE_RUNNING ]]; then 319 | echo "[IGNORED]" 320 | else 321 | echo "- please stop them before continuing." 322 | fi 323 | 324 | echo $running 325 | 326 | [[ -n $OPT_IGNORE_RUNNING ]] || exit 1 327 | fi 328 | } 329 | 330 | usage() { 331 | cat < [OPTION] setup and package the VM 336 | $(basename $0) unregister [-vm ] unregister the VM 337 | 338 | Options: 339 | -u | --upload upload local build result to [$OPT_UPLOAD_HOST] as user [$OPT_UPLOAD_USER] 340 | the uploaded build will be copied to [$OPT_UPLOAD_PATH/] 341 | the upload directory will be created if it is not there 342 | -uh | --uhost override default upload host 343 | -up | --upath override default upload path 344 | -uu | --uuser override default upload user 345 | -y | --non-interactive answer yes to all questions presented by the script 346 | -f | --vdi-file use file as the virtual disk image [required] 347 | -i | --ignore-running ignore running VMs 348 | -r | --refresh force a zypper refresh for MerSDK and sb2 targets 349 | -p | --private use private rpm repository in 10.21.0.20 350 | -td | --test-domain keep test domain after refreshing the repos 351 | -o | --orig-release turn ssu release to this instead of latest after refreshing repos 352 | -rel | --release release number to mention in tooling/target names 353 | -c | --compression <0-9> compression level of 7z [$OPT_COMPRESSION] 354 | -nc | --no-compression do not create the 7z 355 | -t | --tooling tooling tarball , must be in current directory 356 | --target- target rootstrap , must be in current directory 357 | -un | --unregister unregister the created VM at the end of script run 358 | -hax | --horrible-hack disable jolla-core.check systemCheck file 359 | -vm | --vm-name create VM with [$OPT_VM] 360 | --no-meta suppress creating meta data files with 361 | 'make-archive-meta.sh' 362 | --target-basename base name for tooling and targets, 363 | must use alphanumeric characters only [$OPT_TARGET_BASENAME] 364 | -h | --help this help 365 | 366 | EOF 367 | 368 | # exit if any argument is given 369 | [[ -n "$1" ]] && exit 1 370 | } 371 | 372 | # BASIC EXECUTION STARTS HERE: 373 | 374 | # handle commandline options 375 | while [[ ${1:-} ]]; do 376 | case "$1" in 377 | -c | --compression ) shift 378 | OPT_COMPRESSION=$1; shift 379 | if [[ $OPT_COMPRESSION != [0123456789] ]]; then 380 | usage quit 381 | fi 382 | ;; 383 | -nc | --no-compression ) shift 384 | OPT_NO_COMPRESSION=1 385 | ;; 386 | -f | --vdi-file ) shift 387 | OPT_VDI=$1; shift 388 | ;; 389 | -t | --tooling ) shift 390 | # Enforce that the file resides under CWD for sharing with build engine 391 | OPT_TOOLING=$(basename $1); shift 392 | ;; 393 | --target-* ) 394 | # Enforce that the file resides under CWD for sharing with build engine 395 | OPT_TARGETS[${1#--target-}]=$(basename $2) 396 | shift 2 397 | ;; 398 | -td | --test-domain ) shift 399 | OPT_KEEP_TEST_DOMAIN="--test-domain" 400 | ;; 401 | -i | --ignore-running ) shift 402 | OPT_IGNORE_RUNNING=1 403 | ;; 404 | -hax | --horrible-hack ) shift 405 | OPT_HACKIT=1 406 | ;; 407 | -r | --refresh ) shift 408 | OPT_REFRESH=1 409 | ;; 410 | -p | --private ) shift 411 | OPT_PRIVATE_REPO="-p" 412 | ;; 413 | -o | --orig-release ) shift 414 | OPT_ORIGINAL_RELEASE=$1; shift 415 | [[ -z $OPT_ORIGINAL_RELEASE ]] && fatal "empty original release option given" 416 | ;; 417 | -rel | --release ) shift 418 | OPT_RELEASE=$1; shift 419 | [[ -z $OPT_RELEASE ]] && fatal "empty release option given" 420 | ;; 421 | -u | --upload ) shift 422 | OPT_UPLOAD=1 423 | OPT_UL_DIR=$1; shift 424 | if [[ -z $OPT_UL_DIR ]]; then 425 | fatal "upload option requires a directory name" 426 | fi 427 | ;; 428 | -vm | --vm-name ) shift 429 | OPT_VM=$1; shift 430 | ;; 431 | -uh | --uhost ) shift; 432 | OPT_UPLOAD_HOST=$1; shift 433 | ;; 434 | -up | --upath ) shift; 435 | OPT_UPLOAD_PATH=$1; shift 436 | ;; 437 | -uu | --uuser ) shift; 438 | OPT_UPLOAD_USER=$1; shift 439 | ;; 440 | --no-meta ) shift 441 | OPT_NO_META=1 442 | ;; 443 | -h | --help ) shift 444 | usage quit 445 | ;; 446 | -y | --non-interactive ) shift 447 | OPT_YES=1 448 | ;; 449 | -un | --unregister ) shift 450 | OPT_UNREGISTER=1 451 | ;; 452 | unregister ) shift 453 | OPT_DO_UNREGISTER=1 454 | ;; 455 | --target-basename ) shift 456 | OPT_TARGET_BASENAME=$1; shift 457 | [[ -z $OPT_TARGET_BASENAME ]] && fatal "empty target-basename option given" 458 | ;; 459 | * ) 460 | usage quit 461 | ;; 462 | esac 463 | done 464 | 465 | # check if we have VBoxManage 466 | VBOX_VERSION=$(VBoxManage --version 2>/dev/null | cut -f -2 -d '.') 467 | if [[ -z $VBOX_VERSION ]]; then 468 | fatal "VBoxManage not found." 469 | fi 470 | 471 | # handle the explicit unregister case here 472 | if [[ -n $OPT_DO_UNREGISTER ]]; then 473 | unregisterVm 474 | exit $? 475 | fi 476 | 477 | if [[ -z $OPT_VDI ]]; then 478 | # Always require a given vdi file 479 | fatal "VDI file option is required (-f filename.vdi)" 480 | fi 481 | 482 | if [[ ${OPT_VDI: -4} == ".bz2" ]]; then 483 | echo "unpacking $OPT_VDI ..." 484 | bunzip2 -f -k $OPT_VDI 485 | OPT_VDI=${OPT_VDI%.bz2} 486 | fi 487 | 488 | # get our VDI's formatted filename 489 | OPT_VDI=$(basename $OPT_VDI) 490 | 491 | # user can decide to care or not about running vms 492 | checkForRunningVms 493 | 494 | # do we have everything.. 495 | checkForRequiredFiles 496 | 497 | # clear our workarea 498 | initPaths 499 | 500 | # some preliminary checks 501 | checkVBox 502 | checkIfVMexists 503 | 504 | # all go, let's do it: 505 | echo "Creating $OPT_VM, compression=$OPT_COMPRESSION" 506 | 507 | { 508 | echo "Release:;$OPT_RELEASE" 509 | echo "MerSDK VDI:;$OPT_VDI" 510 | echo "Tooling:;$OPT_TOOLING" 511 | for targetarch in ${!OPT_TARGETS[*]} ; do 512 | echo "${targetarch^^} target:;${OPT_TARGETS[$targetarch]}" 513 | done 514 | } |column -t -s ';' |sed 's/^/ /' 515 | 516 | if [[ -n $OPT_REFRESH ]]; then 517 | echo " Force zypper refresh for repos" 518 | if [[ -n $OPT_PRIVATE_REPO ]]; then 519 | if [[ -n $OPT_KEEP_TEST_DOMAIN ]]; then 520 | echo " ... and keep test ssu domain after refresh" 521 | else 522 | echo " ... after update set ssu release to [${OPT_ORIGINAL_RELEASE:-latest}]" 523 | fi 524 | fi 525 | else 526 | echo " Do NOT refresh repos" 527 | fi 528 | if [[ $OPT_NO_COMPRESSION ]]; then 529 | echo " Do NOT compress the resulting VDI" 530 | fi 531 | if [[ -n $OPT_UPLOAD ]]; then 532 | echo " Upload build results as user [$OPT_UPLOAD_USER] to [$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR]" 533 | else 534 | echo " Do NOT upload build results" 535 | fi 536 | 537 | if [[ -n $OPT_HACKIT ]]; then 538 | echo " ### DO HORRIBLE SYSTEMCHECK HACK!!! ###" 539 | fi 540 | 541 | # confirm 542 | if [[ -z $OPT_YES ]]; then 543 | while true; do 544 | read -p "Do you want to continue? (y/n) " answer 545 | case $answer in 546 | [Yy]*) 547 | break ;; 548 | [Nn]*) 549 | echo "Ok, exiting" 550 | exit 0 551 | ;; 552 | *) 553 | echo "Please answer yes or no." 554 | ;; 555 | esac 556 | done 557 | fi 558 | 559 | # record start time 560 | BUILD_START=$(date +%s) 561 | 562 | # set up machine in VirtualBox 563 | createVM 564 | # define the shared directories 565 | createShares 566 | # start the VM 567 | startVM 568 | 569 | # install tooling to the VM 570 | installTooling "$OPT_TARGET_BASENAME-$OPT_RELEASE" "$OPT_TOOLING" 571 | 572 | # install targets to the VM 573 | TARGET_NAMES=() 574 | for targetarch in ${!OPT_TARGETS[*]}; do 575 | installTarget "$OPT_TARGET_BASENAME-$OPT_RELEASE-$targetarch" "${OPT_TARGETS[$targetarch]}" 576 | TARGET_NAMES+=("$OPT_TARGET_BASENAME-$OPT_RELEASE-$targetarch") 577 | done 578 | 579 | if [[ -n $OPT_HACKIT ]]; then 580 | echo "### EMBARRASSING HACK! CLEANING jolla-core.check!!!" 581 | ssh -o UserKnownHostsFile=/dev/null \ 582 | -o StrictHostKeyChecking=no \ 583 | -p $SSH_PORT \ 584 | -i $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine/mersdk \ 585 | mersdk@localhost "cat /dev/null | sudo tee /etc/zypp/systemCheck.d/jolla-core.check" 586 | fi 587 | 588 | # Hack: ensure snapshots are CoW copies also with Docker 589 | ssh -o UserKnownHostsFile=/dev/null \ 590 | -o StrictHostKeyChecking=no \ 591 | -p $SSH_PORT \ 592 | -i $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine/mersdk \ 593 | mersdk@localhost "sudo bash /host_home/hack-snapshots-cow.sh" 594 | 595 | # refresh the zypper repositories 596 | if [[ -n $OPT_REFRESH ]]; then 597 | ssh -o UserKnownHostsFile=/dev/null \ 598 | -o StrictHostKeyChecking=no \ 599 | -p $SSH_PORT \ 600 | -i $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine/mersdk \ 601 | mersdk@localhost "sudo bash /host_home/refresh-sdk-repos.sh -y ${OPT_PRIVATE_REPO:-} ${OPT_KEEP_TEST_DOMAIN:-} --release ${OPT_ORIGINAL_RELEASE:-latest}" 602 | fi 603 | 604 | # shut the VM down cleanly so that it has time to flush its disk 605 | ssh -o UserKnownHostsFile=/dev/null \ 606 | -o StrictHostKeyChecking=no \ 607 | -p $SSH_PORT \ 608 | -i $SSHCONFIG_PATH/vmshare/ssh/private_keys/engine/mersdk \ 609 | mersdk@localhost "sdk-shutdown" 610 | 611 | echo "Giving VM 10 seconds to really shut down ..." 612 | while [[ $(( waitc++ )) -lt 10 ]]; do 613 | 614 | [[ $(VBoxManage list runningvms | grep -c $OPT_VM) -eq 0 ]] && break 615 | 616 | echo "waiting ..." 617 | sleep 1 618 | 619 | [[ $waitc -ge 10 ]] && echo "WARNING: $OPT_VM did not shut down cleanly!" 620 | done 621 | 622 | # wrap it all up into 7z file for installer: 623 | packVM 624 | 625 | # start the VM 626 | createTar 627 | 628 | packDocker 629 | 630 | results=($PACKAGE_NAME) 631 | results+=($DOCKER_PACKAGE_NAME) 632 | 633 | if [[ -z $OPT_NO_META ]]; then 634 | vdi_capacity=$(vdi_capacity <$INSTALL_PATH/mer.vdi) 635 | $BUILD_TOOLS_SRC/make-archive-meta.sh $PACKAGE_NAME "vdi_capacity=$vdi_capacity" \ 636 | "targets=$(echo -n ${TARGET_NAMES[*]})" 637 | results+=($PACKAGE_NAME.meta) 638 | $BUILD_TOOLS_SRC/make-archive-meta.sh $DOCKER_PACKAGE_NAME \ 639 | "targets=$(echo -n ${TARGET_NAMES[*]})" 640 | results+=($DOCKER_PACKAGE_NAME.meta) 641 | fi 642 | 643 | if [[ -n "$OPT_UPLOAD" ]]; then 644 | echo "Uploading $PACKAGE_NAME and $DOCKER_PACKAGE_NAME ..." 645 | 646 | # create upload dir 647 | ssh $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST mkdir -p $OPT_UPLOAD_PATH/$OPT_UL_DIR/ 648 | scp ${results[*]} $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/ 649 | fi 650 | 651 | if [[ -n $OPT_UNREGISTER ]]; then 652 | unregisterVm 653 | fi 654 | 655 | # record end time 656 | BUILD_END=$(date +%s) 657 | 658 | echo "=================================" 659 | time=$(( BUILD_END - BUILD_START )) 660 | hour=$(( $time / 3600 )) 661 | mins=$(( $time / 60 - 60*$hour )) 662 | secs=$(( $time - 3600*$hour - 60*$mins )) 663 | 664 | echo Time used: $(printf "%02d:%02d:%02d" $hour $mins $secs) 665 | 666 | # For Emacs: 667 | # Local Variables: 668 | # indent-tabs-mode:nil 669 | # tab-width:8 670 | # sh-basic-offset:4 671 | # End: 672 | # For VIM: 673 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 674 | -------------------------------------------------------------------------------- /setup-buildenv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python -tt 2 | 3 | # Copyright (C) 2015 Jolla Oy 4 | # Contact: Jussi Pakkanen 5 | # All rights reserved. 6 | # 7 | # You may use this file under the terms of BSD license as follows: 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions are met: 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # * Neither the name of the Jolla Ltd nor the 17 | # names of its contributors may be used to endorse or promote products 18 | # derived from this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 24 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | # Download and extract all source dependencies that we have. 32 | # Run this in ~/invariant (or C:\invariant on Windows). 33 | 34 | import platform 35 | import os, sys 36 | import urllib 37 | import shutil 38 | import subprocess 39 | import tarfile, zipfile 40 | 41 | # Only download gzipped files because Python2 does not have xz 42 | # unpacker. (Python 3 has it.) 43 | 44 | downloads = [ 45 | ('https://download.qt.io/archive/qt/5.6/5.6.2/single/qt-everywhere-opensource-src-5.6.2.tar.gz', 'qt-everywhere-opensource-src-5.6.2.tar.gz', 'qt-everywhere-opensource-src-5.6.2'), 46 | ('https://download.qt.io/official_releases/qt-installer-framework/2.0.5/qt-installer-framework-opensource-2.0.5-src.tar.gz', 'qt-installer-framework-opensource-2.0.5-src.tar.gz', 'qt-installer-framework-opensource-2.0.5-src'), 47 | ] 48 | 49 | if platform.system() == 'Linux': 50 | downloads.append(('http://download.icu-project.org/files/icu4c/4.2.1/icu4c-4_2_1-src.tgz', 'icu4c-4_2_1-src.tgz', 'icu')) 51 | elif platform.system() == 'Windows': 52 | downloads.append(('http://download.icu-project.org/files/icu4c/4.8.1.1/icu4c-4_8_1_1-Win32-msvc10.zip', 'icu4c-4_8_1_1-Win32-msvc10.zip', 'icu')) 53 | elif platform.system() == 'Darwin': 54 | pass # OSX does not need ICU. 55 | else: 56 | print 'Unknown platform:', platform.system() 57 | sys.exit(1) 58 | 59 | for d in downloads: 60 | (url, fname, dirname) = d 61 | try: 62 | os.unlink(fname) 63 | except Exception: 64 | pass 65 | print 'Downloading', url 66 | urllib.urlretrieve(url, fname) 67 | shutil.rmtree(dirname, ignore_errors=True) 68 | if fname.endswith('.zip'): 69 | tf = zipfile.ZipFile(fname, 'r') 70 | else: 71 | tf = tarfile.open(fname) 72 | print 'Extracting', fname 73 | tf.extractall() 74 | 75 | print('''You need to install platform build dependencies by hand. On 76 | Debian-derivatives this means running the following commands: 77 | 78 | sudo apt-get install build-essential pkg-config chrpath 79 | sudo apt-get install "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev 80 | sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby''') 81 | -------------------------------------------------------------------------------- /setup-documentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Build a documentation package for Sailfish SDK installer 4 | # 5 | # Copyright (C) 2014 Jolla Oy 6 | # Contact: Juha Kallioinen 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | 36 | SELF=$(basename "$0") 37 | 38 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 39 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 40 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 41 | 42 | OPT_DOCVERSION=$(date +%y%m%d) 43 | OPT_DOCDIR=$PWD 44 | OPT_COMPRESSION=9 45 | 46 | QTDOC_NAME=qtdocumentation.7z 47 | SAILDOC_NAME=sailfishdocumentation.7z 48 | 49 | failure() { 50 | echo "Error: $1" 51 | exit 1 52 | } 53 | 54 | usage() { 55 | cat < set documentation version [$OPT_DOCVERSION] 63 | -d | --docdir search for .qch files from [$OPT_DOCDIR] 64 | -u | --upload upload local build result to [$OPT_UPLOAD_HOST] as user [$OPT_UPLOAD_USER] 65 | the uploaded build will be copied to [$OPT_UPLOAD_PATH/] 66 | the upload directory will be created if it is not there 67 | -uh | --uhost override default upload host 68 | -up | --upath override default upload path 69 | -uu | --uuser override default upload user 70 | -y | --non-interactive answer yes to all questions presented by the script 71 | -c | --compression <0-9> compression level of 7z [$OPT_COMPRESSION] 72 | -h | --help this help 73 | 74 | EOF 75 | 76 | # exit if any argument is given 77 | [[ -n "$1" ]] && exit 1 78 | } 79 | 80 | add_filter() ( 81 | set -o nounset 82 | 83 | QCH=$1 84 | FILTER_ATTRIBUTE=$2 85 | FILTER_NAME=$3 86 | 87 | sql() { 88 | local query=$1 89 | sqlite3 "$QCH" "$query" 90 | } 91 | 92 | existing_filter_id=$(sql "SELECT Id FROM FilterNameTable WHERE Name = '$FILTER_NAME';") || exit 93 | if [[ $existing_filter_id ]]; then 94 | echo "$SELF: '$QCH' already contains required filter. Nothing to do." >&2 95 | exit 0 96 | else 97 | echo "$SELF: Adding filter to '$QCH'" >&2 98 | fi 99 | 100 | sql "INSERT INTO FilterAttributeTable VALUES(NULL, '$FILTER_ATTRIBUTE');" || exit 101 | attribute_id=$(sql "SELECT MAX(Id) FROM FilterAttributeTable;") || exit 102 | 103 | sql "INSERT INTO FilterNameTable VALUES(NULL, '$FILTER_NAME');" || exit 104 | filter_id=$(sql "SELECT MAX(Id) FROM FilterNameTable;") || exit 105 | 106 | sql "INSERT INTO FilterTable VALUES($filter_id, $attribute_id);" || exit 107 | 108 | sql "INSERT INTO IndexFilterTable (FilterAttributeId, IndexId) \ 109 | SELECT $attribute_id, Id FROM IndexTable;" || exit 110 | 111 | sql "INSERT INTO ContentsFilterTable (FilterAttributeId, ContentsId) \ 112 | SELECT $attribute_id, Id FROM ContentsTable;" || exit 113 | 114 | sql "INSERT INTO FileAttributeSetTable \ 115 | SELECT MAX(Id), $attribute_id FROM FileAttributeSetTable;" || exit 116 | 117 | sql "INSERT INTO FileFilterTable \ 118 | SELECT $attribute_id, Id FROM FileDataTable;" || exit 119 | ) 120 | 121 | # handle commandline options 122 | while [[ ${1:-} ]]; do 123 | case "$1" in 124 | -v | --version ) shift 125 | OPT_DOCVERSION=$1; shift 126 | ;; 127 | -d | --docdir ) shift 128 | OPT_DOCDIR=$1; shift 129 | OPT_DOCDIR=$(readlink -f $OPT_DOCDIR) 130 | ;; 131 | -u | --upload ) shift 132 | OPT_UPLOAD=1 133 | OPT_UL_DIR=$1; shift 134 | if [[ -z $OPT_UL_DIR ]]; then 135 | failure "upload option requires a directory name" 136 | fi 137 | ;; 138 | -uh | --uhost ) shift; 139 | OPT_UPLOAD_HOST=$1; shift 140 | ;; 141 | -up | --upath ) shift; 142 | OPT_UPLOAD_PATH=$1; shift 143 | ;; 144 | -uu | --uuser ) shift; 145 | OPT_UPLOAD_USER=$1; shift 146 | ;; 147 | -c | --compression ) shift 148 | OPT_COMPRESSION=$1; shift 149 | if [[ $OPT_COMPRESSION != [0123456789] ]]; then 150 | usage quit 151 | fi 152 | ;; 153 | -y | --non-interactive ) shift 154 | OPT_YES=1 155 | ;; 156 | -h | --help ) shift 157 | usage quit 158 | ;; 159 | * ) 160 | shift 161 | ;; 162 | esac 163 | done 164 | 165 | INSTALL_PATH=$PWD/documentation 166 | 167 | # summary 168 | echo "Summary of chosen actions:" 169 | echo "Using .qch files in [$OPT_DOCDIR]" 170 | echo "Workdir [$INSTALL_PATH]" 171 | echo " 1) Create documentation packages with version [$OPT_DOCVERSION]" 172 | if [[ -n $OPT_UPLOAD ]]; then 173 | echo " 2) Upload packages as user [$OPT_UPLOAD_USER] to [$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR]" 174 | else 175 | echo " 2) Do NOT upload packages" 176 | fi 177 | 178 | # confirm 179 | if [[ -z $OPT_YES ]]; then 180 | while true; do 181 | read -p "Do you want to continue? (y/n) " answer 182 | case $answer in 183 | [Yy]*) 184 | break ;; 185 | [Nn]*) 186 | echo "Ok, exiting" 187 | exit 0 188 | ;; 189 | *) 190 | echo "Please answer yes or no." 191 | ;; 192 | esac 193 | done 194 | fi 195 | 196 | mkdir -p $INSTALL_PATH 197 | rm -rf $INSTALL_PATH/* 198 | rm -f $QTDOC_NAME $SAILDOC_NAME 199 | 200 | # create Qt documentation package 201 | for NAME in $(ls $OPT_DOCDIR/q*.qch); do 202 | newname=$(basename $NAME) 203 | ln $NAME $INSTALL_PATH/${newname%.qch}$OPT_DOCVERSION.qch 204 | done 205 | 206 | 7z a -mx=$OPT_COMPRESSION $QTDOC_NAME $INSTALL_PATH/ 207 | rm -f $INSTALL_PATH/* 208 | 209 | # create Sailfish documentation package 210 | for NAME in $(ls $OPT_DOCDIR/{amber,sdk-,*sailfish,KF5*,lipstick,nemo,libkeepalive}*.qch); do 211 | if ! add_filter "$NAME" "$DEF_DOCS_FILTER_ATTRIBUTE" "$DEF_DOCS_FILTER_NAME"; then 212 | failure "Failed to add filter to '$NAME'" 213 | fi 214 | newname=$(basename $NAME) 215 | ln $NAME $INSTALL_PATH/${newname%.qch}$OPT_DOCVERSION.qch 216 | done 217 | 218 | 7z a -mx=$OPT_COMPRESSION $SAILDOC_NAME $INSTALL_PATH/ 219 | rm -f $INSTALL_PATH/* 220 | 221 | if [ "$OPT_UPLOAD" ]; then 222 | echo "Uploading documentation" 223 | 224 | # create upload dir 225 | ssh $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST mkdir -p $OPT_UPLOAD_PATH/$OPT_UL_DIR/ 226 | scp $QTDOC_NAME $SAILDOC_NAME $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/ 227 | fi 228 | -------------------------------------------------------------------------------- /setup-emulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # SDK emulator creation script 4 | # 5 | # Copyright (C) 2014 Jolla Oy 6 | # Contact: Juha Kallioinen 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | . $(dirname $0)/utils.sh 36 | 37 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 38 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 39 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 40 | OPT_BASENAME=$DEF_EMULATOR_BASENAME 41 | OPT_SHARED_PATH=$DEF_SHARED_EMULATORS_PATH 42 | 43 | OPT_COMPRESSION=9 44 | 45 | fatal() { 46 | echo "FAIL: $@" 47 | exit 1 48 | } 49 | 50 | checkForVDI() { 51 | if [[ ! -f "$VDI" ]];then 52 | fatal "VDI file \"$VDI\" does not exist." 53 | fi 54 | } 55 | 56 | usage() { 57 | cat < [OPTION] 62 | 63 | Options: 64 | -u | --upload upload local build result to [$OPT_UPLOAD_HOST] as user [$OPT_UPLOAD_USER] 65 | is the root directory for this SDK build, 66 | relative to the global upload path 67 | [$OPT_UPLOAD_PATH]. Files will be uploaded under 68 | the '/emulators' path. If this path does not 69 | exist, a symbolic link will be created using this 70 | name, pointing to the shared location for emulator 71 | images. This can be overriden by '--no-shared', in 72 | which case a a directory will be created instead 73 | of the symbolic link. The default shared location 74 | can be overriden with '--shared-path'. 75 | --no-shared see '--upload' 76 | --shared-path see '--upload'. Relative will be resolved 77 | relatively to '--upath' [$DEF_SHARED_EMULATORS_PATH] 78 | -uh | --uhost override default upload host 79 | -up | --upath override default upload path 80 | -uu | --uuser override default upload user 81 | -y | --non-interactive answer yes to all questions presented by the script 82 | --basename basename for the resulting archive [$DEF_EMULATOR_BASENAME] 83 | -rel | --release release number [required] 84 | -f | --vdi-file use this vdi file [required] 85 | -c | --compression <0-9> compression level of 7z [$OPT_COMPRESSION] 86 | --no-meta suppress creating meta data files with 87 | 'make-archive-meta.sh' 88 | -h | --help this help 89 | 90 | EOF 91 | 92 | # exit if any argument is given 93 | [[ -n "$1" ]] && exit 1 94 | } 95 | 96 | 97 | # handle commandline options 98 | while [[ ${1:-} ]]; do 99 | case "$1" in 100 | -c | --compression ) shift 101 | OPT_COMPRESSION=$1; shift 102 | if [[ $OPT_COMPRESSION != [0123456789] ]]; then 103 | usage quit 104 | fi 105 | ;; 106 | -u | --upload ) shift 107 | OPT_UPLOAD=1 108 | OPT_UL_DIR=$1; shift 109 | if [[ -z $OPT_UL_DIR ]]; then 110 | fatal "upload option requires a directory name" 111 | fi 112 | ;; 113 | -uh | --uhost ) shift; 114 | OPT_UPLOAD_HOST=$1; shift 115 | ;; 116 | -up | --upath ) shift; 117 | OPT_UPLOAD_PATH=$1; shift 118 | ;; 119 | -uu | --uuser ) shift; 120 | OPT_UPLOAD_USER=$1; shift 121 | ;; 122 | -y | --non-interactive ) shift 123 | OPT_YES=1 124 | ;; 125 | -f | --vdi-file ) shift 126 | OPT_VDI=$1; shift 127 | ;; 128 | --basename ) shift 129 | OPT_BASENAME=$1; shift 130 | if [[ -z $OPT_BASENAME ]]; then 131 | fatal "the --basename option requires an argument" 132 | fi 133 | ;; 134 | -rel | --release ) shift 135 | OPT_RELEASE=$1; shift 136 | if [[ -z $OPT_RELEASE ]]; then 137 | fatal "the --release option requires an argument" 138 | fi 139 | ;; 140 | --no-shared ) shift 141 | OPT_NO_SHARED=1 142 | ;; 143 | --shared-path ) shift 144 | OPT_SHARED_PATH=$1; shift 145 | if [[ -z $OPT_SHARED_PATH ]]; then 146 | fatal "the --shared-path option requires an argument" 147 | fi 148 | ;; 149 | --no-meta ) shift 150 | OPT_NO_META=1 151 | ;; 152 | -h | --help ) shift 153 | usage quit 154 | ;; 155 | * ) 156 | usage quit 157 | ;; 158 | esac 159 | done 160 | 161 | if [[ -z $OPT_RELEASE ]]; then 162 | echo "The --release option is required" 163 | exit 1 164 | fi 165 | 166 | if [[ $OPT_SHARED_PATH && $OPT_SHARED_PATH != /* ]]; then 167 | OPT_SHARED_PATH=$OPT_UPLOAD_PATH/$OPT_SHARED_PATH 168 | fi 169 | 170 | ARCHIVE_NAME=$OPT_BASENAME-$OPT_RELEASE-Sailfish_SDK_Emulator.7z 171 | 172 | if [[ -n $OPT_VDI ]]; then 173 | VDIFILE=$OPT_VDI 174 | 175 | if [[ ${VDIFILE: -4} == ".bz2" ]]; then 176 | echo "unpacking $VDIFILE ..." 177 | bunzip2 -f -k $VDIFILE 178 | VDIFILE=${VDIFILE%.bz2} 179 | fi 180 | else 181 | # Always require a given vdi file 182 | # VDIFILE=$(find . -iname "*.vdi" | head -1) 183 | 184 | echo "VDI file option is required (-f filename.vdi)" 185 | exit 1 186 | fi 187 | 188 | # get our VDI's formatted filename. 189 | if [[ -n $VDIFILE ]]; then 190 | VDI=$(basename $VDIFILE) 191 | fi 192 | 193 | # check if we even have files 194 | checkForVDI 195 | 196 | # all go, let's do it: 197 | cat < sailfishos.vdi" 226 | ln $PWD/$VDI sailfishos.vdi 227 | 7z a -mx=$OPT_COMPRESSION $ARCHIVE_NAME sailfishos.vdi 228 | results=($ARCHIVE_NAME) 229 | 230 | if [[ -z $OPT_NO_META ]]; then 231 | vdi_capacity=$(vdi_capacity &2 249 | $BUILD_TOOLS_SRC/prune-shared.sh --uhost "$OPT_UPLOAD_HOST" \ 250 | --uuser "$OPT_UPLOAD_USER" --upath "$OPT_UPLOAD_PATH" "$OPT_SHARED_PATH" 251 | fi 252 | rsync --ignore-existing --verbose --info=skip ${results[*]} \ 253 | $OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_UPLOAD_PATH/$OPT_UL_DIR/emulators/ 254 | fi 255 | 256 | # For Emacs: 257 | # Local Variables: 258 | # indent-tabs-mode:nil 259 | # tab-width:8 260 | # sh-basic-offset:4 261 | # End: 262 | # For VIM: 263 | # vim:set softtabstop=4 shiftwidth=4 tabstop=8 expandtab: 264 | -------------------------------------------------------------------------------- /setup-sb2-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Create installer archives from sb2 tooling/target images in tar.bz2 format 4 | # 5 | # Copyright (C) 2018 Jolla Ltd. 6 | # Contact: Martin Kampas 7 | # All rights reserved. 8 | # 9 | # You may use this file under the terms of BSD license as follows: 10 | # 11 | # Redistribution and use in source and binary forms, with or without 12 | # modification, are permitted provided that the following conditions are met: 13 | # * Redistributions of source code must retain the above copyright 14 | # notice, this list of conditions and the following disclaimer. 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the distribution. 18 | # * Neither the name of the Jolla Ltd nor the 19 | # names of its contributors may be used to endorse or promote products 20 | # derived from this software without specific prior written permission. 21 | # 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 26 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | # 33 | 34 | . $(dirname $0)/defaults.sh 35 | . $(dirname $0)/utils.sh 36 | 37 | set -o nounset 38 | set -o pipefail 39 | 40 | synopsis() 41 | { 42 | cat <] [-n|--dry-run] 44 | [-P|--max-procs ] [--no-meta] [--no-shared] 45 | [--shared-path ] [-u|--upload ] 46 | [--uhost ] [--uuser ] [--upath ] 47 | ... 48 | END 49 | } 50 | 51 | short_usage() 52 | { 53 | cat < 76 | Set the 7z compression level from 0 (fast) to 9 (best) 77 | 78 | -n, --dry-run 79 | Suppress normal operation, show what would be done 80 | 81 | -P, --max-procs 82 | Limit the maximum number of processors to use. Defaults to N-1 83 | available processors or 1 on single processor systems 84 | 85 | --no-meta 86 | Suppress creating meta data files with 'make-archive-meta.sh' 87 | 88 | --no-shared 89 | See '--upload'. 90 | 91 | --shared-path 92 | See '--upload'. Relative will be resolved relatively to 93 | '--upath'. Defaults to [$DEF_SHARED_SB2_IMAGES_PATH] 94 | 95 | -u, --upload 96 | Upload results. is the root directory for this SDK build, 97 | relative to the global upload path. Files will be uploaded under the 98 | '/targets' path. If this path does not exists, a symbolic link 99 | will be created using this name, pointing to the shared location for 100 | sb2 images. This can be overriden by '--no-shared', in which case a 101 | directory will be created instead of the symbolic link. The default 102 | shared location can be overriden with '--shared-path'. 103 | 104 | --uhost 105 | Override the default upload host [$DEF_UPLOAD_HOST] 106 | 107 | --uuser 108 | Override the default upload user [$DEF_UPLOAD_USER] 109 | 110 | --upath 111 | Override the default global upload path [$DEF_UPLOAD_PATH] 112 | END 113 | } 114 | 115 | fatal() 116 | { 117 | echo "setup-sb2-images.sh: fatal: $*" >&2 118 | } 119 | 120 | bad_usage() 121 | { 122 | fatal "$*" 123 | short_usage >&2 124 | } 125 | 126 | xargs_() 127 | { 128 | xargs --max-procs="$OPT_MAX_PROCS" "$@" 129 | } 130 | 131 | recompress() 132 | { 133 | local files=("$@") 134 | 135 | recompress_worker_initial_args=("$OPT_LEVEL" "$OPT_NO_META" "$BUILD_TOOLS_SRC" "$OPT_DRY_RUN") 136 | recompress_worker() 137 | { 138 | set -o nounset 139 | set -o pipefail 140 | 141 | local level=$1 142 | local no_meta=$2 143 | local build_tools_src=$3 144 | local dry_run=$4 145 | 146 | local file=$5 147 | 148 | local dirname= 149 | dirname=$(dirname "$file") || return 150 | local basename= 151 | basename=$(basename "$file") || return 152 | local decompressed_basename=${basename%.bz2} 153 | 154 | local ok= 155 | recompress_worker_cleanup() 156 | ( 157 | trap 'echo cleaning up...' INT TERM HUP 158 | if [[ ! $dry_run ]]; then 159 | rm -f "$dirname/$decompressed_basename" 160 | rm -f "$dirname/$decompressed_basename.meta" 161 | if [[ ! $ok ]]; then 162 | rm -f "$dirname/$decompressed_basename.7z" 163 | rm -f "$dirname/$decompressed_basename.7z.meta" 164 | fi 165 | fi 166 | ) 167 | trap 'recompress_worker_cleanup; trap - RETURN' RETURN 168 | trap 'return 1' INT TERM HUP 169 | 170 | _ pushd "$dirname" >/dev/null || return 171 | 172 | echo "Decompressing '$dirname/$basename'..." >&2 173 | # Pass --force to allow working with input files that are symlinks 174 | _ bunzip2 --keep --force -- "$basename" || return 175 | echo "Finished decompressing '$dirname/$basename'" >&2 176 | 177 | basename=$decompressed_basename 178 | 179 | echo "Creating meta data file for '$dirname/$basename'" >&2 180 | _ $build_tools_src/make-sb2-image-meta.sh "$basename" || return 181 | 182 | echo "Creating archive '$dirname/$basename.7z'..." >&2 183 | _ rm -f -- "$basename.7z" || return 184 | _ 7z a ${level:+-mx="$level"} -- "$basename.7z" "$basename" >/dev/null || return 185 | _ 7z a ${level:+-mx="$level"} -- "$basename.7z" "$basename.meta" >/dev/null || return 186 | _ rm -f -- "$basename" || : 187 | echo "Finished creating archive '$dirname/$basename.7z'" >&2 188 | 189 | if [[ ! $no_meta ]]; then 190 | echo "Creating meta data file for '$dirname/$basename.7z" >&2 191 | _ $build_tools_src/make-archive-meta.sh "$basename.7z" || return 192 | fi 193 | 194 | md5sum() { command md5sum "$1" > "$2"; } 195 | _ md5sum "$basename.7z"{,.md5sum} 196 | 197 | _ popd >/dev/null || return 198 | 199 | ok=1 200 | } 201 | export -f recompress_worker || return 202 | 203 | printf '%s\n' "${files[@]}" \ 204 | |xargs_ -L1 bash -c 'recompress_worker "$@"' bash "${recompress_worker_initial_args[@]}" 205 | } 206 | 207 | set_defaults() 208 | { 209 | # Use up to N-1 available processors by default 210 | DEF_MAX_PROCS= 211 | DEF_MAX_PROCS=$(nproc) 212 | let DEF_MAX_PROCS-- 213 | if (( DEF_MAX_PROCS <= 0 )); then 214 | DEF_MAX_PROCS=1 215 | fi 216 | 217 | OPT_H= 218 | OPT_HELP= 219 | OPT_DRY_RUN= 220 | OPT_IMAGES=() 221 | OPT_LEVEL= 222 | OPT_MAX_PROCS=$DEF_MAX_PROCS 223 | OPT_NO_META= 224 | OPT_NO_SHARED= 225 | OPT_SHARED_PATH=$DEF_SHARED_SB2_IMAGES_PATH 226 | OPT_UPLOAD= 227 | OPT_UPLOAD_DIR= 228 | OPT_UPLOAD_HOST=$DEF_UPLOAD_HOST 229 | OPT_UPLOAD_PATH=$DEF_UPLOAD_PATH 230 | OPT_UPLOAD_USER=$DEF_UPLOAD_USER 231 | 232 | TARGETS_SUBDIR=targets 233 | OPT_TARGETS_UPLOAD_PATH=$OPT_UPLOAD_PATH/$OPT_UPLOAD_DIR/$TARGETS_SUBDIR 234 | } 235 | 236 | parse_opts() 237 | { 238 | while (( $# > 0 )); do 239 | case $1 in 240 | -h) 241 | OPT_H=1 242 | return 243 | ;; 244 | --help) 245 | OPT_HELP=1 246 | return 247 | ;; 248 | -c|--compression) 249 | if [[ ! ${2:-} ]]; then 250 | bad_usage "Argument expected: $1" 251 | return 1 252 | fi 253 | OPT_LEVEL=$2 254 | shift 255 | ;; 256 | -n|--dry-run) 257 | OPT_DRY_RUN=1 258 | ;; 259 | -P|--max-procs) 260 | if [[ ! ${2:-} ]]; then 261 | bad_usage "Argument expected: $1" 262 | return 1 263 | fi 264 | OPT_MAX_PROCS=$2 265 | shift 266 | ;; 267 | --no-meta) 268 | OPT_NO_META=1 269 | ;; 270 | --no-shared) 271 | OPT_NO_SHARED=1 272 | ;; 273 | --shared-path) 274 | if [[ ! ${2:-} ]]; then 275 | bad_usage "Argument expected: $1" 276 | return 1 277 | fi 278 | OPT_SHARED_PATH=$2 279 | shift 280 | ;; 281 | -u|--upload) 282 | if [[ ! ${2:-} ]]; then 283 | bad_usage "Argument expected: $1" 284 | return 1 285 | fi 286 | OPT_UPLOAD=1 287 | OPT_UPLOAD_DIR=$2 288 | shift 289 | ;; 290 | --uhost) 291 | if [[ ! ${2:-} ]]; then 292 | bad_usage "Argument expected: $1" 293 | return 1 294 | fi 295 | OPT_UPLOAD_HOST=$2 296 | shift 297 | ;; 298 | --upath) 299 | if [[ ! ${2:-} ]]; then 300 | bad_usage "Argument expected: $1" 301 | return 1 302 | fi 303 | OPT_UPLOAD_PATH=$2 304 | shift 305 | ;; 306 | --uuser) 307 | if [[ ! ${2:-} ]]; then 308 | bad_usage "Argument expected: $1" 309 | return 1 310 | fi 311 | OPT_UPLOAD_USER=$2 312 | shift 313 | ;; 314 | --) 315 | shift 316 | break 317 | ;; 318 | -*) 319 | bad_usage "Unexpected argument: $1" 320 | return 1 321 | ;; 322 | *) 323 | OPT_IMAGES+=("$1") 324 | ;; 325 | esac 326 | shift 327 | done 328 | 329 | if [[ $OPT_SHARED_PATH && $OPT_SHARED_PATH != /* ]]; then 330 | OPT_SHARED_PATH=$OPT_UPLOAD_PATH/$OPT_SHARED_PATH 331 | fi 332 | 333 | OPT_TARGETS_UPLOAD_PATH=$OPT_UPLOAD_PATH/$OPT_UPLOAD_DIR/$TARGETS_SUBDIR 334 | 335 | OPT_IMAGES+=("$@") 336 | 337 | if (( ${#OPT_IMAGES[@]} == 0 )); then 338 | bad_usage "Argument expected" 339 | return 1 340 | fi 341 | } 342 | 343 | setup_dry_run() 344 | { 345 | if [[ $OPT_DRY_RUN ]]; then 346 | OPT_MAX_PROCS=1 347 | _() { printf '%q ' + "$@"; echo; } >&2 348 | else 349 | _() { "$@"; } 350 | fi 351 | export -f _ 352 | } 353 | 354 | main() 355 | { 356 | set_defaults || return 357 | parse_opts "$@" || return 358 | setup_dry_run || return 359 | 360 | if [[ $OPT_H ]]; then 361 | short_usage 362 | return 363 | fi 364 | 365 | if [[ $OPT_HELP ]]; then 366 | usage 367 | return 368 | fi 369 | 370 | local decompressed_images=() 371 | 372 | main_cleanup() 373 | ( 374 | trap 'echo cleaning up...' INT TERM HUP 375 | if [[ ! $OPT_DRY_RUN ]]; then 376 | rm -f "${decompressed_images[@]}" 377 | fi 378 | ) 379 | trap 'main_cleanup; trap - RETURN' RETURN 380 | trap 'return 1' INT TERM HUP 381 | 382 | decompressed_images=("${OPT_IMAGES[@]%.bz2}") 383 | recompress "${OPT_IMAGES[@]}" || return 384 | 385 | if [[ $OPT_UPLOAD ]]; then 386 | local results=("${decompressed_images[@]/%/.7z}" "${decompressed_images[@]/%/.7z.md5sum}") 387 | if [[ ! $OPT_NO_META ]]; then 388 | results+=("${decompressed_images[@]/%/.7z.meta}") 389 | fi 390 | echo "Uploading..." >&2 391 | if [[ $OPT_NO_SHARED ]]; then 392 | _ ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" "mkdir -p $OPT_TARGETS_UPLOAD_PATH" || return 393 | else 394 | local target=$(realpath --canonicalize-missing \ 395 | --relative-to="$OPT_UPLOAD_PATH/$OPT_UPLOAD_DIR" "$OPT_SHARED_PATH") 396 | _ ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" "test -e $OPT_TARGETS_UPLOAD_PATH \ 397 | || (mkdir -p $OPT_UPLOAD_PATH/$OPT_UPLOAD_DIR \ 398 | && ln -s $target $OPT_TARGETS_UPLOAD_PATH)" || return 399 | # Remove possibly existing targets.json to avoid being noisy updating it twice 400 | _ ssh "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST" "rm -f $OPT_TARGETS_UPLOAD_PATH/targets.json" 401 | echo "Looking for possible unused images on the upload host..." >&2 402 | _ "$BUILD_TOOLS_SRC/prune-shared.sh" --uhost "$OPT_UPLOAD_HOST" \ 403 | --uuser "$OPT_UPLOAD_USER" --upath "$OPT_UPLOAD_PATH" "$OPT_SHARED_PATH" 404 | fi 405 | _ rsync --ignore-existing --verbose --info=skip "${results[@]}" \ 406 | "$OPT_UPLOAD_USER@$OPT_UPLOAD_HOST:$OPT_TARGETS_UPLOAD_PATH/" || return 407 | if [[ ! $OPT_DRY_RUN ]]; then 408 | echo "Updating targets.json..." >&2 409 | update_remote_targets_json "$OPT_TARGETS_UPLOAD_PATH" || return 410 | else 411 | echo "Would update targets.json" >&2 412 | fi 413 | fi 414 | } 415 | 416 | main "$@" 417 | -------------------------------------------------------------------------------- /utils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2019 Jolla Ltd. 4 | # Contact: Martin Kampas 5 | # All rights reserved. 6 | # 7 | # You may use this file under the terms of BSD license as follows: 8 | # 9 | # Redistribution and use in source and binary forms, with or without 10 | # modification, are permitted provided that the following conditions are met: 11 | # * Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # * Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # * Neither the name of the Jolla Ltd nor the 17 | # names of its contributors may be used to endorse or promote products 18 | # derived from this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 24 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | # 31 | 32 | nproc() 33 | { 34 | if [[ $# -gt 0 ]]; then 35 | echo "nproc: This is not a real 'nproc'!" >&2 36 | return 1 37 | fi 38 | 39 | command nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 40 | } 41 | 42 | # Read VDI header on stdin and output its capacity in megabytes 43 | # 44 | # See https://forums.virtualbox.org/viewtopic.php?p=29267#p29267 for the 45 | # description of VDI header structure 46 | vdi_capacity() 47 | { 48 | local hex_capacity= 49 | hex_capacity=$(od --skip-bytes=$((0x170)) --read-bytes=8 \ 50 | --address-radix=n --format=x1 --width=1 --output-duplicates \ 51 | |tac |tr -d ' \n') || return 52 | echo $((0x$hex_capacity>>20)) 53 | } 54 | 55 | target_image_to_target_name() 56 | { 57 | local name=$1 58 | name=${name%.tar.7z} 59 | name=${name/-Sailfish_SDK_Target-/-} 60 | name=${name//_/} 61 | printf '%s\n' "$name" 62 | } 63 | 64 | target_image_to_tooling_image() 65 | { 66 | local name=$1 67 | name=${name%-Sailfish_SDK_Target-*}-Sailfish_SDK_Tooling-i486.tar.7z 68 | printf '%s\n' "$name" 69 | } 70 | 71 | target_name_to_tooling_name() 72 | { 73 | local name=$1 74 | name=${name%-*} 75 | printf '%s\n' "$name" 76 | } 77 | 78 | make_targets_json() 79 | { 80 | local url_prefix=$1 81 | local target_images=$2 82 | 83 | target_images=$(sort --version-sort --reverse <<<"$target_images") 84 | 85 | cat </dev/null" \ 141 | <<<"$targets_json" || return 142 | } 143 | --------------------------------------------------------------------------------