101 lines
2.6 KiB
Python
101 lines
2.6 KiB
Python
import os
|
|
import shutil
|
|
import subprocess
|
|
|
|
from lib import cpp, arch, packie
|
|
from lib.make import *
|
|
|
|
|
|
upstream_version = "7.2.3"
|
|
|
|
version(f"{upstream_version}")
|
|
description("the Linux operating system kernel")
|
|
maintainer("sisungo <[email protected]>")
|
|
source_url(
|
|
f"https://cdn.kernel.org/pub/linux/kernel/v7.x/linux-{upstream_version}.tar.xz"
|
|
)
|
|
|
|
builddep("shortcut/c")
|
|
builddep("shortcut/autotools")
|
|
builddep("libncurses-dev")
|
|
builddep("aws-lc-dev @target")
|
|
builddep("aws-lc-tools")
|
|
builddep("airboot-linux-stage2-mkinitramfs")
|
|
builddep("airboot-linux-stage2-arch @target")
|
|
builddep("flex")
|
|
builddep("bison")
|
|
builddep("bc")
|
|
builddep("gzip")
|
|
|
|
|
|
def get_arch():
|
|
return arch.get_target().split("-")[0].replace("aarch64", "arm64")
|
|
|
|
|
|
def build():
|
|
makeopts = [f"ARCH={get_arch()}", "LLVM=1", f"HOSTCC={os.environ.get('HOSTCC', 'cc')}"]
|
|
config_name = get_arch()
|
|
if os.environ.get("LINUX_VARIANT"):
|
|
config_name += "-" + os.environ["LINUX_VARIANT"]
|
|
config_file = "../../configs/config." + config_name
|
|
|
|
shutil.copy2(config_file, ".config")
|
|
|
|
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(
|
|
["modules_install", "INSTALL_MOD_STRIP=1", "INSTALL_MOD_PATH=../kmod_install"]
|
|
)
|
|
os.remove(f"../kmod_install/lib/modules/{upstream_version}/build")
|
|
|
|
asp_prefix = packie.prefix_of(f"airboot-linux-stage2-arch @{arch.get_target()}")
|
|
subprocess.run([
|
|
"mkinitramfs",
|
|
"-a", f"{asp_prefix}/data",
|
|
"-o", f"{os.getcwd()}/../initramfs.img",
|
|
"-m", f"{os.getcwd()}/../kmod_install",
|
|
"-k", upstream_version,
|
|
], check=True)
|
|
|
|
on_build(build)
|
|
|
|
base_name = "linux"
|
|
if os.environ.get("LINUX_VARIANT"):
|
|
base_name += "-" + os.environ["LINUX_VARIANT"]
|
|
|
|
|
|
def pack_linux_dev(composer):
|
|
composer.add_dir(
|
|
"../kheaders_install/include",
|
|
"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")
|
|
|
|
|
|
package(f"{base_name}")
|
|
on_pack(pack_linux)
|