diff --git a/.github/workflows/build_deb.yml b/.github/workflows/build_deb.yml new file mode 100644 index 0000000000..3caf6a0c28 --- /dev/null +++ b/.github/workflows/build_deb.yml @@ -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 diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 2eb0737947..d818270ca8 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -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: | diff --git a/packages/deb/Dockerfile b/packages/deb/Dockerfile index f1adb784b7..ba833b1870 100644 --- a/packages/deb/Dockerfile +++ b/packages/deb/Dockerfile @@ -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 @@ -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 @@ -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 diff --git a/packages/deb/README.md b/packages/deb/README.md new file mode 100644 index 0000000000..fc79aa4e0e --- /dev/null +++ b/packages/deb/README.md @@ -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. diff --git a/packages/deb/setup.sh b/packages/deb/setup.sh index d684c5fdb3..a3595dfd2c 100755 --- a/packages/deb/setup.sh +++ b/packages/deb/setup.sh @@ -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 @@ -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