| 1 | #!/bin/bash |
| 2 | |
| 3 | # x86_64 build on CentOS 7.7 |
| 4 | # gcc 7 installed |
| 5 | # sudo yum install -y centos-release-scl |
| 6 | # sudo yum install -y devtoolset-7-gcc* |
| 7 | # run below command before build |
| 8 | # scl enable devtoolset-7 bash |
| 9 | |
| 10 | # newer cmake is required than one included in CentOS 7 |
| 11 | # download from http://www.cmake.org/download |
| 12 | # sudo mkdir /opt/cmake |
| 13 | # sudo sh cmake-$version.$build-Linux-x86_64.sh --prefix=/opt/cmake |
| 14 | |
| 15 | if [ $(arch) = "x86_64" ]; then |
| 16 | CMAKE="/opt/cmake/bin/cmake" |
| 17 | fi |
| 18 | |
| 19 | # i686 build on Ubuntu 16.04 LTS |
| 20 | |
| 21 | # armv7l build on raspbian stretch |
| 22 | |
| 23 | # Qt path and flags set in env e.g.: |
| 24 | # export PATH="/opt/Qt/5.14.0/bin/:$PATH" |
| 25 | # export CPPFLAGS="-I/opt/Qt/5.14.0/bin/include/" |
| 26 | # export LDFLAGS="-L/opt/Qt/5.14.0/bin/lib/" |
| 27 | # export LD_LIBRARY_PATH="/opt/Qt/5.14.0/bin/lib/:$LD_LIBRARY_PATH" |
| 28 | |
| 29 | # for x86_64 and i686 platform |
| 30 | # Qt 5.14.0 uses openssl 1.1 and some older distros still use 1.0 |
| 31 | # we build openssl 1.1.1d from source using following setup: |
| 32 | # ./config shared --prefix=/opt/openssl-1.1.1/ && make --jobs=`nproc --all` && sudo make install |
| 33 | # and add to build env |
| 34 | # export LD_LIBRARY_PATH="/opt/openssl-1.1.1/lib/:$LD_LIBRARY_PATH" |
| 35 | |
| 36 | if [ "$1" = "SIGN" ]; then |
| 37 | export SIGN="1" |
| 38 | fi |
| 39 | |
| 40 | # check gcc version on Centos |
| 41 | if [ $(arch) = "x86_64" ]; then |
| 42 | currentver="$(gcc -dumpversion)" |
| 43 | if [ "${currentver:0:1}" -lt "7" ]; then |
| 44 | echo "gcc version 7 or newer required" |
| 45 | echo "on Cetos 7 run" |
| 46 | echo "scl enable devtoolset-7 bash" |
| 47 | exit |
| 48 | fi |
| 49 | fi |
| 50 | |
| 51 | # building AppImage in temporary directory to keep system clean |
| 52 | # use RAM disk if possible (as in: not building on CI system like Travis, and RAM disk is available) |
| 53 | if [ "$CI" == "" ] && [ -d /dev/shm ]; then |
| 54 | TEMP_BASE=/dev/shm |
| 55 | else |
| 56 | TEMP_BASE=/tmp |
| 57 | fi |
| 58 | |
| 59 | # we run it from our project scripts folder |
| 60 | ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/.. |
| 61 | VERSION=$(cat "$ROOT"/VERSION)-$(git rev-parse --short HEAD) |
| 62 | # linuxdeploy uses $VERSION env variable for AppImage name |
| 63 | export VERSION=$VERSION |
| 64 | BUILD="$ROOT"/build |
| 65 | TARGET=rclone-browser-$VERSION.AppImage |
| 66 | |
| 67 | # clean AppImage temporary folder |
| 68 | if [ -d "$TEMP_BASE/$TARGET" ]; then |
| 69 | rm -rf "$TEMP_BASE/$TARGET" |
| 70 | fi |
| 71 | mkdir "$TEMP_BASE/$TARGET" |
| 72 | |
| 73 | # clean build folder |
| 74 | if [ -d "$BUILD" ]; then |
| 75 | rm -rf "$BUILD" |
| 76 | fi |
| 77 | mkdir "$BUILD" |
| 78 | |
| 79 | # create release folder if does not exist |
| 80 | mkdir -p "$ROOT"/release |
| 81 | |
| 82 | # clean current version previous build |
| 83 | if [ $(arch) = "armv7l" ] && [ -f "$ROOT"/release/rclone-browser-"$VERSION"-armhf.AppImage ]; then |
| 84 | rm "$ROOT"/release/rclone-browser-"$VERSION"-armhf.AppImage |
| 85 | fi |
| 86 | |
| 87 | if [ $(arch) = "i686" ] && [ -f "$ROOT"/release/rclone-browser-"$VERSION"-i386.AppImage ]; then |
| 88 | rm "$ROOT"/release/rclone-browser-"$VERSION"-i386.AppImage |
| 89 | fi |
| 90 | |
| 91 | if [ $(arch) = "x86_64" ] && [ -f "$ROOT"/release/rclone-browser-"$VERSION"-x86_64.AppImage ]; then |
| 92 | rm "$ROOT"/release/rclone-browser-"$VERSION"-x86_64.AppImage |
| 93 | fi |
| 94 | |
| 95 | # build and install to temporary AppDir folder |
| 96 | cd "$BUILD" |
| 97 | |
| 98 | if [ $(arch) = "armv7l" ]; then |
| 99 | # more threads need swap on 1GB RAM RPi |
| 100 | cmake .. -DCMAKE_INSTALL_PREFIX=/usr |
| 101 | make -j 2 |
| 102 | fi |
| 103 | |
| 104 | if [ $(arch) = "x86_64" ]; then |
| 105 | "$CMAKE" .. -DCMAKE_INSTALL_PREFIX=/usr |
| 106 | make --jobs=$(nproc --all) |
| 107 | fi |
| 108 | |
| 109 | if [ $(arch) = "i686" ]; then |
| 110 | cmake .. -DCMAKE_INSTALL_PREFIX=/usr |
| 111 | make --jobs=$(nproc --all) |
| 112 | fi |
| 113 | |
| 114 | make install DESTDIR="$TEMP_BASE"/"$TARGET"/AppDir |
| 115 | |
| 116 | # prepare AppImage |
| 117 | cd "$TEMP_BASE/$TARGET" |
| 118 | |
| 119 | # metainfo file |
| 120 | #mkdir $TEMP_BASE/$TARGET/AppDir/usr/share/metainfo |
| 121 | #cp $ROOT/assets/rclone-browser.appdata.xml $TEMP_BASE/$TARGET/AppDir/usr/share/metainfo/ |
| 122 | |
| 123 | # copy info files to AppImage |
| 124 | cp "$ROOT"/README.md "$TEMP_BASE"/"$TARGET"/AppDir/Readme.md |
| 125 | cp "$ROOT"/CHANGELOG.md "$TEMP_BASE"/"$TARGET"/AppDir/Changelog.md |
| 126 | cp "$ROOT"/LICENSE "$TEMP_BASE"/"$TARGET"/AppDir/License.txt |
| 127 | |
| 128 | # https://github.com/linuxdeploy/linuxdeploy |
| 129 | # https://github.com/linuxdeploy/linuxdeploy-plugin-qt |
| 130 | linuxdeploy --appdir AppDir --desktop-file=AppDir/usr/share/applications/rclone-browser.desktop |
| 131 | linuxdeploy-plugin-qt --appdir AppDir |
| 132 | |
| 133 | if [ $(arch) != "armv7l" ] |
| 134 | then |
| 135 | # we add openssl 1.1.1 libs needed for distros still using openssl 1.0 |
| 136 | cp /opt/openssl-1.1.1/lib/libssl.so.1.1 ./AppDir/usr/bin/ |
| 137 | cp /opt/openssl-1.1.1/lib/libcrypto.so.1.1 ./AppDir/usr/bin/ |
| 138 | fi |
| 139 | |
| 140 | # https://github.com/linuxdeploy/linuxdeploy-plugin-appimage |
| 141 | linuxdeploy-plugin-appimage --appdir=AppDir |
| 142 | |
| 143 | # raspberry pi build |
| 144 | if [ $(arch) = "armv7l" ]; then |
| 145 | rename 's/Rclone_Browser/rclone-browser/' Rclone_Browser* |
| 146 | fi |
| 147 | |
| 148 | # x86 build |
| 149 | if [ $(arch) = "i686" ]; then |
| 150 | rename 's/Rclone_Browser/rclone-browser/' Rclone_Browser* |
| 151 | fi |
| 152 | |
| 153 | # x86_64 build |
| 154 | if [ $(arch) = "x86_64" ]; then |
| 155 | rename Rclone_Browser rclone-browser Rclone_Browser* |
| 156 | fi |
| 157 | |
| 158 | cp ./*AppImage "$ROOT"/release/ |
| 159 | |
| 160 | # clean AppImage temporary folder |
| 161 | cd .. |
| 162 | rm -rf "$TARGET" |