Skip to content

extension: add ksrc packaging #8211

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EvilOlaf
Copy link
Member

Description

A (very poorly made) attempt to address #8161

It spits out some sort of kernel source package, but I think {version} is still missing since I couldn't get it to work and probably needs more fixes until production-ready. I probably won't go further here due to lacking expertise in framework and bash foo.

Maybe someone want to pick it up from here.

Also to do: Re-enable BUILD_KSRC switch to enable the extension.

How Has This Been Tested?

  • enable extension
  • see some sort of kernel package being created
  • ???
  • Profit!

Checklist:

  • My code follows the style guidelines of this project - Well...kind of?
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@EvilOlaf EvilOlaf added the Help needed We need your involvement label May 21, 2025
Copy link
Contributor

coderabbitai bot commented May 21, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new shell script extension has been added to facilitate packaging the Linux kernel source into a Debian package. The script introduces three primary functions: one to set configuration variables for building the kernel source package, another to add the fakeroot utility to the host dependencies, and a third to handle the actual packaging process. The packaging function checks for the presence of a kernel configuration file, prepares the necessary directory structure, compresses the kernel source, includes documentation and license files, generates Debian package metadata, and builds the package using fakeroot. The script also manages temporary files and provides progress notifications.


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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 05 Milestone: Second quarter release size/medium PR with more then 50 and less then 250 lines Needs review Seeking for review Framework Framework components labels May 21, 2025
@EvilOlaf
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented May 21, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (3)
extensions/linux-source-package.sh (3)

1-1: Add a shebang or shell directive
Specify the interpreter to satisfy ShellCheck (SC2148) and ensure consistent execution. For example, add at the top:

+#!/usr/bin/env bash
🧰 Tools
🪛 Shellcheck (0.10.0)

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

(SC2148)


19-21: Scope variables locally and quote values
Use local for function-scoped variables and quote interpolations for safety:

-declare kernel_work_dir="${SRC}/cache/sources/${LINUXSOURCEDIR}"
-declare CHOSEN_KSRC=linux-source-${BRANCH}-${LINUXFAMILY}
+local kernel_work_dir="${SRC}/cache/sources/${LINUXSOURCEDIR}"
+local CHOSEN_KSRC="linux-source-${BRANCH}-${LINUXFAMILY}"

31-33: Quote paths and handle failures when compressing config
Ensure file paths are quoted and errors are propagated:

-cp "${SRC}/config/kernel/${LINUXCONFIG}.config" "default_${LINUXCONFIG}.config"
-xz < ${kernel_work_dir}/.config > "${sources_pkg_dir}/usr/src/${LINUXCONFIG}_${version}_${REVISION}_config.xz"
+cp "${SRC}/config/kernel/${LINUXCONFIG}.config" "default_${LINUXCONFIG}.config" || exit 1
+xz < "${kernel_work_dir}/.config" > "${sources_pkg_dir}/usr/src/${LINUXCONFIG}_${version}_${REVISION}_config.xz" || exit 1
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d0f708d and 00b9ae4.

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

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

(SC2148)


[warning] 3-3: ARTIFACT_IGNORE_CACHE appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 4-4: KERNEL_GIT appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 16-16: kernel_version_family is referenced but not assigned.

(SC2154)


[warning] 25-25: ret is referenced but not assigned.

(SC2154)


[warning] 25-25: Use single quotes, otherwise this expands now rather than when signalled.

(SC2064)


[warning] 28-28: version is referenced but not assigned.

(SC2154)

🔇 Additional comments (2)
extensions/linux-source-package.sh (2)

3-4: Verify global variables are used by the build system
ShellCheck flags ARTIFACT_IGNORE_CACHE and KERNEL_GIT as unused (SC2034). Confirm these globals are consumed downstream or export/remove them accordingly.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 3-3: ARTIFACT_IGNORE_CACHE appears unused. Verify use (or export if used externally).

(SC2034)


[warning] 4-4: KERNEL_GIT appears unused. Verify use (or export if used externally).

(SC2034)


53-58: Verify DEB_STORAGE and enforce error propagation
Ensure that ${DEB_STORAGE} is defined and writable so rsync doesn't fail silently. Also, make sure fakeroot dpkg-deb errors halt the build (e.g., via set -e or || exit 1).

Comment on lines +23 to +27
local sources_pkg_dir tmp_src_dir
tmp_src_dir=$(mktemp -d)
trap "ret=\$?; rm -rf \"${tmp_src_dir}\" ; exit \$ret" 0 1 2 3 15
sources_pkg_dir=${tmp_src_dir}/${CHOSEN_KSRC}_${REVISION}_all
mkdir -p "${sources_pkg_dir}"/usr/src/ \
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

Improve trap quoting and exit handling
The trap uses double quotes causing premature expansion and references ret before assignment (SC2064, SC2154). A more robust pattern is:

-trap "ret=\$?; rm -rf \"${tmp_src_dir}\" ; exit \$ret" 0 1 2 3 15
+trap 'rc=$?; rm -rf "'"${tmp_src_dir}"'"; exit $rc' 0 1 2 3 15

Alternatively, simplify to:

trap 'rm -rf "${tmp_src_dir}"' EXIT INT TERM
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 25-25: ret is referenced but not assigned.

(SC2154)


[warning] 25-25: Use single quotes, otherwise this expands now rather than when signalled.

(SC2064)

🤖 Prompt for AI Agents
In extensions/linux-source-package.sh around lines 23 to 27, the trap command
uses double quotes causing premature variable expansion and references the
variable ret before it is assigned. To fix this, replace the double quotes with
single quotes in the trap command to delay expansion, or simplify the trap to
just remove the temporary directory on EXIT, INT, and TERM signals without
capturing the exit code. For example, use trap 'rm -rf "${tmp_src_dir}"' EXIT
INT TERM to ensure proper cleanup without premature expansion or undefined
variable usage.

EvilOlaf and others added 2 commits May 21, 2025 08:11
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@The-going
Copy link
Contributor

It spits out some sort of kernel source package, but I think {version} is still missing since I couldn't get it to work and probably needs more fixes until production-ready. I probably won't go further here due to lacking expertise in framework and bash foo.

Maybe someone want to pick it up from here.

Also to do: Re-enable BUILD_KSRC switch to enable the extension.

In the previous branch, the package contained only the archive and additional actions were required locally on the system to make it work.

I'll see what I can do about it.

@igorpecovnik igorpecovnik added Work in progress Unfinished / work in progress and removed Needs review Seeking for review labels Jun 3, 2025
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 Help needed We need your involvement size/medium PR with more then 50 and less then 250 lines Work in progress Unfinished / work in progress
Development

Successfully merging this pull request may close these issues.

3 participants