290 lines
12 KiB
Diff
290 lines
12 KiB
Diff
From 704be6fc9efd009c8f1da9abdb626e7fb18c86bb Mon Sep 17 00:00:00 2001
|
|
From: sun_hai_10 <sunhai10@huawei.com>
|
|
Date: Fri, 28 Mar 2025 01:51:43 +0800
|
|
Subject: [PATCH] adapt vendor
|
|
|
|
---
|
|
cobbler/actions/buildiso.py | 22 ++++++++++-----------
|
|
cobbler/actions/check.py | 2 +-
|
|
cobbler/actions/reposync.py | 2 +-
|
|
cobbler/autoinstallgen.py | 2 +-
|
|
cobbler/tftpgen.py | 2 +-
|
|
cobbler/utils.py | 4 +++-
|
|
config/cobbler/distro_signatures.json | 28 +++++++++++++++++++++++++++
|
|
distro_build_configs.sh | 5 ++++-
|
|
templates/etc/dhcp.template | 10 +++++-----
|
|
9 files changed, 55 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/cobbler/actions/buildiso.py b/cobbler/actions/buildiso.py
|
|
index f1be922..e469535 100644
|
|
--- a/cobbler/actions/buildiso.py
|
|
+++ b/cobbler/actions/buildiso.py
|
|
@@ -220,7 +220,7 @@ class BuildIso:
|
|
else:
|
|
append_line += " autoyast=%s" % data["autoinstall"]
|
|
|
|
- if dist.breed == "redhat":
|
|
+ if dist.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
if "proxy" in data and data["proxy"] != "":
|
|
append_line += " proxy=%s http_proxy=%s" % (data["proxy"], data["proxy"])
|
|
if dist.os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
|
|
@@ -273,7 +273,7 @@ class BuildIso:
|
|
else:
|
|
append_line += " autoyast=%s" % data["autoinstall"]
|
|
|
|
- if dist.breed == "redhat":
|
|
+ if dist.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
if "proxy" in data and data["proxy"] != "":
|
|
append_line += " proxy=%s http_proxy=%s" % (data["proxy"], data["proxy"])
|
|
if dist.os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
|
|
@@ -312,7 +312,7 @@ class BuildIso:
|
|
my_mask = None
|
|
my_gw = None
|
|
my_dns = None
|
|
- if dist.breed in ["suse", "redhat"]:
|
|
+ if dist.breed in ["suse", "redhat", "generic_lower_os"]:
|
|
if "netmask" in data["kernel_options"] and data["kernel_options"]["netmask"] != "":
|
|
my_mask = data["kernel_options"]["netmask"]
|
|
del data["kernel_options"]["netmask"]
|
|
@@ -320,7 +320,7 @@ class BuildIso:
|
|
my_gw = data["kernel_options"]["gateway"]
|
|
del data["kernel_options"]["gateway"]
|
|
|
|
- if dist.breed == "redhat":
|
|
+ if dist.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
if "ksdevice" in data["kernel_options"] and data["kernel_options"]["ksdevice"] != "":
|
|
my_int = data["kernel_options"]["ksdevice"]
|
|
if my_int == "bootif":
|
|
@@ -422,7 +422,7 @@ class BuildIso:
|
|
append_line += " netdevice=%s" % data["mac_address_" + my_int].lower()
|
|
else:
|
|
append_line += " netdevice=%s" % my_int
|
|
- if dist.breed == "redhat":
|
|
+ if dist.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
if intmac in data and data[intmac] != "":
|
|
append_line += " ksdevice=%s" % data["mac_address_" + my_int]
|
|
else:
|
|
@@ -433,19 +433,19 @@ class BuildIso:
|
|
if my_ip is not None:
|
|
if dist.breed == "suse":
|
|
append_line += " hostip=%s" % my_ip
|
|
- if dist.breed == "redhat":
|
|
+ if dist.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
append_line += " ip=%s" % my_ip
|
|
if dist.breed in ["ubuntu", "debian"]:
|
|
append_line += " netcfg/get_ipaddress=%s" % my_ip
|
|
|
|
if my_mask is not None:
|
|
- if dist.breed in ["suse", "redhat"]:
|
|
+ if dist.breed in ["suse", "redhat", "generic_lower_os"]:
|
|
append_line += " netmask=%s" % my_mask
|
|
if dist.breed in ["ubuntu", "debian"]:
|
|
append_line += " netcfg/get_netmask=%s" % my_mask
|
|
|
|
if my_gw is not None:
|
|
- if dist.breed in ["suse", "redhat"]:
|
|
+ if dist.breed in ["suse", "redhat", "generic_lower_os"]:
|
|
append_line += " gateway=%s" % my_gw
|
|
if dist.breed in ["ubuntu", "debian"]:
|
|
append_line += " netcfg/get_gateway=%s" % my_gw
|
|
@@ -456,7 +456,7 @@ class BuildIso:
|
|
append_line += " nameserver=%s" % ",".join(my_dns)
|
|
else:
|
|
append_line += " nameserver=%s" % my_dns
|
|
- if dist.breed == "redhat":
|
|
+ if dist.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
if type(my_dns) == list:
|
|
append_line += " dns=%s" % ",".join(my_dns)
|
|
else:
|
|
@@ -545,7 +545,7 @@ class BuildIso:
|
|
cfg.write(" kernel %s\n" % os.path.basename(distro.kernel))
|
|
|
|
append_line = " append initrd=%s" % os.path.basename(distro.initrd)
|
|
- if distro.breed == "redhat":
|
|
+ if distro.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
if distro.os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
|
|
append_line += " ks=cdrom:/isolinux/%s.cfg" % descendant.name
|
|
else:
|
|
@@ -566,7 +566,7 @@ class BuildIso:
|
|
elif descendant.COLLECTION_TYPE == 'system':
|
|
autoinstall_data = self.api.autoinstallgen.generate_autoinstall_for_system(descendant.name)
|
|
|
|
- if distro.breed == "redhat":
|
|
+ if distro.breed == "redhat" or dist.breed == "generic_lower_os":
|
|
cdregex = re.compile(r"^\s*url .*\n", re.IGNORECASE | re.MULTILINE)
|
|
autoinstall_data = cdregex.sub("cdrom\n", autoinstall_data, count=1)
|
|
|
|
diff --git a/cobbler/actions/check.py b/cobbler/actions/check.py
|
|
index 4fadab5..4893bf9 100644
|
|
--- a/cobbler/actions/check.py
|
|
+++ b/cobbler/actions/check.py
|
|
@@ -138,7 +138,7 @@ class CobblerCheck:
|
|
if notes != "":
|
|
notes = " (NOTE: %s)" % notes
|
|
return_code = 0
|
|
- if self.checked_family in ("redhat", "suse"):
|
|
+ if self.checked_family in ("redhat", "suse", "generic_lower_os"):
|
|
if os.path.exists("/etc/rc.d/init.d/%s" % which):
|
|
return_code = utils.subprocess_call(self.logger,
|
|
"/sbin/service %s status > /dev/null 2>/dev/null" % which,
|
|
diff --git a/cobbler/actions/reposync.py b/cobbler/actions/reposync.py
|
|
index 651514f..ddee79c 100644
|
|
--- a/cobbler/actions/reposync.py
|
|
+++ b/cobbler/actions/reposync.py
|
|
@@ -257,7 +257,7 @@ class RepoSync:
|
|
mdoptions.append("-g %s" % os.path.join(origin_path, groupmdfile))
|
|
if "prestodelta" in rd:
|
|
# need createrepo >= 0.9.7 to add deltas
|
|
- if utils.get_family() in ("redhat", "suse"):
|
|
+ if utils.get_family() in ("redhat", "suse", "generic_lower_os"):
|
|
cmd = "/usr/bin/rpmquery --queryformat=%{VERSION} createrepo"
|
|
createrepo_ver = utils.subprocess_get(self.logger, cmd)
|
|
if not createrepo_ver[0:1].isdigit():
|
|
diff --git a/cobbler/autoinstallgen.py b/cobbler/autoinstallgen.py
|
|
index d8532ca..0486bf8 100644
|
|
--- a/cobbler/autoinstallgen.py
|
|
+++ b/cobbler/autoinstallgen.py
|
|
@@ -312,7 +312,7 @@ class AutoInstallationGen:
|
|
meta.update(autoinstall_meta)
|
|
|
|
# add package repositories metadata to autoinstall metavariables
|
|
- if distro.breed == "redhat":
|
|
+ if distro.breed == "redhat" or distro.breed == "generic_lower_os":
|
|
meta["yum_repo_stanza"] = self.generate_repo_stanza(obj, (system is None))
|
|
meta["yum_config_stanza"] = self.generate_config_stanza(obj, (system is None))
|
|
# FIXME: implement something similar to zypper (SUSE based distros) and apt (Debian based distros)
|
|
diff --git a/cobbler/tftpgen.py b/cobbler/tftpgen.py
|
|
index 087d8c0..5e10636 100644
|
|
--- a/cobbler/tftpgen.py
|
|
+++ b/cobbler/tftpgen.py
|
|
@@ -746,7 +746,7 @@ class TFTPGen:
|
|
autoinstall_path = "http://%s/cblr/svc/op/autoinstall/profile/%s" \
|
|
% (httpserveraddress, profile.name)
|
|
|
|
- if distro.breed is None or distro.breed == "redhat":
|
|
+ if distro.breed is None or distro.breed == "redhat" or distro.breed == "generic_lower_os":
|
|
|
|
if distro.os_version in ["rhel4", "rhel5", "rhel6", "fedora16"]:
|
|
append_line += " kssendmac ks=%s" % autoinstall_path
|
|
diff --git a/cobbler/utils.py b/cobbler/utils.py
|
|
index 98663a5..7475a27 100644
|
|
--- a/cobbler/utils.py
|
|
+++ b/cobbler/utils.py
|
|
@@ -1017,8 +1017,10 @@ def os_release():
|
|
make = "suse"
|
|
if "suse" not in distro.like():
|
|
make = "unknown"
|
|
- return make, float(distro_version)
|
|
+ return make, float(distro_versioni)
|
|
|
|
+ elif family == "generic_lower_os":
|
|
+ return "generic_lower_os", float(distro_version)
|
|
|
|
def is_safe_to_hardlink(src: str, dst: str, api) -> bool:
|
|
"""
|
|
diff --git a/config/cobbler/distro_signatures.json b/config/cobbler/distro_signatures.json
|
|
index 6d2c04b..804f735 100644
|
|
--- a/config/cobbler/distro_signatures.json
|
|
+++ b/config/cobbler/distro_signatures.json
|
|
@@ -1,5 +1,33 @@
|
|
{
|
|
"breeds": {
|
|
+ "generic_lower_os": {
|
|
+ "generic_lower_os": {
|
|
+ "signatures": [
|
|
+ "Packages"
|
|
+ ],
|
|
+ "version_file": "generic_os-release-(.*).rpm",
|
|
+ "version_file_regex": null,
|
|
+ "kernel_arch": "kernel-(.*).rpm",
|
|
+ "kernel_arch_regex": null,
|
|
+ "supported_arches": [
|
|
+ "aarch64",
|
|
+ "x86_64"
|
|
+ ],
|
|
+ "supported_repo_breeds": [
|
|
+ "rsync",
|
|
+ "rhn",
|
|
+ "yum"
|
|
+ ],
|
|
+ "kernel_file": "vmlinuz(.*)",
|
|
+ "initrd_file": "initrd(.*)\\.img",
|
|
+ "isolinux_ok": true,
|
|
+ "default_autoinstall": "sample.ks",
|
|
+ "kernel_options": "repo=$tree",
|
|
+ "kernel_options_post": "",
|
|
+ "boot_files": [],
|
|
+ "boot_loaders": {}
|
|
+ }
|
|
+ },
|
|
"redhat": {
|
|
"rhel4": {
|
|
"signatures": [
|
|
diff --git a/distro_build_configs.sh b/distro_build_configs.sh
|
|
index 31ee5ce..19fc711 100644
|
|
--- a/distro_build_configs.sh
|
|
+++ b/distro_build_configs.sh
|
|
@@ -30,6 +30,9 @@ if [ "$DISTRO" = "" ] && [ -r /etc/os-release ];then
|
|
ubuntu*|debian*)
|
|
DISTRO="UBUNTU"
|
|
;;
|
|
+ generic_os*)
|
|
+ DISTRO=`echo 'generic_os'|tr 'a-z' 'A-Z'`
|
|
+ ;;
|
|
esac
|
|
fi
|
|
|
|
@@ -43,7 +46,7 @@ elif [ "$DISTRO" = "UBUNTU" ];then
|
|
export WEBROOT="/var/www"
|
|
export WEBCONFIG="/etc/apache2/conf-available"
|
|
export DEFAULTPATH="etc/default"
|
|
-elif [ "$DISTRO" = "FEDORA" ];then
|
|
+elif [ "$DISTRO" = "FEDORA" ] || [ "$DISTRO" = `echo 'generic_os'|tr 'a-z' 'A-Z'` ];then
|
|
export APACHE_USER="apache"
|
|
export HTTP_USER=$APACHE_USER # overrule setup.py
|
|
export APACHE_GROUP="apache"
|
|
diff --git a/templates/etc/dhcp.template b/templates/etc/dhcp.template
|
|
index a24f903..68ebe8a 100644
|
|
--- a/templates/etc/dhcp.template
|
|
+++ b/templates/etc/dhcp.template
|
|
@@ -33,7 +33,7 @@ subnet 192.168.1.0 netmask 255.255.255.0 {
|
|
|
|
# Legacy
|
|
if option system-arch = 00:00 {
|
|
- filename "grub/grub.0";
|
|
+ filename "pxelinux.0";
|
|
}
|
|
# UEFI-32-1
|
|
if option system-arch = 00:06 {
|
|
@@ -47,15 +47,15 @@ subnet 192.168.1.0 netmask 255.255.255.0 {
|
|
}
|
|
# UEFI-64-1
|
|
else if option system-arch = 00:07 {
|
|
- filename "grub/grubx64.efi";
|
|
+ filename "grubx64.efi";
|
|
}
|
|
# UEFI-64-2
|
|
else if option system-arch = 00:08 {
|
|
- filename "grub/grubx64.efi";
|
|
+ filename "grubx64.efi";
|
|
}
|
|
# UEFI-64-3
|
|
else if option system-arch = 00:09 {
|
|
- filename "grub/grubx64.efi";
|
|
+ filename "grubx64.efi";
|
|
}
|
|
# armv7 (aka arm 32 bit)
|
|
else if option system-arch = 00:0a {
|
|
@@ -63,7 +63,7 @@ subnet 192.168.1.0 netmask 255.255.255.0 {
|
|
}
|
|
# aarch64 (aka arm 64 bit)
|
|
else if option system-arch = 00:0b {
|
|
- filename "grub/grubaa64.efi";
|
|
+ filename "grubaa64.efi";
|
|
}
|
|
# RiskV 32 bit
|
|
else if option system-arch = 00:25 {
|
|
--
|
|
2.43.0
|
|
|