+53
-32
@@ -26,30 +26,37 @@ builddep("flex")
|
||||
builddep("bison")
|
||||
builddep("bc")
|
||||
builddep("gzip")
|
||||
builddep("zstd")
|
||||
|
||||
|
||||
def get_arch():
|
||||
return arch.get_target().split("-")[0].replace("aarch64", "arm64")
|
||||
|
||||
def get_variant():
|
||||
return os.environ.get("LINUX_VARIANT")
|
||||
|
||||
def build():
|
||||
makeopts = [f"ARCH={get_arch()}", "LLVM=1", f"HOSTCC={os.environ.get('HOSTCC', 'cc')}"]
|
||||
|
||||
def prepare_config():
|
||||
config_name = get_arch()
|
||||
if os.environ.get("LINUX_VARIANT"):
|
||||
config_name += "-" + os.environ["LINUX_VARIANT"]
|
||||
if get_variant():
|
||||
config_name += "-" + get_variant()
|
||||
config_file = "../../configs/config." + config_name
|
||||
|
||||
shutil.copy2(config_file, ".config")
|
||||
|
||||
def make_install_everything():
|
||||
makeopts = [f"ARCH={get_arch()}", "LLVM=1", f"HOSTCC={os.environ.get('HOSTCC', 'cc')}"]
|
||||
|
||||
cpp.make(makeopts + ["olddefconfig"])
|
||||
cpp.make(makeopts)
|
||||
cpp.make(["headers_install", "INSTALL_HDR_PATH=../kheaders_install"])
|
||||
cpp.make(["install", "INSTALL_PATH=../kimage_install"])
|
||||
cpp.make(makeopts + ["headers_install", "INSTALL_HDR_PATH=../kheaders_install"])
|
||||
cpp.make(makeopts + ["install", "INSTALL_PATH=../kimage_install"])
|
||||
cpp.make(
|
||||
["modules_install", "INSTALL_MOD_STRIP=1", "INSTALL_MOD_PATH=../kmod_install"]
|
||||
makeopts + ["modules_install", "INSTALL_MOD_STRIP=1", "INSTALL_MOD_PATH=../kmod_install"]
|
||||
)
|
||||
os.remove(f"../kmod_install/lib/modules/{upstream_version}/build")
|
||||
|
||||
def create_initramfs():
|
||||
asp_prefix = packie.prefix_of(f"airboot-linux-stage2-arch @{arch.get_target()}")
|
||||
subprocess.run([
|
||||
"mkinitramfs",
|
||||
@@ -59,11 +66,22 @@ def build():
|
||||
"-k", upstream_version,
|
||||
], check=True)
|
||||
|
||||
on_build(build)
|
||||
def generate_info():
|
||||
info = ""
|
||||
info += f"KERNEL_INFO_UPSTREAM_VERSION={upstream_version}\n"
|
||||
info += f"KERNEL_INFO_VARIANT={get_variant() or ''}\n"
|
||||
info += f"KERNEL_INFO_ARCHITECTURE={get_arch()}\n"
|
||||
with open(f"../KernelInfo.txt", "wt+") as fd:
|
||||
fd.write(info)
|
||||
|
||||
base_name = "linux"
|
||||
if os.environ.get("LINUX_VARIANT"):
|
||||
base_name += "-" + os.environ["LINUX_VARIANT"]
|
||||
|
||||
def build():
|
||||
prepare_config()
|
||||
make_install_everything()
|
||||
create_initramfs()
|
||||
generate_info()
|
||||
|
||||
on_build(build)
|
||||
|
||||
|
||||
def pack_linux_dev(composer):
|
||||
@@ -72,29 +90,32 @@ def pack_linux_dev(composer):
|
||||
"include",
|
||||
)
|
||||
|
||||
|
||||
package(f"{base_name}-dev")
|
||||
on_pack(pack_linux_dev)
|
||||
|
||||
|
||||
def pack_linux(composer):
|
||||
try:
|
||||
composer.addfile(f"../kimage_install/vmlinux-{upstream_version}", "vmlinux")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
composer.addfile(f"../kimage_install/vmlinuz-{upstream_version}", "vmlinuz")
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
composer.addfile(
|
||||
f"../kimage_install/System.map-{upstream_version}", "System.map"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
composer.add_dir(f"../kmod_install/lib/modules/{upstream_version}", "modules")
|
||||
composer.addfile("../initramfs.img", "initramfs.img")
|
||||
vmlinux_origin = f"../kimage_install/vmlinux-{upstream_version}"
|
||||
vmlinuz_origin = f"../kimage_install/vmlinuz-{upstream_version}"
|
||||
system_map_origin = f"../kimage_install/System.map-{upstream_version}"
|
||||
modules_origin = f"../kmod_install/lib/modules/{upstream_version}"
|
||||
initramfs_origin = "../initramfs.img"
|
||||
if os.path.exists(vmlinux_origin):
|
||||
composer.addfile(vmlinux_origin, "vmlinux")
|
||||
if os.path.exists(vmlinuz_origin):
|
||||
composer.addfile(vmlinuz_origin, "vmlinuz")
|
||||
if os.path.exists(system_map_origin):
|
||||
composer.addfile(system_map_origin, "System.map")
|
||||
composer.add_dir(modules_origin, "modules")
|
||||
composer.addfile(initramfs_origin, "initramfs.img")
|
||||
composer.addfile("../KernelInfo.txt", "KernelInfo.txt")
|
||||
|
||||
|
||||
base_name = "linux"
|
||||
if os.environ.get("LINUX_VARIANT"):
|
||||
base_name += "-" + os.environ["LINUX_VARIANT"]
|
||||
|
||||
|
||||
package(f"{base_name}")
|
||||
configure_script("configure/kernel-install")
|
||||
configure_script("configure/kernel-remove")
|
||||
on_pack(pack_linux)
|
||||
|
||||
package(f"{base_name}-dev")
|
||||
on_pack(pack_linux_dev)
|
||||
|
||||
Reference in New Issue
Block a user