From 7a42e91dba7f034b9c362b516ef51593c1350b3d Mon Sep 17 00:00:00 2001 From: redcatbaer Date: Sun, 6 Sep 2026 10:32:58 +0200 Subject: [PATCH] Added package revision can now be controlled by user. --- .github/workflows/release.yml | 28 +++++++++++++++++----------- README.md | 6 +++--- create-binary-package.sh | 32 ++++++++++++++++++++++---------- create-source-package.sh | 30 +++++++++++++++++++++--------- test-packaging.sh | 18 ++++++++++-------- 5 files changed, 73 insertions(+), 41 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f36dc1..267b638 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,11 @@ on: description: OpenFastTrace version to package and release required: true type: string - default: 4.9.0 + package_revision: + description: Debian package revision + required: true + default: "1" + type: string jobs: release: @@ -23,6 +27,8 @@ jobs: shell: bash env: VERSION: ${{ inputs.version }} + PACKAGE_REVISION: ${{ inputs.package_revision }} + PACKAGE_VERSION: ${{ inputs.version }}-${{ inputs.package_revision }} steps: - name: Checkout @@ -75,10 +81,10 @@ jobs: EOF - name: Create source package - run: ./create-source-package.sh "$VERSION" + run: ./create-source-package.sh "$VERSION" "$PACKAGE_REVISION" - name: Create binary package - run: ./create-binary-package.sh "$VERSION" + run: ./create-binary-package.sh "$VERSION" "$PACKAGE_REVISION" - name: Generate SHA-256 checksums run: | @@ -86,21 +92,21 @@ jobs: cd out sha256sum \ "openfasttrace_${VERSION}.orig.tar.gz" \ - "openfasttrace_${VERSION}-1.debian.tar.xz" \ - "openfasttrace_${VERSION}-1.dsc" \ - "openfasttrace_${VERSION}-1_all.deb" + "openfasttrace_${PACKAGE_VERSION}.debian.tar.xz" \ + "openfasttrace_${PACKAGE_VERSION}.dsc" \ + "openfasttrace_${PACKAGE_VERSION}_all.deb" ) > out/SHA256SUMS - name: Create GitHub release run: | - gh release create "$VERSION" \ + gh release create "$PACKAGE_VERSION" \ --target main \ - --title "OpenFastTrace Debian package $VERSION" \ + --title "$PACKAGE_VERSION: OpenFastTrace Debian Package" \ --generate-notes \ "out/openfasttrace_${VERSION}.orig.tar.gz" \ - "out/openfasttrace_${VERSION}-1.debian.tar.xz" \ - "out/openfasttrace_${VERSION}-1.dsc" \ - "out/openfasttrace_${VERSION}-1_all.deb" \ + "out/openfasttrace_${PACKAGE_VERSION}.debian.tar.xz" \ + "out/openfasttrace_${PACKAGE_VERSION}.dsc" \ + "out/openfasttrace_${PACKAGE_VERSION}_all.deb" \ out/SHA256SUMS env: GH_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md index 57ea371..680939d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This repository builds Debian packages for [OpenFastTrace](https://github.com/it Pre-built source and binary packages are available from the [GitHub releases](https://github.com/itsallcode/openfasttrace-debian-package/releases). Install the binary package with its Java runtime dependency: ```sh -sudo apt install ./openfasttrace_-1_all.deb +sudo apt install ./openfasttrace_-_all.deb ``` Run OpenFastTrace with: @@ -26,8 +26,8 @@ On Debian or a derived distribution, install the tools listed by the preconditio ```sh ./check-preconditions.sh -./create-source-package.sh -./create-binary-package.sh +./create-source-package.sh [package-revision] +./create-binary-package.sh [package-revision] ``` The resulting artifacts are placed in `out/`. The scripts download the specified OpenFastTrace source release, incorporate this repository's `debian/` packaging metadata, and build the package. diff --git a/create-binary-package.sh b/create-binary-package.sh index 16188c2..9f836b8 100755 --- a/create-binary-package.sh +++ b/create-binary-package.sh @@ -26,16 +26,25 @@ validate_version() { fi } +validate_package_revision() { + local -r package_revision="$1" + if [[ ! "$package_revision" =~ ^[1-9][0-9]*$ ]]; then + echo "Error: Invalid Debian package revision '$package_revision'. Expected a positive integer." >&2 + return 1 + fi +} + # [impl->dsn~build-orchestration-scripts~1] check_source_package_exists() { local -r version="$1" - local -r dsc_file="$BUILD_DIR/openfasttrace_$version-1.dsc" + local -r package_revision="$2" + local -r dsc_file="$BUILD_DIR/openfasttrace_$version-$package_revision.dsc" local -r orig_tarball="$BUILD_DIR/openfasttrace_$version.orig.tar.gz" - local -r debian_tarball="$BUILD_DIR/openfasttrace_$version-1.debian.tar.xz" + local -r debian_tarball="$BUILD_DIR/openfasttrace_$version-$package_revision.debian.tar.xz" if [[ ! -f "$dsc_file" ]]; then echo "Error: Source package control file not found at $dsc_file." >&2 - echo "Please run ./create-source-package.sh $version first." >&2 + echo "Please run ./create-source-package.sh $version $package_revision first." >&2 return 1 fi @@ -48,7 +57,8 @@ check_source_package_exists() { # [impl->dsn~build-orchestration-scripts~1] extract_source_package() { local -r version="$1" - local -r dsc_file="openfasttrace_${version}-1.dsc" + local -r package_revision="$2" + local -r dsc_file="openfasttrace_${version}-${package_revision}.dsc" local -r build_subdir="$BUILD_DIR/openfasttrace-$version" echo "Cleaning up any existing build directory $build_subdir..." @@ -67,23 +77,25 @@ build_binary_package() { # [impl->dsn~build-orchestration-scripts~1] main() { - if [[ $# -ne 1 ]]; then - echo "Usage: $0 " >&2 + if [[ $# -lt 1 || $# -gt 2 ]]; then + echo "Usage: $0 [package-revision]" >&2 exit 1 fi local -r version="$1" + local -r package_revision="${2:-1}" validate_version "$version" + validate_package_revision "$package_revision" verify_preconditions ensure_build_dir - check_source_package_exists "$version" - extract_source_package "$version" + check_source_package_exists "$version" "$package_revision" + extract_source_package "$version" "$package_revision" build_binary_package "$version" echo "" - echo "Binary package for version $version created successfully in $BUILD_DIR." - ls -l "$BUILD_DIR"/openfasttrace_"$version"-1_*.deb + echo "Binary package for version $version-$package_revision created successfully in $BUILD_DIR." + ls -l "$BUILD_DIR"/openfasttrace_"$version"-"$package_revision"_*.deb } main "$@" diff --git a/create-source-package.sh b/create-source-package.sh index 5bddfd5..f9c2269 100755 --- a/create-source-package.sh +++ b/create-source-package.sh @@ -30,6 +30,14 @@ validate_version() { fi } +validate_package_revision() { + local -r package_revision="$1" + if [[ ! "$package_revision" =~ ^[1-9][0-9]*$ ]]; then + echo "Error: Invalid Debian package revision '$package_revision'. Expected a positive integer." >&2 + return 1 + fi +} + # [impl->dsn~source-fetching~1] download_source() { local -r version="$1" @@ -91,8 +99,9 @@ extract_markdown_changes() { # [impl->dsn~changelog-extraction~1] apply_changelog_entries() { local -r version="$1" - local -r entries_file="$2" - local -r debian_version="$version-1" + local -r package_revision="$2" + local -r entries_file="$3" + local -r debian_version="$version-$package_revision" # Check if version already exists in changelog if dpkg-parsechangelog -S Version | grep -q "^$debian_version$"; then @@ -120,6 +129,7 @@ apply_changelog_entries() { # [impl->dsn~changelog-extraction~1] update_changelog() { local -r version="$1" + local -r package_revision="$2" local -r source_dir="$BUILD_DIR/openfasttrace-$version" local -r changes_dir="$source_dir/doc/changes" local -r change_file="$changes_dir/changes_$version.md" @@ -128,19 +138,19 @@ update_changelog() { if [[ ! -d "$changes_dir" ]]; then echo "Warning: No changes directory found in source." >&2 - dch --newversion "$version-1" --distribution unstable --force-distribution "New upstream release $version" + dch --newversion "$version-$package_revision" --distribution unstable --force-distribution "New upstream release $version" return fi if [[ ! -f "$change_file" ]]; then echo "Warning: No change file found for version $version at $change_file" >&2 - dch --newversion "$version-1" --distribution unstable --force-distribution "New upstream release $version" + dch --newversion "$version-$package_revision" --distribution unstable --force-distribution "New upstream release $version" return fi local -r temp_changelog_msg=$(mktemp) extract_markdown_changes "$change_file" "$temp_changelog_msg" - apply_changelog_entries "$version" "$temp_changelog_msg" + apply_changelog_entries "$version" "$package_revision" "$temp_changelog_msg" rm "$temp_changelog_msg" } @@ -170,24 +180,26 @@ cleanup_extraction() { # [impl->dsn~build-orchestration-scripts~1] main() { - if [[ $# -ne 1 ]]; then - echo "Usage: $0 " >&2 + if [[ $# -lt 1 || $# -gt 2 ]]; then + echo "Usage: $0 [package-revision]" >&2 exit 1 fi local -r version="$1" + local -r package_revision="${2:-1}" validate_version "$version" + validate_package_revision "$package_revision" verify_preconditions ensure_build_dir download_source "$version" download_screenshots extract_source "$BUILD_DIR/openfasttrace-$version.tar.gz" "$version" - update_changelog "$version" + update_changelog "$version" "$package_revision" prepare_debian_source "$version" cleanup_extraction "$version" - echo "Source package for version $version created successfully in $BUILD_DIR." + echo "Source package for version $version-$package_revision created successfully in $BUILD_DIR." } main "$@" diff --git a/test-packaging.sh b/test-packaging.sh index 6d06986..89310a6 100755 --- a/test-packaging.sh +++ b/test-packaging.sh @@ -14,10 +14,11 @@ readonly BUILD_DIR="out" # [itest->dsn~user-guide-manpage~1] verify_output_files() { local -r version="$1" + local -r package_revision="$2" local -r expected_files=( "$BUILD_DIR/openfasttrace_$version.orig.tar.gz" - "$BUILD_DIR/openfasttrace_$version-1.dsc" - "$BUILD_DIR/openfasttrace_$version-1.debian.tar.xz" + "$BUILD_DIR/openfasttrace_$version-$package_revision.dsc" + "$BUILD_DIR/openfasttrace_$version-$package_revision.debian.tar.xz" ) echo "Verifying output files..." @@ -30,7 +31,7 @@ verify_output_files() { done local deb_file="" - for f in "$BUILD_DIR"/openfasttrace_"$version"-1_*.deb; do + for f in "$BUILD_DIR"/openfasttrace_"$version"-"$package_revision"_*.deb; do if [[ -e "$f" ]]; then deb_file="$f" break @@ -141,19 +142,20 @@ validate_appstream() { # [itest->dsn~finding-free-shellcheck~1] main() { local -r version="${1:-$DEFAULT_VERSION}" - echo "Starting integration test for version: $version" + local -r package_revision="${2:-1}" + echo "Starting integration test for version: $version-$package_revision" echo "Step 1: Checking preconditions..." ./check-preconditions.sh echo "Step 2: Creating source package..." - ./create-source-package.sh "$version" + ./create-source-package.sh "$version" "$package_revision" echo "Step 3: Creating binary package..." - ./create-binary-package.sh "$version" + ./create-binary-package.sh "$version" "$package_revision" echo "Step 4: Verifying output files..." - verify_output_files "$version" + verify_output_files "$version" "$package_revision" echo "Step 5: Running shellcheck..." run_shellcheck @@ -162,7 +164,7 @@ main() { validate_appstream "$version" echo "" - echo "Integration test for OpenFastTrace version $version COMPLETED SUCCESSFULLY." + echo "Integration test for OpenFastTrace version $version-$package_revision COMPLETED SUCCESSFULLY." } main "$@"