mirror of
https://github.com/andreili/SBC_builder.git
synced 2025-08-23 19:04:06 +02:00
Add a basic user environment preparation.
This commit is contained in:
parent
e86266df6c
commit
9884de6b97
@ -1,3 +1,12 @@
|
||||
{
|
||||
"user": "klipper"
|
||||
"user": "klipper",
|
||||
"user_groups": "wheel,video,audio,disk,usb",
|
||||
"repos":
|
||||
[
|
||||
{
|
||||
"directory": "kiauh",
|
||||
"url": "https://github.com/dw-0/kiauh.git"
|
||||
}
|
||||
],
|
||||
"make_venv": true
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ from .sources import *
|
||||
from .initramfs import *
|
||||
from .board import *
|
||||
from .target import *
|
||||
from .os import *
|
||||
from .software import *
|
||||
from .os import *
|
||||
|
||||
__all__ = [ "Board", "Target", "Sources", "Logger", "OS", "Software", "Initramfs" ]
|
||||
|
@ -101,7 +101,9 @@ class OS:
|
||||
def __extract_tar(self, arch_fn, to_path):
|
||||
Logger.os("Extract to temporary directory...")
|
||||
os.makedirs(to_path, exist_ok=True)
|
||||
self.__sudo(["tar", "xf", arch_fn], cwd=to_path)
|
||||
my_env = os.environ.copy()
|
||||
my_env["XZ_OPT"] = "-9 --extreme --threads=0"
|
||||
self.__sudo(["tar", "xf", arch_fn], cwd=to_path, env=my_env)
|
||||
|
||||
def __make_sqh(self, root_path, to_file):
|
||||
Logger.os("Create squashed archive...")
|
||||
|
@ -10,11 +10,24 @@ class Software:
|
||||
js = json.load(json_data)
|
||||
json_data.close()
|
||||
self.user = js["user"]
|
||||
self.user_groups = js["user_groups"]
|
||||
self.repos = js["repos"]
|
||||
self.make_venv = js["make_venv"]
|
||||
|
||||
def finalize(self, dir):
|
||||
cmd_user = f"useradd -m -G wheel,video,audio,disk,usb {self.user} --password {self.user}"
|
||||
cmd_klipper = "sudo klipper 'cd ~ && git clone https://github.com/dw-0/kiauh.git --depth=1'"
|
||||
cmd_venv = "sudo klipper 'cd ~ && python -m venv ~/venv'"
|
||||
self.os.chroot_ext(cmd_user, dir)
|
||||
self.os.chroot_ext(cmd_klipper, dir)
|
||||
self.os.chroot_ext(cmd_venv, dir)
|
||||
home_dir = f"/home/{self.user}"
|
||||
cmds = []
|
||||
# create user
|
||||
cmds.push_back(f"useradd -m -G {self.user_groups} {self.user} --password {self.user}")
|
||||
#make password for user
|
||||
cmds.push_back(f"echo '{self.user}:{self.user}' | chpasswd")
|
||||
for repo in self.repos:
|
||||
#clone repos from configuration
|
||||
repo_dir = repo["directory"]
|
||||
repo_url = repo["url"]
|
||||
cmds.push_back(f"sudo -i -u klipper git clone {repo_url} --depth=1 {home_dir}/{repo_dir}")
|
||||
if (self.make_venv):
|
||||
# make python environment
|
||||
cmds.push_back(f"sudo -i -u klipper python -m venv {home_dir}/venv")
|
||||
for cmd in cmds:
|
||||
self.os.chroot_ext(cmd, dir)
|
||||
|
@ -71,7 +71,7 @@ class Target:
|
||||
self.sources.do_patch(self.board_name, self.patch_dir)
|
||||
|
||||
def build(self, sub_target, out_dir):
|
||||
self.source_sync()
|
||||
#self.source_sync()
|
||||
if (not self.no_build):
|
||||
opts = self.makeopts.split(" ")
|
||||
config = ""
|
||||
@ -80,6 +80,7 @@ class Target:
|
||||
targets = self.target
|
||||
else:
|
||||
if (sub_target == "config"):
|
||||
shutil.copyfile("cfg/printer_defconfig", "build/common/kernel/arch/arm64/configs/printer_defconfig")
|
||||
opts.append(self.defconfig)
|
||||
opts.append(self.config_target)
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user