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,106 @@ 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 ("mkdistgitdiff.log" )
267+
268+ # mkdistgitdiff needs these to be set
269+ ssh_cmd = f'git config --global user.name "{ config .user } "'
270+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
271+ ssh_cmd = f"git config --global user.email { config .email } "
272+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
273+
274+ ssh_cmd = (
275+ f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && { mkdistgitdiff } "
276+ f"--srcgit { self .kernel_workspace .src_worktree .folder .absolute ()} "
277+ f"--srcgit-branch { self .kernel_workspace .src_worktree .local_branch } "
278+ f"--distgit . "
279+ f"--distgit-branch { self .kernel_workspace .dist_worktree .local_branch } "
280+ f"--last-tag "
281+ f"--bump"
282+ )
283+ SshCommand .run_with_output (output_file = output_file , domain = self .domain , command = [ssh_cmd ])
284+
285+ ssh_cmd = (
286+ f"git -C { self .kernel_workspace .dist_worktree .folder .absolute ()} "
287+ f"checkout {{${{USER}}}}_{ self .kernel_workspace .src_worktree .local_branch } "
288+ )
289+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
290+
291+ ssh_cmd = (
292+ f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && "
293+ f"curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/getsrc/getsrc.sh"
294+ )
295+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
296+
297+ ssh_cmd = f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && chmod +x ./getsrc.sh && ./getsrc.sh"
298+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
299+
300+ ssh_cmd = f"cd { self .kernel_workspace .folder } && mkdir -p build_files"
301+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
302+
303+ mock_configs_path = str (config .base_path / Path ("mock-configs" ))
304+
305+ # Get the mock_config from kernels.yaml
306+ kernels_info = KernelsInfo .from_yaml (config = config )
307+ kernel_name = Vm ._extract_kernel_name (self .kernel_workspace .folder .name )
308+ mock_config = kernels_info .kernels [kernel_name ].mock_config
309+
310+ ssh_cmd = (
311+ f"cd { self .kernel_workspace .folder } && "
312+ f"cp { mock_configs_path } /{ mock_config } ${{USER}}_{ mock_config } && "
313+ f"sed -i 's/DEPOT_USER/{ config .depot_user } /g' ${{USER}}_{ mock_config } && "
314+ f"sed -i 's/DEPOT_TOKEN/{ config .depot_token } /g' ${{USER}}_{ mock_config } "
315+ )
316+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
317+
318+ ssh_cmd = "sudo usermod -a -G mock ${USER}"
319+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
320+
321+ ssh_cmd = (
322+ f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && "
323+ f"mock -v -r ../${{USER}}_{ mock_config } --resultdir={ self .kernel_workspace .folder .absolute ()} /build_files --buildsrpm "
324+ f"--spec=SPECS/kernel.spec --sources=SOURCES"
325+ )
326+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
327+
328+ ssh_cmd = (
329+ f"cd { self .kernel_workspace .dist_worktree .folder .absolute ()} && "
330+ f"mock -v -r ../${{USER}}_{ mock_config } --resultdir={ self .kernel_workspace .folder .absolute ()} /build_files "
331+ f"{ self .kernel_workspace .folder .absolute ()} /build_files/*.src.rpm"
332+ )
333+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
334+
335+ ssh_cmd = f"cd { self .kernel_workspace .folder } && rm ${{USER}}_{ mock_config } "
336+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
337+
338+ ssh_cmd = (
339+ f"cd { self .kernel_workspace .folder } && "
340+ 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"
341+ )
342+ output_file = self .kernel_workspace .folder .absolute () / Path ("install.log" )
343+ SshCommand .run_with_output (output_file = output_file , domain = self .domain , command = [ssh_cmd ])
344+
345+ self .reboot ()
346+
347+ ssh_cmd = f"sudo /usr/libexec/kselftests/run_kselftest.sh | tee { self .kernel_workspace .folder .absolute ()} /selftest-$(uname -r).log"
348+ SshCommand .run (domain = self .domain , command = [ssh_cmd ])
349+
262350 def console (self ):
263351 VmCommand .console (vm_name = self .name )
264352
265353
266- def main (name : str , console : bool , destroy : bool , override : bool , list_all : bool , test : bool = False ):
354+ def main (
355+ name : str ,
356+ console : bool ,
357+ destroy : bool ,
358+ override : bool ,
359+ list_all : bool ,
360+ test : bool = False ,
361+ content_release : bool = False ,
362+ ):
267363 if list_all :
268364 VmCommand .list_all ()
269365 return
@@ -289,5 +385,11 @@ def main(name: str, console: bool, destroy: bool, override: bool, list_all: bool
289385 time .sleep (Constants .VM_DEPS_INSTALL_WAIT_SECONDS )
290386 vm_instance .test (config = config )
291387
388+ if content_release :
389+ # Wait for the dependencies to be installed
390+ logging .info ("Waiting for the deps to be installed" )
391+ # time.sleep(Constants.VM_DEPS_INSTALL_WAIT_SECONDS)
392+ vm_instance .content_release (config = config )
393+
292394 if console :
293395 vm_instance .console ()
0 commit comments