1212
1313from kt .ktlib .config import Config
1414from kt .ktlib .kernel_workspace import KernelWorkspace
15+ from kt .ktlib .kernels import KernelsInfo
1516from kt .ktlib .ssh import SshCommand
1617from kt .ktlib .util import Constants
1718from kt .ktlib .virt import VirtHelper , VmCommand
@@ -259,11 +260,89 @@ def test(self, config):
259260
260261 self .kselftests (config = config )
261262
263+ def content_release (self , config ):
264+ logging .debug ("Running mkdistgitdiff" )
265+ mkdistgitdiff = str (config .base_path / Path ("kernel-tools" ) / Path ("mkdistgitdiff.py" ))
266+ output_file = self .kernel_workspace .folder .absolute () / Path (
267+ f"mkdistgitdiff.log"
268+ )
269+
270+ # mkdistgitdiff needs these to be set
271+ ssh_cmd = f"git config --global user.name \" { config .user } \" "
272+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
273+ ssh_cmd = f"git config --global user.email { config .email } "
274+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
275+
276+ ssh_cmd = (f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && { mkdistgitdiff } "
277+ f"--srcgit { self .kernel_workspace .src_worktree .folder .absolute ()} "
278+ f"--srcgit-branch { self .kernel_workspace .src_worktree .local_branch } "
279+ f"--distgit . "
280+ f"--distgit-branch { self .kernel_workspace .dist_worktree .local_branch } "
281+ f"--last-tag "
282+ f"--bump" )
283+ SshCommand .run_with_output (output_file = output_file , domain = self .domain , command = [ssh_cmd ])
284+
285+ ssh_cmd = (f"git -C { self .kernel_workspace .dist_worktree .folder .absolute ()} "
286+ f"checkout {{${{USER}}}}_{ self .kernel_workspace .src_worktree .local_branch } " )
287+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
288+
289+ ssh_cmd = (f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && "
290+ f"curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/getsrc/getsrc.sh" )
291+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
292+
293+ ssh_cmd = f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && chmod +x ./getsrc.sh && ./getsrc.sh"
294+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
295+
296+ ssh_cmd = f"cd { self .kernel_workspace .folder } && mkdir build_files"
297+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
298+
299+ mock_configs_path = str (config .base_path / Path ("mock-configs" ))
300+
301+ # Get the mock_config from kernels.yaml
302+ kernels_info = KernelsInfo .from_yaml (config = config )
303+ kernel_name = Vm ._extract_kernel_name (self .kernel_workspace .folder .name )
304+ mock_config = kernels_info .kernels [kernel_name ].mock_config
305+
306+ ssh_cmd = (f"cd { self .kernel_workspace .folder } && "
307+ f"cp { mock_configs_path } /{ mock_config } ${{USER}}_{ mock_config } && "
308+ f"sed -i 's/DEPOT_USER/{ config .depot_user } /g' ${{USER}}_{ mock_config } && "
309+ f"sed -i 's/DEPOT_TOKEN/{ config .depot_token } /g' ${{USER}}_{ mock_config } " )
310+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
311+
312+ ssh_cmd = f"sudo usermod -a -G mock ${{USER}}"
313+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
314+
315+ ssh_cmd = (f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && "
316+ f"mock -v -r ../${{USER}}_{ mock_config } --resultdir={ self .kernel_workspace .folder .absolute ()} /build_files --buildsrpm "
317+ f"--spec=SPECS/kernel.spec --sources=SOURCES" )
318+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
319+
320+ ssh_cmd = (f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && "
321+ f"mock -v -r ../${{USER}}_{ mock_config } --resultdir={ self .kernel_workspace .folder .absolute ()} /build_files "
322+ f"{ self .kernel_workspace .folder .absolute ()} /build_files/*.src.rpm" )
323+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
324+
325+ ssh_cmd = (f"cd { self .kernel_workspace .folder } && "
326+ f"rm ${{USER}}_{ mock_config } " )
327+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
328+
329+ ssh_cmd = (f"cd { self .kernel_workspace .folder } && "
330+ f"sudo dnf install $(find build_files -maxdepth 1 -name '*.rpm' -not -name '*.src.rpm' -not -name 'kernel-rt*.rpm' -not -name 'kernel-debug-*.rpm') -y" )
331+ output_file = self .kernel_workspace .folder .absolute () / Path (
332+ f"install.log"
333+ )
334+ SshCommand .run_with_output (output_file = output_file , domain = self .domain , command = [ssh_cmd ])
335+
336+ self .reboot ()
337+
338+ ssh_cmd = f"sudo /usr/libexec/kselftests/run_kselftest.sh | tee { self .kernel_workspace .folder .absolute ()} /selftest-$(uname -r).log"
339+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
340+
262341 def console (self ):
263342 VmCommand .console (vm_name = self .name )
264343
265344
266- def main (name : str , console : bool , destroy : bool , override : bool , list_all : bool , test : bool = False ):
345+ def main (name : str , console : bool , destroy : bool , override : bool , list_all : bool , test : bool = False , content_release : bool = False ):
267346 if list_all :
268347 VmCommand .list_all ()
269348 return
@@ -289,5 +368,11 @@ def main(name: str, console: bool, destroy: bool, override: bool, list_all: bool
289368 time .sleep (Constants .VM_DEPS_INSTALL_WAIT_SECONDS )
290369 vm_instance .test (config = config )
291370
371+ if content_release :
372+ # Wait for the dependencies to be installed
373+ logging .info ("Waiting for the deps to be installed" )
374+ #time.sleep(Constants.VM_DEPS_INSTALL_WAIT_SECONDS)
375+ vm_instance .content_release (config = config )
376+
292377 if console :
293378 vm_instance .console ()
0 commit comments