From ea42c2803a79b146a27bd988a4d18ef0881fcdf6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 17 Dec 2024 00:07:13 -0500 Subject: [PATCH] Creating a functional Debian Package for Capstone v5 (#2569) --- .gitattributes | 3 ++ .github/workflows/build_release.yml | 52 ++++++++++++++-------- CMakeLists.txt | 67 +++++++++++++++++++++------- bindings/python/setup.py | 16 ++----- capstone.pc.in | 1 - nmake.bat | 30 ------------- packages/deb/.gitignore | 2 + packages/deb/Dockerfile | 69 +++++++++++++++++++++++++++++ packages/deb/check_capstone.sh | 50 +++++++++++++++++++++ packages/deb/control | 25 +++++++++++ packages/deb/setup.sh | 57 ++++++++++++++++++++++++ packages/deb/triggers | 2 + 12 files changed, 294 insertions(+), 80 deletions(-) delete mode 100644 nmake.bat create mode 100644 packages/deb/.gitignore create mode 100644 packages/deb/Dockerfile create mode 100644 packages/deb/check_capstone.sh create mode 100644 packages/deb/control create mode 100644 packages/deb/setup.sh create mode 100644 packages/deb/triggers diff --git a/.gitattributes b/.gitattributes index 03e638de69..e7ea118ba2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ /arch/**/*.inc linguist-language=C + +# Ensure shell scripts have LF line endings +*.sh text eol=lf \ No newline at end of file diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 5859fabf27..01b1a57403 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -11,10 +11,33 @@ jobs: name: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true + - name: Make setup.sh and check_capstone.sh are executable + run: | + chmod +x ./packages/deb/setup.sh + chmod +x ./packages/deb/check_capstone.sh + + - 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_${{ github.event.release.tag_name }}_amd64.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: archive id: archive run: | @@ -27,24 +50,15 @@ jobs: TARBALL=$PKGNAME.tar.xz tar cJf $TARBALL $PKGNAME sha256sum $TARBALL > $SHASUM - echo "::set-output name=tarball::$TARBALL" - echo "::set-output name=shasum::$SHASUM" - - name: upload tarball - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./${{ steps.archive.outputs.tarball }} - asset_name: ${{ steps.archive.outputs.tarball }} - asset_content_type: application/gzip - - - name: upload shasum - uses: actions/upload-release-asset@v1 + echo "tarball=$TARBALL" >> $GITHUB_OUTPUT + echo "shasum=$SHASUM" >> $GITHUB_OUTPUT + + - name: Upload tarball and shasum to release + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./${{ steps.archive.outputs.shasum }} - asset_name: ${{ steps.archive.outputs.shasum }} - asset_content_type: text/plain + tag_name: ${{ github.event.release.tag_name }} + files: | + ${{ steps.archive.outputs.tarball }} + ${{ steps.archive.outputs.shasum }} diff --git a/CMakeLists.txt b/CMakeLists.txt index a0a70bb3ce..53ca9373dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,16 @@ cmake_policy(SET CMP0042 NEW) # Enable support for MSVC_RUNTIME_LIBRARY cmake_policy(SET CMP0091 NEW) -project(capstone - VERSION 5.0.3 -) +# Check if VERSION is provided externally, otherwise default to 5.0.3 +if(NOT DEFINED PROJECT_VERSION) + set(PROJECT_VERSION "5.0.3") +endif() + +# Extract the major, minor, and patch versions +string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" PROJECT_VERSION_BASE ${PROJECT_VERSION}) + +# Set the project version without the pre-release identifier +project(capstone VERSION ${PROJECT_VERSION_BASE}) if (MSVC) add_compile_options(/W1 /w14189) @@ -35,7 +42,8 @@ endif() # to configure the options specify them in in the command line or change them in the cmake UI. # Don't edit the makefile! option(BUILD_SHARED_LIBS "Build shared library" OFF) -option(CAPSTONE_BUILD_STATIC_RUNTIME "Embed static runtime" ${BUILD_SHARED_LIBS}) +option(BUILD_STATIC_LIBS "Build static library" ON) +option(BUILD_STATIC_RUNTIME "Embed static MSVC runtime (Windows only). Always set if BUILD_SHARED_LIBS=ON" ${BUILD_SHARED_LIBS}) option(CAPSTONE_BUILD_MACOS_THIN "Disable universal2 builds on macOS" OFF) option(CAPSTONE_BUILD_DIET "Build diet library" OFF) option(CAPSTONE_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL}) @@ -46,6 +54,10 @@ option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by defau option(CAPSTONE_DEBUG "Whether to enable extra debug assertions" OFF) option(CAPSTONE_INSTALL "Generate install target" ${PROJECT_IS_TOP_LEVEL}) +if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) + FATAL_ERROR("BUILD_SHARED_LIBS and BUILD_STATIC_LIBS are both unset. Nothing to build.") +endif() + set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM MOS65XX WASM BPF RISCV SH TRICORE) set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM MOS65XX WASM BPF RISCV SH TriCore) @@ -109,7 +121,7 @@ if(CAPSTONE_DEBUG) endif() # Force static runtime libraries -if(CAPSTONE_BUILD_STATIC_RUNTIME) +if(BUILD_STATIC_RUNTIME) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() @@ -631,19 +643,33 @@ set(ALL_HEADERS set_property(GLOBAL PROPERTY VERSION ${PROJECT_VERSION}) ## targets -add_library(capstone ${ALL_SOURCES} ${ALL_HEADERS}) -add_library(capstone::capstone ALIAS capstone) +add_library(capstone OBJECT ${ALL_SOURCES} ${ALL_HEADERS}) +set_property(TARGET capstone PROPERTY C_STANDARD 99) target_include_directories(capstone PUBLIC $ ) -set_property(TARGET capstone PROPERTY C_STANDARD 99) +if(BUILD_STATIC_LIBS) + add_library(capstone_static STATIC $) + # Use normal capstone name. Otherwise we get libcapstone_static.a + set_target_properties(capstone_static PROPERTIES OUTPUT_NAME "capstone") + target_include_directories(capstone_static PUBLIC + $ + ) +endif() if(BUILD_SHARED_LIBS) - target_compile_definitions(capstone PUBLIC CAPSTONE_SHARED) - set_target_properties(capstone PROPERTIES + set_property(TARGET capstone PROPERTY POSITION_INDEPENDENT_CODE 1) + add_library(capstone_shared SHARED $) + # Use normal capstone name. Otherwise we get libcapstone_shared.so + set_target_properties(capstone_shared PROPERTIES OUTPUT_NAME "capstone") + set_target_properties(capstone_shared PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) + target_include_directories(capstone_shared PUBLIC + $ + ) + target_compile_definitions(capstone PUBLIC CAPSTONE_SHARED) endif() if(CAPSTONE_BUILD_TESTS) @@ -712,7 +738,6 @@ source_group("Include\\TriCore" FILES ${HEADERS_TRICORE}) ## installation if(CAPSTONE_INSTALL) include(GNUInstallDirs) - install(FILES ${HEADERS_COMMON} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone) # Support absolute installation paths (discussion: https://github.com/NixOS/nixpkgs/issues/144170) @@ -753,12 +778,20 @@ if(CAPSTONE_INSTALL) DESTINATION ${CAPSTONE_CMAKE_CONFIG_INSTALL_DIR} ) - install(TARGETS capstone - EXPORT capstone-targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + if(BUILD_SHARED_LIBS) + set(LIB_INSTALL_TARGETS capstone_shared) + endif() + + if (BUILD_STATIC_LIBS) + set(LIB_INSTALL_TARGETS ${LIB_INSTALL_TARGETS} capstone_static) + endif() + + install(TARGETS ${LIB_INSTALL_TARGETS} + EXPORT capstone-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(EXPORT capstone-targets diff --git a/bindings/python/setup.py b/bindings/python/setup.py index a5cb08c8be..ef1eeb9a2d 100755 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -62,15 +62,12 @@ if SYSTEM == 'darwin': VERSIONED_LIBRARY_FILE = "libcapstone.{PKG_MAJOR}.dylib".format(**VERSION_DATA) LIBRARY_FILE = "libcapstone.dylib" - STATIC_LIBRARY_FILE = 'libcapstone.a' elif SYSTEM in ('win32', 'cygwin'): VERSIONED_LIBRARY_FILE = "capstone.dll" LIBRARY_FILE = "capstone.dll" - STATIC_LIBRARY_FILE = None else: VERSIONED_LIBRARY_FILE = "libcapstone.so.{PKG_MAJOR}".format(**VERSION_DATA) LIBRARY_FILE = "libcapstone.so" - STATIC_LIBRARY_FILE = 'libcapstone.a' def clean_bins(): shutil.rmtree(LIBS_DIR, ignore_errors=True) @@ -124,12 +121,9 @@ def build_libraries(): shutil.copytree(os.path.join(BUILD_DIR, 'include', 'capstone'), os.path.join(HEADERS_DIR, 'capstone')) # if prebuilt libraries are available, use those and cancel build - if os.path.exists(os.path.join(ROOT_DIR, 'prebuilt', LIBRARY_FILE)) and \ - (not STATIC_LIBRARY_FILE or os.path.exists(os.path.join(ROOT_DIR, 'prebuilt', STATIC_LIBRARY_FILE))): + if os.path.exists(os.path.join(ROOT_DIR, 'prebuilt', LIBRARY_FILE)): logger.info('Using prebuilt libraries') shutil.copy(os.path.join(ROOT_DIR, 'prebuilt', LIBRARY_FILE), LIBS_DIR) - if STATIC_LIBRARY_FILE is not None: - shutil.copy(os.path.join(ROOT_DIR, 'prebuilt', STATIC_LIBRARY_FILE), LIBS_DIR) return os.chdir(BUILD_DIR) @@ -145,8 +139,8 @@ def build_libraries(): os.chdir("build") print("Build Directory: {}\n".format(os.getcwd())) # Only build capstone.dll / libcapstone.dylib - if SYSTEM == "win32": - os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "NMake Makefiles" ..') + if SYSTEM in ('win32', 'cygwin'): + os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "NMake Makefiles" ..') else: os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "Unix Makefiles" ..') os.system("cmake --build .") @@ -154,10 +148,6 @@ def build_libraries(): os.system("CAPSTONE_BUILD_CORE_ONLY=yes bash ./make.sh") shutil.copy(VERSIONED_LIBRARY_FILE, os.path.join(LIBS_DIR, LIBRARY_FILE)) - - # only copy static library if it exists (it's a build option) - if STATIC_LIBRARY_FILE and os.path.exists(STATIC_LIBRARY_FILE): - shutil.copy(STATIC_LIBRARY_FILE, LIBS_DIR) os.chdir(cwd) diff --git a/capstone.pc.in b/capstone.pc.in index 97fcf947f6..d77460b6c8 100644 --- a/capstone.pc.in +++ b/capstone.pc.in @@ -10,4 +10,3 @@ URL: https://www.capstone-engine.org/ archive=${libdir}/libcapstone.a Libs: -L${libdir} -lcapstone Cflags: -I${includedir}/capstone -archs=@CAPSTONE_ARCHITECTURES@ diff --git a/nmake.bat b/nmake.bat deleted file mode 100644 index ec2496edf5..0000000000 --- a/nmake.bat +++ /dev/null @@ -1,30 +0,0 @@ -:: Capstone disassembler engine (www.capstone-engine.org) -:: Build Capstone libs (capstone.dll & capstone.lib) on Windows with CMake & Nmake -:: By Nguyen Anh Quynh, Jorn Vernee, 2017, 2019 - -@echo off - -set flags="-DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_STATIC_RUNTIME=ON" - -if "%1"=="ARM" set %arch%=ARM -if "%1"=="ARM64" set %arch%=ARM64 -if "%1"=="M68K" set %arch%=M68K -if "%1"=="MIPS" set %arch%=MIPS -if "%1"=="PowerPC" set %arch%=PPC -if "%1"=="Sparc" set %arch%=SPARC -if "%1"=="SystemZ" set %arch%=SYSZ -if "%1"=="XCore" set %arch%=XCORE -if "%1"=="x86" set %arch%=X86 -if "%1"=="TMS320C64x" set %arch%=TMS320C64X -if "%1"=="M680x" set %arch%=M680X -if "%1"=="EVM" set %arch%=EVM -if "%1"=="MOS65XX" set %arch%=MOS65XX -if "%1"=="WASM" set %arch%=WASM -if "%1"=="BPF" set %arch%=BPF -if "%1"=="RISCV" set %arch%=RISCV - -if not "%arch%"=="" set flags=%flags% and " -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF -DCAPSTONE_%arch%_SUPPORT=ON" - -cmake %flags% -G "NMake Makefiles" .. -nmake - diff --git a/packages/deb/.gitignore b/packages/deb/.gitignore new file mode 100644 index 0000000000..c636824af1 --- /dev/null +++ b/packages/deb/.gitignore @@ -0,0 +1,2 @@ +*.deb +*.txt \ No newline at end of file diff --git a/packages/deb/Dockerfile b/packages/deb/Dockerfile new file mode 100644 index 0000000000..f55f55ad96 --- /dev/null +++ b/packages/deb/Dockerfile @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: MIT +# Copyright (C) 2024 Andrew Quijano +# Contact: andrewquijano92@gmail.com +ARG VERSION="" + +# Run in the root of the repo +# docker build -f ./packages/deb/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 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" +ARG VERSION +RUN cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DPROJECT_VERSION=${VERSION} -DCMAKE_INSTALL_PREFIX=/usr +RUN cmake --build build + +# List files before cmake install +# RUN find / -type f > /before-install.txt + +# 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 mkdir -p /package-root/usr/share/doc/libcapstone-dev + +# Run cmake install +RUN cmake --install build --prefix /package-root/usr/ + +# List files after cmake install +# RUN find / -type f > /after-install.txt + +# Create DEBIAN directory and control file +COPY ./packages/deb/control /package-root/DEBIAN/control + +# Copy documentation over +COPY ./ChangeLog /package-root/usr/share/doc/libcapstone-dev +COPY ./CREDITS.TXT /package-root/usr/share/doc/libcapstone-dev +COPY ./HACK.TXT /package-root/usr/share/doc/libcapstone-dev +COPY ./LICENSE.TXT /package-root/usr/share/doc/libcapstone-dev +COPY ./README.md /package-root/usr/share/doc/libcapstone-dev +COPY ./SPONSORS.TXT /package-root/usr/share/doc/libcapstone-dev + +# Generate MD5 checksums for all files and save to DEBIAN/md5sums +RUN cd /package-root && \ + find . -type f ! -path './DEBIAN/*' -exec md5sum {} + | sed 's| \./| |' > /package-root/DEBIAN/md5sums + +# Update control file with the correct information +ARG VERSION +RUN INSTALLED_SIZE=$(du -sk /package-root | cut -f1) && \ + sed -i "s/^Installed-Size:.*/Installed-Size: ${INSTALLED_SIZE}/" /package-root/DEBIAN/control +RUN sed -i "s/^Version:.*/Version: ${VERSION}/" /package-root/DEBIAN/control + +# 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_${VERSION}_amd64.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" diff --git a/packages/deb/check_capstone.sh b/packages/deb/check_capstone.sh new file mode 100644 index 0000000000..deb791b4d4 --- /dev/null +++ b/packages/deb/check_capstone.sh @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: MIT +# Copyright (C) 2024 Andrew Quijano +# Contact: andrewquijano92@gmail.com + +#!/bin/bash +set -eu + +# Usage: ./check_capstone_pc.sh + +DEB_FILE=$1 + +# 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" + +# Check if the capstone.pc file exists +CAPSTONE_PC="$TEMP_DIR/usr/lib/x86_64-linux-gnu/pkgconfig/capstone.pc" +if [[ ! -f "$CAPSTONE_PC" ]]; then + echo "capstone.pc file not found in the package!" + rm -rf "$TEMP_DIR" + exit 1 +fi + +# Check if libcapstone.a is included in the package +LIBCAPSTONE_A="$TEMP_DIR/usr/lib/x86_64-linux-gnu/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/lib/x86_64-linux-gnu/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 diff --git a/packages/deb/control b/packages/deb/control new file mode 100644 index 0000000000..1c9cee3ea6 --- /dev/null +++ b/packages/deb/control @@ -0,0 +1,25 @@ +Package: libcapstone-dev +Source: capstone +Version: +Architecture: amd64 +Maintainer: Rot127 +Original-Maintainer: Debian Security Tools +Installed-Size: +Depends: libc6 (>= 2.2.5) +Section: libdevel +Priority: optional +Multi-Arch: same +Homepage: https://www.capstone-engine.org/ +Description: lightweight multi-architecture disassembly framework - devel files + Capstone is a lightweight multi-platform, multi-architecture disassembly + framework. These are the development headers and libraries. + Features: + - Support hardware architectures: AArch64, ARM, Alpha, BPF, EVM, HPPA, LongArch, M680X, M68K, MOS65XX, Mips, PowerPC, RISCV, SH, Sparc, SystemZ, TMS320C64x, TriCore, WASM, x86, XCore. + - Clean/simple/lightweight/intuitive architecture-neutral API. + - Provide details on disassembled instructions (called "decomposer" by some + others). + - Provide some semantics of the disassembled instruction, such as list of + implicit registers read & written. + - Thread-safe by design. + - Special support for embedding into firmware or OS kernel. + - Distributed under the open source BSD license. diff --git a/packages/deb/setup.sh b/packages/deb/setup.sh new file mode 100644 index 0000000000..6c7f71bb45 --- /dev/null +++ b/packages/deb/setup.sh @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: MIT +# Copyright (C) 2024 Andrew Quijano +# Contact: andrewquijano92@gmail.com + +# !/bin/bash +set -eu + +# Function to get the current Ubuntu version +get_os_version() { + lsb_release -i -s 2>/dev/null +} + +# 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 + +OS_VERSION=$(get_os_version) +if [[ "$OS_VERSION" != "Ubuntu" && "$OS_VERSION" != "Debian" ]]; then + echo "ERROR: OS is not Ubuntu or Debian and unsupported" + exit 1 +fi + +# Get the version number as an input +# Check if version argument is provided +if [[ $# -ne 1 ]]; then + echo "ERROR: Version argument is required" + exit 1 +fi + +# Get the version number as an input +version=$1 + +# Remove leading 'v' if present, e. g. v1.5.1 -> 1.5.1 +if [[ "$version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + version=${version:1} +fi + +# Check if the version follows the format for Debian Packages +if [[ ! "$version" =~ ^[0-9]+(.[0-9]+)*(-[A-Za-z0-9]+)?$ ]]; then + echo "ERROR: Version must be in a valid Debian package format" + exit 1 +fi + +# Now build the packager container from that +pushd ../../ +docker build -f ./packages/deb/Dockerfile -t packager --build-arg VERSION="${version}" . +popd + +# Copy deb file out of container to host +docker run --rm -v $(pwd):/out packager bash -c "cp /*.deb /out" + +# Check which files existed before and after 'make install' was executed. +# docker run --rm -v $(pwd):/out packager bash -c "cp /before-install.txt /out" +# docker run --rm -v $(pwd):/out packager bash -c "cp /after-install.txt /out" +# diff before-install.txt after-install.txt diff --git a/packages/deb/triggers b/packages/deb/triggers new file mode 100644 index 0000000000..eafa63be77 --- /dev/null +++ b/packages/deb/triggers @@ -0,0 +1,2 @@ +# Trigger ldconfig after install +activate-noawait ldconfig