-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change CI to create Debian Package to Release (#2521)
* Updating CI to create Debian package and version is assigned by tag version. Also updating release CI to not use end-of-life workflows * Clear up usage of static libraries. - Python bindings only use the dynamic lib. But built and copied the static ones sometimes nonetheless. - Add toggles to build only static, static/dyn or only dynamic. --------- Co-authored-by: Rot127 <[email protected]>
- Loading branch information
1 parent
f6f9679
commit d7be5f9
Showing
12 changed files
with
298 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Ignore source control directories | ||
.git | ||
.svn | ||
|
||
# Ignore build directories | ||
build | ||
dist | ||
|
||
# Ignore dependency directories | ||
node_modules | ||
vendor | ||
|
||
# Ignore temporary files | ||
*.log | ||
*.tmp | ||
|
||
# Ignore environment files | ||
.env | ||
|
||
# Ignore tests | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/arch/**/*.inc linguist-language=C | ||
|
||
# Ensure shell scripts have LF line endings | ||
*.sh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.deb | ||
*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
ARG VERSION="" | ||
|
||
# Assume this is run from capstone/debian directory | ||
# Run in the root of the repo | ||
# docker build -f ./debian/Dockerfile -t packager . | ||
FROM debian:bookworm-slim | ||
|
||
# Install necessary tools for packaging | ||
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 | ||
RUN mkdir /capstone | ||
COPY . /capstone | ||
WORKDIR /capstone/ | ||
|
||
# Using cmake, see BUILDING.md file | ||
# For debug build change "Release" to "Debug" | ||
RUN cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 | ||
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 | ||
|
||
# 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 | ||
|
||
# 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 | ||
|
||
# Add postinst script to run ldconfig after installation | ||
COPY ./debian/postinst /package-root/DEBIAN/postinst | ||
RUN chmod 755 /package-root/DEBIAN/postinst | ||
|
||
# Build the package | ||
RUN fakeroot dpkg-deb --build /package-root /libcapstone-dev.deb | ||
|
||
# The user can now extract the .deb file from the container with something like | ||
# docker run --rm -v $(pwd):/out packager bash -c "cp /libcapstone-dev.deb /out" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
|
||
# Usage: ./check_capstone_pc.sh <path_to_deb_file> <expected_version> | ||
|
||
DEB_FILE=$1 | ||
EXPECTED_VERSION=$2 | ||
|
||
# Check if the deb file exists | ||
if [[ ! -f "$DEB_FILE" ]]; then | ||
echo "Debian package file not found!" | ||
exit 1 | ||
fi | ||
|
||
# Create a temporary directory to extract the deb file | ||
TEMP_DIR=$(mktemp -d) | ||
|
||
# Extract the deb file | ||
dpkg-deb -x "$DEB_FILE" "$TEMP_DIR" | ||
|
||
# Path to the capstone.pc file | ||
CAPSTONE_PC="$TEMP_DIR/usr/local/lib/pkgconfig/capstone.pc" | ||
|
||
# Check if the capstone.pc file exists | ||
if [[ ! -f "$CAPSTONE_PC" ]]; then | ||
echo "capstone.pc file not found in the package!" | ||
rm -rf "$TEMP_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Remove leading 'v' if present, e. g. v1.5.1 -> 1.5.1 | ||
if [[ "$EXPECTED_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
EXPECTED_VERSION=${EXPECTED_VERSION:1} | ||
fi | ||
|
||
# Check if the version follows the format X.Y.Z, e. g. 1.5.1 or 1.9.1 | ||
if [[ ! "$EXPECTED_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
echo "ERROR: Version must be in the format X.Y.Z" | ||
exit 1 | ||
fi | ||
|
||
|
||
# Check the version in the capstone.pc file | ||
ACTUAL_VERSION=$(grep "^Version:" "$CAPSTONE_PC" | awk '{print $2}') | ||
if [[ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]]; then | ||
echo "Version mismatch! Expected: $EXPECTED_VERSION, Found: $ACTUAL_VERSION" | ||
rm -rf "$TEMP_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Check if libcapstone.a is included in the package | ||
LIBCAPSTONE_A="$TEMP_DIR/usr/local/lib/libcapstone.a" | ||
if [[ ! -f "$LIBCAPSTONE_A" ]]; then | ||
echo "libcapstone.a not found in the package!" | ||
rm -rf "$TEMP_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Check if libcapstone.so is included in the package | ||
LIBCAPSTONE_SO="$TEMP_DIR/usr/local/lib/libcapstone.so" | ||
if [[ ! -f "$LIBCAPSTONE_SO" ]]; then | ||
echo "libcapstone.so not found in the package!" | ||
rm -rf "$TEMP_DIR" | ||
exit 1 | ||
fi | ||
|
||
echo "libcapstone-dev.deb file is correct." | ||
rm -rf "$TEMP_DIR" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Package: capstone | ||
Version: <version-placeholder> | ||
Architecture: all | ||
Maintainer: Rot127 <[email protected]> | ||
Description: Capstone is a lightweight multi-platform, multi-architecture disassembly framework. | ||
Capstone supports the following frameworks; | ||
Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), | ||
SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
# postinst script for capstone package | ||
set -e | ||
|
||
# Update the shared library cache | ||
ldconfig |
Oops, something went wrong.