From e3a96d99542c4bc1a69fb1832a052b7a2e88bdcc Mon Sep 17 00:00:00 2001 From: Bruce Collie Date: Fri, 21 Jun 2024 16:02:36 +0100 Subject: [PATCH] Debian package (#3955) This PR sets up a Debian package build for the Haskell backend, similarly to code that already exists for the LLVM backend and K Frontend. The changes here are additive and do not affect any of the build details of the existing backend code. --- .github/workflows/release.yml | 56 +++++++++++++++++++++- .github/workflows/test.yml | 5 +- package/debian/build-package | 21 ++++++++ package/debian/changelog | 5 ++ package/debian/compat.jammy | 1 + package/debian/control.jammy | 16 +++++++ package/debian/copyright | 34 +++++++++++++ package/debian/k-haskell-backend-docs.docs | 0 package/debian/rules.jammy | 17 +++++++ package/debian/source/format | 1 + package/version.sh | 1 + 11 files changed, 155 insertions(+), 2 deletions(-) create mode 100755 package/debian/build-package create mode 100644 package/debian/changelog create mode 100644 package/debian/compat.jammy create mode 100644 package/debian/control.jammy create mode 100644 package/debian/copyright create mode 100644 package/debian/k-haskell-backend-docs.docs create mode 100644 package/debian/rules.jammy create mode 100644 package/debian/source/format diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 538361b4f8..7f74ec17f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,11 +55,65 @@ jobs: - name: Build run: nix build .#kore-exec .#kore-rpc-booster + ubuntu-package: + name: 'Build Ubuntu package' + needs: draft-release + runs-on: ubuntu-22.04 + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Cache Stack root + uses: actions/cache@v4 + with: + path: ~/.stack + key: stack-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('stack.yaml') }}-${{ hashFiles('stack.yaml.lock') }} + restore-keys: | + stack-${{ runner.os }}-ghc-${{ env.ghc_version }}-${{ hashFiles('stack.yaml') }} + stack-${{ runner.os }}-ghc-${{ env.ghc_version }} + + - uses: haskell-actions/setup@v2.7 + id: setup-haskell-stack + with: + ghc-version: ${{ env.ghc_version }} + stack-version: ${{ env.stack_version }} + enable-stack: true + stack-setup-ghc: true + + - name: Build Ubuntu package + run: ./package/debian/build-package jammy k-haskell-backend.deb + + - name: 'Upload to release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -x + VERSION=v$(cat package/version) + cp k-haskell-backend.deb k-haskell-backend_${VERSION}_amd64_ubuntu_jammy.deb + gh release upload ${VERSION} \ + --repo runtimeverification/haskell-backend \ + --clobber \ + k-haskell-backend_${VERSION}_amd64_ubuntu_jammy.deb + + - name: 'On failure, delete drafted release' + if: failure() + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -x + VERSION=v$(cat package/version) + gh release delete ${VERSION} \ + --repo runtimeverification/haskell-backend \ + --yes \ + --cleanup-tag + update-dependents: name: 'Publish Release' runs-on: ubuntu-latest environment: production - needs: [draft-release, release] + needs: [draft-release, ubuntu-package, release] env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ needs.draft-release.outputs.version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 402d40674e..6214395bc1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -191,7 +191,7 @@ jobs: steps: - name: Install prerequisites run: | - sudo apt install --yes z3 libsecp256k1-dev + sudo apt install --yes debhelper z3 libsecp256k1-dev - uses: actions/checkout@v4 with: @@ -230,6 +230,9 @@ jobs: - name: Run unit tests run: stack test kore:kore-test hs-backend-booster:unit-tests + - name: Build Ubuntu package + run: ./package/debian/build-package jammy k-haskell-backend.deb + hlint: name: 'HLint' needs: formatting diff --git a/package/debian/build-package b/package/debian/build-package new file mode 100755 index 0000000000..8a08cdb7b9 --- /dev/null +++ b/package/debian/build-package @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +base_distro="$1" ; shift +pkg_name="$1" ; shift + +mkdir debian + +mv package/debian/changelog debian/changelog +mv package/debian/copyright debian/copyright +mv package/debian/k-haskell-backend-docs.docs debian/k-haskell-backend-docs.docs +mv package/debian/source debian/source + +mv package/debian/compat.${base_distro} debian/compat +mv package/debian/control.${base_distro} debian/control +mv package/debian/rules.${base_distro} debian/rules + +dpkg-buildpackage + +mv ../k-haskell-backend_$(cat package/version)_amd64.deb ${pkg_name} diff --git a/package/debian/changelog b/package/debian/changelog new file mode 100644 index 0000000000..57b86c16b8 --- /dev/null +++ b/package/debian/changelog @@ -0,0 +1,5 @@ +k-haskell-backend (0.1.0) unstable; urgency=medium + + * Initial release + + -- Bruce Collie Fri, 26 Apr 2024 15:43:00 +0100 diff --git a/package/debian/compat.jammy b/package/debian/compat.jammy new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/package/debian/compat.jammy @@ -0,0 +1 @@ +10 diff --git a/package/debian/control.jammy b/package/debian/control.jammy new file mode 100644 index 0000000000..59d77bac55 --- /dev/null +++ b/package/debian/control.jammy @@ -0,0 +1,16 @@ +Source: k-haskell-backend +Section: devel +Priority: optional +Maintainer: Bruce Collie +Build-Depends: debhelper (>=10) +Standards-Version: 3.9.6 +Homepage: https://github.com/runtimeverification/haskell-backend + +Package: k-haskell-backend +Architecture: any +Section: devel +Priority: optional +Depends: libsecp256k1-dev , z3 +Description: K Framework Haskell Backend + The symbolic execution engine powering the K Framework +Homepage: https://github.com/runtimeverification/haskell-backend diff --git a/package/debian/copyright b/package/debian/copyright new file mode 100644 index 0000000000..567882a9dd --- /dev/null +++ b/package/debian/copyright @@ -0,0 +1,34 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: k-haskell-backend +Upstream-Contact: Bruce Collie +Source: https://github.com/runtimeverification/haskell-backend + +Files: * +Copyright: 2018-2024 K Team +License: BSD-3-Clause + +License: BSD-3-Clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/package/debian/k-haskell-backend-docs.docs b/package/debian/k-haskell-backend-docs.docs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/package/debian/rules.jammy b/package/debian/rules.jammy new file mode 100644 index 0000000000..787cfc72cf --- /dev/null +++ b/package/debian/rules.jammy @@ -0,0 +1,17 @@ +#!/usr/bin/make -f + +DESTDIR=$(shell pwd)/debian/k-haskell-backend +PREFIX=/usr +export DESTDIR +export PREFIX + +%: + dh $@ + +override_dh_auto_build: + stack build + +override_dh_auto_install: + stack install --local-bin-path $(DESTDIR)$(PREFIX)/bin + +override_dh_auto_test: diff --git a/package/debian/source/format b/package/debian/source/format new file mode 100644 index 0000000000..89ae9db8f8 --- /dev/null +++ b/package/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/package/version.sh b/package/version.sh index 803499805f..b1453753f8 100755 --- a/package/version.sh +++ b/package/version.sh @@ -32,6 +32,7 @@ version_sub() { sed -i "s/^version: '.*'$/version: '${version}'/" booster/package.yaml sed -i "s/^version: .*$/version: ${version}/" kore/kore.cabal sed -i "s/^version: .*$/version: ${version}/" ./kore-rpc-types/kore-rpc-types.cabal + sed -i 's/^k-haskell-backend (.*) unstable; urgency=medium$/k-haskell-backend ('"$version"') unstable; urgency=medium/' package/debian/changelog } version_command="$1" ; shift