Enable Alpine community and tagged edge for guest tools - #55
Conversation
During initial config on Alpine, ensure the matching community repository is enabled and add a tagged @edge community overlay so xe-guest-utilities can install after upgrades where only main was configured. Co-authored-by: Michael <Narehood@users.noreply.github.com>
📝 WalkthroughWalkthroughThe installer now manages Alpine repositories and installs ChangesAlpine guest utility installation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant serverSetup.sh
participant setup-apkrepos
participant repositories_file
participant apk
participant service
serverSetup.sh->>setup-apkrepos: Prepare Alpine repositories
setup-apkrepos->>repositories_file: Update repository entries
serverSetup.sh->>apk: Refresh indexes and install xe-guest-utilities
serverSetup.sh->>service: Enable and start xe-guest-utilities
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Installers/serverSetup.sh`:
- Around line 391-392: Update update_repos to propagate the exit status from apk
update: only set PKG_MANAGER_UPDATED to "true" and return success when the
command succeeds, and return a nonzero status on failure so the existing
update_repos || return 1 path stops installation.
- Around line 366-369: Update the `main_line` processing before constructing
`edge_line` so any existing repository tag is removed while retaining the
repository URL. Ensure `edge_base` contains only the normalized `/alpine` URL,
allowing `edge_line` to produce a single `@edge` tag followed by the community
repository path.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 20b8c1ad-6256-4e44-b47c-337cd87a119f
📒 Files selected for processing (4)
Installers/.checksums.sha256Installers/serverSetup.shtests/security-checks.shtests/server-setup-alpine.sh
| main_line=$(grep -E "^[[:space:]]*[^#].*/alpine/v${branch_escaped}/main(/|[[:space:]]|$)" "$repos" | head -n1 || true) | ||
| if [[ -n "$main_line" ]]; then | ||
| edge_base=$(printf '%s\n' "$main_line" | sed -E "s|^[[:space:]]*||; s|/alpine/v${branch_escaped}/main.*|/alpine|") | ||
| edge_line="@edge ${edge_base}/edge/community" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
branch_escaped='3\.24'
main_line='`@stable` https://dl-cdn.alpinelinux.org/alpine/v3.24/main'
edge_base=$(printf '%s\n' "$main_line" |
sed -E "s|^[[:space:]]*||; s|/alpine/v${branch_escaped}/main.*|/alpine|")
printf '`@edge` %s/edge/community\n' "$edge_base"
# Current output contains a second tag: "`@edge` `@stable` https://..."Repository: Narehood/VM-Setup
Length of output: 222
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- Installers/serverSetup.sh outline matching repo-related context ---\n'
ast-grep outline Installers/serverSetup.sh --match repo --view expanded || true
printf '\n--- Relevant lines 340-385 ---\n'
sed -n '340,385p' Installers/serverSetup.sh | nl -ba -v340
printf '\n--- Search for repository tag handling nearby ---\n'
rg -n "@(stable|testing|edge)|set_repository|repos|/alpine/v|edge/community|edge_base" Installers/serverSetup.shRepository: Narehood/VM-Setup
Length of output: 246
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Read-only behavioral probe for the current construction and the proposed fix.
branch_escaped='3\.24'
current_edge_base() {
printf '%s\n' "$1" | sed -E "s|^[[:space:]]*||; s|/alpine/v${branch_escaped}/main.*|/alpine|";
}
proposed_edge_base() {
printf '%s\n' "$1" | sed -_E "s|^[[:space:]]*||; s|^@[^[:space:]]+[[:space:]]+||; s|/alpine/v${branch_escaped}/main.*|/alpine|";
}
for main_line in \
'`@stable` https://dl-cdn.alpinelinux.org/alpine/v3.24/main' \
'https://dl-cdn.alpinelinux.org/alpine/v3.24/main'
do
current="$(printf '`@edge` %s/edge/community\n' "$(current_edge_base "$main_line")")"
proposed="$(printf '`@edge` %s/edge/community\n' "$(proposed_edge_base "$main_line")")"
echo "input: $main_line"
echo "current: $current"
echo "proposed: $proposed"
echo "---"
doneRepository: Narehood/VM-Setup
Length of output: 4661
Remove an existing repository tag before building edge_line.
If the main repository line has a tag, such as @stable https://…/v3.24/main, keep the URL instead of preserving that tag. Otherwise this writes @edge @stable https://…/edge/community, which is not a valid repository URL.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Installers/serverSetup.sh` around lines 366 - 369, Update the `main_line`
processing before constructing `edge_line` so any existing repository tag is
removed while retaining the repository URL. Ensure `edge_base` contains only the
normalized `/alpine` URL, allowing `edge_line` to produce a single `@edge` tag
followed by the community repository path.
| PKG_MANAGER_UPDATED="false" | ||
| update_repos || return 1 |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Propagate apk update failures.
update_repos ignores the exit status from apk update at Line 154. It then sets PKG_MANAGER_UPDATED="true" and returns success. Therefore, Line 392 can continue with stale package indexes after an update failure.
Proposed fix
if [[ "$OS" == "alpine" ]]; then
- apk update >/dev/null 2>&1
+ apk update >/dev/null 2>&1 || return 1🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Installers/serverSetup.sh` around lines 391 - 392, Update update_repos to
propagate the exit status from apk update: only set PKG_MANAGER_UPDATED to
"true" and return success when the command succeeds, and return a nonzero status
on failure so the existing update_repos || return 1 path stops installation.
Summary
Alpine initial config was failing to install
xe-guest-utilitiesafter upgrading to 3.24.1 because onlymainwas effectively available. That package lives in community on stable (and also on edge/community).Change
During Server Initial Config on Alpine, before installing XCP-NG guest tools:
vX.Y/communityrepo (setup-apkrepos -cwhen available, otherwise uncomment/add the line)@edge .../edge/communityoverlay (safe; not untagged edge)apk update, then installxe-guest-utilities(falls back toxe-guest-utilities@edgeif needed)Why not only edge?
On Alpine 3.24,
xe-guest-utilitiesis inv3.24/community. Enabling community is the correct primary fix; tagged@edgeis included as requested for overlay access without reintroducing untagged mixed repos.Summary by CodeRabbit
New Features
Bug Fixes
Tests