From 25dae229feca0912e2cd479204f5149e60843fd0 Mon Sep 17 00:00:00 2001 From: klei1984 <53688147+klei1984@users.noreply.github.com> Date: Thu, 16 May 2024 21:37:28 +0200 Subject: [PATCH] Generate 64 bit ubuntu 22.04 deb package --- .github/workflows/build.yml | 2 +- .github/workflows/build_deb.yml | 76 +++++++++++++++++++++++++++++++++ cmake/enet.cmake | 2 + debian/rules | 9 +++- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_deb.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a2e44223..76adc884 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: test -f /usr/share/doc/kitware-archive-keyring/copyright || sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg sudo apt-get install kitware-archive-keyring - sudo apt install -y file build-essential cmake debmake dh-make ninja-build wget gettext p7zip-full libsdl2-dev + sudo apt install -y file build-essential cmake ninja-build wget gettext p7zip-full libsdl2-dev - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/build_deb.yml b/.github/workflows/build_deb.yml new file mode 100644 index 00000000..1a7ed900 --- /dev/null +++ b/.github/workflows/build_deb.yml @@ -0,0 +1,76 @@ +name: Build Deb Workflow +on: + workflow_run: + workflows: [Build Workflow] + types: [completed] + inputs: + build_type: + description: 'Build Configuration to use (Debug, Release, RelWithDebInfo or MinSizeRel).' + required: false + default: 'Release' + +jobs: + Linux-64: + name: Linux x64 + runs-on: ubuntu-latest + container: ubuntu:22.04 + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Set build configuration + id: build_configuration + run: | + BUILD_TYPE=${{github.event.inputs.build_type}} + echo "build_type=${BUILD_TYPE:-"Debug"}" >> $GITHUB_OUTPUT + + - name: Setup Dependencies + run: | + apt update -y && apt install -y sudo + sudo apt-get update -y + sudo apt-get install -y ca-certificates gpg wget + test -f /usr/share/doc/kitware-archive-keyring/copyright || + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null + echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null + sudo apt-get update -y + test -f /usr/share/doc/kitware-archive-keyring/copyright || + sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg + sudo apt-get install kitware-archive-keyring + sudo apt install -y file build-essential cmake ninja-build wget gettext p7zip-full libsdl2-dev + + - name: Download source package + uses: actions/github-script@v7 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "Linux-x64" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/Linux-x64.zip`, Buffer.from(download.data)); + + - name: Package Debian + run: | + sudo apt install -y debmake debhelper dh-make + 7z x Linux-x64.zip -aoa -bd -y + mkdir -p Debian/Linux-x64 + tar zxf Linux-x64/max-port-*-Source.tar.gz --directory=Debian/Linux-x64 + cd Debian/Linux-x64/max-port-*-Source + sh ../../../.github/workflows/scripts/linux/get-dependencies cmake/versions.cmake + debmake --tar --monoarch --invoke debuild + cp ../max-port_*_amd64.deb ../../../${{steps.build_configuration.outputs.build_type}}/Artifacts2/Linux-x64/ + cp ../max-port-dbgsym_*_amd64.ddeb ../../../${{steps.build_configuration.outputs.build_type}}/Artifacts2/Linux-x64/ + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{github.job}} + path: ${{steps.build_configuration.outputs.build_type}}/Artifacts2 diff --git a/cmake/enet.cmake b/cmake/enet.cmake index e17b907e..a136a58f 100644 --- a/cmake/enet.cmake +++ b/cmake/enet.cmake @@ -17,6 +17,7 @@ if(ENET_RELEASE) URL_HASH ${ENET_HASH_TYPE}=${ENET_HASH} DOWNLOAD_EXTRACT_TIMESTAMP FALSE OVERRIDE_FIND_PACKAGE + EXCLUDE_FROM_ALL ) else() FetchContent_Declare( @@ -26,6 +27,7 @@ else() GIT_TAG ${ENET_TAG} DOWNLOAD_EXTRACT_TIMESTAMP FALSE OVERRIDE_FIND_PACKAGE + EXCLUDE_FROM_ALL ) endif() diff --git a/debian/rules b/debian/rules index 6b802ab7..89f8184c 100644 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,9 @@ #!/usr/bin/make -f # Output every command that modifies files on the build system. -#export DH_VERBOSE = 1 +export DH_VERBOSE = 1 + +# Make sure architecture is defined +DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) # Apply all hardening options #export DEB_BUILD_MAINT_OPTIONS = hardening=+all @@ -25,6 +28,10 @@ override_dh_auto_configure: -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-linux-x86_64.cmake \ -DBUILD_SHARED_LIBS=ON +# Manually add search path +override_dh_shlibdeps: + dh_shlibdeps -l$(CURDIR)/debian/max-port/usr/lib/$(DEB_HOST_MULTIARCH)/max-port/ + # You may need to patch CMakeLists.txt to set the library install path to be: #-install(TARGETS LIBRARY DESTINATION lib) #+install(TARGETS LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE})