Skip to content

Commit

Permalink
Make debian package generation dispatch only
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Nov 10, 2024
1 parent 7827f86 commit dfbb5a3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 30 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build_deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build Debian Package

on: workflow_dispatch

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: Build Debian Package
working-directory: ./packages/deb
run: ./setup.sh "$(git describe --tags --abbrev=0)"

- name: Run sanity checks on the Debian package
working-directory: ./packages/deb
run: |
./check_capstone.sh ./libcapstone-dev.deb "$(git describe --tags --abbrev=0)"
- uses: actions/upload-artifact@v4
with:
path: ./packages/deb/libcapstone-dev.deb
23 changes: 0 additions & 23 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,6 @@ jobs:
with:
submodules: true

- name: Build Debian Package
working-directory: ./packages/deb
run: ./setup.sh ${{ github.event.release.tag_name }}

- name: Run sanity checks on the Debian package
working-directory: ./packages/deb
run: |
./check_capstone.sh ./libcapstone-dev.deb ${{ github.event.release.tag_name }}
- name: Rename Debian package
working-directory: ./packages/deb
run: |
dpkg-name libcapstone-dev.deb
- name: Upload debian package to release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.release.tag_name }}
files: |
./packages/deb/*.deb
- name: Create archive
id: archive
run: |
Expand Down
7 changes: 3 additions & 4 deletions packages/deb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
ARG VERSION=""

# Assume this is run from capstone/debian directory
# Run in the root of the repo
# docker build -f ./debian/Dockerfile -t packager .
# docker build -f ./packages/deb/Dockerfile -t packager .
FROM debian:bookworm-slim

# Install necessary tools for packaging
Expand Down Expand Up @@ -35,7 +34,7 @@ RUN cmake --install build --prefix /package-root/usr/
# RUN find / -type f > /after-install.txt

# Create DEBIAN directory and control file
COPY ./debian/control /package-root/DEBIAN/control
COPY ./packages/deb/control /package-root/DEBIAN/control

# Update capstone.pc file with the correct version and remove archs field
# Update control file with the correct version
Expand All @@ -45,7 +44,7 @@ RUN sed -i "s/^Version:.*/Version: ${VERSION}/" /package-root/usr/lib/pkgconfig/
RUN sed -i "/^archs=/d" /package-root/usr/lib/pkgconfig/capstone.pc

# Add triggers script to run ldconfig after installation
COPY ./debian/triggers /package-root/DEBIAN/triggers
COPY ./packages/deb/triggers /package-root/DEBIAN/triggers

# Build the package
RUN fakeroot dpkg-deb --build /package-root /libcapstone-dev.deb
Expand Down
7 changes: 7 additions & 0 deletions packages/deb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Incomplete Debian package implementation.
It can be used to generate an easily installable Capstone, but misses a lot of
mandatory things to add it in the Debian repos (`debian/control` is incomplete, no dependencies added etc.).

You can build the package by dispatching the `Build Debian Package` workflow or executing the commands in the `Dockerfile`.
It assumes the current commit is tagged and `"$(git describe --tags --abbrev=0)"` returns a valid version number.
The package is uploaded as artifact.
6 changes: 3 additions & 3 deletions packages/deb/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ get_os_version() {
lsb_release -i -s 2>/dev/null
}

# Check if the script is running in the ./debian folder
# Check if the script is running in the ./packages/deb folder
if [[ $(basename "$PWD") != "deb" ]]; then
echo "ERROR: Script must be run from the ./deb directory"
exit 1
Expand Down Expand Up @@ -40,8 +40,8 @@ if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
fi

# Now build the packager container from that
pushd ../
docker build -f ./debian/Dockerfile -t packager --build-arg VERSION="${version}" .
pushd ../../
docker build -f ./packages/deb/Dockerfile -t packager --build-arg VERSION="${version}" .
popd

# Copy deb file out of container to host
Expand Down

0 comments on commit dfbb5a3

Please sign in to comment.