-
Notifications
You must be signed in to change notification settings - Fork 55
Remove rpm depency from packagesystem! #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ parallel build: { | |
| } | ||
| stage("Unit tests") { | ||
| shwrap(""" | ||
| cargo test --features rpm | ||
| cargo test | ||
| """) | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ RELEASE ?= 1 | |
| CONTAINER_RUNTIME ?= podman | ||
| IMAGE_PREFIX ?= | ||
| IMAGE_NAME ?= bootupd-build | ||
| PACKAGESYSTEM ?= rpm | ||
|
|
||
| ifeq ($(RELEASE),1) | ||
| PROFILE ?= release | ||
|
|
@@ -24,10 +25,16 @@ all: | |
| ln -f target/${PROFILE}/bootupd target/${PROFILE}/bootupctl | ||
|
|
||
| .PHONY: install | ||
| install: | ||
| install: query-file-$(PACKAGESYSTEM) | ||
| mkdir -p "${DESTDIR}$(PREFIX)/bin" "${DESTDIR}$(LIBEXECDIR)" | ||
| install -D -t "${DESTDIR}$(LIBEXECDIR)" target/${PROFILE}/bootupd | ||
| ln -f ${DESTDIR}$(LIBEXECDIR)/bootupd ${DESTDIR}$(PREFIX)/bin/bootupctl | ||
| ln -f "${DESTDIR}$(LIBEXECDIR)/bootupd" "${DESTDIR}$(PREFIX)/bin/bootupctl" | ||
|
|
||
| .PHONY: query-file-$(PACKAGESYSTEM) | ||
| query-file-$(PACKAGESYSTEM): | ||
| install -D -m 755 \ | ||
| "packagesystem/query-file-owner-$(PACKAGESYSTEM)" \ | ||
| "${DESTDIR}$(PREFIX)/lib/bootupd/packagesystem/query-file-owner" | ||
|
Comment on lines
+28
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Keep the Debian selector and helper name consistent. 📍 Affects 2 files
🤖 Prompt for AI Agents |
||
|
|
||
| .PHONY: install-grub-static | ||
| install-grub-static: | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These scripts perform 80% of the same operations. It's probably cleaner to have one file with some switch cases. Can be a followup
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thoughts, can we have this in bootupd itself? We can always check
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No not really. As I mentioned in #1130 (comment), that would have been my first approach. @cgwalters suggested a script in the discussion over in #468, and confirmed it in #468 (comment), so that's what was done here. The multiple scripts vs 1 was to avoid
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In favour of the scripts, it's a lot easier for someone to adjust the script for a package system we don't have covered here than it would be if it was in Rust code. One line change if modifying one of these reference scripts.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another point in favour of separate scripts is the Alpine comment I made below - there may be subtle adjustments needed for each distro. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #!/usr/bin/sh | ||
| set -eu | ||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/sh
set -eu
printf '%s\n' '--- helper ---'
cat -n packagesystem/query-file-owner-apk
printf '%s\n' '--- references to helper and Alpine image support ---'
rg -n -C 3 'query-file-owner-apk|/usr/bin/sh|/bin/sh|alpine' packagesystem .github Dockerfile* 2>/dev/null || trueRepository: coreos/bootupd Length of output: 1502 🌐 Web query:
💡 Result: In Alpine Linux, /bin/sh is the standard location for the system's POSIX-compliant shell [1]. By default, this path is a symlink to the BusyBox ash shell [1]. There is no absolute, immutable guarantee that /bin/sh will always point to BusyBox. While it is the standard and default configuration provided by the busybox-binsh package [2][3], Alpine's package management system allows users to replace this provider [1]. Specifically, you can install an alternative package, such as dash-binsh, which changes the /bin/sh symlink target to the dash shell [1][4]. Because the shell is managed via the package manager (apk), the actual implementation of /bin/sh is determined by which "binsh" provider package is installed on the system [1][2][4]. Consequently, while BusyBox is the default, it is a configurable behavior rather than an architectural requirement [1]. Users and developers should rely on /bin/sh as the POSIX-compliant interface path but should not hardcode expectations of specific features unique to BusyBox ash unless they control the environment configuration [1]. Citations:
Use Alpine’s standard shell path. Alpine provides the POSIX shell at 🤖 Prompt for AI Agents |
||
|
|
||
| # Script to detect package ownership of a file in a Linux system. | ||
| # Required environment setup for consistent output | ||
| export LC_ALL=C | ||
| export LANG=C | ||
|
|
||
| # Usage: ./query-file-owner [FILE] [FILE...] | ||
| if [ "$#" -eq 0 ]; then | ||
| echo "Usage: $0 [FILE] [FILE...]" | ||
| exit 1 | ||
| 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" 2>/dev/null || echo "$FILE") | ||
|
|
||
| apk info -W "$ABS_FILE" 2>/dev/null | \ | ||
| sed 's/.*is owned by //' | \ | ||
| awk -F'-' '{ | ||
| # Build version from the end | ||
| ver = $(NF-1) "-" $NF; | ||
| name = $1; | ||
| for(i=2; i<NF-1; i++) name = name "-" $i; | ||
| print name " " ver | ||
| }' | ||
|
Comment on lines
+20
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/sh
set -eu
printf '%s\n' '--- helper ---'
cat -n packagesystem/query-file-owner-apk
printf '%s\n' '--- direct references ---'
rg -n -C 8 'query-file-owner-apk|query_files|NAME VERSION|apk info -W' src packagesystemRepository: coreos/bootupd Length of output: 6676 🏁 Script executed: #!/bin/sh
set -eu
printf '%s\n' '--- metadata parsing ---'
cat -n src/packagesystem.rs | sed -n '1,155p'
printf '%s\n' '--- metadata consumers and script contract ---'
rg -n -C 6 'parse_package_metadata|ContentMetadata|QUERY_FILE_OWNER_SCRIPT|query-file-owner' src packagesystem Cargo.tomlRepository: coreos/bootupd Length of output: 40529 Propagate failed The pipeline returns 🤖 Prompt for AI Agents |
||
| done | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Script to detect package ownership of a file in a Linux system. | ||
| # Required environment setup for consistent output | ||
| export LC_ALL=C | ||
| export LANG=C | ||
|
|
||
| # Usage: ./query-file-owner [FILE] [FILE...] | ||
| if [ "$#" -eq 0 ]; then | ||
| echo "Usage: $0 [FILE] [FILE...]" | ||
| exit 1 | ||
| 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)" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/sh
set -eu
printf '%s\n' '--- target file ---'
cat -n packagesystem/query-file-owner-dpkg
printf '%s\n' '--- dpkg-query help/version contract ---'
command -v dpkg-query || true
dpkg-query --version 2>&1 | sed -n '1,4p' || true
dpkg-query --help 2>&1 | sed -n '1,80p' || trueRepository: coreos/bootupd Length of output: 1010 🌐 Web query:
💡 Result: To output a comma-separated list of packages using dpkg-query, you should utilize the --showformat (-f) option combined with the --show (-W) command [1][2][3]. By default, dpkg-query -W outputs one package per line [4][3]. You can override this behavior by defining a custom format string that uses a comma as a separator instead of a newline (\n) [2][3]. Example command: dpkg-query -W -f='${Package},' packagename1 packagename2 If you want to list all installed packages comma-separated, you can omit the specific package arguments and pipe the output to a tool like sed to remove the final trailing comma: dpkg-query -W -f='${Package},' | sed 's/,$//' Explanation of options: - -W, --show: This command lists packages matching the given patterns (or all installed packages if no pattern is provided) [1][4]. - -f, --showformat=format: This allows you to customize the output string [1][2]. You can reference package fields using the syntax ${field}, such as ${Package}, ${Version}, or ${Architecture} [5][3]. - Escapes: The format string supports common escape characters like \n (newline), \r (carriage return), and \t (tab) [2][3]. By using a comma in your format string instead of \n, you create a comma-separated list [2]. Note that dpkg-query natively separates information for each package by a newline in its default behavior [2][4]; the custom format string is the standard way to achieve custom delimiters or machine-readable outputs [2][3]. Citations:
🌐 Web query:
💡 Result: The dpkg-query command does not use commas to separate multiple package names [1][2]. Instead, multiple packages are specified by listing them as separate, space-separated arguments on the command line [1][3]. For example, to query the status of multiple packages, you would use: dpkg-query -s package1 package2 package3 When multiple package names are provided in this manner, dpkg-query processes them in the order specified and separates the output for each package with an empty line [1][4]. While commas are used in certain Debian configuration files (such as deb-control(5) files) to define dependency relationships or lists [5][6], and some other tools may accept comma-separated inputs (like the debootsnap utility) [7][8], the dpkg-query utility itself expects space-delimited arguments for its operations [1][3]. Citations:
🌐 Web query:
💡 Result: The dpkg-query tool uses the -l or --list action to list packages matching a specified package-name-pattern [1]. The syntax is: dpkg-query -l package-name-pattern... This command supports standard shell-style glob patterns (e.g., using asterisks as wildcards) to filter the list of installed packages [1][2][3]. For example, to list all installed packages that contain the string "vi" in their name, you would use: dpkg-query -l 'vi' Note that if you wish to include non-installed packages that are still present in the available database (e.g., previously purged packages or those whose information is cached), you may need to use the --load-avail option, as dpkg-query does not load the available file by default in modern versions [1][2][3]. Citations:
🌐 Web query:
💡 Result: When you use the dpkg-query --search (or -S) command to find which package owns a specific file, the utility automatically handles cases where multiple packages own the same file [1][2]. The output format is explicitly designed to list all such packages on a single line, separated by a comma and a space [1][2]. According to the official documentation, the output format is: pkgname1, pkgname2: pathname For example, if both package1 and package2 provide the same file, the output will appear as [1][2]: package1, package2: /path/to/file You do not need to provide any additional flags or formatting options to achieve this comma-separated list; it is the default behavior of the --search command [1][2]. If you are machine-parsing this output, it is recommended to set the locale to C.UTF-8 to ensure the output remains consistent and reproducible across different environments [2]. Citations:
Parse all For multiple owners, 🤖 Prompt for AI Agents |
||
| done | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Script to detect package ownership of a file in a Linux system. | ||
| # Required environment setup for consistent output | ||
| export LC_ALL=C | ||
| export LANG=C | ||
|
|
||
| # Usage: ./query-file-owner [FILE] [FILE...] | ||
| if [ "$#" -eq 0 ]; then | ||
| echo "Usage: $0 [FILE] [FILE...]" | ||
| exit 1 | ||
| 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 | ||
| pacman -Q "$(pacman -Qoq "$FILE")" | ||
| done | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/usr/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # Script to detect package ownership of a file in a Linux system. | ||
| # Required environment setup for consistent output | ||
| export LC_ALL=C | ||
| export LANG=C | ||
|
|
||
| # Usage: ./query-file-owner [FILE] [FILE...] | ||
| if [ "$#" -eq 0 ]; then | ||
| echo "Usage: $0 [FILE] [FILE...]" | ||
| exit 1 | ||
| 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 | ||
| rpm -q --qf '%{NAME} %{EVR}\n' -f "$FILE" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again let's keep the current semantics of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was discussed above - space-separated so we can actually parse out the package name vs version in something like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, this makes sense. I'm not a 100% sure about this. If we're changing this anyway, maybe we could take a more structured approach where the script returns some sort of structured data, maybe json. Don't think this is a huge deal, but it feels like we're splitting the work 50-50 between the scripts and bootupd
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how complex it would be to get JSON output from all of these package managers, but that doesn't sound easy. Splitting on whitespace just seemed like the way to go so it's easy to implement getting the expected output while keeping it simple for us to parse out name+version. |
||
| done | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.