diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..3ca1c7e --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,42 @@ +name: ci + +on: + push: +jobs: + buildx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + id: buildx + uses: crazy-max/ghaction-docker-buildx@v3 + with: + buildx-version: latest + qemu-version: latest + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Run Buildx + run: | + docker buildx build \ + --platform linux/arm/v7 \ + --load \ + -t "screenly-ose-webview-builder" \ + --file Dockerfile . + + - name: Make artifacts folder + run: mkdir -p artifacts + + - name: Run webviewer build + run: | + docker run \ + -v $(pwd)/artifacts:/build \ + screenly-ose-webview-builder build.sh + + - uses: actions/upload-artifact@v2 + with: + name: build-artifacts + path: artifacts diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eeab62d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: cpp -sudo: required -services: - - docker - -script: - - "/bin/true" - -before_deploy: - - docker run --rm --privileged multiarch/qemu-user-static:register --reset - - docker build . -t screenly/screenly-webview-build - - docker run --rm -t --name screenly-webview-build -e VERSION=$TRAVIS_TAG -v $TRAVIS_BUILD_DIR:/Screenly-webview screenly/screenly-webview-build - -deploy: - provider: releases - api_key: - secure: uNFv3HpZEr6HIPBxD0KJnoEtS0uGcIP1z0mOXn0VbQxKrSIX9D2W1QZ40+u9wV8viEOgcL7c2o9UD4kFY3jLG3sjdUVWhoZ0hkb2QKbGUQp66gf3mRm1VWjwHHyd4E5sZEByrn4DksFMWoaD7S5QDWmacpgTfY2GQ1KVHB+dCzSGU++ejTIaDWgeKguXc1u9mH3/XbSfFdh3MwlG9zwH7CRJa761FmVzn7G5q/4JiHzeGFuOVPo/u0JfpO70Ctgt4UVNLhi+hpz6O6Hg+Zpp6O913rv040653PQjr7mFQZtSPAYmrO98Qu2SVdOd7BKRWESA/dP+n3FNDBstvJQWdwM+Ivy6szhgbRVyRq9xTcUrJibZe8CMEaRuMR2cLPKmgs+XNuMm4AzsfEmyzlsHfsHB108+uJFUPNleXBYVdvA1tn7z7SIT8dc1QgTcJi9wf1gS2Xu3xqqKJZYIlyrXIFJt0jzN93UktrmOdf5I7jHV9BdIpQbRwU31vrF2hnjg3BxmGzDeA2xS+UEnJNk8JT3SxaYwSIjea/ZNDJ8VlxXi9hN9PuVeXJ9/bvwypfUqVFgAdrM/84TIj6c/KNSDaUvQD6odhmR8zbw1aERSi+tSO2ECPxGfpbbvcqPoTekVgYLCXMqLjlp/BWAzzwL2o/oYB/5fnfkvEcGRSiMkovk= - file: screenly-webview-${TRAVIS_TAG}.tar.gz - skip_cleanup: true - on: - repo: Screenly/screenly-ose-webview - tags: true diff --git a/Dockerfile b/Dockerfile index 17d1930..a01978c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,31 @@ -FROM resin/rpi-raspbian:stretch -MAINTAINER Anton Molodykh +FROM balenalib/rpi-raspbian:buster + +RUN echo "deb-src http://archive.raspberrypi.org/debian buster main ui" >> /etc/apt/sources.list.d/raspi.list +RUN echo "deb-src http://archive.raspbian.org/raspbian buster main contrib non-free rpi firmware" >> /etc/apt/sources.list RUN apt-get update && \ - apt-get -y install \ + apt-get -y install --no-install-recommends \ build-essential \ + freetds-dev \ g++ \ + git \ + libinput-dev \ + libqt5gui5 \ libqt5webkit5-dev \ + libqt5x11extras5-dev \ + libraspberrypi0 \ + libraspberrypi-dev \ + libts-dev \ + libudev-dev \ + libxcb-xinerama0 \ + libxcb-xinerama0-dev \ make && \ + apt-get build-dep libqt5gui5 && \ apt-get clean -WORKDIR /Screenly-webview - -CMD ["bash", "build.sh"] +WORKDIR /build +RUN mkdir /src +COPY build_qtbase.sh /usr/local/bin/ +COPY build.sh /usr/local/bin/ +COPY . /src diff --git a/README.md b/README.md index cad4c2d..8e3677e 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,36 @@ -# ScreenlyOSE-WebView - -[![Build Status](https://travis-ci.org/Screenly/screenly-ose-webview.svg?branch=master)](https://travis-ci.org/Screenly/screenly-ose-webview) +# Screenly OSE WebView ## Building -Before building, you need to install the following packages: - -``` -libqt5webkit5-dev -gstreamer1.0-plugins-good -libdbus-glib-1-dev -``` - -Building: +The build process depends on cross compiling on Docker. You may need to enable the `buildx` functionality. +Build the docker container: ``` -qmake -make -make install +$ docker buildx build \ + --platform linux/arm/v6,linux/arm/v7 \ + --load \ + -t screenly/screenly-webview-build \ + -f Dockerfile . ``` -You can change the folder to build: - +Build the actual web view ``` -export PREFIX=/home/pi/webview_build/ +$ docker run --rm \ + -v $(pwd):/build \ + screenly/screenly-webview-build + build.sh ``` -Besides, you need to copy `res` folder to `/usr/local/bin/ScreenlyWebview/res` - - -To prepare for a release, use the docker container: - +Build out the QT Base ``` $ docker run --rm \ - -e VERSION=*version* \ - -v $(pwd):/Screenly-webview \ + -v $(pwd):/build \ screenly/screenly-webview-build + build_qtbase.sh ``` +Note that this is done automatically on GitHub Actions, so there is usually no need to build this locally. + ## Usage DBus is used for communication. diff --git a/build.sh b/build.sh index bacaf4f..fb244c5 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,12 @@ #!/bin/bash +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# -*- sh-basic-offset: 4 -*- +set -euo pipefail + +cd /src /usr/lib/arm-linux-gnueabihf/qt5/bin/qmake -make +make -j "$(nproc --all)" make install -tar -zcvf "screenly-webview-${VERSION}.tar.gz" res ScreenlyWebview + +tar -zcvf "/build/screenly-webview.tar.gz" res ScreenlyWebview diff --git a/build_qtbase.sh b/build_qtbase.sh index 32d077f..f6fdd3a 100755 --- a/build_qtbase.sh +++ b/build_qtbase.sh @@ -1,69 +1,114 @@ -#!/bin/bash -x - -sudo sed -i -e 's/#deb-src/deb-src/' /etc/apt/sources.list -sudo apt-get update -sudo apt-get -y build-dep libqt5gui5 -sudo apt-get -y build-dep qt4-x11 -sudo apt-get -y install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0 - -QT_FOLDER_1=/home/pi/src/qt5/pi_1 # For pi 1 and pi zero -QT_FOLDER_2=/home/pi/src/qt5/pi_2 # For pi 2 -QT_FOLDER_3=/home/pi/src/qt5/pi_3 # For pi 3 - -set -x - -if [ ! -d "$QT_FOLDER_1" ]; then - mkdir $QT_FOLDER_1 - cd $QT_FOLDER_1 - git clone git://code.qt.io/qt/qtbase.git -b 5.9 - cd qtbase - ./configure -release -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/usr/bin/ -opensource -confirm-license -release -make libs -prefix /usr/local/qt5pi -extprefix $QT_FOLDER_1/qt5pi -no-use-gold-linker -else - cd $QT_FOLDER_1/qtbase -fi +#!/bin/bash + +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# -*- sh-basic-offset: 4 -*- + +set -euo pipefail + +QT_PI_1=/src/qt5/pi_1 # For Pi 1 and Pi Zero +QT_PI_2=/src/qt5/pi_2 # For Pi 2 +QT_PI_3=/src/qt5/pi_3 # For Pi 3 +BUILD_TARGET=/build +QT_BRANCH="5.12" + +mkdir -p "$BUILD_TARGET" + +echo "Building QT Base version $QT_BRANCH." + +if [ ! -f "$BUILD_TARGET/qtbase-pi1.tar.gz" ]; then + echo "Building QT Base for Pi 1" + mkdir -p "$QT_PI_1" + cd "$QT_PI_1" + git clone git://code.qt.io/qt/qtbase.git -b "$QT_BRANCH" + cd qtbase + + # Patch QT as per https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/ + sed -i 's/-lEGL/-lbrcmEGL/' mkspecs/devices/linux-rasp-pi-g++/qmake.conf + sed -i 's/-lGLESv2/-lbrcmGLESv2/' mkspecs/devices/linux-rasp-pi-g++/qmake.conf + + ./configure \ + -release \ + -opengl es2 \ + -device linux-rasp-pi-g++ \ + -device-option CROSS_COMPILE=/usr/bin/ \ + -opensource \ + -confirm-license \ + -make libs \ + -prefix /usr/local/qt5pi \ + -extprefix $QT_PI_1/qt5pi \ + -no-use-gold-linker -make -j 4 -make install -cp -r /usr/share/fonts/truetype/dejavu/ $QT_FOLDER_1/qt5pi/lib/fonts -cd $QT_FOLDER_1 -tar -zcvf /home/pi/qtbase-pi1.tar.gz qt5pi -cd /home/pi -echo $(md5sum qtbase-pi1.tar.gz) > qtbase-pi1.tar.gz.md5 - - -if [ ! -d "$QT_FOLDER_2" ]; then - mkdir $QT_FOLDER_2 - cd $QT_FOLDER_2 - git clone git://code.qt.io/qt/qtbase.git -b 5.9 - cd qtbase - ./configure -release -opengl es2 -device linux-rasp-pi2-g++ -device-option CROSS_COMPILE=/usr/bin/ -opensource -confirm-license -release -make libs -prefix /usr/local/qt5pi -extprefix $QT_FOLDER_2/qt5pi -no-use-gold-linker -else - cd $QT_FOLDER_2/qtbase + make -j "$(nproc --all)" + make install + cp -r /usr/share/fonts/truetype/dejavu/ "$QT_PI_1/qt5pi/lib/fonts" + cd "$QT_PI_1" + tar -zcvf $BUILD_TARGET/qtbase-pi1.tar.gz qt5pi + cd "$BUILD_TARGET" + sha256sum qtbase-pi1.tar.gz > qtbase-pi1.tar.gz.sha256 fi -make -j 4 -make install -cp -r /usr/share/fonts/truetype/dejavu/ $QT_FOLDER_2/qt5pi/lib/fonts -cd $QT_FOLDER_2 -tar -zcvf /home/pi/qtbase-pi2.tar.gz qt5pi -cd /home/pi -echo $(md5sum qtbase-pi2.tar.gz) > qtbase-pi2.tar.gz.md5 - - -if [ ! -d "$QT_FOLDER_3" ]; then - mkdir $QT_FOLDER_3 - cd $QT_FOLDER_3 - git clone git://code.qt.io/qt/qtbase.git -b 5.9 - cd qtbase - ./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=/usr/bin/ -opensource -confirm-license -release -make libs -prefix /usr/local/qt5pi -extprefix $QT_FOLDER_3/qt5pi -no-use-gold-linker -else - cd $QT_FOLDER_3/qtbase + +if [ ! -f "$BUILD_TARGET/qtbase-pi2.tar.gz" ]; then + echo "Building QT Base for Pi 2" + mkdir -p "$QT_PI_2" + cd "$QT_PI_2" + git clone git://code.qt.io/qt/qtbase.git -b "$QT_BRANCH" + cd qtbase + + # Patch QT as per https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/ + sed -i 's/-lEGL/-lbrcmEGL/' mkspecs/devices/linux-rasp-pi2-g++/qmake.conf + sed -i 's/-lGLESv2/-lbrcmGLESv2/' mkspecs/devices/linux-rasp-pi2-g++/qmake.conf + + ./configure \ + -release \ + -opengl es2 \ + -device linux-rasp-pi2-g++ \ + -device-option CROSS_COMPILE=/usr/bin/ \ + -opensource \ + -confirm-license \ + -make libs \ + -prefix /usr/local/qt5pi \ + -extprefix "$QT_PI_2/qt5pi" \ + -no-use-gold-linker + + make -j "$(nproc --all)" + make install + cp -r /usr/share/fonts/truetype/dejavu/ "$QT_PI_2/qt5pi/lib/fonts" + cd "$QT_PI_2" + tar -zcvf "$BUILD_TARGET/qtbase-pi2.tar.gz" qt5pi + cd "$BUILD_TARGET" + sha256sum qtbase-pi2.tar.gz > qtbase-pi2.tar.gz.sha256 fi -make -j 4 -make install -cp -r /usr/share/fonts/truetype/dejavu/ $QT_FOLDER_3/qt5pi/lib/fonts -cd $QT_FOLDER_3 -tar -zcvf /home/pi/qtbase-pi3.tar.gz qt5pi -cd /home/pi -echo $(md5sum qtbase-pi3.tar.gz) > qtbase-pi3.tar.gz.md5 +if [ ! -f "$BUILD_TARGET/qtbase-pi3.tar.gz" ]; then + echo "Building QT Base for Pi 3" + mkdir -p $QT_PI_3 + cd "$QT_PI_3" + git clone git://code.qt.io/qt/qtbase.git -b "$QT_BRANCH" + cd qtbase + + # Patch QT as per https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/ + sed -i 's/-lEGL/-lbrcmEGL/' mkspecs/devices/linux-rasp-pi3-g++/qmake.conf + sed -i 's/-lGLESv2/-lbrcmGLESv2/' mkspecs/devices/linux-rasp-pi3-g++/qmake.conf + + ./configure \ + -release \ + -opengl es2 \ + -device linux-rasp-pi3-g++ \ + -device-option CROSS_COMPILE=/usr/bin/ \ + -opensource \ + -confirm-license \ + -release \ + -make libs \ + -prefix /usr/local/qt5pi \ + -extprefix "$QT_PI_3/qt5pi" \ + -no-use-gold-linker + + make -j "$(nproc --all)" + make install + cp -r /usr/share/fonts/truetype/dejavu/ "$QT_PI_3/qt5pi/lib/fonts" + cd "$QT_PI_3" + tar -zcvf "$BUILD_TARGET/qtbase-pi3.tar.gz" qt5pi + cd "$BUILD_TARGET" + sha256sum qtbase-pi3.tar.gz > qtbase-pi3.tar.gz.sha256 +fi