From 792e49a72f81dc9e9cdffb7471e177b41a1bbace Mon Sep 17 00:00:00 2001 From: userdocs <16525024+userdocs@users.noreply.github.com> Date: Sat, 30 Oct 2021 00:03:09 +0100 Subject: [PATCH] zlib-ng crossbuild --- .github/workflows/zlib-ng-crossbuild.yml | 200 +++++++++++++++++++++++ README.md | 6 + 2 files changed, 206 insertions(+) create mode 100644 .github/workflows/zlib-ng-crossbuild.yml create mode 100644 README.md diff --git a/.github/workflows/zlib-ng-crossbuild.yml b/.github/workflows/zlib-ng-crossbuild.yml new file mode 100644 index 0000000..47fb864 --- /dev/null +++ b/.github/workflows/zlib-ng-crossbuild.yml @@ -0,0 +1,200 @@ +name: zlib-ng+crossbuild+package+release +on: + - workflow_dispatch +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + name: [zlib-ng] + os_id: [debian, ubuntu] + os_version_id: [stretch, buster, bullseye, bionic, focal] + arch: [amd64, armhf, arm64] + zlib_compat: ["", "-D ZLIB_COMPAT=ON"] + include: + - arch: amd64 + CHOST: "x86_64-linux-gnu" + docker_arch: amd64 + docker_platform: linux/amd64 + - arch: armhf + CHOST: "arm-linux-gnueabihf" + docker_arch: arm32v7 + docker_platform: linux/arm/v7 + - arch: arm64 + CHOST: "aarch64-linux-gnu" + docker_arch: arm64v8 + docker_platform: linux/arm64/v8 + - zlib_compat: "" + pretty_name: v2 + - zlib_compat: "-D ZLIB_COMPAT=ON" + pretty_name: v1 + exclude: + - os_id: debian + os_version_id: bionic + - os_id: debian + os_version_id: focal + - os_id: ubuntu + os_version_id: stretch + - os_id: ubuntu + os_version_id: buster + - os_id: ubuntu + os_version_id: bullseye + + name: ${{ matrix.arch }} ${{ matrix.os_id }}:${{ matrix.os_version_id }} ${{ matrix.name }} ${{ matrix.pretty_name }} + env: + CHOST: "${{ matrix.CHOST }}" + CC: "${{ matrix.CHOST }}-gcc" + AR: "${{ matrix.CHOST }}-ar" + CXX: "${{ matrix.CHOST }}-g++" + opt_dir_name: "opt/swizzin_apps" + install_prefix: "/root/build/opt/${{ matrix.name }}" + + prerelease: false + + steps: + - uses: actions/checkout@v2.3.4 + + - name: Host - update + run: sudo apt-get update + + - name: Host - upgrade + run: sudo apt-get -y upgrade + + - name: Host - Install host qemu-static + run: sudo apt-get install -y qemu binfmt-support qemu-user-static + + - name: Host - Docker multiarch bootstrap + run: sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + + - name: Host - Create Docker template env file + run: | + echo "PATH=/${{ env.opt_dir_name }}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" > env.custom + echo "LD_LIBRARY_PATH=/${{ env.opt_dir_name }}/lib:/usr/lib/${{ env.CHOST }}:/usr/lib:/usr/local/lib" >> env.custom + + - name: Host - Create docker multiarch ${{ matrix.arch }} container + run: docker run --name multiarch -it -d --env-file env.custom -w /root -e 'LANG=en_US.UTF-8' -e 'DEBIAN_FRONTEND=noninteractive' -e CHOST=${{ env.CHOST }} -e CC=${{ env.CC }} -e AR=${{ env.AR }} -e CXX=${{ env.CXX }} -v ${{ github.workspace }}:/root ${{ matrix.os_id }}:${{ matrix.os_version_id }} + + - name: Host - Create docker binary_test ${{ matrix.arch }} container + run: docker run --name binary_test -it -d --env-file env.custom -w /root -e 'LANG=en_US.UTF-8' -e 'DEBIAN_FRONTEND=noninteractive' --platform ${{ matrix.docker_platform }} -v ${{ github.workspace }}:/root ${{ matrix.docker_arch }}/${{ matrix.os_id }}:${{ matrix.os_version_id }} + + - name: Docker target - fix Ubuntu sources + if: | + matrix.os_id == 'ubuntu' && matrix.arch != 'amd64' + run: | + docker exec --env-file env.custom -w /etc/apt/ multiarch bash -c 'echo "deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports ${{ matrix.os_version_id }} main restricted universe multiverse" > sources.list' + docker exec --env-file env.custom -w /etc/apt/ multiarch bash -c 'echo "deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports ${{ matrix.os_version_id }}-updates main restricted universe multiverse" >> sources.list' + docker exec --env-file env.custom -w /etc/apt/ multiarch bash -c 'echo "deb [arch=${{ matrix.arch }}] http://ports.ubuntu.com/ubuntu-ports ${{ matrix.os_version_id }}-security main restricted universe multiverse" >> sources.list' + docker exec --env-file env.custom -w /etc/apt/ multiarch bash -c 'echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${{ matrix.os_version_id }} main restricted universe multiverse" >> sources.list' + docker exec --env-file env.custom -w /etc/apt/ multiarch bash -c 'echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${{ matrix.os_version_id }}-updates main restricted universe multiverse" >> sources.list' + docker exec --env-file env.custom -w /etc/apt/ multiarch bash -c 'echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${{ matrix.os_version_id }}-backports restricted universe multiverse" >> sources.list' + docker exec --env-file env.custom -w /etc/apt/ multiarch bash -c 'echo "deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${{ matrix.os_version_id }}-security main restricted universe multiverse" >> sources.list' + + - name: Docker target - dpkg configure arch + run: docker exec --env-file env.custom multiarch dpkg --add-architecture ${{ matrix.arch }} + + - name: Docker target - Run apt-get update + run: | + docker exec --env-file env.custom multiarch apt-get update + docker exec --env-file env.custom binary_test apt-get update + + - name: Docker target - Run apt-get upgrade + run: | + docker exec --env-file env.custom multiarch apt-get upgrade -y + docker exec --env-file env.custom binary_test apt-get upgrade -y + + - name: Docker target - apt-get install the core build dependencies + run: | + docker exec --env-file env.custom multiarch apt-get install -y build-essential curl pkg-config automake libtool git perl python3 python3-dev unzip ccache + docker exec --env-file env.custom binary_test apt-get install -y openssl binutils + + - name: Docker target - apt-get install crossbuild-essential + if: matrix.arch != 'amd64' + run: docker exec --env-file env.custom multiarch apt-get install -y crossbuild-essential-${{ matrix.arch }} + + - name: Docker target - apt-get install cross target deps + run: | + docker exec --env-file env.custom multiarch apt-get install -y libssl-dev:${{ matrix.arch }} re2c:${{ matrix.arch }} libstdc++-*-dev:${{ matrix.arch }} + + - name: Docker target - bionic - apt-get install gcc-8-base g++-8 + if: matrix.arch == 'amd64' && matrix.os_version_id == 'bionic' + run: docker exec --env-file env.custom multiarch apt-get install -y gcc-8 g++-8 + + - name: Docker target - bionic - apt-get install gcc-8 g++-8 cross + if: matrix.arch != 'amd64' && matrix.os_version_id == 'bionic' + run: docker exec --env-file env.custom multiarch apt-get install -y cpp-8-${{ matrix.CHOST }} g++-8-${{ matrix.CHOST }} gcc-8-${{ matrix.CHOST }} + + - name: Docker target - bionic - reconfigure build vars + if: matrix.os_version_id == 'bionic' + run: | + echo "CC=${{ env.CC }}-8" >> env.custom + echo "AR=${{ env.AR }}-8" >> env.custom + echo "CXX=${{ env.CXX }}-8" >> env.custom + + - name: Docker target - cmake download and install + run: | + docker exec --env-file env.custom multiarch curl -sNL "https://github.com/userdocs/cmake_crossbuild/releases/latest/download/${{ matrix.os_id }}-${{ matrix.os_version_id }}-cmake-${{ matrix.arch }}.deb" -o ${{ matrix.os_id }}-${{ matrix.os_version_id }}-cmake-${{ matrix.arch }}.deb + docker exec --env-file env.custom multiarch dpkg -i ${{ matrix.os_id }}-${{ matrix.os_version_id }}-cmake-${{ matrix.arch }}.deb + + - name: Docker target - Git clone ${{ matrix.name }} develop + run: docker exec --env-file env.custom -w /root multiarch git clone --single-branch --branch develop --shallow-submodules --recurse-submodules --depth 1 https://github.com/zlib-ng/zlib-ng.git /root/${{ matrix.name }} + + - name: Docker target - Cmake ${{ matrix.name }} + run: | + docker exec --env-file env.custom -w /root/${{ matrix.name }} multiarch cmake -Wno-dev -Wno-deprecated -G Ninja -B build \ + ${{ matrix.zlib_compat }} \ + -D CMAKE_VERBOSE_MAKEFILE="ON" \ + -D CMAKE_CXX_STANDARD="17" \ + -D CMAKE_INSTALL_PREFIX="${{ env.install_prefix }}" + + - name: Docker target - ${{ matrix.name }} - cmake build + run: docker exec --env-file env.custom -w /root/${{ matrix.name }} multiarch cmake --build build + + - name: Docker target - ${{ matrix.name }} - cmake install + run: docker exec --env-file env.custom -w /root/${{ matrix.name }} multiarch cmake --install build + + - name: Host - Set zlib version to variable + run: | + docker exec --env-file env.custom -w "${{ env.install_prefix }}/lib" binary_test bash -c 'strings libz*.a | grep -Pm1 "^\d+\.\d+\.\d+" > /root/${{ matrix.name }}.version' + zlib_ng_version="$(<${{ matrix.name }}.version)" + echo "zlib_ng_version=${zlib_ng_version%.*}" >> $GITHUB_ENV + + - name: Host - Set zlib release version + if: matrix.pretty_name == 'v1' + run: | + echo "prerelease=true" >> $GITHUB_ENV + + - name: Docker target - Set deb dependencies for ${{ matrix.name }} + run: echo "deb-deps=openssl" >> $GITHUB_ENV + + - name: Host - Create deb packages + uses: jiro4989/build-deb-action@v2 + with: + package: "${{ matrix.name }}" + package_root: build + maintainer: userdocs + version: "${{ env.zlib_ng_version }}" + depends: "${{ env.deb-deps }}" + arch: "${{ matrix.arch }}" + desc: "${{ matrix.name }}-${{ env.zlib_ng_version }}-${{ matrix.arch }} for ${{ matrix.os_id }}-${{ matrix.os_version_id }}" + + - name: Host - Remove version from release name and use hyphens + run: mv -f "${{ matrix.name }}_${{ env.zlib_ng_version }}_${{ matrix.arch }}.deb" "${{ matrix.os_id }}-${{ matrix.os_version_id }}-${{ matrix.name }}-${{ env.zlib_ng_version }}-${{ matrix.arch }}.deb" + + - name: Host - Upload artifacts + uses: actions/upload-artifact@v2.2.4 + with: + name: "${{ matrix.os_id }}-${{ matrix.os_version_id }}-${{ matrix.name }}-${{ env.zlib_ng_version }}-${{ matrix.arch }}" + path: "${{ matrix.os_id }}-${{ matrix.os_version_id }}-${{ matrix.name }}-${{ env.zlib_ng_version }}-${{ matrix.arch }}.deb" + + - name: Host - "Create release - tag - assets" + uses: ncipollo/release-action@v1 + with: + prerelease: ${{ env.prerelease }} + artifacts: "${{ matrix.os_id }}-${{ matrix.os_version_id }}-${{ matrix.name }}-${{ env.zlib_ng_version }}-${{ matrix.arch }}.deb" + replacesArtifacts: true + tag: "${{ env.zlib_ng_version }}" + name: "${{ matrix.name }} ${{ env.zlib_ng_version }}" + body: "${{ matrix.name }} built from github master on amd64 arm64 armhf for Debian Stretch Buster Bullseye and Ubuntu bionic Focal" + allowUpdates: true + token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/README.md b/README.md new file mode 100644 index 0000000..dede4cf --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# zlib-ng cross builds + +Multiarch cross builds to use with Debian based platforms. + +Deb packages are created and published as releases. +