From c2896c78ecf319e5a88b2ea79e7431bb3ed5294d Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Thu, 5 Oct 2023 15:05:53 -0700 Subject: [PATCH] Added OpenSUSE support to build & test pipeline (#344) * Also added build documentation Resolves #89 --- .../build-and-install/mapnik/action.yml | 15 ++-- .../mapnik/latest/action.yml | 2 +- .../actions/dependencies/install/action.yml | 76 +++++++++++++++++++ .../dependencies/install/zypper/action.yml | 12 +++ .github/workflows/build-and-test.yml | 5 ++ CMakeLists.txt | 3 + README.rst | 1 + docs/build/building_on_opensuse.md | 66 ++++++++++++++++ etc/apache2/renderd-example-map.conf | 8 +- tests/CMakeLists.txt | 11 +-- tests/httpd.conf.in | 21 +++-- 11 files changed, 196 insertions(+), 24 deletions(-) create mode 100644 .github/actions/dependencies/install/zypper/action.yml create mode 100644 docs/build/building_on_opensuse.md diff --git a/.github/actions/dependencies/build-and-install/mapnik/action.yml b/.github/actions/dependencies/build-and-install/mapnik/action.yml index 682eb0f0..0cefae6d 100644 --- a/.github/actions/dependencies/build-and-install/mapnik/action.yml +++ b/.github/actions/dependencies/build-and-install/mapnik/action.yml @@ -7,12 +7,6 @@ inputs: runs: using: composite steps: - - name: Install `gcc-c++` (CentOS 7) - uses: ./.github/actions/dependencies/install/yum - with: - packages: gcc-c++ - if: matrix.image == 'centos:7' && matrix.compiler == 'LLVM' - - name: Create `Mapnik` source directory run: | mkdir mapnik-src @@ -46,9 +40,12 @@ runs: mkdir --parents ${GDAL_DATA} ${PROJ_LIB} # Configure & build - ./configure FAST=True \ - PREFIX="/usr" \ - OPTIMIZATION=0 + ./configure \ + CC=${CC:-gcc} \ + CXX=${CXX:-g++} \ + FAST=True \ + OPTIMIZATION=0 \ + PREFIX="/usr" make PYTHON=${PYTHON} || make PYTHON=${PYTHON} shell: bash --noprofile --norc -euxo pipefail {0} working-directory: mapnik-src diff --git a/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml b/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml index 3a7fd23e..2ee30317 100644 --- a/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml +++ b/.github/actions/dependencies/build-and-install/mapnik/latest/action.yml @@ -22,7 +22,7 @@ runs: - name: Build `Mapnik` run: | export CMAKE_BUILD_PARALLEL_LEVEL=${BUILD_PARALLEL_LEVEL:-$(nproc)} - cmake -S mapnik-src -B mapnik-build \ + cmake -B mapnik-build -S mapnik-src \ -DBUILD_DEMO_VIEWER:BOOL=OFF \ -DBUILD_TESTING:BOOL=OFF \ -DCMAKE_BUILD_TYPE:STRING=Release \ diff --git a/.github/actions/dependencies/install/action.yml b/.github/actions/dependencies/install/action.yml index 2d18a84e..34702516 100644 --- a/.github/actions/dependencies/install/action.yml +++ b/.github/actions/dependencies/install/action.yml @@ -70,6 +70,45 @@ inputs: macos-test-dependencies: default: >- coreutils + opensuse-build-dependencies: + default: >- + apache2-devel + cairo-devel + curl + glib2-devel + libcurl-devel + libiniparser-devel + libmemcached-devel + librados-devel + opensuse-test-dependencies: + default: >- + apache2 + apache2-event + apache2-prefork + opensuse-mapnik-build-dependencies: + default: >- + bzip2 + freetype-devel + gdal-devel + harfbuzz-devel + libboost_filesystem1_75_0-devel + libboost_headers1_75_0-devel + libboost_program_options1_75_0-devel + libboost_regex1_75_0-devel + libboost_system1_75_0-devel + libicu-devel + libjpeg8-devel + libpng16-devel + libtiff-devel + libwebp-devel + libxml2-devel + make + postgresql-devel + proj-devel + python3 + sqlite3-devel + tar + zlib-devel rhel-build-dependencies: default: >- cairo-devel @@ -137,6 +176,8 @@ inputs: default: 3.1.0 mapnik-build-version-amazonlinux2-centos7: default: 3.0.17 + mapnik-build-version-opensuse: + default: 3.1.0 runs: using: composite @@ -151,6 +192,7 @@ runs: ${{ inputs.rhel-test-dependencies }} ${{ matrix.build_system == 'CMake' && 'cmake3' || 'autoconf automake redhat-rpm-config' }} ${{ matrix.compiler == 'LLVM' && 'clang' || 'gcc gcc-c++' }} + ${{ matrix.image == 'centos:7' && matrix.compiler == 'LLVM' && 'gcc-c++' || '' }} if: | startsWith(matrix.image, 'amazonlinux:') || startsWith(matrix.image, 'centos:') || @@ -196,6 +238,17 @@ runs: ${{ matrix.compiler == 'GNU' && 'gcc' || '' }} if: github.job == 'macOS' + - name: Install Dependencies (openSUSE) + uses: ./.github/actions/dependencies/install/zypper + with: + packages: >- + ${{ inputs.opensuse-build-dependencies }} + ${{ inputs.opensuse-mapnik-build-dependencies }} + ${{ inputs.opensuse-test-dependencies }} + ${{ matrix.build_system == 'CMake' && 'cmake' || 'automake' }} + ${{ matrix.compiler == 'LLVM' && 'clang' || 'gcc12 gcc12-c++' }} + if: startsWith(matrix.image, 'opensuse/') + - name: Install Dependencies (Ubuntu) uses: ./.github/actions/dependencies/install/apt-get with: @@ -209,6 +262,19 @@ runs: startsWith(matrix.image, 'ubuntu:') || (!matrix.image && runner.os == 'Linux') + - name: Link `gcc`/`g++` (openSUSE) + run: | + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 40 + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 40 + shell: bash --noprofile --norc -euxo pipefail {0} + if: startsWith(matrix.image, 'opensuse/') && matrix.compiler == 'GNU' + + - name: Add `nobody` user/group (openSUSE) + run: | + useradd --home-dir / --no-create-home --shell /usr/sbin/nologin --system --user-group nobody + shell: bash --noprofile --norc -euxo pipefail {0} + if: startsWith(matrix.image, 'opensuse/') + - name: Build & Install `mapnik` (Amazon Linux 2/CentOS 7) uses: ./.github/actions/dependencies/build-and-install/mapnik with: @@ -221,8 +287,18 @@ runs: version: ${{ inputs.mapnik-build-version-centos-stream }} if: startsWith(matrix.image, 'quay.io/centos/centos:stream') + - name: Build & Install `mapnik` (openSUSE) + uses: ./.github/actions/dependencies/build-and-install/mapnik + with: + version: ${{ inputs.mapnik-build-version-opensuse }} + if: (!matrix.mapnik_latest && startsWith(matrix.image, 'opensuse/')) + - name: Build & Install latest `mapnik` (Debian/Ubuntu) uses: ./.github/actions/dependencies/build-and-install/mapnik/latest if: | matrix.mapnik_latest && (startsWith(matrix.image, 'debian:') || startsWith(matrix.image, 'ubuntu:')) + + - name: Build & Install latest `mapnik` (openSUSE) + uses: ./.github/actions/dependencies/build-and-install/mapnik/latest + if: (matrix.mapnik_latest && startsWith(matrix.image, 'opensuse/')) diff --git a/.github/actions/dependencies/install/zypper/action.yml b/.github/actions/dependencies/install/zypper/action.yml new file mode 100644 index 00000000..9875749e --- /dev/null +++ b/.github/actions/dependencies/install/zypper/action.yml @@ -0,0 +1,12 @@ +--- +inputs: + packages: + description: List of package(s) to install + required: true + +runs: + using: composite + steps: + - name: Install package(s) + run: ${{ !matrix.image && 'sudo' || '' }} zypper --non-interactive install ${{ inputs.packages }} + shell: bash --noprofile --norc -euxo pipefail {0} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 96823011..48f54e8a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -23,6 +23,7 @@ jobs: - "fedora:37" - "fedora:38" - "fedora:rawhide" + - "opensuse/leap:15" - "ubuntu:20.04" build_system: - CMake @@ -66,6 +67,10 @@ jobs: run: yum --assumeyes install git if: matrix.image == 'amazonlinux:2' + - name: Install `git` (openSUSE) + run: zypper --non-interactive install git + if: startsWith(matrix.image, 'opensuse/') + - name: Checkout code (CentOS 7) uses: actions/checkout@v3 if: matrix.image == 'centos:7' diff --git a/CMakeLists.txt b/CMakeLists.txt index 81e627b2..83972b8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,6 +220,9 @@ if(EXISTS "/etc/os-release") elseif(DISTRO_ID MATCHES "freebsd") set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/modules.d") set(TILE_LOAD_FILENAME "080_tile.conf") + elseif(DISTRO_ID MATCHES "opensuse-leap") + set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/conf.d") + set(TILE_LOAD_FILENAME "mod_tile.conf") endif() elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/extra") diff --git a/README.rst b/README.rst index c953eadc..542bdf5e 100644 --- a/README.rst +++ b/README.rst @@ -71,6 +71,7 @@ distributions: * `Fedora `__ * `FreeBSD `__ * `macOS `__ +* `openSUSE `__ * `Ubuntu `__ Configuration diff --git a/docs/build/building_on_opensuse.md b/docs/build/building_on_opensuse.md new file mode 100644 index 00000000..ba4d3fdb --- /dev/null +++ b/docs/build/building_on_opensuse.md @@ -0,0 +1,66 @@ +# Building on openSUSE + +This document provides users with step-by-step instructions on how to compile and use`mod_tile` and `renderd`. + +Please see our [Continuous Integration script](/.github/workflows/build-and-test.yml) for more details. + +_openSUSE does not provide a `mapnik`/`mapnik-devel` package, so it will first need to be built & installed, which is beyond the scope of this document, please visit the project's [installation document on GitHub](https://github.com/mapnik/mapnik/blob/master/INSTALL.md) or our [Continuous Integration script](/.github/actions/dependencies/build-and-install/mapnik/action.yml) for more information._ + +## openSUSE 15 + +```shell +#!/usr/bin/env bash + +# Update installed packages +sudo zypper --non-interactive update + +# Install build dependencies +# (libmemcached-devel & librados-devel are optional) +sudo zypper --non-interactive install \ + apache2 \ + apache2-devel \ + apache2-prefork \ + cairo-devel \ + curl \ + glib2-devel \ + libcurl-devel \ + libiniparser-devel \ + libmemcached-devel \ + librados-devel + +# Create `nobody` user and group +sudo useradd --home-dir / --no-create-home --shell /usr/sbin/nologin --system --user-group nobody + +# Download, Build, Test & Install `mod_tile` +export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) +rm -rf /tmp/mod_tile_src /tmp/mod_tile_build +mkdir /tmp/mod_tile_src /tmp/mod_tile_build +cd /tmp/mod_tile_src +git clone --depth 1 https://github.com/openstreetmap/mod_tile.git . +cd /tmp/mod_tile_build +cmake -B . -S /tmp/mod_tile_src \ + -DCMAKE_BUILD_TYPE:STRING=Release \ + -DENABLE_TESTS:BOOL=ON +cmake --build . +ctest +sudo cmake --install . --prefix /usr --strip + +# Create /usr/share/renderd directory +sudo mkdir --parents /usr/share/renderd + +# Copy files of example map +sudo cp -av /tmp/mod_tile_src/utils/example-map /usr/share/renderd/example-map + +# Add configuration +sudo cp -av /tmp/mod_tile_src/etc/apache2/renderd-example-map.conf /etc/apache2/conf.d/renderd-example-map.conf +printf '\n[example-map]\nURI=/tiles/renderd-example\nXML=/usr/share/renderd/example-map/mapnik.xml\n' | sudo tee -a /etc/renderd.conf + +# Enable `mod_access_compat` +sudo sed -i 's/^APACHE_MODULES="actions/APACHE_MODULES="access_compat actions/g' /etc/sysconfig/apache2 + +# Start services +sudo apache2ctl start +sudo renderd -f +``` + +Then you can visit: `http://localhost:8081/renderd-example-map` diff --git a/etc/apache2/renderd-example-map.conf b/etc/apache2/renderd-example-map.conf index d4cbc255..8265fe29 100644 --- a/etc/apache2/renderd-example-map.conf +++ b/etc/apache2/renderd-example-map.conf @@ -3,10 +3,10 @@ Redirect /renderd-example-map/leaflet/leaflet.css https://unpkg.com/leaflet/dist Redirect /renderd-example-map/leaflet/leaflet.min.js https://unpkg.com/leaflet/dist/leaflet.js - Options +FollowSymLinks - AllowOverride All - Order Allow,Deny - Allow from all + Options +FollowSymLinks + AllowOverride All + Order Allow,Deny + Allow from all Require all granted diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cdb16b25..086b28e9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,11 +27,6 @@ find_program(MKDIR_EXECUTABLE NAMES mkdir REQUIRED) find_program(SHA256SUM_EXECUTABLE NAMES gsha256sum sha256sum REQUIRED) find_program(TOUCH_EXECUTABLE NAMES gtouch touch REQUIRED) -execute_process(COMMAND ${ID_EXECUTABLE} -gn nobody - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE NOGROUP_NAME -) - #----------------------------------------------------------------------------- # # Test configurations @@ -42,6 +37,7 @@ set(MAP_NAME "default") set(HTTPD0_PORT "59980") set(HTTPD1_PORT "59981") set(RENDERD1_PORT "59991") +set(WWW_USER_NAME "nobody") set(TILE_DEFAULT_URL "http://localhost:${HTTPD0_PORT}/tiles/renderd-example/9/297/191.png") set(TILE_JPG_URL "http://localhost:${HTTPD0_PORT}/tiles/renderd-example-jpg/9/297/191.jpg") @@ -62,6 +58,11 @@ set(TILE_WEBP_SHA256SUM_4 "ef3862a57831b21ec69c15be196e1e2b4fea66246c361142631b9 set(TILE_WEBP_SHA256SUM_6 "96fc0455b2269a7bcd4a5b3c9844529c3c77e3bb15f56e72f78a5af3bc15b6b5") # libwebp.so.6 set(TILE_WEBP_SHA256SUM_7 "a82ef9ba5dc333de88af7b645084c30ab2b01c664e17162cbf6659c287cc4df4") # libwebp.so.7 +execute_process(COMMAND ${ID_EXECUTABLE} -gn ${WWW_USER_NAME} + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE WWW_GROUP_NAME +) + configure_file( renderd.conf.in conf/renderd.conf diff --git a/tests/httpd.conf.in b/tests/httpd.conf.in index eb70bb73..6e7b180e 100644 --- a/tests/httpd.conf.in +++ b/tests/httpd.conf.in @@ -60,14 +60,14 @@ Redirect /renderd-example-map/leaflet/leaflet.min.js https://unpkg.com/leaflet/d CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b" ErrorLog logs/error_log -Group @NOGROUP_NAME@ +Group @WWW_GROUP_NAME@ Listen @HTTPD0_PORT@ Listen @HTTPD1_PORT@ LogLevel debug PidFile run/httpd.pid ServerName localhost ServerRoot @PROJECT_BINARY_DIR@/tests -User nobody +User @WWW_USER_NAME@ LoadModule access_compat_module @HTTPD_LIBEXECDIR@/mod_access_compat.so @@ -84,9 +84,20 @@ User nobody LoadModule log_config_module @HTTPD_LIBEXECDIR@/mod_log_config.so - - LoadModule mpm_event_module @HTTPD_LIBEXECDIR@/mod_mpm_event.so - + + + + LoadModule mpm_event_module @HTTPD_LIBEXECDIR@/mod_mpm_event.so + + + + + + + LoadModule mpm_prefork_module @HTTPD_LIBEXECDIR@/mod_mpm_prefork.so + + + LoadModule unixd_module @HTTPD_LIBEXECDIR@/mod_unixd.so