Finalized Automation scripts for x86-64 RT kernel Upgrade #345
Finalized Automation scripts for x86-64 RT kernel Upgrade #345jatinjb444 wants to merge 4 commits into
Conversation
|
Please run flake8 ( python3 -m flake8 ) on all the python files and fix all the issues we can. Some of them could be fixed by running black (python3 -m black ). |
dbeefde to
e0fcb85
Compare
5328398 to
4709c45
Compare
- Install kernel on target with reboot and SSH readiness checks. - Rebuild out-of-tree drivers automatically using DKMS. - Kernel source is mounted via SSHFS to avoid local copy. - Fix build/source symlinks and prepare kernel headers. Verified on real NI RT target with DKMS-managed drivers. Signed-off-by: Jatin Bharti <jatin.bharti@emerson.com>
Signed-off-by: Jatin Bharti <jatin.bharti@emerson.com>
…ndling , formatted and cleaned up json.config Signed-off-by: Jatin Bharti <jatin.bharti@emerson.com>
|
|
||
| def __init__(self, automation_conf_path, work_item_id): | ||
| with open(automation_conf_path, "r", encoding="utf-8") as file: | ||
| def __init__(self, config_path, work_item_id): |
There was a problem hiding this comment.
Any particular reason to rename it?
There was a problem hiding this comment.
It is to make sure that the json config file is a generic config loader file, and not tied to work with automation_conf only.
| self.ssh_connection = config.get("ssh_connection") | ||
| # Kernel build configuration (optional section) | ||
| kernel_config = config.get("kernel_build", {}) | ||
| # Expand environment variables in paths |
There was a problem hiding this comment.
I don't see the need for using environment variables
There was a problem hiding this comment.
Yeah , i have changed it to standardize the overall json config file and use the paths explicitly.
| self.work_item_id = config.get("work_item_id", "") | ||
| self.ssh_target = kernel_config.get("ssh_target") | ||
|
|
||
| def _expand_path(self, path): |
There was a problem hiding this comment.
If we aren't making use of any environment variables, then this can be removed.
There was a problem hiding this comment.
Agreed — since we’re not relying on environment variable expansion right now, I can remove _expand_path and keep the paths explicit.
| return 1 | ||
|
|
||
|
|
||
| def run_cmd(cmd): |
There was a problem hiding this comment.
Is run_cmd any different from run_command in its usage and implementation? It would be better to use run_command .
There was a problem hiding this comment.
Yes—run_cmd differs intentionally. run_command relies on shlex.split, which breaks SSH commands that include shell operators (||, &&, pipes, quoted remote commands). The rebuild/install steps depend on shell semantics, so run_cmd executes via the shell to preserve existing behavior.
|
|
||
| git_fetch("origin") | ||
| git_checkout(config.target_branch, create=True, force_checkout=True) | ||
| git_reset(hard=True, target=f"origin/{config.target_branch}") |
There was a problem hiding this comment.
As the ni/linux repo will be freshly cloned, I don't really see the need for git_merge_abort(), git_reset(), git_clean().
There was a problem hiding this comment.
It was just added for an extra check, but yes it can be removed if we are assuming it will work for cloning freshly every time .
| print("[INFO] Cloning kernel repository") | ||
|
|
||
| repo = os.path.abspath(config.kernel_src_dir) | ||
| config.kernel_src_dir = repo |
There was a problem hiding this comment.
Sure , i have handled it in the json_config.py
| git_reset(hard=True, target=f"origin/{config.target_branch}") | ||
|
|
||
| _, remotes = git_remote() | ||
| if "stable-rt" not in remotes: |
There was a problem hiding this comment.
Is there a reason to not use kernel_repo.add_remote()?
There was a problem hiding this comment.
so since we already have a GitRepo instance here, I’ve switched to using kernel_repo.add_remote() to keep git operations encapsulated and consistent
Signed-off-by: Jatin Bharti <jatin.bharti@emerson.com>
Changes
This PR introduces automation to fetch and merge the latest stable‑RT kernel tags into the target NI Linux Real‑Time branch.
Key changes:
Automatically clone the NI Linux kernel repository in a clean workspace.
Fetch upstream stable‑RT tags from the RT kernel repository.
Identify and merge the latest applicable RT tag into the configured target branch.
Ensure a deterministic and clean git state before merging to support re‑runs and CI usage.
Send notification emails on successful merge or on merge failure with relevant details.
This automation is focused only on the fetch and merge workflow.
Kernel build and deployment steps will be added in follow‑up changes.
Update: April 14th , 2026
Get the Cross Compile toolchain from the nirvana path and set it
Build and install the kernel on the NI's target
Copied the modules to the target
Check the network configurations working fine after reboot
Update: May 5th , 2026
Automates out‑of‑tree driver rebuild after kernel installation.
Mounts kernel source on the target via SSHFS (no local copy).
Fixes build and source symlinks under /lib/modules/.
Prepares kernel headers and invokes dkms auto install.
Integrated into the existing kernel build and test flow
Update: May 7th , 2026
Implements US‑4 and US‑5 automation:
Regenerates nati_x86_64_defconfig when required
Adds gated kernel PR creation after successful RT merge, build, install, and driver rebuild
Failure paths send immediate notification; success sends a single final summary email
Kernel PR creation is guarded behind --skip-push-and-pr and is intended to be enabled only after review.
Testing
The changes were validated by:
Running the script in a fresh workspace to verify repository cloning and RT tag discovery.
Verifying that the latest stable‑RT tag is correctly detected and merged.
After the target reboot , was able to check the latest kernel version using - { uname -r }
Verified the network modules working fine after reboot.
Confirmed SSHFS mount, header preparation, and DKMS rebuild.
Validated rebuilt drivers using dkms status.
Process
Suggested Reviewers:
@rajendra-desai-ni
@Shreejit-03