Skip to content

Conversation

leggewie
Copy link
Collaborator

@leggewie leggewie commented Apr 27, 2025

using this extension allows for activation of the APA armbian package archive and installation of the provided binary packages at image creation time from within the Armbian Build Framework.

The goal of APA is to simplify maintenance of Armbian Core by moving dependency logic and other packaging information into a separate space and handle that meta-data with the proper distribution-creation and -publication tools. Currently, much of this is done with fragile bash scripting in Armbian Core instead.

@leggewie leggewie requested a review from igorpecovnik as a code owner April 27, 2025 23:48
Copy link
Contributor

coderabbitai bot commented Apr 27, 2025

Walkthrough

A new script extension named apa.sh has been added to the Armbian project. This script enables the Armbian Package Archive (APA) repository by default on target images. It defines three functions: one to display an informational alert about enabling APA, another to add the APA repository to the system's APT sources list on the SD card, and a third to install packages from the APA repository during image customization. The installation process includes conditional logic based on whether the build is minimal and the selected desktop environment (XFCE, KDE, or GNOME), installing relevant packages such as armbian-common, armbian-bsp, and the corresponding desktop packages with recommended dependencies.

Suggested labels

ready to merge


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 445ebad and ceb1b55.

📒 Files selected for processing (1)
  • extensions/apa.sh (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
extensions/apa.sh (2)
.github/generate_CODEOWNERS.sh (1)
  • display_alert (6-6)
lib/functions/logging/runners.sh (2)
  • run_host_command_logged (192-194)
  • chroot_sdcard_apt_get (40-118)
🪛 Shellcheck (0.10.0)
extensions/apa.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

🔇 Additional comments (1)
extensions/apa.sh (1)

3-5: Approve extension_prepare_config__apa definition
This function cleanly alerts users that APA will be enabled by default. The signature and parameters are correct.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added size/small PR with less then 50 lines 05 Milestone: Second quarter release Needs review Seeking for review Framework Framework components labels Apr 27, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Apr 27, 2025
@leggewie leggewie requested a review from rpardini April 27, 2025 23:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5194e0f and 445ebad.

📒 Files selected for processing (1)
  • extensions/apa.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
extensions/apa.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)

🔇 Additional comments (1)
extensions/apa.sh (1)

3-5: Looks good: user notification is clear.

The extension_prepare_config__apa function cleanly informs the user that APA will be enabled by default, aligning with the extension’s purpose.

Comment on lines +13 to +14
[[ "${BUILD_MINIMAL,,}" =~ ^(true|yes)$ ]] && INSTALL_RECOMMENDS="no" || INSTALL_RECOMMENDS="yes"
chroot_sdcard_apt_get --install-recommends=$INSTALL_RECOMMENDS install "armbian-common armbian-bsp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace Bash-specific ${VAR,,} with a POSIX-compatible check.

If this script is ever run under /bin/sh, ${BUILD_MINIMAL,,} and regex matching may fail. Use a case statement for a portable, case-insensitive check:

-[[ "${BUILD_MINIMAL,,}" =~ ^(true|yes)$ ]] && INSTALL_RECOMMENDS="no" || INSTALL_RECOMMENDS="yes"
+case "${BUILD_MINIMAL}" in
+  [Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]) INSTALL_RECOMMENDS="no" ;;
+  *)                                   INSTALL_RECOMMENDS="yes" ;;
+esac
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[[ "${BUILD_MINIMAL,,}" =~ ^(true|yes)$ ]] && INSTALL_RECOMMENDS="no" || INSTALL_RECOMMENDS="yes"
chroot_sdcard_apt_get --install-recommends=$INSTALL_RECOMMENDS install "armbian-common armbian-bsp"
case "${BUILD_MINIMAL}" in
[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]) INSTALL_RECOMMENDS="no" ;;
*) INSTALL_RECOMMENDS="yes" ;;
esac
chroot_sdcard_apt_get --install-recommends=$INSTALL_RECOMMENDS install "armbian-common armbian-bsp"

Comment on lines +14 to +15
chroot_sdcard_apt_get --install-recommends=$INSTALL_RECOMMENDS install "armbian-common armbian-bsp"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refresh APT cache and fix package arguments.

Before installing from APA, run apt-get update in the chroot. Also, supply package names as separate arguments instead of a single quoted string:

-function post_armbian_repo_customize_image__install_from_apa() {
-  # do not install armbian recommends for minimal images
-  [[ ... ]]
-  chroot_sdcard_apt_get --install-recommends=$INSTALL_RECOMMENDS install "armbian-common armbian-bsp"
+function post_armbian_repo_customize_image__install_from_apa() {
+  # do not install armbian recommends for minimal images
+  case "${BUILD_MINIMAL}" in ... esac
+
+  # Refresh repository index
+  chroot_sdcard_apt_get update
+
+  # Install core APA packages
+  chroot_sdcard_apt_get --install-recommends="$INSTALL_RECOMMENDS" install armbian-common armbian-bsp

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +7 to +9
function custom_apt_repo__add_apa() {
run_host_command_logged echo "deb [signed-by=${APT_SIGNING_KEY_FILE}] https://github.armbian.com/apa current main" "|" tee "${SDCARD}"/etc/apt/sources.list.d/armbian-apa.list
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix incorrect piping in custom_apt_repo__add_apa.

The literal "|" argument to echo won’t create a pipe. Wrap the entire command in Bash so it executes the pipe properly:

-function custom_apt_repo__add_apa() {
-  run_host_command_logged echo "deb [signed-by=${APT_SIGNING_KEY_FILE}] https://github.armbian.com/apa current main" "|" tee "${SDCARD}"/etc/apt/sources.list.d/armbian-apa.list
-}
+function custom_apt_repo__add_apa() {
+  run_host_command_logged bash -c \
+    "echo 'deb [signed-by=${APT_SIGNING_KEY_FILE}] https://github.armbian.com/apa current main' | \
+     tee '${SDCARD}/etc/apt/sources.list.d/armbian-apa.list'"
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function custom_apt_repo__add_apa() {
run_host_command_logged echo "deb [signed-by=${APT_SIGNING_KEY_FILE}] https://github.armbian.com/apa current main" "|" tee "${SDCARD}"/etc/apt/sources.list.d/armbian-apa.list
}
function custom_apt_repo__add_apa() {
run_host_command_logged bash -c \
"echo 'deb [signed-by=${APT_SIGNING_KEY_FILE}] https://github.armbian.com/apa current main' | \
tee '${SDCARD}/etc/apt/sources.list.d/armbian-apa.list'"
}

Comment on lines +17 to +21
case ${DESKTOP_ENVIRONMENT^^} in
XFCE|KDE|GNOME)
display_alert "installing ${DESKTOP_ENVIRONMENT^^} desktop environment" "${EXTENSION}: ${DESKTOP_ENVIRONMENT^^}" "info"
chroot_sdcard_apt_get --install-recommends=yes "armbian-desktop-${DESKTOP_ENVIRONMENT,,}"
;;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Correct desktop environment installation command.

Similarly, include the install subcommand and avoid quoting multiple packages as one string. Also make the case‐insensitive match POSIX‐compliant:

-case ${DESKTOP_ENVIRONMENT^^} in
-  XFCE|KDE|GNOME)
-    display_alert "installing ${DESKTOP_ENVIRONMENT^^} desktop environment" "${EXTENSION}: ${DESKTOP_ENVIRONMENT^^}" "info"
-    chroot_sdcard_apt_get --install-recommends=yes "armbian-desktop-${DESKTOP_ENVIRONMENT,,}"
-    ;;
-esac
+case "${DESKTOP_ENVIRONMENT}" in
+  [Xx][Ff][Cc][Ee]|[Kk][Dd][Ee]|[Gg][Nn][Oo][Mm][Ee])
+    display_alert "Installing ${DESKTOP_ENVIRONMENT} desktop environment" \
+                  "${EXTENSION}: ${DESKTOP_ENVIRONMENT}" "info"
+    chroot_sdcard_apt_get --install-recommends=yes install armbian-desktop-"${DESKTOP_ENVIRONMENT}"
+    ;;
+esac
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case ${DESKTOP_ENVIRONMENT^^} in
XFCE|KDE|GNOME)
display_alert "installing ${DESKTOP_ENVIRONMENT^^} desktop environment" "${EXTENSION}: ${DESKTOP_ENVIRONMENT^^}" "info"
chroot_sdcard_apt_get --install-recommends=yes "armbian-desktop-${DESKTOP_ENVIRONMENT,,}"
;;
case "${DESKTOP_ENVIRONMENT}" in
[Xx][Ff][Cc][Ee]|[Kk][Dd][Ee]|[Gg][Nn][Oo][Mm][Ee])
display_alert "Installing ${DESKTOP_ENVIRONMENT} desktop environment" \
"${EXTENSION}: ${DESKTOP_ENVIRONMENT}" "info"
chroot_sdcard_apt_get --install-recommends=yes install armbian-desktop-"${DESKTOP_ENVIRONMENT}"
;;
esac

using this extension allows for activation of the APA armbian package
archive and installation of the provided binary packages at image
creation time from within the Armbian Build Framework.

The goal of APA is to simplify maintenance of Armbian Core by moving
dependency logic and other packaging information into a separate space
and handle that meta-data with the proper distribution-creation and
-publication tools.  Currently, much of this is done with fragile bash
scripting in Armbian Core instead.

https://github.com/armbian/apa
@leggewie leggewie force-pushed the wip-introduce-APA-extension branch from 445ebad to ceb1b55 Compare April 28, 2025 00:22
@github-actions github-actions bot removed the Ready to merge Reviewed, tested and ready for merge label Apr 28, 2025
@coderabbitai coderabbitai bot added the Ready to merge Reviewed, tested and ready for merge label Apr 28, 2025
@leggewie leggewie requested a review from lanefu April 28, 2025 00:23
@igorpecovnik igorpecovnik merged commit 723d5f0 into armbian:main May 3, 2025
1 check passed
@leggewie leggewie deleted the wip-introduce-APA-extension branch May 4, 2025 22:46
@coderabbitai coderabbitai bot mentioned this pull request Jun 9, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
05 Milestone: Second quarter release Framework Framework components Needs review Seeking for review Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines
Development

Successfully merging this pull request may close these issues.

2 participants