From c4eff873a7126de0bb7522d42454ea994fce6d8c Mon Sep 17 00:00:00 2001 From: Rolv Apneseth Date: Tue, 20 Oct 2026 12:07:20 +0100 Subject: [PATCH 1/3] ci: add workflow to check the output of the query-file-owner scripts Add CI with simple checks that our query-file-owner scripts are outputting in the expected format. This is a follow-up to e4e9a493be4f. --- .github/workflows/package-system.yml | 66 ++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/package-system.yml diff --git a/.github/workflows/package-system.yml b/.github/workflows/package-system.yml new file mode 100644 index 00000000..1c032903 --- /dev/null +++ b/.github/workflows/package-system.yml @@ -0,0 +1,66 @@ +name: Package system scripts + +on: + workflow_dispatch: + schedule: + # Weekly + - cron: '0 0 * * 1' + push: + branches: ["main"] + paths: ['packagesystem/*', '.github/workflows/**'] + pull_request: + branches: ["main"] + paths: ['packagesystem/*', '.github/workflows/**'] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-package-system-script-output: + runs-on: ubuntu-latest + name: Check script output for ${{ matrix.package_manager }} (${{ matrix.image }}) + + strategy: + matrix: + include: + - image: alpine:latest + package_manager: apk + - image: fedora:latest + package_manager: rpm + - image: ubuntu:latest + package_manager: dpkg + - image: archlinux:latest + package_manager: pacman + + container: + image: ${{ matrix.image }} + + steps: + - name: Check out repository + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Confirm output matches expected format + run: | + pkg_count="2" + output=$(packagesystem/query-file-owner-${{ matrix.package_manager }} /bin/sh /usr/bin/env) + printf "Script output:\n%s\n" "${output}" + # Verify we got at least one line per queried file + line_count=$(echo "${output}" | wc -l) + if [ "${line_count}" -lt "${pkg_count}" ]; then + echo "ERROR: expected at least ${pkg_count} lines of output, got ${line_count}" >&2 + exit 1 + fi + # Verify each line matches the expected "NAME VERSION" format + echo "${output}" | while IFS= read -r line; do + if ! echo "${line}" | grep -qE '^[^ ]+ [^ ]+$'; then + echo "ERROR: output line does not match 'NAME VERSION' format: ${line}" >&2 + exit 1 + fi + done || exit 1 + echo "All output lines match expected format." From e13a42b53b5e70083e7344dad3d4bdc063a97e19 Mon Sep 17 00:00:00 2001 From: Rolv Apneseth Date: Tue, 20 Oct 2026 12:27:22 +0100 Subject: [PATCH 2/3] packagesystem/query-file-owner-dpkg: manually handle symlinks As observed in CI, the script was failing to find /bin/sh on Ubuntu since it's a symlink to /usr/bin/dash. --- packagesystem/query-file-owner-dpkg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packagesystem/query-file-owner-dpkg b/packagesystem/query-file-owner-dpkg index 62d644ef..cf033c2d 100755 --- a/packagesystem/query-file-owner-dpkg +++ b/packagesystem/query-file-owner-dpkg @@ -15,7 +15,8 @@ fi for FILE in "$@"; do # Use your package manager to find the package that owns the file # Package Manager should return two space-separated values: NAME and VERSION + ABS_FILE=$(realpath "$FILE") dpkg-query -W -f '${Package} ${Version}\n' \ - $(dpkg -S "$FILE" | cut -d: -f1 | tr ',' ' ') + $(dpkg -S "$ABS_FILE" | cut -d: -f1 | tr ',' ' ') done From 3d10b5e2c568a11e5f9e048e056012f871f386c0 Mon Sep 17 00:00:00 2001 From: Rolv Apneseth Date: Tue, 20 Oct 2026 18:46:45 +0100 Subject: [PATCH 3/3] packagesystem/query-file-owner-dpkg: catch failures in dpkg -S --- packagesystem/query-file-owner-dpkg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packagesystem/query-file-owner-dpkg b/packagesystem/query-file-owner-dpkg index cf033c2d..66281a08 100755 --- a/packagesystem/query-file-owner-dpkg +++ b/packagesystem/query-file-owner-dpkg @@ -16,7 +16,6 @@ for FILE in "$@"; do # Use your package manager to find the package that owns the file # Package Manager should return two space-separated values: NAME and VERSION ABS_FILE=$(realpath "$FILE") - dpkg-query -W -f '${Package} ${Version}\n' \ - $(dpkg -S "$ABS_FILE" | cut -d: -f1 | tr ',' ' ') + PKG=$(dpkg -S "$ABS_FILE" | cut -d: -f1 | tr ',' ' ') + dpkg-query -W -f '${Package} ${Version}\n' $PKG done -