Add draft installation

This commit is contained in:
andreili 2025-06-27 22:43:01 +02:00
parent 42da8519ad
commit e6071dd03e
8 changed files with 6743 additions and 7 deletions

View File

@ -12,6 +12,7 @@ parser.add_argument('--board', type=str, default='', help='Select board to build
parser.add_argument('--target', type=str, default='', help='Target to build, default "%(default)s"') parser.add_argument('--target', type=str, default='', help='Target to build, default "%(default)s"')
parser.add_argument('--sync', action='store_true', help='Sync all source with latest') parser.add_argument('--sync', action='store_true', help='Sync all source with latest')
parser.add_argument('--os_act', type=str, default='', help=f'Actions to OS ({os_actions}), comma separated list') parser.add_argument('--os_act', type=str, default='', help=f'Actions to OS ({os_actions}), comma separated list')
parser.add_argument('--install', type=str, default='', help='Install to selected directory/device')
args = parser.parse_args() args = parser.parse_args()
if (args.board == ''): if (args.board == ''):
@ -35,3 +36,6 @@ if (args.os_act != ""):
acts = args.os_act.split(",") acts = args.os_act.split(",")
for act in acts: for act in acts:
os.action(act) os.action(act)
if (args.install != ""):
target_board.install(args.install)

View File

@ -2,9 +2,9 @@
# Automatically generated file; DO NOT EDIT. # Automatically generated file; DO NOT EDIT.
# Linux/arm64 6.14.0-rc7 Kernel Configuration # Linux/arm64 6.14.0-rc7 Kernel Configuration
# #
CONFIG_CC_VERSION_TEXT="aarch64-unknown-linux-gnu-gcc (Gentoo 14.3.0 p8) 14.3.0" CONFIG_CC_VERSION_TEXT="aarch64-linux-gnu-gcc (Gentoo 15.1.0 p1) 15.1.0"
CONFIG_CC_IS_GCC=y CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=140300 CONFIG_GCC_VERSION=150100
CONFIG_CLANG_VERSION=0 CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=24400 CONFIG_AS_VERSION=24400
@ -13,11 +13,14 @@ CONFIG_LD_VERSION=24400
CONFIG_LLD_VERSION=0 CONFIG_LLD_VERSION=0
CONFIG_RUSTC_VERSION=108700 CONFIG_RUSTC_VERSION=108700
CONFIG_RUSTC_LLVM_VERSION=200101 CONFIG_RUSTC_LLVM_VERSION=200101
CONFIG_CC_CAN_LINK=y
CONFIG_CC_CAN_LINK_STATIC=y
CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y CONFIG_CC_HAS_ASM_GOTO_OUTPUT=y
CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y CONFIG_CC_HAS_ASM_GOTO_TIED_OUTPUT=y
CONFIG_TOOLS_SUPPORT_RELR=y CONFIG_TOOLS_SUPPORT_RELR=y
CONFIG_CC_HAS_ASM_INLINE=y CONFIG_CC_HAS_ASM_INLINE=y
CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y CONFIG_CC_HAS_NO_PROFILE_FN_ATTR=y
CONFIG_CC_HAS_COUNTED_BY=y
CONFIG_RUSTC_HAS_COERCE_POINTEE=y CONFIG_RUSTC_HAS_COERCE_POINTEE=y
CONFIG_PAHOLE_VERSION=130 CONFIG_PAHOLE_VERSION=130
CONFIG_IRQ_WORK=y CONFIG_IRQ_WORK=y

File diff suppressed because it is too large Load Diff

View File

@ -77,7 +77,14 @@
"version_type": "branch", "version_type": "branch",
"target": [ "modules" ], "target": [ "modules" ],
"makeopts": "CROSS_COMPILE=%{CROSS_C}% ARCH=arm64 INSTALL_MOD_PATH=%{out_dir}%/kmods KSRC=%{build_dir}%/kernel_%{board_name}%", "makeopts": "CROSS_COMPILE=%{CROSS_C}% ARCH=arm64 INSTALL_MOD_PATH=%{out_dir}%/kmods KSRC=%{build_dir}%/kernel_%{board_name}%",
"artifacts": [] "artifacts":
[
{
"file": "8189fs.ko",
"store_type": "boot",
"subdir": "modules"
}
]
}, },
{ {
"parent": "buildroot", "parent": "buildroot",
@ -92,6 +99,16 @@
{ {
"target": "image", "target": "image",
"block_size": "1k", "block_size": "1k",
"image_size": "2g" "partitions":
[
{
"name": "boot",
"size": "2g"
},
{
"name": "rw",
"size": "2g"
}
]
} }
} }

View File

@ -1,7 +1,9 @@
import json, os import json, os, stat, re
from pathlib import Path from pathlib import Path
from . import * from . import *
units = { "B": 1, "K": 2**10, "M": 2**20, "G": 2**30 }
class Board: class Board:
def __init__(self, name, js_fn, targets_meta): def __init__(self, name, js_fn, targets_meta):
self.name = name self.name = name
@ -11,6 +13,7 @@ class Board:
self.json = json.load(json_data) self.json = json.load(json_data)
json_data.close() json_data.close()
self.build_list = self.json["build"] self.build_list = self.json["build"]
self.installs = self.json["install"]
self.targets = [] self.targets = []
self.variables = [] self.variables = []
self.__load_vars() self.__load_vars()
@ -85,3 +88,67 @@ class Board:
break break
if (not is_finded): if (not is_finded):
Logger.error("Don't find target!") Logger.error("Don't find target!")
def __do_cmd(self, args, cwd=None, env=None, stdin=None):
if (stdin != None):
p = subprocess.Popen(args, cwd=cwd, env=env, stdin=subprocess.PIPE, text=True)
else:
p = subprocess.Popen(args, cwd=cwd, env=env)
if (stdin != None):
p.communicate(input=stdin)
if (p.wait() != 0):
Logger.error(f"Command '{args[0]}' finished with error code!")
def __make_blk_struct(self, dev):
Logger.install("\tBlock device. Prepare and mount it...")
def __create_img_file(self, path, size):
Logger.install("\tCreate image file...")
img_f = Path(path)
if (img_f.is_file()):
shutil.rmtree(path, ignore_errors=True)
blk_size = 1024*1024
blk_count = int(size / blk_size)
self.__do_cmd(["dd", "if=/dev/zero", f"of={path}", f"bs={blk_size}", f"count={blk_count}"])
def __parse_size(elf, size):
size = size.upper()
if not re.match(r' ', size):
size = re.sub(r'([KMGT])', r' \1', size)
number, unit = [string.strip() for string in size.split()]
return int(float(number)*units[unit])
def __create_parts(self, img_or_dev):
args = ""
args += "o\n"
for part in self.installs["partitions"]:
part_sz = part["size"]
args += "n\n"
args += "p\n"
args += "\n"
args += "\n"
args += f"+{part_sz}\n"
args += "w\n"
args += "q\n"
self.__do_cmd(["fdisk", img_or_dev], stdin=args)
def __install_to_img(self):
Logger.install("\tImage. Prepare and mount it...")
img_fn = f"{self.out_dir}/all.img"
# basic image offset - space for partition table and bootloader
img_sz = 1024*1024 + 512
parts = self.installs["partitions"]
for part in parts:
img_sz += self.__parse_size(part["size"])
self.__create_img_file(img_fn, img_sz)
self.__create_parts(img_fn)
def install(self, dir):
Logger.install(f"Install to '{dir}'")
if (self.installs["target"] == "image"):
self.__install_to_img()
else:
Logger.error("Unsupported instalation type!")
#is_blk = False
#if (stat.S_ISBLK(os.stat(dir).st_mode)):
# dir = self.__make_blk_struct(dir)

View File

@ -14,3 +14,6 @@ class Logger:
def os(msg): def os(msg):
print(f"[🖥] {msg}") print(f"[🖥] {msg}")
def install(msg):
print(f"[💽] {msg}")

View File

@ -155,7 +155,9 @@ class OS:
# remove temp directory # remove temp directory
self.__tmp_clean(temp_dir) self.__tmp_clean(temp_dir)
self.__extract_tar(arch_path, temp_dir) self.__extract_tar(arch_path, temp_dir)
self.__make_sqh(temp_dir, f"{ROOT_DIR}/out/root_" + date + ".sqh") sqh_fn = f"{ROOT_DIR}/out/root_{date}.sqh"
self.__make_sqh(temp_dir, sqh_fn)
os.symlink(sqh_fn, f"{ROOT_DIR}/out/root.sqh")
self.__tmp_clean(temp_dir) self.__tmp_clean(temp_dir)
def action(self, action): def action(self, action):

View File

@ -149,12 +149,22 @@ class Sources:
tags = self.repo_bare.git.ls_remote("--tags", "origin", f"tags/{self.version}") tags = self.repo_bare.git.ls_remote("--tags", "origin", f"tags/{self.version}")
return tags.split('\t')[0] return tags.split('\t')[0]
def __parse_version(self):
if (self.type == "branch"):
return f"origin/{self.version}"
elif (self.type == "head"):
return f"{self.version}"
elif (self.type == "commit"):
return f"{self.version}"
elif (self.type == "tag"):
return f"{self.version}"
def git_work_reset_state(self): def git_work_reset_state(self):
hash_local = self.repo.git.rev_parse("@") hash_local = self.repo.git.rev_parse("@")
hash_remote = self.git_work_get_hash_remote() hash_remote = self.git_work_get_hash_remote()
if (hash_local == "") or (hash_local == "@") or (hash_local != hash_remote): if (hash_local == "") or (hash_local == "@") or (hash_local != hash_remote):
Logger.git(f"\tUpdate references: {hash_local}->{hash_remote}") Logger.git(f"\tUpdate references: {hash_local}->{hash_remote}")
self.repo.git.fetch("--no-tags", self.bare_dir, self.version) self.repo.git.fetch("--no-tags", self.bare_dir, self.__parse_version())
#git fetch --no-tags "${repo_local}" "${ref_name}" #git fetch --no-tags "${repo_local}" "${ref_name}"
Logger.git(f"\tCheckout: {hash_remote}") Logger.git(f"\tCheckout: {hash_remote}")
self.repo.git.checkout("-f", "-q", hash_remote) self.repo.git.checkout("-f", "-q", hash_remote)