Skip to content

feat(buildkit): add Debian and RPM packaging for BuildKit#218

Merged
gounthar merged 6 commits intomainfrom
feat/buildkit-packaging
Dec 9, 2025
Merged

feat(buildkit): add Debian and RPM packaging for BuildKit#218
gounthar merged 6 commits intomainfrom
feat/buildkit-packaging

Conversation

@gounthar
Copy link
Copy Markdown
Owner

@gounthar gounthar commented Dec 9, 2025

Summary

  • Add Debian packaging infrastructure for BuildKit RISC-V64 binaries
  • Add RPM packaging infrastructure for BuildKit RISC-V64 binaries
  • Add GitHub Actions workflows to automate package creation
  • Add release tracking workflow for automatic builds

Changes

Debian Packaging (debian-buildkit/)

  • control: Package metadata with containerd/docker recommendations
  • rules: Skip build phase (uses pre-built binaries)
  • install: Installs buildkitd and buildctl to /usr/bin
  • changelog, copyright, source/format: Standard Debian files

RPM Packaging (rpm-buildkit/)

  • buildkit.spec: RPM spec installing both binaries to /usr/bin

Workflows

  • build-buildkit-package.yml: Creates .deb package, triggered by weekly build
  • build-buildkit-rpm.yml: Creates .rpm package, triggered by weekly build
  • track-buildkit-releases.yml: Daily check for new BuildKit releases at 08:00 UTC

Features

  • Supports both development builds (buildkit-v20251209-dev) and official releases (buildkit-v0.26.2-riscv64)
  • Automatic version extraction from release tags
  • Skips build if packages already exist in release
  • Package name buildkit aligned with official Debian work at salsa.debian.org
  • Automatic release tracking creates GitHub issues when new versions detected

Test plan

  • Merge PR
  • Manually trigger build-buildkit-package.yml with buildkit-v20251209-dev
  • Manually trigger build-buildkit-rpm.yml with buildkit-v20251209-dev
  • Verify .deb and .rpm packages are uploaded to release
  • Test installation on Debian and Fedora systems
  • Wait for v0.26.2 build (currently running) to complete

Summary by CodeRabbit

  • New Features

    • BuildKit RISC‑V64 packages (Debian .deb and RPM) are now published to releases with post‑install instructions.
  • Chores

    • CI workflows added to build, validate, lint and upload RISC‑V64 packages; release tracking and repo workflows updated to detect and distribute BuildKit packages.
    • Packaging metadata, changelog and install mappings added for Debian and RPM.
    • Release-detection and scheduling logic improved for more accurate builds and status logging.

✏️ Tip: You can customize this high-level summary in your review settings.

Add packaging infrastructure for BuildKit RISC-V64 binaries:

Debian packaging (debian-buildkit/):
- control: Package metadata with containerd/docker recommendations
- rules: Skip build (pre-built binaries)
- install: Install buildkitd and buildctl to /usr/bin
- changelog, copyright, source/format

RPM packaging (rpm-buildkit/):
- buildkit.spec: RPM spec for both binaries

Workflows:
- build-buildkit-package.yml: Triggered by weekly build, creates .deb
- build-buildkit-rpm.yml: Triggered by weekly build, creates .rpm

Both workflows support:
- Development builds (buildkit-v20251209-dev)
- Official releases (buildkit-v0.17.3-riscv64)
- Automatic version extraction from release tags
- Skip if packages already exist

Package name aligned with official Debian packaging work at
salsa.debian.org/go-team/packages/golang-github-moby-buildkit
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 9, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds GitHub Actions workflows and packaging metadata to build, validate, and upload BuildKit .deb and .rpm packages for riscv64: release detection, binary download/validation, version extraction, package assembly (Debian/RPM), lint checks, and idempotent upload to GitHub releases.

Changes

Cohort / File(s) Summary
Workflows — Build & Release
*.github/workflows/*
.github/workflows/build-buildkit-package.yml, .github/workflows/build-buildkit-rpm.yml, .github/workflows/track-buildkit-releases.yml, .github/workflows/update-apt-repo.yml, .github/workflows/update-rpm-repo.yml
New and updated GitHub Actions workflows to detect BuildKit releases, gate on existing artifacts, derive package versions, run packaging pipelines on riscv64 runners, run linting (lintian/rpmlint), and upload artifacts with retry and idempotence logic.
Debian packaging
debian-buildkit/*
debian-buildkit/changelog, debian-buildkit/control, debian-buildkit/copyright, debian-buildkit/install, debian-buildkit/rules, debian-buildkit/source/format
New Debian packaging for buildkit (riscv64): changelog/version, control metadata, copyright/license, install mappings for buildkitd and buildctl, rules that use upstream pre-built binaries (skip build/tests/shlibdeps), and source format.
RPM packaging
rpm-buildkit/buildkit.spec
New RPM spec packaging BuildKit (riscv64): metadata, dependencies, install steps for pre-built buildkitd and buildctl, files listing, and changelog.
Utilities / scripts
.github/scripts/*
.github/scripts/extract-buildkit-version.sh
New helper script to parse BuildKit release tags and output normalized package version strings (supports dev and stable tag formats).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Scheduler as Scheduler / Manual
    participant GH_Actions as GitHub Actions Workflows
    participant Runner as RISC‑V Self‑Hosted Runner
    participant GH_API as GitHub Release API
    participant Release as GitHub Release Assets

    Scheduler->>GH_Actions: trigger (cron or manual with release_tag)
    GH_Actions->>GH_API: query latest stable BuildKit release/tag
    alt no release found
        GH_Actions->>GH_Actions: exit with error
    else release found
        GH_Actions->>GH_API: check if .deb/.rpm assets exist
        alt assets exist
            GH_Actions->>GH_Actions: set already_built -> log & stop
        else assets missing
            GH_Actions->>Runner: dispatch packaging job
            Runner->>GH_API: download upstream binaries (buildkitd, buildctl)
            Runner->>Runner: validate files, check arch
            Runner->>Runner: run extract-buildkit-version.sh -> derive package version
            Runner->>Runner: update changelog/spec, build package (.deb/.rpm)
            Runner->>Runner: run lint checks (lintian / rpmlint)
            Runner->>GH_API: upload built packages (with retries)
            GH_API->>Release: store uploaded assets
            Runner->>GH_Actions: output install instructions/status
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review release-detection and tag-parsing logic across workflows (regex and gh usage).
  • Inspect artifact-existence gating and retry/upload flows in both Debian and RPM workflows.
  • Validate Debian packaging files: control, rules overrides (skipping tests/shlibdeps), install mappings, and changelog.
  • Validate RPM spec for correct file lists, dependencies, and versioning.
  • Review the new version-extraction script for regex correctness and edge cases.

Possibly related PRs

Suggested labels

enhancement, automation

Poem

🐰 I found two bins and a shiny tag to pack,

buildkitd and buildctl, I hop them in my sack.
I lint, I stamp the version neat and small,
then upload to the cloud — CI hears my call.
Hooray, riscv64 packages, bounce and ball! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(buildkit): add Debian and RPM packaging for BuildKit' directly and clearly describes the main changes in the pull request, which centers on adding packaging infrastructure for BuildKit across both Debian and RPM formats.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/buildkit-packaging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @gounthar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances BuildKit's distribution by introducing official Debian and RPM packaging for the RISC-V64 architecture. It establishes the necessary infrastructure and automates the package generation process through GitHub Actions, ensuring consistent and streamlined delivery of BuildKit binaries for this platform.

Highlights

  • Debian Packaging: Introduces Debian packaging infrastructure for BuildKit RISC-V64 binaries, including control, rules, install, changelog, and copyright files.
  • RPM Packaging: Adds RPM packaging infrastructure for BuildKit RISC-V64 binaries, defined by the buildkit.spec file.
  • Automated Workflows: Implements GitHub Actions workflows (build-buildkit-package.yml and build-buildkit-rpm.yml) to automate the creation of both Debian and RPM packages, triggered weekly.
  • Flexible Versioning: Supports both development builds (e.g., buildkit-v20251209-dev) and official releases (e.g., buildkit-v0.17.3-riscv64), with automatic version extraction from release tags.
  • Optimized Build Process: Includes logic to skip package creation if the packages already exist in a release, and utilizes pre-built binaries to streamline the packaging process.
  • Debian Alignment: Aligns the buildkit package name with official Debian work, ensuring consistency with existing packaging efforts.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/build-buildkit-package.yml
    • .github/workflows/build-buildkit-rpm.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Debian and RPM packaging for BuildKit on RISC-V64, using pre-built binaries. The packaging infrastructure for both dpkg and rpm is well-structured. My review focuses on improving the package dependency declarations to be more accurate and avoid redundancy. Specifically, I've suggested changes to the Recommends fields in both the Debian control file and the RPM .spec file to correctly express an 'OR' relationship for runtime dependencies like containerd and docker, rather than the current 'AND' relationship which could be misleading.

Package: buildkit
Architecture: riscv64
Depends: ${shlibs:Depends}, ${misc:Depends}
Recommends: containerd (>= 1.7) | containerd.io (>= 1.7), docker.io (>= 20.10) | docker-ce (>= 20.10)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comma in the Recommends field acts as an 'AND' operator, meaning this package recommends installing both a containerd package and a docker package. This is likely not the intended behavior, as installing Docker typically includes a containerd runtime, making the separate containerd recommendation redundant. To recommend any one of these packages as a suitable runtime, you should use the pipe | symbol to create a single list of alternatives.

Recommends: containerd (>= 1.7) | containerd.io (>= 1.7) | docker.io (>= 20.10) | docker-ce (>= 20.10)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Changed the dependency semantics:

  • Recommends: containerd (>= 1.7) | containerd.io (>= 1.7) - BuildKit requires a container runtime
  • Suggests: docker.io (>= 20.10) | docker-ce (>= 20.10) - Docker is optional, only needed for buildx integration

This correctly expresses that containerd is the required backend, while Docker is an optional enhancement.

Comment on lines +12 to +13
Recommends: containerd
Recommends: docker-ce
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using two separate Recommends tags is equivalent to a logical 'AND', which means the package recommends installing both containerd and docker-ce. This is likely redundant, as docker-ce includes a containerd runtime.

To express an 'OR' relationship, you can use boolean dependencies if your target RPM-based distributions support RPM v4.13+ (e.g., RHEL 8+, Fedora 28+). This would better reflect that either package is a suitable runtime.

If you need to support older systems that don't support boolean dependencies, consider recommending only containerd and listing docker-ce as a Suggests.

Recommends:     (containerd or docker-ce)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Changed the dependency semantics:

  • Recommends: containerd - BuildKit requires a container runtime
  • Suggests: docker-ce and Suggests: moby-engine - Docker is optional

This correctly expresses that containerd is the required backend, while Docker is an optional enhancement.

Automatically detects new BuildKit releases from moby/buildkit daily at 08:00 UTC.
When a new release is found, triggers buildkit-weekly-build.yml and creates
a tracking issue.

Features:
- Filters for stable releases (excludes dockerfile/* and pre-releases)
- Checks if release already built before triggering
- Creates GitHub issue to track build progress
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (7)
debian-buildkit/copyright (1)

7-11: Update copyright years to include 2025.

The copyright years appear outdated. Since we're now in December 2025:

  • Line 7: Upstream copyright should likely be 2017-2025
  • Line 11: Debian packaging copyright should be 2024-2025 or just 2025
 Files: *
-Copyright: 2017-2024 The Moby Authors
+Copyright: 2017-2025 The Moby Authors
 License: Apache-2.0
 
 Files: debian/*
-Copyright: 2024 Bruno Verächten <bruno@verachten.fr>
+Copyright: 2024-2025 Bruno Verächten <bruno@verachten.fr>
 License: Apache-2.0
debian-buildkit/changelog (1)

1-8: Update the changelog date to 2025.

The changelog date shows Dec 2024, but the current date is December 2025. This should likely be updated.

Additionally, including riscv64 in the version string (0.17.3-riscv64-1) is unconventional for Debian packaging—architecture is typically handled by the Architecture field in debian/control. However, if this aligns with the upstream Debian work mentioned in the PR objectives, it may be intentional.

-buildkit (0.17.3-riscv64-1) trixie; urgency=medium
+buildkit (0.17.3-riscv64-1) trixie; urgency=medium

   * Initial RISC-V64 build of BuildKit
   * Built from upstream moby/buildkit repository
   * Native compilation on RISC-V64 hardware
   * Includes buildkitd daemon and buildctl CLI

- -- Bruno Verächten <bruno@verachten.fr>  Mon, 09 Dec 2024 08:00:00 +0000
+ -- Bruno Verächten <bruno@verachten.fr>  Tue, 09 Dec 2025 08:00:00 +0000
rpm-buildkit/buildkit.spec (2)

53-55: Consider including the license file in the package.

The RPM spec doesn't include a %license directive. For compliance best practices, consider adding the Apache-2.0 license file to the package.

 %files
+%license LICENSE
 %{_bindir}/buildkitd
 %{_bindir}/buildctl

This would require providing the LICENSE file as an additional source or extracting it from the upstream repository during the workflow.


58-58: Update changelog date to 2025.

The changelog date shows Dec 09 2024, but the current date is December 2025.

-%changelog
-* Mon Dec 09 2024 Bruno Verachten <bruno@verachten.fr> - 0.17.3-1
+%changelog
+* Tue Dec 09 2025 Bruno Verachten <bruno@verachten.fr> - 0.17.3-1
debian-buildkit/rules (1)

8-14: Consider adding basic validation for pre-built binaries.

While skipping build and test phases is appropriate for pre-built binaries, consider adding a minimal check to verify that the binaries exist and are executable before packaging.

Apply this diff to add basic validation:

 override_dh_auto_build:
 	# Binary provided pre-built from upstream release
+	@test -x buildkitd || { echo "Error: buildkitd not found or not executable"; exit 1; }
+	@test -x buildctl || { echo "Error: buildctl not found or not executable"; exit 1; }
 	@echo "Using pre-built binaries"
 
 override_dh_auto_test:
 	# Skip tests - binaries already tested upstream
+	@./buildkitd --version >/dev/null 2>&1 || echo "Warning: buildkitd version check failed"
+	@./buildctl --version >/dev/null 2>&1 || echo "Warning: buildctl version check failed"
 	@echo "Skipping tests for pre-built binaries"
.github/workflows/build-buildkit-package.yml (2)

81-88: Extract duplicate release detection logic.

The release tag detection logic is duplicated from lines 44-45. This creates maintenance overhead and potential for inconsistency.

Consider storing the release tag in the check step's output and reusing it:

       - name: Check if new release exists
         id: check_release
         env:
           GH_TOKEN: ${{ github.token }}
         run: |
           set -euo pipefail
 
           # Skip check for manual dispatch
           if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
             echo "Manual dispatch - proceeding with build"
             echo "skip=false" >> $GITHUB_OUTPUT
+            echo "release_tag=${{ github.event.inputs.release_tag }}" >> $GITHUB_OUTPUT
             exit 0
           fi
 
           # Find the latest BuildKit release (matches both dev and official releases)
           # gh release list outputs: Title<TAB>Status<TAB>Tag<TAB>Date
           # Match buildkit-v* pattern (dev: buildkit-v20251209-dev, official: buildkit-v0.17.3-riscv64)
           RELEASE_TAG=$(gh release list --repo gounthar/docker-for-riscv64 --limit 20 | \
                         awk -F'\t' '$3 ~ /^buildkit-v/ {print $3; exit}')
 
           if [ -z "$RELEASE_TAG" ]; then
             echo "No BuildKit release found - skipping package build"
             echo "skip=true" >> $GITHUB_OUTPUT
             exit 0
           fi
 
           echo "Found release: $RELEASE_TAG"
+          echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT

Then in the download step:

       - name: Download BuildKit binaries
         if: steps.check_release.outputs.skip != 'true'
         env:
           GH_TOKEN: ${{ github.token }}
         run: |
           set -euo pipefail
-          # Get release tag from workflow_run or manual input
-          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
-            RELEASE_TAG="${{ github.event.inputs.release_tag }}"
-          else
-            # Find the latest buildkit release created by the workflow
-            RELEASE_TAG=$(gh release list --repo gounthar/docker-for-riscv64 --limit 20 | \
-                          awk -F'\t' '$3 ~ /^buildkit-v/ {print $3; exit}')
-          fi
+          RELEASE_TAG="${{ steps.check_release.outputs.release_tag }}"
           echo "Building package for release: $RELEASE_TAG"
           echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV

131-135: Consider parameterizing the Debian distribution.

The distribution "trixie" is hard-coded, which may cause issues if packages need to be built for other Debian versions or Ubuntu releases.

Consider adding a workflow input to specify the distribution:

   workflow_dispatch:
     inputs:
       release_tag:
         description: 'BuildKit release tag'
         required: true
         default: 'buildkit-v20251209-dev'
+      distribution:
+        description: 'Debian distribution (e.g., trixie, bookworm, sid)'
+        required: false
+        default: 'trixie'

Then use it in the dch command:

           cd debian
           dch --check-dirname-level 0 \
               --force-distribution \
               --newversion "${VERSION}-riscv64-1" \
-              --distribution trixie \
+              --distribution "${{ github.event.inputs.distribution || 'trixie' }}" \
               "RISC-V64 prebuilt BuildKit ${VERSION}"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12e04a5 and cd26d9b.

📒 Files selected for processing (9)
  • .github/workflows/build-buildkit-package.yml (1 hunks)
  • .github/workflows/build-buildkit-rpm.yml (1 hunks)
  • debian-buildkit/changelog (1 hunks)
  • debian-buildkit/control (1 hunks)
  • debian-buildkit/copyright (1 hunks)
  • debian-buildkit/install (1 hunks)
  • debian-buildkit/rules (1 hunks)
  • debian-buildkit/source/format (1 hunks)
  • rpm-buildkit/buildkit.spec (1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures

Applied to files:

  • .github/workflows/build-buildkit-package.yml
📚 Learning: 2025-12-09T10:39:18.263Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 211
File: docs/BUILDKIT-IMPLEMENTATION-GUIDE.md:482-482
Timestamp: 2025-12-09T10:39:18.263Z
Learning: Enforce a single Go version across all workflows by setting a minimum Go version of 1.25.3 (Go 1.25.3+). Update all CI workflow configurations (e.g., actions/setup-go) to use this minimum version to maintain consistency and prevent drift.

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-10-31T21:15:53.276Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.

Applied to files:

  • debian-buildkit/control
  • rpm-buildkit/buildkit.spec
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to docker-bake.hcl : Use docker-bake.hcl for orchestrating multi-platform builds with Docker Buildx, specifying how to build images for different architectures

Applied to files:

  • debian-buildkit/control
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to Makefile : Use a Makefile as the central entry point for building, testing, and packaging Docker, with targets for different architectures and platforms

Applied to files:

  • debian-buildkit/rules
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to scripts/**/*.sh : Use shell scripts to automate complex build steps, apply patches, and work around upstream limitations for specific architectures

Applied to files:

  • debian-buildkit/rules
🪛 RuboCop (1.81.7)
rpm-buildkit/buildkit.spec

[fatal] 1-1: unexpected token tCOLON
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Agent
🔇 Additional comments (12)
debian-buildkit/source/format (1)

1-1: LGTM!

The 3.0 (native) source format is appropriate for this packaging approach using pre-built binaries.

debian-buildkit/install (1)

1-2: LGTM!

The install mappings correctly place both BuildKit binaries (buildkitd and buildctl) in /usr/bin/, consistent with the RPM packaging and standard system binary locations.

debian-buildkit/control (2)

1-38: LGTM overall — well-structured control file.

The control file is well-formatted with appropriate metadata, clear package description, and sensible recommendations for containerd and docker. The RISC-V64 targeting is correctly specified.


13-14: No action needed on this file.

The debian-buildkit/rules file explicitly overrides dh_shlibdeps with a comment stating the binaries are statically linked. This means ${shlibs:Depends} correctly resolves to empty, which is the appropriate behavior for statically linked binaries. The control file configuration is correct as-is.

Likely an incorrect or invalid review comment.

rpm-buildkit/buildkit.spec (1)

1-62: LGTM — well-structured RPM spec file.

The spec file correctly handles pre-built binaries with appropriate install commands, permissions, and RPM macros. The static analysis hint about Ruby syntax is a false positive—this is an RPM spec file, not Ruby code.

debian-buildkit/rules (2)

1-6: LGTM! Standard Debian packaging structure.

The shebang, verbose flag, and debhelper invocation follow Debian packaging conventions correctly.


16-18: Verified: binaries are statically linked.

The buildkit binaries are compiled with CGO_ENABLED=0 (as shown in .github/workflows/buildkit-weekly-build.yml line 319), which produces statically linked Go binaries. Skipping dh_shlibdeps is appropriate for this configuration.

.github/workflows/build-buildkit-package.yml (3)

27-63: LGTM! Well-structured release detection logic.

The release detection correctly handles both manual dispatch and automatic triggers, with appropriate idempotency checks to avoid rebuilding packages that already exist.


183-187: LGTM! Good retry logic for upload resilience.

The retry logic with exponential backoff and the --clobber flag appropriately handles transient failures during release uploads.


116-121: Version extraction regex patterns are working correctly.

The patterns have been validated and correctly handle both dev and official release formats. All test cases pass, including edge cases with dates and multi-digit version numbers.

.github/workflows/build-buildkit-rpm.yml (2)

27-64: LGTM! Consistent release detection logic.

The release detection correctly handles both manual dispatch and automatic triggers, matching the Debian workflow's approach.


163-170: LGTM! Appropriate retry logic for upload resilience.

The retry mechanism with --clobber flag correctly handles transient failures, matching the Debian workflow's approach.

Comment on lines +75 to +105
- name: Download BuildKit binaries
if: steps.check_release.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Get release tag from workflow_run or manual input
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
RELEASE_TAG="${{ github.event.inputs.release_tag }}"
else
# Find the latest buildkit release created by the workflow
RELEASE_TAG=$(gh release list --repo gounthar/docker-for-riscv64 --limit 20 | \
awk -F'\t' '$3 ~ /^buildkit-v/ {print $3; exit}')
fi
echo "Building package for release: $RELEASE_TAG"
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV

# Download binaries
gh release download $RELEASE_TAG -p buildkitd -p buildctl
chmod +x buildkitd buildctl

# Verify binary architecture
echo "=== buildkitd ==="
file ./buildkitd || true
./buildkitd --version || echo "Version check skipped"

echo "=== buildctl ==="
file ./buildctl || true
./buildctl --version || echo "Version check skipped"

ls -lh buildkitd buildctl
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add checksum verification for downloaded binaries.

Downloading binaries without verifying checksums or signatures introduces a security risk. If the release is compromised or corrupted, malicious or broken binaries could be packaged.

Consider adding checksum verification:

       - name: Download BuildKit binaries
         if: steps.check_release.outputs.skip != 'true'
         env:
           GH_TOKEN: ${{ github.token }}
         run: |
           set -euo pipefail
           # Get release tag from workflow_run or manual input
           if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
             RELEASE_TAG="${{ github.event.inputs.release_tag }}"
           else
             # Find the latest buildkit release created by the workflow
             RELEASE_TAG=$(gh release list --repo gounthar/docker-for-riscv64 --limit 20 | \
                           awk -F'\t' '$3 ~ /^buildkit-v/ {print $3; exit}')
           fi
           echo "Building package for release: $RELEASE_TAG"
           echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
 
           # Download binaries
           gh release download $RELEASE_TAG -p buildkitd -p buildctl
+          
+          # Download and verify checksums if available
+          if gh release download $RELEASE_TAG -p "checksums.txt" 2>/dev/null; then
+            echo "Verifying checksums..."
+            sha256sum -c checksums.txt --ignore-missing || {
+              echo "Error: Checksum verification failed"
+              exit 1
+            }
+          else
+            echo "Warning: No checksums available for verification"
+          fi
+          
           chmod +x buildkitd buildctl
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Download BuildKit binaries
if: steps.check_release.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Get release tag from workflow_run or manual input
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
RELEASE_TAG="${{ github.event.inputs.release_tag }}"
else
# Find the latest buildkit release created by the workflow
RELEASE_TAG=$(gh release list --repo gounthar/docker-for-riscv64 --limit 20 | \
awk -F'\t' '$3 ~ /^buildkit-v/ {print $3; exit}')
fi
echo "Building package for release: $RELEASE_TAG"
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
# Download binaries
gh release download $RELEASE_TAG -p buildkitd -p buildctl
chmod +x buildkitd buildctl
# Verify binary architecture
echo "=== buildkitd ==="
file ./buildkitd || true
./buildkitd --version || echo "Version check skipped"
echo "=== buildctl ==="
file ./buildctl || true
./buildctl --version || echo "Version check skipped"
ls -lh buildkitd buildctl
- name: Download BuildKit binaries
if: steps.check_release.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
# Get release tag from workflow_run or manual input
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
RELEASE_TAG="${{ github.event.inputs.release_tag }}"
else
# Find the latest buildkit release created by the workflow
RELEASE_TAG=$(gh release list --repo gounthar/docker-for-riscv64 --limit 20 | \
awk -F'\t' '$3 ~ /^buildkit-v/ {print $3; exit}')
fi
echo "Building package for release: $RELEASE_TAG"
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
# Download binaries
gh release download $RELEASE_TAG -p buildkitd -p buildctl
# Download and verify checksums if available
if gh release download $RELEASE_TAG -p "checksums.txt" 2>/dev/null; then
echo "Verifying checksums..."
sha256sum -c checksums.txt --ignore-missing || {
echo "Error: Checksum verification failed"
exit 1
}
else
echo "Warning: No checksums available for verification"
fi
chmod +x buildkitd buildctl
# Verify binary architecture
echo "=== buildkitd ==="
file ./buildkitd || true
./buildkitd --version || echo "Version check skipped"
echo "=== buildctl ==="
file ./buildctl || true
./buildctl --version || echo "Version check skipped"
ls -lh buildkitd buildctl
🤖 Prompt for AI Agents
.github/workflows/build-buildkit-package.yml lines 75-105: the workflow
downloads buildkit binaries without verifying their integrity; update the steps
to fetch the release checksum or signature (from the release assets or a trusted
source) before making the files executable, verify the downloaded artifacts
against that checksum (e.g., sha256sum --check) or verify GPG signatures, and
fail the job if verification fails; ensure the checksum/signature is downloaded
with gh release download or retrieved via gh release view, perform verification
prior to chmod/packaging, and emit clear error messages on mismatch.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Checksum verification is a valid security concern. However, this requires infrastructure changes:

  1. The BuildKit build workflow needs to generate and upload checksums (e.g., SHA256SUMS file)
  2. Then the packaging workflow can verify against those checksums

This will be tracked as a future enhancement after we update the upstream BuildKit build workflow to generate checksum files.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gounthar, that makes sense! You're right that the checksum generation needs to happen in the upstream BuildKit build workflow first before this packaging workflow can verify them. It's a logical dependency.

Would you like me to create a GitHub issue to track this security enhancement? I can document:

  • The need to update the BuildKit build workflow to generate and upload checksums (SHA256SUMS or similar)
  • Then update this packaging workflow (and the RPM one) to verify against those checksums
  • Link back to this PR and discussion for context

Let me know if you'd like me to open that issue, or if you prefer to handle it separately!


🧠 Learnings used
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to docker-bake.hcl : Use docker-bake.hcl for orchestrating multi-platform builds with Docker Buildx, specifying how to build images for different architectures

Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures

Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go ahead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Create GitHub issue for checksum verification enhancement
gh issue create \
  --repo gounthar/docker-for-riscv64 \
  --title "Add checksum verification to BuildKit build and packaging workflows" \
  --body "## Summary

Add checksum generation and verification to BuildKit workflows to improve supply chain security.

## Background

During review of PR #218, a security concern was identified: the BuildKit packaging workflows download binaries without verifying their integrity. This creates a risk if releases are compromised or corrupted.

## Implementation Plan

This enhancement requires two phases:

### Phase 1: Generate checksums in build workflow
- Update the BuildKit build workflow (Weekly BuildKit RISC-V64 Build) to generate checksum files (e.g., \`SHA256SUMS\` or \`checksums.txt\`)
- Upload the checksum file as a release asset alongside the binaries
- Include checksums for: \`buildkitd\`, \`buildctl\`, and any other artifacts

### Phase 2: Verify checksums in packaging workflows
- Update \`.github/workflows/build-buildkit-package.yml\` (Debian packaging) to:
  - Download the checksum file from the release
  - Verify downloaded binaries using \`sha256sum -c\`
  - Fail the workflow if verification fails
- Update \`.github/workflows/build-buildkit-rpm.yml\` (RPM packaging) with the same verification logic

## References

- PR: https://github.com/gounthar/docker-for-riscv64/pull/218
- Discussion: https://github.com/gounthar/docker-for-riscv64/pull/218#discussion_r2602526498
- Requested by: @gounthar

## Priority

Medium - Security enhancement that should be implemented before wider distribution of packages."

Length of output: 57


@gounthar, done! I've created issue #219 to track this security enhancement:

🔗 #219

The issue documents both phases:

  1. Phase 1: Update the BuildKit build workflow to generate and upload checksums
  2. Phase 2: Update the packaging workflows (Debian and RPM) to verify those checksums

The issue includes links back to this PR and discussion for context. You can implement these improvements whenever you're ready to enhance the supply chain security! 🔒


🧠 Learnings used
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to docker-bake.hcl : Use docker-bake.hcl for orchestrating multi-platform builds with Docker Buildx, specifying how to build images for different architectures

Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.

Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures

Comment on lines +88 to +110
- name: Download BuildKit binaries
if: steps.release.outputs.has-new-release == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail

RELEASE_TAG="${{ steps.release.outputs.release-tag }}"
echo "Building package for release: $RELEASE_TAG"

# Clean and download binaries to SOURCES
cd ~/rpmbuild/SOURCES
rm -f buildkitd buildctl
gh release download $RELEASE_TAG -p buildkitd -p buildctl --repo gounthar/docker-for-riscv64

# Validate binaries were downloaded
if [ ! -f buildkitd ] || [ ! -f buildctl ]; then
echo "Error: Failed to download BuildKit binaries from release $RELEASE_TAG"
exit 1
fi

chmod +x buildkitd buildctl
ls -lh
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add checksum verification for downloaded binaries.

Similar to the Debian workflow, downloading binaries without verifying checksums or signatures introduces a security risk.

Apply this diff to add checksum verification:

       - name: Download BuildKit binaries
         if: steps.release.outputs.has-new-release == 'true'
         env:
           GH_TOKEN: ${{ github.token }}
         run: |
           set -euo pipefail
 
           RELEASE_TAG="${{ steps.release.outputs.release-tag }}"
           echo "Building package for release: $RELEASE_TAG"
 
           # Clean and download binaries to SOURCES
           cd ~/rpmbuild/SOURCES
           rm -f buildkitd buildctl
           gh release download $RELEASE_TAG -p buildkitd -p buildctl --repo gounthar/docker-for-riscv64
+          
+          # Download and verify checksums if available
+          if gh release download $RELEASE_TAG -p "checksums.txt" --repo gounthar/docker-for-riscv64 2>/dev/null; then
+            echo "Verifying checksums..."
+            sha256sum -c checksums.txt --ignore-missing || {
+              echo "Error: Checksum verification failed"
+              exit 1
+            }
+          else
+            echo "Warning: No checksums available for verification"
+          fi
 
           # Validate binaries were downloaded
           if [ ! -f buildkitd ] || [ ! -f buildctl ]; then
             echo "Error: Failed to download BuildKit binaries from release $RELEASE_TAG"
             exit 1
           fi
🤖 Prompt for AI Agents
.github/workflows/build-buildkit-rpm.yml lines 88-110: the workflow downloads
buildkitd and buildctl without verifying integrity; add checksum verification by
fetching the release checksum file (or a .sha256 file) for the RELEASE_TAG from
the same repository/release, compute and verify SHA256 (or the provided
algorithm) against the downloaded binaries, fail the job if verification fails,
and only chmod +x and proceed when checksums match; if the release provides a
detached signature, optionally download and verify it with a trusted GPG key
before accepting the checksum file.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Same as the Debian workflow - checksum verification requires the BuildKit build workflow to first generate and upload checksums. Will be tracked as a future enhancement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gounthar, understood! Thank you for planning to track this as a future enhancement. Once the BuildKit build workflow is updated to generate and upload checksums, adding verification to both the Debian and RPM packaging workflows will indeed improve security.


🧠 Learnings used
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.

Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive packaging infrastructure for BuildKit RISC-V64 binaries, enabling distribution through both Debian (.deb) and RPM package formats. The implementation includes complete packaging metadata, build configurations, and automated GitHub Actions workflows that trigger on weekly builds or manual dispatch. The packages install pre-built buildkitd and buildctl binaries to /usr/bin and support both development builds (date-tagged) and official releases (version-tagged).

Key Changes

  • Added Debian packaging infrastructure with standard debian/ directory structure including control files, build rules, and copyright information
  • Added RPM packaging with a complete spec file for building .rpm packages
  • Implemented two GitHub Actions workflows to automate package creation and upload to releases, with intelligent release detection and skip logic

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
rpm-buildkit/buildkit.spec RPM specification file defining package metadata, dependencies, and installation rules for BuildKit binaries
debian-buildkit/source/format Declares Debian source package format as "3.0 (native)"
debian-buildkit/rules Debian build rules that skip compilation and testing for pre-built binaries
debian-buildkit/install Specifies installation paths for buildkitd and buildctl binaries
debian-buildkit/copyright Documents licensing and copyright information for both upstream and packaging
debian-buildkit/control Debian package control file with metadata, dependencies, and package description
debian-buildkit/changelog Debian changelog documenting the initial RISC-V64 build
.github/workflows/build-buildkit-rpm.yml GitHub Actions workflow to build and upload RPM packages
.github/workflows/build-buildkit-package.yml GitHub Actions workflow to build and upload Debian packages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +119 to +120
else
VERSION="$(echo "$RELEASE_TAG" | sed 's/^buildkit-v//; s/-riscv64$//')"
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version extraction logic assumes a specific date format (8 digits) for dev builds. If a dev build tag doesn't match the exact pattern ^buildkit-v([0-9]{8})-dev$, it will fall through to the else branch which may produce unexpected results. Consider adding explicit error handling or validation to ensure VERSION is properly set before use.

Suggested change
else
VERSION="$(echo "$RELEASE_TAG" | sed 's/^buildkit-v//; s/-riscv64$//')"
elif [[ "$RELEASE_TAG" =~ ^buildkit-v[0-9]+\.[0-9]+\.[0-9]+-riscv64$ ]]; then
VERSION="$(echo "$RELEASE_TAG" | sed 's/^buildkit-v//; s/-riscv64$//')"
else
echo "Error: Unrecognized release tag format: $RELEASE_TAG" >&2
exit 1

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Added explicit pattern matching with error handling for unrecognized tag formats:

if [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]{8})-dev$ ]]; then
  VERSION="0.0.${BASH_REMATCH[1]}"
elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)-riscv64$ ]]; then
  VERSION="${BASH_REMATCH[1]}"
elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
  VERSION="${BASH_REMATCH[1]}"
else
  echo "Error: Unrecognized release tag format"
  exit 1
fi

Comment on lines +163 to +171
for rpm in ~/rpmbuild/RPMS/riscv64/buildkit-*.rpm; do
echo "Uploading $(basename $rpm)..."
for i in {1..3}; do
gh release upload "$RELEASE_TAG" "$rpm" --clobber && break
echo "Retry $i..."
sleep 3
done
done

Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry loop attempts 3 retries but doesn't exit with an error if all retries fail. The loop will complete successfully even if the upload fails, potentially causing the workflow to report success when uploads have actually failed. Add explicit error handling after the loop to ensure the step fails if all retries are exhausted.

Suggested change
for rpm in ~/rpmbuild/RPMS/riscv64/buildkit-*.rpm; do
echo "Uploading $(basename $rpm)..."
for i in {1..3}; do
gh release upload "$RELEASE_TAG" "$rpm" --clobber && break
echo "Retry $i..."
sleep 3
done
done
UPLOAD_FAILED=0
for rpm in ~/rpmbuild/RPMS/riscv64/buildkit-*.rpm; do
echo "Uploading $(basename $rpm)..."
UPLOAD_SUCCESS=0
for i in {1..3}; do
if gh release upload "$RELEASE_TAG" "$rpm" --clobber; then
UPLOAD_SUCCESS=1
break
fi
echo "Retry $i..."
sleep 3
done
if [ "$UPLOAD_SUCCESS" -ne 1 ]; then
echo "Failed to upload $(basename $rpm) after 3 attempts."
UPLOAD_FAILED=1
fi
done
if [ "$UPLOAD_FAILED" -ne 0 ]; then
echo "One or more RPM uploads failed. Exiting with error."
exit 1
fi

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Added proper retry loop error handling with UPLOAD_FAILED flag that causes the step to fail if all retries are exhausted:

UPLOAD_FAILED=0
for rpm in ~/rpmbuild/RPMS/riscv64/buildkit-*.rpm; do
  UPLOAD_SUCCESS=0
  for i in {1..3}; do
    if gh release upload "$RELEASE_TAG" "$rpm" --clobber; then
      UPLOAD_SUCCESS=1
      break
    fi
  done
  if [ "$UPLOAD_SUCCESS" -eq 0 ]; then
    UPLOAD_FAILED=1
  fi
done
if [ "$UPLOAD_FAILED" -eq 1 ]; then
  exit 1
fi

Comment on lines +183 to +187
for i in {1..3}; do
gh release upload "$RELEASE_TAG" "$deb" --clobber && break
echo "Retry $i..."
sleep 3
done
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry loop attempts 3 retries but doesn't exit with an error if all retries fail. The loop will complete successfully even if the upload fails, potentially causing the workflow to report success when uploads have actually failed. Add explicit error handling after the loop to ensure the step fails if all retries are exhausted.

Suggested change
for i in {1..3}; do
gh release upload "$RELEASE_TAG" "$deb" --clobber && break
echo "Retry $i..."
sleep 3
done
success=0
for i in {1..3}; do
if gh release upload "$RELEASE_TAG" "$deb" --clobber; then
success=1
break
fi
echo "Retry $i..."
sleep 3
done
if [ "$success" -ne 1 ]; then
echo "Error: Failed to upload $(basename $deb) after 3 attempts."
exit 1
fi

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Same fix applied - added UPLOAD_FAILED flag to properly track and report failures after all retries are exhausted.

License: Apache-2.0

Files: debian/*
Copyright: 2024 Bruno Verächten <bruno@verachten.fr>
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an inconsistency in the spelling of the name. In the copyright file, it's "Bruno Verächten" (with umlaut ä), while in other files (control, changelog, RPM spec) it's "Bruno Verächten" or "Bruno Verachten". The name should be consistently spelled across all files.

Suggested change
Copyright: 2024 Bruno Verächten <bruno@verachten.fr>
Copyright: 2024 Bruno Verachten <bruno@verachten.fr>

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. The maintainer name spelling should be consistent across all packaging files. Will standardize in a follow-up commit.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. The name spelling inconsistency between files is a minor issue. Both spellings are correct (with/without umlaut). Will consider standardizing.

Source: buildkit
Section: devel
Priority: optional
Maintainer: Bruno Verächten <bruno@verachten.fr>
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an inconsistency in the spelling of the name. In the control file, it's "Bruno Verächten" (with umlaut ä), while in the RPM spec it's "Bruno Verachten" (without umlaut). The name should be consistently spelled across all packaging files.

Suggested change
Maintainer: Bruno Verächten <bruno@verachten.fr>
Maintainer: Bruno Verachten <bruno@verachten.fr>

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Will standardize the maintainer name spelling across all packaging files in a follow-up commit.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Same as the copyright file - both spellings are acceptable. Will consider standardizing.

Comment on lines +101 to +109
gh release download $RELEASE_TAG -p buildkitd -p buildctl --repo gounthar/docker-for-riscv64

# Validate binaries were downloaded
if [ ! -f buildkitd ] || [ ! -f buildctl ]; then
echo "Error: Failed to download BuildKit binaries from release $RELEASE_TAG"
exit 1
fi

chmod +x buildkitd buildctl
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binaries are downloaded and made executable without any checksum verification. This poses a security risk as the binaries could be tampered with. Consider adding checksum validation after download to ensure binary integrity, especially since these are pre-built binaries being packaged for distribution.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Same as the Debian workflow - checksum verification requires infrastructure changes. Tracked for future implementation.

Comment on lines +128 to +129
else
VERSION=$(echo $RELEASE_TAG | sed 's/^buildkit-v//; s/-riscv64$//')
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version extraction logic assumes a specific date format (8 digits) for dev builds. If a dev build tag doesn't match the exact pattern ^buildkit-v([0-9]{8})-dev$, it will fall through to the else branch which may produce unexpected results. Consider adding explicit error handling or validation to ensure VERSION is properly set before use.

Suggested change
else
VERSION=$(echo $RELEASE_TAG | sed 's/^buildkit-v//; s/-riscv64$//')
elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)-riscv64$ ]]; then
VERSION=$(echo $RELEASE_TAG | sed 's/^buildkit-v//; s/-riscv64$//')
else
echo "Error: RELEASE_TAG '$RELEASE_TAG' does not match expected patterns for dev or official builds."
exit 1

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Same fix applied to RPM workflow - added explicit pattern matching with error handling for all supported tag formats.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Added explicit pattern matching with error handling for unrecognized tag formats. The version extraction is validated before use.

echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV

# Download binaries
gh release download $RELEASE_TAG -p buildkitd -p buildctl
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The download command doesn't specify the --repo parameter. While this might work if run from within the repository checkout, it's more explicit and safer to always specify --repo gounthar/docker-for-riscv64 as done in the RPM workflow (line 101). This ensures the command works correctly regardless of the repository context.

Suggested change
gh release download $RELEASE_TAG -p buildkitd -p buildctl
gh release download $RELEASE_TAG --repo gounthar/docker-for-riscv64 -p buildkitd -p buildctl

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 2a22afc. Added explicit --repo gounthar/docker-for-riscv64 parameter to all gh release commands.

fi

# Find the latest BuildKit release (matches both dev and official releases)
# gh release list outputs: Title<TAB>Status<TAB>Tag<TAB>Date
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment describes the output format of gh release list but the actual format in the command doesn't match exactly. The comment states "TitleStatusTagDate" but the default output format is slightly different. While the awk command will work correctly, the comment could cause confusion. Consider updating the comment to match the actual output format or being more general.

Suggested change
# gh release list outputs: Title<TAB>Status<TAB>Tag<TAB>Date
# gh release list outputs tab-separated columns; we select the Tag column (3rd column)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Minor documentation improvement - the comment describes the format accurately for the awk command that follows. Will consider updating for clarity.

fi

# Find the latest BuildKit release (matches both dev and official releases)
# gh release list outputs: Title<TAB>Status<TAB>Tag<TAB>Date
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment describes the output format of gh release list but the actual format in the command doesn't match exactly. The comment states "TitleStatusTagDate" but the default output format is slightly different. While the awk command will work correctly, the comment could cause confusion. Consider updating the comment to match the actual output format or being more general.

Suggested change
# gh release list outputs: Title<TAB>Status<TAB>Tag<TAB>Date
# gh release list outputs multiple columns separated by tabs; the third column is the tag

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. Minor documentation improvement - the comment describes the format accurately for the awk command that follows. Will consider updating for clarity.

gounthar and others added 2 commits December 9, 2025 14:00
Update repository update workflows to include BuildKit packages:

APT Repository (update-apt-repo.yml):
- Add 'Build BuildKit Debian Package' workflow trigger
- Add buildkit-v* pattern to release detection regex
- Add BuildKit release detection and package download
- Add buildkit to cleanup patterns
- Add buildkit package type handling in commit logic

RPM Repository (update-rpm-repo.yml):
- Add 'Build BuildKit RPM Package' workflow trigger
- Add buildkit-v pattern to release detection regex

This ensures BuildKit packages are automatically added to the
APT and RPM repositories when new BuildKit releases are built.
Changes based on automated code review feedback:

Workflow improvements:
- Add proper retry loop error handling (fail if all retries exhausted)
- Add explicit --repo parameter to gh release commands
- Add binary architecture validation (RISC-V64 check)
- Add static/dynamic linking verification
- Add version extraction error handling for edge cases
- Fix variable quoting in shell scripts
- Improve gh CLI installation error handling

Packaging fixes:
- Fix Recommends/Suggests semantics in Debian control:
  - containerd is Recommended (required runtime backend)
  - Docker is Suggested (optional, for buildx integration)
- Fix Recommends/Suggests semantics in RPM spec:
  - containerd is Recommended
  - docker-ce and moby-engine are Suggested

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/update-apt-repo.yml (1)

3-3: Fix workflow lint warnings (truthy on, long line, trailing spaces)

The Lint Workflows job is currently failing on this file:

  • Line 3: on: is parsed as a truthy scalar by the generic YAML linter. Quoting the key (e.g. 'on':) will satisfy the linter while remaining valid for GitHub Actions.
  • Line 189: the for pattern in ... line exceeds the 120‑character limit; break the list over multiple lines or use an array variable to shorten it.
  • Line 316: there are trailing spaces in the PACKAGE_LIST/COMMIT_MSG area; trim them to clear the error.

Addressing these will get the workflow lint job green again.

Also applies to: 189-189, 315-325

♻️ Duplicate comments (4)
debian-buildkit/control (1)

4-4: Align maintainer spelling across Debian and RPM metadata

The control file uses Bruno Verächten while rpm-buildkit/buildkit.spec uses Bruno Verachten. It would be better to standardize on one spelling (with or without the umlaut) across all packaging files to avoid inconsistent metadata.

.github/workflows/build-buildkit-rpm.yml (2)

153-185: Consider de-duplicating BuildKit version extraction logic

The tag → version extraction block here is effectively the same as in build-buildkit-package.yml. Pulling this into a small shared script/composite action (e.g. .github/scripts/extract-buildkit-version.sh) would reduce maintenance overhead and keep Debian/RPM packaging behavior in sync as tag formats evolve.


88-147: Verify integrity of downloaded BuildKit binaries before packaging

As in the Debian workflow, buildkitd and buildctl are downloaded and then executed/packaged without any checksum or signature verification. This is a security and reliability risk if the release assets are ever corrupted or tampered with.

Add checksum and/or signature verification (e.g., download a checksum file from the same release and run sha256sum -c, or verify a signed checksum file) before chmod +x and proceeding with RPM build, and fail the job on mismatch.

.github/workflows/build-buildkit-package.yml (1)

80-113: Add checksum or signature verification for downloaded BuildKit binaries

buildkitd and buildctl are downloaded and executed/packaged without any integrity check. If the release assets are ever corrupted or tampered with, this workflow would blindly ship compromised binaries.

Please add checksum and/or signature verification before chmod +x and packaging (e.g., download a SHA256SUMS/checksums.txt asset and run sha256sum -c, or verify a signed checksum file with a trusted GPG key), and fail the job on mismatch.

🧹 Nitpick comments (1)
rpm-buildkit/buildkit.spec (1)

10-16: Consider whether container runtime should be a hard requirement

Right now containerd is only a Recommends. If BuildKit on these hosts is not really usable without a local container runtime, you may want to promote this to Requires (and keep Docker flavors as Suggests) so that a working runtime is installed by default.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd26d9b and 2a22afc.

📒 Files selected for processing (7)
  • .github/workflows/build-buildkit-package.yml (1 hunks)
  • .github/workflows/build-buildkit-rpm.yml (1 hunks)
  • .github/workflows/track-buildkit-releases.yml (4 hunks)
  • .github/workflows/update-apt-repo.yml (7 hunks)
  • .github/workflows/update-rpm-repo.yml (2 hunks)
  • debian-buildkit/control (1 hunks)
  • rpm-buildkit/buildkit.spec (1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to scripts/**/*.sh : Use shell scripts to automate complex build steps, apply patches, and work around upstream limitations for specific architectures

Applied to files:

  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-12-09T10:39:18.263Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 211
File: docs/BUILDKIT-IMPLEMENTATION-GUIDE.md:482-482
Timestamp: 2025-12-09T10:39:18.263Z
Learning: Enforce a single Go version across all workflows by setting a minimum Go version of 1.25.3 (Go 1.25.3+). Update all CI workflow configurations (e.g., actions/setup-go) to use this minimum version to maintain consistency and prevent drift.

Applied to files:

  • .github/workflows/build-buildkit-rpm.yml
  • .github/workflows/update-apt-repo.yml
  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/track-buildkit-releases.yml
  • .github/workflows/update-rpm-repo.yml
📚 Learning: 2025-10-19T20:52:41.872Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-19T20:52:41.872Z
Learning: In Debian packaging, use `Conflicts+Replaces+Breaks` (without version constraints) when two separate, competing packages provide the same files and cannot coexist at any version. This is distinct from package transitions/renames, which use `Breaks+Replaces` without `Conflicts`.

Applied to files:

  • rpm-buildkit/buildkit.spec
  • debian-buildkit/control
📚 Learning: 2025-10-19T20:52:41.872Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-19T20:52:41.872Z
Learning: When fixing file conflicts in Debian packages, if the conflicting package is from Debian's official repositories with a version higher than previous constraints (e.g., docker-compose 2.26.1 vs constraint `<< 2.0`), remove version constraints to ensure the conflict declaration is effective.

Applied to files:

  • rpm-buildkit/buildkit.spec
  • debian-buildkit/control
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures

Applied to files:

  • .github/workflows/update-apt-repo.yml
  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/track-buildkit-releases.yml
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to docker-bake.hcl : Use docker-bake.hcl for orchestrating multi-platform builds with Docker Buildx, specifying how to build images for different architectures

Applied to files:

  • .github/workflows/update-apt-repo.yml
  • debian-buildkit/control
📚 Learning: 2025-10-31T21:15:53.276Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.

Applied to files:

  • debian-buildkit/control
🪛 GitHub Actions: Lint Workflows
.github/workflows/update-apt-repo.yml

[warning] 3-3: truthy value should be one of [false, no, true, yes]


[warning] 189-189: line too long (124 > 120 characters)


[error] 316-316: trailing spaces

🪛 GitHub Check: Lint YAML Files
.github/workflows/update-apt-repo.yml

[warning] 189-189:
189:121 [line-length] line too long (124 > 120 characters)

🪛 RuboCop (1.81.7)
rpm-buildkit/buildkit.spec

[fatal] 1-1: unexpected token tCOLON
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)

(Lint/Syntax)

🔇 Additional comments (3)
.github/workflows/update-rpm-repo.yml (1)

5-6: BuildKit RPM workflow integration looks consistent

The added workflow name matches the new Build BuildKit RPM Package workflow, and the updated regex correctly includes buildkit-v* tags in the search for RPM‑bearing releases without altering existing behavior.

Also applies to: 54-56

.github/workflows/update-apt-repo.yml (1)

50-71: BuildKit APT integration is consistent with existing package flows

The added detection of buildkit-v* tags, download of buildkit_*.deb, cleanup pattern update, and PACKAGE_TYPE=buildkit handling all mirror the existing patterns for buildx/cli/compose/cagent and should slot cleanly into the existing APT repo update logic.

Also applies to: 131-138, 179-185, 189-193, 295-303

.github/workflows/track-buildkit-releases.yml (1)

5-7: Release tracking logic and messaging look solid

The switch to gh release list for latest vX.Y.Z detection (with pre-release filtering), the explicit guard when no release is found, and the clearer tracking‑issue text (expected tag and artifacts) plus the “already built” logging step together make the BuildKit release flow safer and more observable. No issues from my side.

Also applies to: 25-37, 40-42, 69-93, 102-107

Add `set -euo pipefail` and explicit package verification to prevent
silent failures in build steps. If dpkg-buildpackage or rpmbuild fails
but leaves partial artifacts, the step will now correctly fail.

Addresses CodeRabbit review comment on error handling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
.github/workflows/build-buildkit-rpm.yml (2)

153-184: Extract version extraction logic to a reusable script (duplicate concern from past review).

The version extraction at lines 161–173 duplicates the exact logic from the Debian workflow, creating maintenance overhead.

Use the shared .github/scripts/extract-buildkit-version.sh script suggested in the Debian workflow review:

       - name: Update package version
         if: steps.release.outputs.has-new-release == 'true'
         env:
           RELEASE_TAG: ${{ steps.release.outputs.release-tag }}
         run: |
-          # Extract version from tag
-          # Dev build: buildkit-v20251209-dev -> 0.0.20251209
-          # Official: buildkit-v0.26.2-riscv64 -> 0.26.2
-          if [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]{8})-dev$ ]]; then
-            DATE_VER="${BASH_REMATCH[1]}"
-            VERSION="0.0.${DATE_VER}"
-          elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)-riscv64$ ]]; then
-            VERSION="${BASH_REMATCH[1]}"
-          elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
-            # Handle case without -riscv64 suffix
-            VERSION="${BASH_REMATCH[1]}"
-          else
-            echo "Error: Unrecognized release tag format: $RELEASE_TAG"
-            echo "Expected formats: buildkit-vYYYYMMDD-dev, buildkit-vX.Y.Z-riscv64, or buildkit-vX.Y.Z"
-            exit 1
-          fi
-
-          # Validate version is not empty
-          if [ -z "$VERSION" ]; then
-            echo "Error: Failed to extract version from tag: $RELEASE_TAG"
-            exit 1
-          fi
+          VERSION=$(bash .github/scripts/extract-buildkit-version.sh "$RELEASE_TAG")

This centralizes logic and reduces inconsistency risk.


88-146: ⚠️ Add checksum verification for downloaded binaries (duplicate of past review).

Same critical security gap as the Debian workflow: binaries are downloaded without integrity verification.

Apply checksum verification (if available in BuildKit releases):

           # Clean and download binaries to SOURCES
           cd ~/rpmbuild/SOURCES
           rm -f buildkitd buildctl
           gh release download "$RELEASE_TAG" -p buildkitd -p buildctl --repo gounthar/docker-for-riscv64

+          # Download and verify checksums
+          if gh release download "$RELEASE_TAG" -p "SHA256SUMS" --repo gounthar/docker-for-riscv64 2>/dev/null; then
+            echo "Verifying checksums..."
+            sha256sum -c SHA256SUMS --ignore-missing || {
+              echo "Error: Checksum verification failed for BuildKit binaries"
+              exit 1
+            }
+          else
+            echo "Warning: No checksums file available for verification"
+          fi
+
           # Validate binaries were downloaded
           if [ ! -f buildkitd ] || [ ! -f buildctl ]; then
             echo "Error: Failed to download BuildKit binaries from release $RELEASE_TAG"
             exit 1
           fi

Coordinate with the BuildKit upstream release process to ensure checksums are available.

.github/workflows/build-buildkit-package.yml (1)

80-145: ⚠️ Add checksum verification for downloaded binaries (duplicate of past review).

Binaries are downloaded without integrity verification. If the release is compromised or corrupted, malicious or broken binaries could be packaged. This is a critical security gap flagged in previous reviews.

Verify the downloaded binaries by adding checksum validation. If BuildKit releases provide a checksums file:

           # Download binaries with explicit repo parameter
           gh release download "$RELEASE_TAG" -p buildkitd -p buildctl --repo gounthar/docker-for-riscv64

+          # Download and verify checksums
+          if gh release download "$RELEASE_TAG" -p "SHA256SUMS" --repo gounthar/docker-for-riscv64 2>/dev/null; then
+            echo "Verifying checksums..."
+            sha256sum -c SHA256SUMS --ignore-missing || {
+              echo "Error: Checksum verification failed for BuildKit binaries"
+              exit 1
+            }
+          else
+            echo "Warning: No checksums file available for verification"
+          fi
+
           # Validate binaries were downloaded
           if [ ! -f buildkitd ] || [ ! -f buildctl ]; then
             echo "Error: Failed to download BuildKit binaries from release $RELEASE_TAG"
             exit 1
           fi

           chmod +x buildkitd buildctl

Investigate whether BuildKit upstream provides published checksums or GPG-signed releases, and prefer signature verification over basic checksums if available.

🧹 Nitpick comments (2)
.github/workflows/build-buildkit-package.yml (2)

65-78: Improve gh CLI availability check for better diagnostics.

The conditional installation at lines 74–77 suppresses the error and continues with an assumption that gh is available. While reasonable on GitHub-hosted runners, this could mask missing dependencies if run on runners where gh is not pre-installed.

Consider either:

  1. Enforce that gh must be available (fail fast if not):
          if ! command -v gh >/dev/null 2>&1; then
-           echo "gh CLI not found, attempting to install..."
-           if ! sudo apt-get install -y gh; then
-             echo "Warning: Failed to install gh CLI via apt, but it may be available via other means"
-             echo "Continuing as gh is likely pre-installed on the runner"
-           fi
+           if ! sudo apt-get install -y gh; then
+             echo "Error: gh CLI is required but installation failed"
+             exit 1
+           fi
          fi
  1. Or verify gh is actually available after the attempted install:
+           if ! command -v gh >/dev/null 2>&1; then
+             echo "Error: gh CLI is not available and installation failed"
+             exit 1
+           fi

147-190: Extract version extraction logic to a reusable script (duplicate concern from past review).

The version extraction at lines 156–174 is identical to the RPM workflow (lines 161–173 in build-buildkit-rpm.yml). This duplication creates maintenance overhead and inconsistency risk.

Create a reusable script .github/scripts/extract-buildkit-version.sh:

#!/bin/bash
# Extract version from BuildKit release tag
# Usage: extract-buildkit-version.sh <release_tag>
# Output: Prints extracted version to stdout

set -euo pipefail

RELEASE_TAG="$1"

# Dev build: buildkit-v20251209-dev -> 0.0.20251209
# Official: buildkit-v0.17.3-riscv64 -> 0.17.3
if [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]{8})-dev$ ]]; then
  DATE_VER="${BASH_REMATCH[1]}"
  echo "0.0.${DATE_VER}"
elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)-riscv64$ ]]; then
  echo "${BASH_REMATCH[1]}"
elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
  echo "${BASH_REMATCH[1]}"
else
  echo "Error: Unrecognized release tag format: $RELEASE_TAG" >&2
  echo "Expected formats: buildkit-vYYYYMMDD-dev, buildkit-vX.Y.Z-riscv64, or buildkit-vX.Y.Z" >&2
  exit 1
fi

Then replace lines 156–174 with:

-          # Extract version from tag
-          # Dev build: buildkit-v20251209-dev -> 0.0.20251209
-          # Official: buildkit-v0.26.2-riscv64 -> 0.26.2
-          if [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]{8})-dev$ ]]; then
-            DATE_VER="${BASH_REMATCH[1]}"
-            VERSION="0.0.${DATE_VER}"
-          elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)-riscv64$ ]]; then
-            VERSION="${BASH_REMATCH[1]}"
-          elif [[ "$RELEASE_TAG" =~ ^buildkit-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
-            # Handle case without -riscv64 suffix
-            VERSION="${BASH_REMATCH[1]}"
-          else
-            echo "Error: Unrecognized release tag format: $RELEASE_TAG"
-            echo "Expected formats: buildkit-vYYYYMMDD-dev, buildkit-vX.Y.Z-riscv64, or buildkit-vX.Y.Z"
-            exit 1
-          fi
-
-          # Validate version is not empty
-          if [ -z "$VERSION" ]; then
-            echo "Error: Failed to extract version from tag: $RELEASE_TAG"
-            exit 1
-          fi
+          VERSION=$(bash .github/scripts/extract-buildkit-version.sh "$RELEASE_TAG")

This centralizes the logic for both Debian and RPM workflows, reducing duplication and maintenance risk.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a22afc and 16169be.

📒 Files selected for processing (2)
  • .github/workflows/build-buildkit-package.yml (1 hunks)
  • .github/workflows/build-buildkit-rpm.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to scripts/**/*.sh : Use shell scripts to automate complex build steps, apply patches, and work around upstream limitations for specific architectures

Applied to files:

  • .github/workflows/build-buildkit-rpm.yml
  • .github/workflows/build-buildkit-package.yml
📚 Learning: 2025-12-09T10:39:18.263Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 211
File: docs/BUILDKIT-IMPLEMENTATION-GUIDE.md:482-482
Timestamp: 2025-12-09T10:39:18.263Z
Learning: Enforce a single Go version across all workflows by setting a minimum Go version of 1.25.3 (Go 1.25.3+). Update all CI workflow configurations (e.g., actions/setup-go) to use this minimum version to maintain consistency and prevent drift.

Applied to files:

  • .github/workflows/build-buildkit-rpm.yml
  • .github/workflows/build-buildkit-package.yml
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures

Applied to files:

  • .github/workflows/build-buildkit-package.yml
🔇 Additional comments (12)
.github/workflows/build-buildkit-package.yml (5)

1-22: ✓ Workflow configuration is sound.

The trigger setup, permissions, and runner configuration are appropriate for the Debian packaging workflow.


27-63: ✓ Release detection and idempotence check is solid.

The logic properly skips builds when packages already exist and handles manual dispatch appropriately.


192-205: ✓ Build step has proper error handling.

The set -euo pipefail and verification of .deb creation prevent masked failures.


207-229: ✓ Linting and diagnostics are appropriately configured.

The || true on lintian allows warnings without failing, and package info provides useful output.


231-275: ✓ Upload step has robust error handling and retry logic.

The UPLOAD_FAILED flag and explicit error exit ensure the job fails if uploads don't succeed after retries.

.github/workflows/build-buildkit-rpm.yml (7)

1-22: ✓ Workflow setup is sound.

Configuration appropriately mirrors the Debian packaging workflow.


27-64: ✓ Release detection and idempotence check is solid.

The logic properly gates the build based on existing RPM assets.


66-86: ✓ Dependency and build tree setup is well-structured.

Platform detection for Fedora/Debian and the rpmdev-setuptree fallback are good practices.


148-151: ✓ Spec file copy is correct.


186-201: ✓ RPM build step has robust error handling.

The verification and strict shell semantics prevent masked failures.


203-206: ✓ RPM linting is appropriately configured.


208-254: ✓ Upload step has proper error handling and retry logic.

The UPLOAD_FAILED flag and explicit error exit ensure failures are properly reported.

- Create .github/scripts/extract-buildkit-version.sh for DRY version extraction
- Update both Debian and RPM workflows to use the shared script
- Improve gh CLI availability check with fail-fast error handling
- Add verification that gh is actually available after installation

Addresses CodeRabbit review suggestions for code deduplication
and better error diagnostics.
@gounthar
Copy link
Copy Markdown
Owner Author

gounthar commented Dec 9, 2025

Addressed in commit 0def98f:

  • Created shared script .github/scripts/extract-buildkit-version.sh for DRY version extraction
  • Updated both Debian and RPM workflows to use the shared script
  • Improved gh CLI availability check with fail-fast error handling
  • Added verification that gh is actually available after installation attempt

Checksum verification remains tracked for future work as it requires infrastructure changes (publishing checksums with BuildKit releases).

@gounthar gounthar merged commit 3d428cf into main Dec 9, 2025
3 of 4 checks passed
@gounthar gounthar deleted the feat/buildkit-packaging branch December 9, 2025 14:34
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/build-buildkit-rpm.yml (1)

66-74: Consider adding gh CLI availability verification for consistency with Debian workflow.

The Debian workflow (lines 72-83 of build-buildkit-package.yml) explicitly checks for gh CLI availability and installs it if missing, with fail-fast error handling. The RPM workflow lacks this verification, even though it requires gh for binary downloads at line 107. While GitHub Actions runners typically have gh pre-installed, self-hosted runners may not. For robustness and consistency, consider adding similar gh CLI verification to the RPM workflow:

       - name: Install build dependencies
         if: steps.release.outputs.has-new-release == 'true'
         run: |
           if [ -f /etc/fedora-release ]; then
             sudo dnf install -y rpm-build rpmdevtools rpmlint
           elif [ -f /etc/debian_version ]; then
             sudo apt-get update
             sudo apt-get install -y rpm rpmlint
           fi
+          # Verify gh CLI is available (required for binary downloads)
+          if ! command -v gh >/dev/null 2>&1; then
+            echo "Error: gh CLI is required but not found"
+            exit 1
+          fi
+          echo "gh CLI version: $(gh --version | head -1)"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16169be and 0def98f.

📒 Files selected for processing (3)
  • .github/scripts/extract-buildkit-version.sh (1 hunks)
  • .github/workflows/build-buildkit-package.yml (1 hunks)
  • .github/workflows/build-buildkit-rpm.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (13)
📓 Common learnings
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Extend CI/CD configuration to build, test, and publish images for newly supported architectures

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to scripts/**/*.sh : Use shell scripts to automate complex build steps, apply patches, and work around upstream limitations for specific architectures

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/scripts/extract-buildkit-version.sh
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-10-19T20:52:41.872Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-19T20:52:41.872Z
Learning: When fixing file conflicts in Debian packages, if the conflicting package is from Debian's official repositories with a version higher than previous constraints (e.g., docker-compose 2.26.1 vs constraint `<< 2.0`), remove version constraints to ensure the conflict declaration is effective.

Applied to files:

  • .github/workflows/build-buildkit-package.yml
📚 Learning: 2025-10-31T21:15:53.276Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 0
File: :0-0
Timestamp: 2025-10-31T21:15:53.276Z
Learning: For the docker-for-riscv64 repository, Gentoo packaging support is being implemented in phases: Phase 1 focuses on infrastructure (overlay structure, Docker ebuild, UpdateCLI automation, documentation), with additional packages (containerd, runc, docker-cli, docker-compose, tini) planned for follow-up PRs.

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to docker-bake.hcl : Use docker-bake.hcl for orchestrating multi-platform builds with Docker Buildx, specifying how to build images for different architectures

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-10-31T21:28:15.016Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 65
File: gentoo-overlay/app-containers/docker/files/docker.confd:1-1
Timestamp: 2025-10-31T21:28:15.016Z
Learning: In the docker-for-riscv64 repository, files in the gentoo-overlay/ directory are auto-generated by the generate-gentoo-overlay.sh script and should not be manually edited. The correct workflow for fixing issues in generated overlay files is: 1) Fix the upstream source files in upstream-gentoo-ebuilds/app-containers/docker/files/, 2) Re-run generate-gentoo-overlay.sh, 3) The overlay files will be automatically regenerated with the corrected content.

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-10-31T21:28:12.067Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 65
File: gentoo-overlay/app-containers/docker/files/docker.initd:1-1
Timestamp: 2025-10-31T21:28:12.067Z
Learning: In the docker-for-riscv64 repository, files in gentoo-overlay/ are auto-generated by generate-gentoo-overlay.sh from upstream sources in upstream-gentoo-ebuilds/. Any issues in generated files should be fixed in the upstream sources, then the generator script should be re-run to regenerate the overlay files.

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: When adding support for a new architecture, update docker-bake.hcl to define build groups and platforms for the new architecture

Applied to files:

  • .github/workflows/build-buildkit-package.yml
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: Applies to Dockerfile* : Create architecture-specific Dockerfiles tailored for each platform or use case (e.g., Dockerfile.riscv for RISC-V, Dockerfile.windows for Windows)

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-12-02T08:41:41.360Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/01_architecture.md:0-0
Timestamp: 2025-12-02T08:41:41.360Z
Learning: When adding support for a new architecture, create or patch Dockerfiles specific to that architecture

Applied to files:

  • .github/workflows/build-buildkit-package.yml
📚 Learning: 2025-12-09T10:39:18.263Z
Learnt from: gounthar
Repo: gounthar/docker-for-riscv64 PR: 211
File: docs/BUILDKIT-IMPLEMENTATION-GUIDE.md:482-482
Timestamp: 2025-12-09T10:39:18.263Z
Learning: Enforce a single Go version across all workflows by setting a minimum Go version of 1.25.3 (Go 1.25.3+). Update all CI workflow configurations (e.g., actions/setup-go) to use this minimum version to maintain consistency and prevent drift.

Applied to files:

  • .github/workflows/build-buildkit-package.yml
  • .github/workflows/build-buildkit-rpm.yml
📚 Learning: 2025-12-02T08:42:05.866Z
Learnt from: CR
Repo: gounthar/docker-for-riscv64 PR: 0
File: .clinerules/02_coding_policy.md:0-0
Timestamp: 2025-12-02T08:42:05.866Z
Learning: Refactor code for clarity and maintainability, ensuring all tests remain green

Applied to files:

  • .github/workflows/build-buildkit-rpm.yml
🔇 Additional comments (7)
.github/scripts/extract-buildkit-version.sh (1)

1-34: Well-structured version extraction utility with proper error handling.

The script correctly implements version normalization for all three BuildKit release tag formats (dev builds, official releases with/without riscv64 suffix), uses strict shell options for safety, and provides clear error messages for unsupported formats. The regex patterns are distinct and non-overlapping, and the use of BASH_REMATCH is correct.

.github/workflows/build-buildkit-package.yml (4)

27-63: Release detection and idempotence logic is well-implemented.

The step correctly handles both manual dispatch and automatic workflow triggers, properly identifies BuildKit releases using pattern matching, and implements skip-if-already-exists logic to prevent redundant package builds.


65-84: Robust gh CLI availability checks with proper fail-fast error handling.

The dependency installation step properly verifies gh CLI availability, attempts installation only if needed, fails fast if installation fails (line 75), and includes a secondary verification (lines 80-83) to confirm gh is actually available after the installation attempt. This defensive approach ensures the workflow fails clearly if gh is unavailable, preventing cryptic downstream failures.


86-151: Comprehensive binary download with thorough validation.

The step properly handles both event types to determine the release tag, uses explicit --repo parameter for clarity, validates that binaries were actually downloaded, and includes comprehensive architecture and linking verification. The checks for RISC-V64 architecture and static linking are appropriate for the packaging context.


153-261: Build and upload pipeline is well-structured with proper error handling throughout.

The package version is correctly derived using the shared extraction script, the build step includes set -euo pipefail and verifies that .deb packages were actually created (preventing silent failures), the upload step implements proper retry logic with failure tracking (sets UPLOAD_FAILED flag and exits with code 1 on failure), and helpful installation instructions are provided post-upload.

.github/workflows/build-buildkit-rpm.yml (2)

88-180: Binary download, version extraction, and build process are well-implemented.

The binary download includes proper validation, architecture verification, and explicit --repo parameter (consistent with Debian workflow). The package version is correctly derived using the shared extraction script, and the build step includes set -euo pipefail with verification that RPM packages were actually created.


182-233: Upload logic with proper retry handling and error tracking.

The rpmlint checks are appropriately permissive (allowing non-critical issues with || true), the upload step implements proper retry logic with failure tracking (UPLOAD_FAILED flag), exits with code 1 if uploads fail, uses explicit --repo and --clobber for safety and idempotence, and provides clear post-upload status and installation instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants