Move debian package generation to a dispatch only workflow (#2543)
Some checks failed
Run Test / ${{ matrix.config.name }} (map[arch:x64 build-system:cmake diet-build:OFF enable-asan:OFF name:ubuntu-22.04 x64 cmake os:ubuntu-22.04]) (push) Has been cancelled
Run Test / ${{ matrix.config.name }} (map[arch:x64 build-system:cmake diet-build:OFF enable-asan:ON name:ubuntu-24.04 x64 ASAN os:ubuntu-24.04]) (push) Has been cancelled
Run Test / ${{ matrix.config.name }} (map[arch:x64 build-system:make diet-build:OFF enable-asan:OFF name:ubuntu-22.04 x64 make os:ubuntu-22.04]) (push) Has been cancelled
Run Test / ${{ matrix.config.name }} (map[arch:x64 name:windows x64 MSVC 64bit os:windows-latest platform:windows python-arch:x64 python-version:3.9]) (push) Has been cancelled
Run clang-tidy / clang-tidy (push) Has been cancelled
RELEASE BUILD - PyPI 📦 Distribution / Build wheels on ${{ matrix.os }} (macos-latest) (push) Has been cancelled
RELEASE BUILD - PyPI 📦 Distribution / Build wheels on ${{ matrix.os }} (ubuntu-latest) (push) Has been cancelled
RELEASE BUILD - PyPI 📦 Distribution / Build wheels on ${{ matrix.os }} (windows-latest) (push) Has been cancelled
RELEASE BUILD - PyPI 📦 Distribution / Make SDist (push) Has been cancelled
Python Package CI / build (macOS-14, 3.12) (push) Has been cancelled
Python Package CI / build (macOS-14, 3.8) (push) Has been cancelled
Python Package CI / build (ubuntu-24.04, 3.12) (push) Has been cancelled
Python Package CI / build (ubuntu-24.04, 3.8) (push) Has been cancelled
Python Package CI / build (windows-2022, 3.12) (push) Has been cancelled
Python Package CI / build (windows-2022, 3.8) (push) Has been cancelled
RELEASE BUILD - PyPI 📦 Distribution / publish (push) Has been cancelled
Coverity Scan / latest (push) Has been cancelled

* Move deb package gen files int package/deb

* Fix basename check

* Make debian package generation dispatch only
This commit is contained in:
Rot127 2024-11-13 14:10:59 +00:00 committed by GitHub
parent abbf32b431
commit e3bc578d2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 61 additions and 63 deletions

26
.github/workflows/build_deb.yml vendored Normal file
View File

@ -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

View File

@ -15,30 +15,7 @@ jobs:
with:
submodules: true
- name: Make setup.sh and check_capstone.sh are executable
run: |
chmod +x debian/setup.sh
chmod +x debian/check_capstone.sh
- name: Build Debian Package
working-directory: ./debian
run: ./setup.sh ${{ github.event.release.tag_name }}
- name: Run sanity checks on the Debian package
working-directory: ./debian
run: |
./check_capstone.sh ./libcapstone-dev.deb ${{ github.event.release.tag_name }}
- 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: |
./debian/*.deb
- name: archive
- name: Create archive
id: archive
run: |
VERSION=${{ github.event.release.tag_name }}

6
debian/postinst vendored
View File

@ -1,6 +0,0 @@
#!/bin/bash
# postinst script for capstone package
set -e
# Update the shared library cache
ldconfig

View File

@ -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
@ -10,7 +9,7 @@ RUN apt-get -qq update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq install -y \
fakeroot dpkg-dev dos2unix cmake
# Copy your project files into the container
# Copy project files into the container
RUN mkdir /capstone
COPY . /capstone
WORKDIR /capstone/
@ -23,36 +22,29 @@ RUN cmake --build build
# List files before cmake install
# RUN find / -type f > /before-install.txt
# Run cmake install, by default everything goes into /usr/local
RUN cmake --install build
# Make directories as needed
RUN mkdir -p /package-root/usr/include/capstone/
RUN mkdir -p /package-root/usr/lib/pkgconfig/
RUN mkdir -p /package-root/usr/bin/
# Run cmake install
RUN cmake --install build --prefix /package-root/usr/
# List files after cmake install
# RUN find / -type f > /after-install.txt
# Make directories as needed
RUN mkdir -p /package-root/usr/local/include/capstone/
RUN mkdir -p /package-root/usr/local/lib/pkgconfig/
RUN mkdir -p /package-root/usr/local/bin/
# Copy /usr/local/include/capstone/ to /package-root/usr/local/include/capstone/ and all other cases
RUN cp -r /usr/local/include/capstone/* /package-root/usr/local/include/capstone/
RUN cp -r /usr/local/lib/libcapstone* /package-root/usr/local/lib/
RUN cp -r /usr/local/lib/pkgconfig/capstone* /package-root/usr/local/lib/pkgconfig/
RUN cp -r /usr/local/bin/cstool /package-root/usr/local/bin/
# 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
ARG VERSION
RUN sed -i "s/^Version:.*/Version: ${VERSION}/" /package-root/DEBIAN/control
RUN sed -i "s/^Version:.*/Version: ${VERSION}/" /package-root/usr/local/lib/pkgconfig/capstone.pc
RUN sed -i "/^archs=/d" /package-root/usr/local/lib/pkgconfig/capstone.pc
RUN sed -i "s/^Version:.*/Version: ${VERSION}/" /package-root/usr/lib/pkgconfig/capstone.pc
RUN sed -i "/^archs=/d" /package-root/usr/lib/pkgconfig/capstone.pc
# Add postinst script to run ldconfig after installation
COPY ./debian/postinst /package-root/DEBIAN/postinst
RUN chmod 755 /package-root/DEBIAN/postinst
# Add triggers script to run ldconfig after installation
COPY ./packages/deb/triggers /package-root/DEBIAN/triggers
# Build the package
RUN fakeroot dpkg-deb --build /package-root /libcapstone-dev.deb

7
packages/deb/README.md Normal file
View File

@ -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.

View File

@ -18,7 +18,7 @@ TEMP_DIR=$(mktemp -d)
dpkg-deb -x "$DEB_FILE" "$TEMP_DIR"
# Path to the capstone.pc file
CAPSTONE_PC="$TEMP_DIR/usr/local/lib/pkgconfig/capstone.pc"
CAPSTONE_PC="$TEMP_DIR/usr/lib/pkgconfig/capstone.pc"
# Check if the capstone.pc file exists
if [[ ! -f "$CAPSTONE_PC" ]]; then
@ -48,7 +48,7 @@ if [[ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]]; then
fi
# Check if libcapstone.a is included in the package
LIBCAPSTONE_A="$TEMP_DIR/usr/local/lib/libcapstone.a"
LIBCAPSTONE_A="$TEMP_DIR/usr/lib/libcapstone.a"
if [[ ! -f "$LIBCAPSTONE_A" ]]; then
echo "libcapstone.a not found in the package!"
rm -rf "$TEMP_DIR"
@ -56,7 +56,7 @@ if [[ ! -f "$LIBCAPSTONE_A" ]]; then
fi
# Check if libcapstone.so is included in the package
LIBCAPSTONE_SO="$TEMP_DIR/usr/local/lib/libcapstone.so"
LIBCAPSTONE_SO="$TEMP_DIR/usr/lib/libcapstone.so"
if [[ ! -f "$LIBCAPSTONE_SO" ]]; then
echo "libcapstone.so not found in the package!"
rm -rf "$TEMP_DIR"

10
debian/setup.sh → packages/deb/setup.sh Normal file → Executable file
View File

@ -6,9 +6,9 @@ get_os_version() {
lsb_release -i -s 2>/dev/null
}
# Check if the script is running in the ./debian folder
if [[ $(basename "$PWD") != "debian" ]]; then
echo "ERROR: Script must be run from the ./debian directory"
# 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
fi
@ -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

2
packages/deb/triggers Normal file
View File

@ -0,0 +1,2 @@
# Trigger ldconfig after install
activate-noawait ldconfig