Repository: cobbler/cobbler

Issue:
[3.3] /usr/lib/PXELINUX/linux.c32 does not exist, can't create a symlink to it
### Describe the bug

I'm testing branch `release33`. The command `cobbler mkloaders` fails on a fresh install.

```
root@cobblerlab334:~# cobbler mkloaders
task started: 2024-01-31_235056_mkloaders
task started (id=Create bootable bootloader images, time=Wed Jan 31 23:50:56 2024)
Exception occurred: <class 'FileNotFoundError'>
Exception value: /usr/lib/PXELINUX/linux.c32 does not exist, can't create a symlink to it.
Exception Info:
!!! TASK FAILED !!!
```

This seems to be related to #3477. If I comment out the changes to `cobbler/actions/mkloaders.py`, then the task completes.

https://github.com/cobbler/cobbler/blob/7d369dc095b33602f099899594311f9bf3137482/cobbler/actions/mkloaders.py#L149-L163

### Steps to reproduce

1. Build DEBS for Debian 12 from branch `release33`
2. Install cobbler on Debian 12
3. Run `cobbler mkloaders`

### Expected behavior

```
# cobbler mkloaders
task started: 2024-02-01_001832_mkloaders
task started (id=Create bootable bootloader images, time=Thu Feb  1 00:18:32 2024)
GRUB2 modules directory for arch "aarch64" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "arm" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "arm64-efi" did no exist. Skipping GRUB2 creation
Successfully built bootloader for arch "i386-efi"!
GRUB2 modules directory for arch "i386-pc-pxe" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "i686" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "IA64" did no exist. Skipping GRUB2 creation
GRUB2 modules directory for arch "powerpc-ieee1275" did no exist. Skipping GRUB2 creation
Successfully built bootloader for arch "x86_64-efi"!
*** TASK COMPLETE ***
```

### Cobbler version

Branch `release33`.

````
# cobbler version
Cobbler 3.3.3
  source: ?, ?
  build time: Wed Jan 31 22:57:53 2024
````

### Operating system

Debian 12

### Cobbler log

````
[Thread-10 (process_request_thread)] 2024-01-31T23:50:56 - INFO | REMOTE start_task(Create bootable bootloader images); event_id(2024-01-31_235056_mkloaders); user(?)
[2024-01-31_235056_mkloaders] 2024-01-31T23:50:57 - INFO | Exception occurred: <class 'FileNotFoundError'>
[2024-01-31_235056_mkloaders] 2024-01-31T23:50:57 - INFO | Exception value: /usr/lib/PXELINUX/linux.c32 does not exist, can't create a symlink to it.
[2024-01-31_235056_mkloaders] 2024-01-31T23:50:57 - INFO | Exception Info:
  File "/usr/lib/python3/dist-packages/cobbler/remote.py", line 103, in run
    rc = self._run(self)
         ^^^^^^^^^^^^^^^

  File "/usr/lib/python3/dist-packages/cobbler/remote.py", line 405, in runner
    return self.api.mkloaders()
           ^^^^^^^^^^^^^^^^^^^^

  File "/usr/lib/python3/dist-packages/cobbler/api.py", line 2038, in mkloaders
    action.run()

  File "/usr/lib/python3/dist-packages/cobbler/actions/mkloaders.py", line 53, in run
    self.make_syslinux()

  File "/usr/lib/python3/dist-packages/cobbler/actions/mkloaders.py", line 152, in make_syslinux
    symlink(

  File "/usr/lib/python3/dist-packages/cobbler/actions/mkloaders.py", line 233, in symlink
    raise FileNotFoundError(

[2024-01-31_235056_mkloaders] 2024-01-31T23:50:57 - ERROR | ### TASK FAILED ###
````

### Additional information

```
root@cobblerlab334:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
```
```
root@cobblerlab334:~# dpkg -l syslinux
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version                                Architecture Description
+++-==============-======================================-============-=======================================================
ii  syslinux       3:6.04~git20190206.bf6db5b4+dfsg1-3+b1 amd64        collection of bootloaders (DOS FAT and NTFS bootloader)
```
```
root@cobblerlab334:~# find /usr/ -name libcom32.c32
/usr/lib/syslinux/modules/efi32/libcom32.c32
/usr/lib/syslinux/modules/efi64/libcom32.c32
/usr/lib/syslinux/modules/bios/libcom32.c32
```


Discussion:
I have no idea of the path in wimboot, but it seems that the check of the path is somewhat broken.

I can make `cobbler mkloaders` work with the patch below:

```
$ git diff
diff --git a/cobbler/actions/mkloaders.py b/cobbler/actions/mkloaders.py
index 029ee5b4..51c2793b 100644
--- a/cobbler/actions/mkloaders.py
+++ b/cobbler/actions/mkloaders.py
@@ -147,7 +147,7 @@ class MkLoaders:
             skip_existing=True
         )
         # Make linux.c32 for syslinux + wimboot
-        libcom32_c32_path = self.syslinux_folder.joinpath("libcom32.c32")
+        libcom32_c32_path = self.syslinux_pxelinux_folder.joinpath("libcom32.c32")
         if syslinux_version > 4 and libcom32_c32_path.exists():
             symlink(
                 self.syslinux_pxelinux_folder.joinpath("linux.c32"),
```

@tpw56j would a check of the path `self.syslinux_pxelinux_folder.joinpath("libcom32.c32")` instead of `self.syslinux_folder.joinpath("libcom32.c32")` work with syslinux + wimboot?
@btravouillon Could you share the part of your settings for the bootloader paths? I think that this may be relevant since the paths are different between many distros and if the build somehow detected the wrong distro or we missed something in our build scripts for Debian 12 then this might also occur.
@btravouillon There is a bug in this place. It should be like this:
```diff
@@ -150,14 +150,14 @@
         libcom32_c32_path = self.syslinux_folder.joinpath("libcom32.c32")
         if syslinux_version > 4 and libcom32_c32_path.exists():
             symlink(
-                self.syslinux_pxelinux_folder.joinpath("linux.c32"),
+                self.syslinux_folder.joinpath("linux.c32"),
                 self.bootloaders_dir.joinpath("linux.c32"),
                 skip_existing=True,
             )
             # Make libcom32.c32
             # 'linux.c32' depends on 'libcom32.c32'
             symlink(
-                self.syslinux_pxelinux_folder.joinpath("libcom32.c32"),
+                self.syslinux_folder.joinpath("libcom32.c32"),
                 self.bootloaders_dir.joinpath("libcom32.c32"),
                 skip_existing=True,
             )
```
This was the other way. :rofl: 
Anyway, this solves the issue as well, thanks!

This may have to be fixed in `main` first. Should I open a PR?

Resolving patch:
diff --git a/cobbler/actions/mkloaders.py b/cobbler/actions/mkloaders.py
--- a/cobbler/actions/mkloaders.py
+++ b/cobbler/actions/mkloaders.py
@@ -171,14 +171,14 @@ def make_syslinux(self) -> None:
         libcom32_c32_path = self.syslinux_folder.joinpath("libcom32.c32")
         if syslinux_version > 4 and libcom32_c32_path.exists():
             symlink(
-                self.syslinux_pxelinux_folder.joinpath("linux.c32"),
+                self.syslinux_folder.joinpath("linux.c32"),
                 self.bootloaders_dir.joinpath("linux.c32"),
                 skip_existing=True,
             )
             # Make libcom32.c32
             # 'linux.c32' depends on 'libcom32.c32'
             symlink(
-                self.syslinux_pxelinux_folder.joinpath("libcom32.c32"),
+                self.syslinux_folder.joinpath("libcom32.c32"),
                 self.bootloaders_dir.joinpath("libcom32.c32"),
                 skip_existing=True,
             )


Test patch: