-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Change CI to create Debian Package to Release #2521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 . | ||
|
AndrewQuijano marked this conversation as resolved.
|
||
| 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 hidden or 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 | ||
|
AndrewQuijano marked this conversation as resolved.
|
||
|
|
||
| # 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 hidden or 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 <unisono@quyllur.org> | ||
| 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.