Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import logging
import click

from kt.commands.checkout.command import checkout
from kt.commands.content_release.command import content_release
from kt.commands.git_push.command import git_push
from kt.commands.list_kernels.command import list_kernels
from kt.commands.setup.command import setup
Expand All @@ -30,6 +31,7 @@ def main():
cli.add_command(checkout)
cli.add_command(git_push)
cli.add_command(vm)
cli.add_command(content_release)
cli()


Expand Down
2 changes: 2 additions & 0 deletions kernel_install_dep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ install_kselftest_deps_10() {
iptables \
iputils \
ipvsadm \
jq \
kernel-devel \
kernel-selftests-internal \
kernel-tools \
Expand All @@ -179,6 +180,7 @@ install_kselftest_deps_10() {
llvm \
ncurses-devel \
net-tools \
netsniff-ng \
nftables \
nmap-ncat \
numactl-devel \
Expand Down
55 changes: 55 additions & 0 deletions kt/KT.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,58 @@ and then
```
<config.base_path>/kernel-src-tree-tools/kernel-kselftest.sh
```

### kt content-release

Manages the complete content release workflow for kernel packages. This command
automates the process of preparing, building, and testing kernel releases.

The command has three steps that can be run individually or all together:

#### --prepare
Prepares the content release by:
- Validating git user.name and user.email are configured
- Running mkdistgitdiff.py to generate the staging branch and release files
- Checking out the staging branch {automation_tmp}_<src_branch>
- Creating and displaying the new release tag

#### --build
Builds kernel RPMs by:
- Verifying mock is installed and user is in mock group
- Checking DEPOT_USER and DEPOT_TOKEN environment variables are set
- Creating a temporary mock config with depot credentials
- Downloading sources using getsrc.sh
- Building SRPM with mock
- Building binary RPMs from the SRPM
- Listing all created RPMs

Requirements:
- mock must be installed
- User must be in the mock group
- DEPOT_USER and DEPOT_TOKEN environment variables must be set

#### --test
Tests the built kernel by:
- Spinning up a VM (creates if needed, boots if stopped)
- Installing the built kernel RPMs from build_files
- Rebooting the VM
- Running kselftests using /usr/libexec/kselftests/run_kselftest.sh
- Reporting number of tests passed

Output logs:
- install.log: RPM installation output
- selftest-<kernel_version>.log: Kselftest results

#### Example:

Run all steps:
```
$ DEPOT_USER=user@example.com DEPOT_TOKEN=token kt content-release lts-9.2
```

Run individual steps:
```
$ kt content-release lts-9.2 --prepare
$ DEPOT_USER=user@example.com DEPOT_TOKEN=token kt content-release lts-9.2 --build
$ kt content-release lts-9.2 --test
```
75 changes: 75 additions & 0 deletions kt/commands/content_release/command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import click

from kt.commands.content_release.impl import run_prepare, run_build, run_test
from kt.ktlib.shell_completion import ShellCompletion

epilog = """
Manages the complete content release workflow for kernel packages.

This command automates the kernel content release process through three steps:

--prepare: Validates git config, runs mkdistgitdiff.py to create staging branch,
and creates a new tagged release in the src_worktree.

--build: Builds both source and binary RPMs using mock. Downloads sources via
getsrc.sh and builds kernel packages in build_files directory.
Requires DEPOT_USER and DEPOT_TOKEN environment variables.

--test: Spins up a VM, installs the built kernel RPMs, reboots, and runs
kselftests using /usr/libexec/kselftests/run_kselftest.sh.

When run without options, executes all three steps sequentially.

Examples:

\b
$ DEPOT_USER=user@example.com DEPOT_TOKEN=token kt content-release lts-9.2
\b
$ kt content-release lts-9.2 --prepare
\b
$ DEPOT_USER=user@example.com DEPOT_TOKEN=token kt content-release lts-9.2 --build
\b
$ kt content-release lts-9.2 --test
"""


@click.command(epilog=epilog)
@click.argument("kernel_workspace", required=True, shell_complete=ShellCompletion.show_kernel_workspaces)
@click.option(
"--prepare",
is_flag=True,
help="Run only the prepare step",
)
@click.option(
"--build",
is_flag=True,
help="Run only the build step",
)
@click.option(
"--test",
is_flag=True,
help="Run only the test step",
)
def content_release(kernel_workspace, prepare, build, test):
"""Manage content release workflow (prepare, build, test)."""

# Check if any specific step was requested
any_step_specified = prepare or build or test

# Determine which steps to run
run_prepare_step = prepare or not any_step_specified
run_build_step = build or not any_step_specified
run_test_step = test or not any_step_specified

if not any_step_specified:
click.echo(f"Running all content-release steps for {kernel_workspace}: prepare, build, test")

# Run the selected steps
if run_prepare_step:
run_prepare(kernel_workspace=kernel_workspace)

if run_build_step:
run_build(kernel_workspace=kernel_workspace)

if run_test_step:
run_test(kernel_workspace=kernel_workspace)
Loading
Loading