minor changes #15

Merged
kleb merged 3 commits from rework/misc into main 2025-12-15 14:02:40 +01:00
Owner
No description provided.
Collaborator

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵
🧪 No relevant tests
🔒 No security concerns identified
 Recommended focus areas for review

Possible Logic Bug

The added apt show "$package" check may incorrectly treat package specifications that include version constraints or architecture qualifiers, causing valid packages to be skipped. Verify that the check correctly handles such cases or consider using apt-cache policy for availability testing.

if ! apt show "$package" >/dev/null 2>&1; then
    logWarning "Package $package not available, skipping"
    continue
fi
Potential Variable Expansion Issue

The apt install command uses -o Dpkg::Options::='$dpkgOptions'. The single quotes around $dpkgOptions prevent shell variable expansion, which may result in the options not being applied. Ensure the variable is expanded correctly, e.g., by removing the surrounding single quotes.

if ! runWithSpinner "Installing $package..." "apt install -y -o Dpkg::Options::='$dpkgOptions' '$package'" "" "Installed $package"; then
Minor Consistency Concern

The spinner message for .deb packages was changed to "Installing using DPKG $package..." while the command still uses dpkg -i '$package'. This mismatch may confuse users if the variable is not expanded as expected. Align the message with the actual command behavior.

if ! runWithSpinner "Installing using DPKG $package..." "dpkg -i '$package'" "" "Installed $package"; then
## PR Reviewer Guide 🔍 Here are some key observations to aid the review process: <table> <tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 2 🔵🔵⚪⚪⚪</td></tr> <tr><td>🧪&nbsp;<strong>No relevant tests</strong></td></tr> <tr><td>🔒&nbsp;<strong>No security concerns identified</strong></td></tr> <tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br> <details><summary><a href='https://git.kleb.sh/kleb/kInit/src/branch/rework/misc/installer/utils.sh#L497-L500'><strong>Possible Logic Bug</strong></a> The added `apt show "$package"` check may incorrectly treat package specifications that include version constraints or architecture qualifiers, causing valid packages to be skipped. Verify that the check correctly handles such cases or consider using `apt-cache policy` for availability testing. </summary> ```shell if ! apt show "$package" >/dev/null 2>&1; then logWarning "Package $package not available, skipping" continue fi ``` </details> <details><summary><a href='https://git.kleb.sh/kleb/kInit/src/branch/rework/misc/installer/utils.sh#L501-L501'><strong>Potential Variable Expansion Issue</strong></a> The `apt install` command uses `-o Dpkg::Options::='$dpkgOptions'`. The single quotes around `$dpkgOptions` prevent shell variable expansion, which may result in the options not being applied. Ensure the variable is expanded correctly, e.g., by removing the surrounding single quotes. </summary> ```shell if ! runWithSpinner "Installing $package..." "apt install -y -o Dpkg::Options::='$dpkgOptions' '$package'" "" "Installed $package"; then ``` </details> <details><summary><a href='https://git.kleb.sh/kleb/kInit/src/branch/rework/misc/installer/utils.sh#L491-L491'><strong>Minor Consistency Concern</strong></a> The spinner message for `.deb` packages was changed to `"Installing using DPKG $package..."` while the command still uses `dpkg -i '$package'`. This mismatch may confuse users if the variable is not expanded as expected. Align the message with the actual command behavior. </summary> ```shell if ! runWithSpinner "Installing using DPKG $package..." "dpkg -i '$package'" "" "Installed $package"; then ``` </details> </td></tr> </table>
Author
Owner

/improve

/improve
Collaborator

PR Code Suggestions

Latest suggestions up to b454cc8

CategorySuggestion                                                                                                                                    Impact
General
Fix dpkg options quoting

The current quoting passes literal single quotes around the expanded $dpkgOptions,
which can confuse dpkg. Remove the inner single quotes and quote the variable
properly to ensure the option string is interpreted correctly.

installer/utils.sh [501]

-"apt install -y -o Dpkg::Options::='$dpkgOptions' '$package'"
+"apt install -y -o Dpkg::Options::=${dpkgOptions} '$package'"
Suggestion importance[1-10]: 7

__

Why: The original quoting prevents $dpkgOptions from being expanded, so the intended dpkg options are ignored. Correcting the quoting ensures the options are applied, which can affect package installation behavior.

Medium
Use reliable package availability check

The availability check using apt-cache show may incorrectly skip packages that are
provided virtually or via meta‑packages. Replace it with a more reliable test such
as apt-cache policy or a dry‑run install (apt-get -s install "$package"). This
reduces false negatives and ensures required packages are not omitted.

installer/utils.sh [497-500]

-if ! apt-cache show "$package" >/dev/null 2>&1; then
+if ! apt-get -s install "$package" >/dev/null 2>&1; then
     logWarning "Package $package not available, skipping"
     continue
 fi
Suggestion importance[1-10]: 5

__

Why: Replacing apt-cache show with a simulated install (apt-get -s install) gives a more accurate availability test, but it adds overhead and may still produce false negatives if dependencies are missing. The change is useful but not critical.

Low

Previous suggestions

Suggestions up to commit b454cc8
CategorySuggestion                                                                                                                                    Impact
General
Use apt-cache for availability check

Replace apt show with a non‑interactive query like apt-cache policy to reliably
detect package availability without invoking the full apt front‑end. This avoids
potential prompts or slower execution.

installer/utils.sh [497-500]

-if ! apt show "$package" >/dev/null 2>&1; then
+if ! apt-cache policy "$package" | grep -q 'Installed\|Candidate'; then
     logWarning "Package $package not available, skipping"
     continue
 fi
Suggestion importance[1-10]: 4

__

Why: Replacing apt show with apt-cache policy can avoid invoking the full apt front‑end, but the change adds complexity and is not essential; it provides a modest improvement without fixing a bug.

Low
## PR Code Suggestions ✨ <!-- b454cc8 --> Latest suggestions up to b454cc8 <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=2>General</td> <td> <details><summary>Fix dpkg options quoting</summary> ___ **The current quoting passes literal single quotes around the expanded <code>$dpkgOptions</code>, <br>which can confuse <code>dpkg</code>. Remove the inner single quotes and quote the variable <br>properly to ensure the option string is interpreted correctly.** [installer/utils.sh [501]](https://git.kleb.sh/kleb/kInit/src/branch/rework/misc/installer/utils.sh#L501-L501) ```diff -"apt install -y -o Dpkg::Options::='$dpkgOptions' '$package'" +"apt install -y -o Dpkg::Options::=${dpkgOptions} '$package'" ``` <details><summary>Suggestion importance[1-10]: 7</summary> __ Why: The original quoting prevents `$dpkgOptions` from being expanded, so the intended dpkg options are ignored. Correcting the quoting ensures the options are applied, which can affect package installation behavior. </details></details></td><td align=center>Medium </td></tr><tr><td> <details><summary>Use reliable package availability check</summary> ___ **The availability check using <code>apt-cache show</code> may incorrectly skip packages that are <br>provided virtually or via meta‑packages. Replace it with a more reliable test such <br>as <code>apt-cache policy</code> or a dry‑run install (<code>apt-get -s install "$package"</code>). This <br>reduces false negatives and ensures required packages are not omitted.** [installer/utils.sh [497-500]](https://git.kleb.sh/kleb/kInit/src/branch/rework/misc/installer/utils.sh#L497-L500) ```diff -if ! apt-cache show "$package" >/dev/null 2>&1; then +if ! apt-get -s install "$package" >/dev/null 2>&1; then logWarning "Package $package not available, skipping" continue fi ``` <details><summary>Suggestion importance[1-10]: 5</summary> __ Why: Replacing `apt-cache show` with a simulated install (`apt-get -s install`) gives a more accurate availability test, but it adds overhead and may still produce false negatives if dependencies are missing. The change is useful but not critical. </details></details></td><td align=center>Low </td></tr></tr></tbody></table> ___ #### Previous suggestions <details><summary>Suggestions up to commit b454cc8</summary> <br><table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=1>General</td> <td> <details><summary>Use apt-cache for availability check</summary> ___ **Replace <code>apt show</code> with a non‑interactive query like <code>apt-cache policy</code> to reliably <br>detect package availability without invoking the full <code>apt</code> front‑end. This avoids <br>potential prompts or slower execution.** [installer/utils.sh [497-500]](https://git.kleb.sh/kleb/kInit/src/branch/rework/misc/installer/utils.sh#L497-L500) ```diff -if ! apt show "$package" >/dev/null 2>&1; then +if ! apt-cache policy "$package" | grep -q 'Installed\|Candidate'; then logWarning "Package $package not available, skipping" continue fi ``` <details><summary>Suggestion importance[1-10]: 4</summary> __ Why: Replacing `apt show` with `apt-cache policy` can avoid invoking the full `apt` front‑end, but the change adds complexity and is not essential; it provides a modest improvement without fixing a bug. </details></details></td><td align=center>Low </td></tr></tr></tbody></table> </details>
Author
Owner

/improve One last time

/improve One last time
Collaborator

PR Code Suggestions

No code suggestions found for the PR.

## PR Code Suggestions ✨ No code suggestions found for the PR.
kleb changed title from WIP: minor changes to minor changes 2025-12-15 14:02:36 +01:00
kleb merged commit f9f4eb3488 into main 2025-12-15 14:02:40 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kleb/kInit!15
No description provided.