Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/package-system.yml
Original file line number Diff line number Diff line change
@@ -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
Comment thread
coderabbitai[bot] marked this conversation as resolved.
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."
Comment thread
coderabbitai[bot] marked this conversation as resolved.
6 changes: 3 additions & 3 deletions packagesystem/query-file-owner-dpkg
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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
dpkg-query -W -f '${Package} ${Version}\n' \
$(dpkg -S "$FILE" | cut -d: -f1 | tr ',' ' ')
ABS_FILE=$(realpath "$FILE")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
PKG=$(dpkg -S "$ABS_FILE" | cut -d: -f1 | tr ',' ' ')
dpkg-query -W -f '${Package} ${Version}\n' $PKG
done

Loading