-
-
Notifications
You must be signed in to change notification settings - Fork 3k
kernel: improve Git repository detection for KernelSU versioning #3108
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
Conversation
44a4d55 to
23ede6c
Compare
ff3c78d to
684973d
Compare
d90ce42 to
c75edf8
Compare
5ec1cff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensuring that Kernel(KDIR)'s git root directory and MDIR(KernelSU)'s git root directory are different was based on the assumption that KernelSU and the kernel are located in different repositories. Checking this ensures that the commit count obtained comes from the KernelSU repository and not the kernel repository.
|
Why too slow? |
For integrating kernelsu without using git submodule, the speed is unacceptable. |
|
More precisely, since it is built within the tree, not explicitly passing KDIR causes KERNEL_GIT_ROOT to be empty. Changing it to $(srctree) resolves this issue. |
|
你可以讲讲有什么集成方式,如果你的集成方式完全没有 KernelSU 的原始仓库,那根本不需要数提交来获取版本号 |
手动复制和通过 git submodule 两种方式 |
|
如果是要兼容手动复制的方法,改这个的意义是什么? |
|
#2102 和 pr 的描述我想说的已经很清楚了 |
The previous logic for detecting the Git repository in KernelSU's Kbuild assumed two distinct build scenarios—in-tree (as a submodule) and out-of-tree (standalone)—and used hardcoded path checks (e.g., `$(srctree)/$(src)/../.git` or `$(MDIR)/../.git`) to differentiate them. This approach is fragile, sensitive to directory layout changes, and fails in more complex repository structures (e.g., subtrees, nested worktrees, or non-standard submodules). This commit replaces the ad-hoc path inspection with `git rev-parse --show-toplevel`, which reliably determines the root of the containing Git repository from any subdirectory. This eliminates the need to distinguish between in-tree and out-of-tree builds and unifies the version detection logic into a single, robust code path. Additionally: - Removes the use of `realpath`, improving compatibility with older or minimal build environments where `realpath` may be unavailable. - Retains shallow-clone handling by unshallowing the repository before counting commits, ensuring accurate version numbers. - Adds an informative build message (`$(info ...)`) to indicate when a Git repository is successfully detected, aiding debuggability. This change makes KernelSU's build system more portable, maintainable, and resilient across diverse development and integration workflows. Signed-off-by: dabao1955 <[email protected]>
The previous logic for detecting the Git repository in KernelSU's Kbuild assumed two distinct build scenarios—in-tree (as a submodule) and out-of-tree (standalone)—and used hardcoded path checks (e.g.,
$(srctree)/$(src)/../.gitor$(MDIR)/../.git) to differentiate them. This approach is fragile, sensitive to directory layout changes, and fails in more complex repository structures (e.g., subtrees, nested worktrees, or non-standard submodules).This commit replaces the ad-hoc path inspection with
git rev-parse --show-toplevel, which reliably determines the root of the containing Git repository from any subdirectory. This eliminates the need to distinguish between in-tree and out-of-tree builds and unifies the version detection logic into a single, robust code path.Additionally:
realpath, improving compatibility with older or minimal build environments whererealpathmay be unavailable.$(info ...)) to indicate when a Git repository is successfully detected, aiding debuggability.This change makes Kbuild more portable, maintainable, and resilient across diverse development and integration workflows.