mirror of
https://github.com/andreili/SBC_builder.git
synced 2025-08-23 11:04:04 +02:00
Add basic OS support.
This commit is contained in:
parent
7cd66477b7
commit
4190142bcc
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,6 @@
|
||||
git_bare
|
||||
out*
|
||||
out/*
|
||||
build
|
||||
*.pyc
|
||||
*.bak
|
||||
root*
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "buildroot"]
|
||||
path = buildroot
|
||||
url = https://github.com/buildroot/buildroot.git
|
14
build.py
14
build.py
@ -3,10 +3,14 @@
|
||||
import argparse, json
|
||||
from scripts import *
|
||||
|
||||
os = OS()
|
||||
os_actions = ",".join(os.actions_list())
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--board', type=str, default='', help='Select board to build')
|
||||
parser.add_argument('--target', type=str, default='all', 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('--os_act', type=str, default='', help=f'Actions to OS ({os_actions}), comma separated list')
|
||||
args = parser.parse_args()
|
||||
|
||||
if (args.board == ''):
|
||||
@ -15,8 +19,14 @@ if (args.board == ''):
|
||||
|
||||
targets_meta = Target.load_meta(f"config/target_meta.json")
|
||||
target_board = Board(args.board, f"config/board/{args.board}.json", targets_meta)
|
||||
os.set_board(target_board)
|
||||
|
||||
if (args.sync):
|
||||
target_board.sync()
|
||||
else:
|
||||
elif (args.target != ""):
|
||||
target_board.build(args.target)
|
||||
|
||||
if (args.os_act != ""):
|
||||
acts = args.os_act.split(",")
|
||||
for act in acts:
|
||||
os.action(act)
|
||||
|
5072
cfg/btt_cb1/.config
Normal file
5072
cfg/btt_cb1/.config
Normal file
File diff suppressed because it is too large
Load Diff
5095
cfg/btt_cb1/buildroot
Normal file
5095
cfg/btt_cb1/buildroot
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
9345
cfg/btt_cb1/kernel_v6.14-rc7___
Normal file
9345
cfg/btt_cb1/kernel_v6.14-rc7___
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
#
|
||||
|
||||
#
|
||||
# Compiler: aarch64-unknown-linux-gnu-gcc (Gentoo 14.3.0 p8) 14.3.0
|
||||
# Compiler: aarch64-linux-gnu-gcc (Gentoo 15.1.0 p1) 15.1.0
|
||||
#
|
||||
CONFIG_CREATE_ARCH_SYMLINK=y
|
||||
CONFIG_SYS_CACHE_SHIFT_6=y
|
||||
@ -327,7 +327,7 @@ CONFIG_FWU_NUM_IMAGES_PER_BANK=2
|
||||
CONFIG_LOCALVERSION="-armbian-2024.01-S866c-Pb7f6-H8869-V5ccd-B7163-R448a"
|
||||
# CONFIG_LOCALVERSION_AUTO is not set
|
||||
CONFIG_CC_IS_GCC=y
|
||||
CONFIG_GCC_VERSION=140300
|
||||
CONFIG_GCC_VERSION=150100
|
||||
CONFIG_CLANG_VERSION=0
|
||||
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
|
||||
# CONFIG_CC_OPTIMIZE_FOR_SPEED is not set
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,9 @@
|
||||
],
|
||||
"variables":
|
||||
[
|
||||
"CROSS_C:aarch64-unknown-linux-gnu-",
|
||||
"ATF_PLATFORM:sun50i_h616"
|
||||
"CROSS_C:aarch64-linux-gnu-",
|
||||
"ATF_PLATFORM:sun50i_h616",
|
||||
"ARCH:aarch64"
|
||||
],
|
||||
"targets":
|
||||
[
|
||||
@ -21,7 +22,7 @@
|
||||
[
|
||||
{
|
||||
"file": "build/%{ATF_PLATFORM}%/release/bl31.bin",
|
||||
"store_type": "file"
|
||||
"store_type": "temp"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -50,7 +51,7 @@
|
||||
"version": "v6.14-rc7",
|
||||
"version_type": "tag",
|
||||
"patch_dir": "kernel/sunxi-6.14",
|
||||
"target": [ "olddefconfig", "Image", "dtbs" ],
|
||||
"target": [ "Image", "modules", "dtbs" ],
|
||||
"artifacts":
|
||||
[
|
||||
{
|
||||
@ -69,6 +70,20 @@
|
||||
}
|
||||
],
|
||||
"makeopts": "CROSS_COMPILE=%{CROSS_C}% ARCH=arm64"
|
||||
},
|
||||
{
|
||||
"parent": "buildroot",
|
||||
"version": "@",
|
||||
"version_type": "head",
|
||||
"patch_dir": "buildroot/sunxi",
|
||||
"target": [],
|
||||
"artifacts": []
|
||||
}
|
||||
]
|
||||
],
|
||||
"install":
|
||||
{
|
||||
"target": "image",
|
||||
"block_size": "1k",
|
||||
"image_size": "2g"
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,13 @@
|
||||
"config": true,
|
||||
"config_target": "menuconfig"
|
||||
}
|
||||
},
|
||||
{
|
||||
"buildroot":
|
||||
{
|
||||
"url": "https://github.com/buildroot/buildroot.git",
|
||||
"config": true,
|
||||
"config_target": "menuconfig"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1,68 +1,26 @@
|
||||
boot/*
|
||||
_initrd/*
|
||||
usr/src/*
|
||||
var/db/*
|
||||
var/cache/*
|
||||
var/log/*.log
|
||||
usr/portage/*
|
||||
#home/biqu/*
|
||||
root/*
|
||||
back.sh
|
||||
chroot.sh
|
||||
mksquash.sh
|
||||
qemu_init.sh
|
||||
excl*.lst
|
||||
usr/lib64/gconv*
|
||||
usr/lib64/perl5*
|
||||
usr/lib/python3.13/test*
|
||||
usr/share/binutils-data*
|
||||
usr/share/cmake*
|
||||
usr/share/groff*
|
||||
usr/share/gtk-3.0*
|
||||
usr/share/gcc-data*
|
||||
usr/share/genkernel*
|
||||
usr/share/gir-1.0*
|
||||
usr/share/icons*
|
||||
usr/share/i18n*
|
||||
usr/share/locale*
|
||||
usr/share/misc*
|
||||
usr/share/sgml*
|
||||
usr/share/gtk-doc*
|
||||
#usr/share/mc*
|
||||
usr/share/vala*
|
||||
usr/share/vala-0.56*
|
||||
media/rtl8189ES_linux/hal*
|
||||
media/rtl8189ES_linux/core*
|
||||
media/rtl8189ES_linux/include*
|
||||
media/rtl8189ES_linux/.git*
|
||||
media/rtl8189ES_linux/os_dep*
|
||||
media/rtl8189ES_linux/platform*
|
||||
media/rtl8189ES_linux/8189fs.o*
|
||||
media/rtl8189ES_linux/*mod*
|
||||
media/rtl8189ES_linux/Kconfig
|
||||
media/rtl8189ES_linux/Makefile
|
||||
media/rtl8189ES_linux/clean
|
||||
media/rtl8189ES_linux/ifcf*
|
||||
media/rtl8189ES_linux/run*
|
||||
media/rtl8189ES_linux/wlan*
|
||||
media/rtl8189ES_linux/Mod*
|
||||
media/rtl8189ES_linux/*.cmd
|
||||
media/trim*
|
||||
usr/share/textinfo*
|
||||
usr/arm-none-eabi/lib/arm*
|
||||
#usr/arm-none-eabi/lib/thumb/v6-m*
|
||||
#usr/arm-none-eabi/lib/thumb/v7-m*
|
||||
#usr/arm-none-eabi/lib/thumb/v7/*
|
||||
#usr/arm-none-eabi/lib/thumb/v7e-m+fp*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v6-m*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v7-m*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v7/*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v7e-m+fp*
|
||||
#usr/share/mc*
|
||||
boot/*
|
||||
media/*
|
||||
root/*
|
||||
usr/arm-none-eabi/lib/arm*
|
||||
usr/arm-none-eabi/lib/thumb/v7+fp*
|
||||
usr/arm-none-eabi/lib/thumb/v7-a/*
|
||||
usr/arm-none-eabi/lib/thumb/v7-a+fp*
|
||||
usr/arm-none-eabi/lib/thumb/v7-a+simd*
|
||||
#usr/arm-none-eabi/lib/thumb/v7-m*
|
||||
usr/arm-none-eabi/lib/thumb/v7-a/*
|
||||
usr/arm-none-eabi/lib/thumb/v7-r+fp.sp*
|
||||
usr/arm-none-eabi/lib/thumb/v7e-m+dp*
|
||||
#usr/arm-none-eabi/lib/thumb/v7e-m+fp*
|
||||
usr/arm-none-eabi/lib/thumb/v7ve+simd*
|
||||
usr/arm-none-eabi/lib/thumb/v8-a/*
|
||||
usr/arm-none-eabi/lib/thumb/v8-a+simd*
|
||||
usr/arm-none-eabi/lib/thumb/v8-a/*
|
||||
usr/arm-none-eabi/lib/thumb/v8-m.base*
|
||||
usr/arm-none-eabi/lib/thumb/v8-m.main*
|
||||
usr/arm-none-eabi/lib/thumb/v8-m.main+dp*
|
||||
@ -72,26 +30,47 @@ usr/arm-none-eabi/lib/thumb/v8.1-m.main+pacbti*
|
||||
usr/arm-none-eabi/lib/thumb/v8.1-m.main+pacbti+dp*
|
||||
usr/arm-none-eabi/lib/thumb/v8.1-m.main+pacbti+fp*
|
||||
usr/arm-none-eabi/lib/thumb/v8.1-m.main+pacbti+mve*
|
||||
usr/lib/gcc/arm-none-eabi/14/arm*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v6-m*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v7/*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v7+fp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v7-a/*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v7-a+fp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v7-a+simd*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v7-m*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v7-r+fp.sp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v7e-m+dp*
|
||||
#usr/lib/gcc/arm-none-eabi/14/thumb/v7e-m+fp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v7ve+simd*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8-a/*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8-a+simd*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8-m.base*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8-m.main*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8-m.main+dp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8-m.main+fp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8.1-m.main+mve*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8.1-m.main+pacbti*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8.1-m.main+pacbti+dp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8.1-m.main+pacbti+fp*
|
||||
usr/lib/gcc/arm-none-eabi/14/thumb/v8.1-m.main+pacbti+mve*
|
||||
usr/lib/gcc/arm-none-eabi/15/arm*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v7+fp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v7-a+fp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v7-a+simd*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v7-a/*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v7-r+fp.sp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v7e-m+dp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v7ve+simd*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8-a+simd*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8-a/*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8-m.base*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8-m.main*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8-m.main+dp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8-m.main+fp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8.1-m.main+mve*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8.1-m.main+pacbti*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8.1-m.main+pacbti+dp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8.1-m.main+pacbti+fp*
|
||||
usr/lib/gcc/arm-none-eabi/15/thumb/v8.1-m.main+pacbti+mve*
|
||||
usr/lib/python3.13/test*
|
||||
usr/lib64/gconv*
|
||||
usr/lib64/perl5*
|
||||
usr/portage/*
|
||||
usr/share/binutils-data*
|
||||
usr/share/cmake*
|
||||
usr/share/doc*
|
||||
usr/share/gcc-data*
|
||||
usr/share/genkernel*
|
||||
usr/share/gir-*
|
||||
usr/share/groff*
|
||||
usr/share/gtk-3*
|
||||
usr/share/gtk-doc*
|
||||
usr/share/i18n*
|
||||
usr/share/icons*
|
||||
usr/share/locale*
|
||||
usr/share/misc*
|
||||
usr/share/sgml*
|
||||
usr/share/textinfo*
|
||||
usr/share/vala*
|
||||
usr/share/vala-0.56*
|
||||
usr/src/*
|
||||
var/cache/*
|
||||
var/db/*
|
||||
var/log/*.log
|
12
files/backups/excl_min.lst
Normal file
12
files/backups/excl_min.lst
Normal file
@ -0,0 +1,12 @@
|
||||
#home/biqu/*
|
||||
boot/*
|
||||
media/*
|
||||
usr/lib/python3.13/test*
|
||||
usr/lib64/perl5*
|
||||
usr/src/*
|
||||
var/cache/binpkgs/*
|
||||
var/cache/distfiles/*
|
||||
var/cache/edb/*
|
||||
var/cache/eix/*
|
||||
var/db/*
|
||||
var/log/*.log
|
Binary file not shown.
Binary file not shown.
@ -1,6 +1,9 @@
|
||||
from .board import Board
|
||||
from .target import Target
|
||||
from .sources import Sources
|
||||
from .logger import Logger
|
||||
from .lib import *
|
||||
from .logger import *
|
||||
from .board import *
|
||||
from .sources import *
|
||||
from .target import *
|
||||
from .os import *
|
||||
from .software import *
|
||||
|
||||
__all__ = [ "Board", "Target", "Sources", "Logger" ]
|
||||
__all__ = [ "Board", "Target", "Sources", "Logger", "OS", "Software" ]
|
||||
|
@ -1,7 +1,6 @@
|
||||
import json, os
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR = Path(os.path.abspath(__file__)).parent.parent
|
||||
from . import *
|
||||
|
||||
class Board:
|
||||
def __init__(self, name, js_fn, targets_meta):
|
||||
@ -18,7 +17,7 @@ class Board:
|
||||
t = self.__find_meta(targets_meta, target["parent"])
|
||||
if (t == 0):
|
||||
Logger.error("Unable to find parent for package!")
|
||||
t.load_detail(self.name, target, self.variables)
|
||||
t.load_detail(self.name, target, self.parse_variables)
|
||||
self.targets.append(t)
|
||||
self.__scan_deps()
|
||||
|
||||
@ -50,6 +49,12 @@ class Board:
|
||||
self.variables.append(var_def.split(":"))
|
||||
self.variables.append(["out_dir", self.out_dir])
|
||||
|
||||
def parse_variables(self, string):
|
||||
for var_d in self.variables:
|
||||
string = string.replace("%{"+var_d[0]+"}%", var_d[1])
|
||||
#out_dir
|
||||
return string
|
||||
|
||||
def sync(self):
|
||||
for target in self.targets:
|
||||
target.source_sync()
|
||||
@ -63,12 +68,16 @@ class Board:
|
||||
target_list = [ targets[0] ]
|
||||
if (len(targets) > 1):
|
||||
sub_target = targets[1]
|
||||
is_finded = False
|
||||
for t_name in target_list:
|
||||
for target in self.targets:
|
||||
if (t_name == target.name):
|
||||
is_finded = True
|
||||
for dep in target.depends:
|
||||
if (sub_target == ""):
|
||||
#when run sub-target - not need to check a deps
|
||||
dep.build("", self.out_dir)
|
||||
target.build(sub_target, self.out_dir)
|
||||
break
|
||||
if (not is_finded):
|
||||
Logger.error("Don't find target!")
|
||||
|
48
scripts/chroot.sh
Normal file
48
scripts/chroot.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
OS_DIR_DEF="./root/"
|
||||
|
||||
#do_chroot()
|
||||
#{
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
DDIR=${OS_DIR_DEF}
|
||||
else
|
||||
DDIR=$(realpath "$1")
|
||||
mount --bind ${OS_DIR_DEF}/usr/portage ${DDIR}/usr/portage
|
||||
fi
|
||||
mkdir -p ${DDIR}/usr/src/linux-6.14-rc7
|
||||
|
||||
if [ -z "${DDIR}" ]
|
||||
then
|
||||
echo "No directory specified!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mount --bind /dev ${DDIR}/dev
|
||||
mount --bind /dev/shm ${DDIR}/dev/shm
|
||||
mount --bind /dev/pts ${DDIR}/dev/pts
|
||||
mount --bind /sys ${DDIR}/sys
|
||||
mount --bind /proc ${DDIR}/proc
|
||||
mount --bind /var/db/repos ${DDIR}/var/db/repos
|
||||
mount --bind /mnt/work/SBC/universal/build/btt_cb1/kernel_btt_cb1 ${DDIR}/usr/src/linux-6.14-rc7
|
||||
mount -t tmpfs tmpfs ${DDIR}/var/tmp/
|
||||
if [ -z "$2" ]
|
||||
then
|
||||
chroot ${DDIR}/ /bin/bash
|
||||
else
|
||||
chroot ${DDIR}/ /bin/bash -c "${@:2}"
|
||||
fi
|
||||
umount ${DDIR}/var/tmp
|
||||
umount ${DDIR}/usr/src/linux-6.14-rc7
|
||||
umount ${DDIR}/var/db/repos
|
||||
umount ${DDIR}/proc
|
||||
umount ${DDIR}/sys
|
||||
umount ${DDIR}/dev/pts
|
||||
umount ${DDIR}/dev/shm
|
||||
umount ${DDIR}/dev
|
||||
if [ -n "$1" ]
|
||||
then
|
||||
umount ${DDIR}/usr/portage
|
||||
fi
|
||||
#}
|
4
scripts/lib.py
Normal file
4
scripts/lib.py
Normal file
@ -0,0 +1,4 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
ROOT_DIR=Path(os.path.abspath(__file__)).parent.parent
|
@ -11,3 +11,6 @@ class Logger:
|
||||
|
||||
def git(msg):
|
||||
print(f"[📦] {msg}")
|
||||
|
||||
def os(msg):
|
||||
print(f"[🖥] {msg}")
|
||||
|
129
scripts/os.py
Normal file
129
scripts/os.py
Normal file
@ -0,0 +1,129 @@
|
||||
import subprocess, os, sys, datetime, getpass, shutil
|
||||
from pathlib import Path
|
||||
if __name__ != '__main__':
|
||||
from . import *
|
||||
|
||||
class OS:
|
||||
def __init__(self):
|
||||
self.root_dir = f"{ROOT_DIR}/root"
|
||||
self.actions = [
|
||||
[ "chroot", self.chroot ],
|
||||
[ "sync", self.sync_repo ],
|
||||
[ "update", self.update_all ],
|
||||
[ "reinstall", self.rebuild_all ],
|
||||
[ "pack", self.pack ],
|
||||
[ "sqh", self.sqh ]
|
||||
]
|
||||
|
||||
def actions_list(self):
|
||||
lst = []
|
||||
for act in self.actions:
|
||||
lst.append(act[0])
|
||||
return lst
|
||||
|
||||
def set_board(self, board):
|
||||
self.board = board
|
||||
self.arch = board.parse_variables("%{ARCH}%")
|
||||
|
||||
def __sudo(self, args, cwd=None, env=None):
|
||||
args.insert(0, "sudo")
|
||||
p = subprocess.Popen(args, cwd=cwd, env=env)
|
||||
if (p.wait() != 0):
|
||||
Logger.error(f"Command '{args[1]}' finished with error code!")
|
||||
|
||||
def __prepare(self):
|
||||
qemu_f = Path(f"/proc/sys/fs/binfmt_misc/qemu-{self.arch}")
|
||||
if (not qemu_f.is_file()):
|
||||
self.__sudo(["python", os.path.abspath(__file__), self.arch])
|
||||
self.__sudo(["cp", f"{ROOT_DIR}/files/qemu/qemu-{self.arch}", f"{self.root_dir}/bin/"])
|
||||
|
||||
def __chroot(self, command):
|
||||
self.__prepare()
|
||||
Logger.os(f"Start chroot'ed command: '{command}'")
|
||||
self.__sudo(["bash", f"{ROOT_DIR}/scripts/chroot.sh", self.root_dir, command])
|
||||
|
||||
def chroot(self):
|
||||
self.__chroot("")
|
||||
|
||||
def sync_repo(self):
|
||||
self.__chroot("eix-sync -v")
|
||||
|
||||
def update_all(self):
|
||||
self.__chroot("emerge -avuDN1b world -j2 && ldconfig")
|
||||
|
||||
def rebuild_all(self):
|
||||
self.__chroot("emerge -av1be world -j2 && ldconfig")
|
||||
|
||||
def __do_archive(self, excl_list, name):
|
||||
Logger.os(f"Create '{name}' archive...")
|
||||
my_env = os.environ.copy()
|
||||
my_env["XZ_OPT"] = "-9 --extreme --threads=0"
|
||||
date = datetime.datetime.today().strftime('%Y_%m_%d')
|
||||
arch_path = self.board.parse_variables("%{out_dir}%/back_" + name + "_" + date + ".tar.xz")
|
||||
self.__sudo(["tar", "-cJpf", arch_path,
|
||||
f"--exclude-from={ROOT_DIR}/files/backups/{excl_list}.lst", "."],
|
||||
cwd=self.root_dir, env=my_env)
|
||||
if (p.wait() != 0):
|
||||
Logger.error("Archive command finished with error code!")
|
||||
return arch_path
|
||||
|
||||
def pack(self):
|
||||
return self.__do_archive("excl_min", "FULL")
|
||||
|
||||
def __fix_xorg(self):
|
||||
Logger.os("Fix Xorg permissions")
|
||||
self.__sudo(["chmod", "u+s", f"{self.root_dir}/usr/bin/Xorg"])
|
||||
|
||||
def __tmp_clean(self, path):
|
||||
Logger.os("Clean temporary directory...")
|
||||
t_dir = Path(path)
|
||||
if (t_dir.is_dir()):
|
||||
self.__sudo(["rm", "-rf", path])
|
||||
|
||||
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)
|
||||
|
||||
def __make_sqh(self, root_path, to_file):
|
||||
Logger.os("Create squashed archive...")
|
||||
t_file = Path(to_file)
|
||||
if (t_file.is_file()):
|
||||
shutil.move(to_file, f"{to_file}.bak")
|
||||
self.__sudo(["mksquashfs", root_path, to_file, "-comp", "xz", "-xattrs-exclude", "^system.nfs"])
|
||||
user = getpass.getuser()
|
||||
self.__sudo(["chown", user + ":" + user, to_file])
|
||||
|
||||
def sqh(self):
|
||||
self.__fix_xorg()
|
||||
arch_path = self.__do_archive("excl", "OS")
|
||||
temp_dir = f"{ROOT_DIR}/out/tmp"
|
||||
self.__tmp_clean(temp_dir)
|
||||
self.__extract_tar(arch_path, temp_dir)
|
||||
self.__make_sqh(temp_dir, f"{ROOT_DIR}/out/root.sqh")
|
||||
|
||||
def action(self, action):
|
||||
for act in self.actions:
|
||||
if (act[0] == action):
|
||||
act[1]()
|
||||
break
|
||||
|
||||
if __name__ == '__main__':
|
||||
f = open("/proc/sys/fs/binfmt_misc/register","wb")
|
||||
if (len(sys.argv) < 2) or (sys.argv[1] == "aarch64"):
|
||||
name = "aarch64"
|
||||
interp = f"/usr/bin/qemu-{name}"
|
||||
magic = b"\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7\\x00"
|
||||
mask = b"\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff\\xff"
|
||||
else:
|
||||
print("Invalid arguments!")
|
||||
exit(1)
|
||||
_REGISTER_FORMAT = b":%(name)s:M::%(magic)s:%(mask)s:%(interp)s:%(flags)s"
|
||||
s = _REGISTER_FORMAT % {
|
||||
b"name": name.encode("utf-8"),
|
||||
b"magic": magic,
|
||||
b"mask": mask,
|
||||
b"interp": interp.encode("utf-8"),
|
||||
b"flags": b"",
|
||||
}
|
||||
f.write(s)
|
7
scripts/software.py
Normal file
7
scripts/software.py
Normal file
@ -0,0 +1,7 @@
|
||||
import json, os
|
||||
from pathlib import Path
|
||||
from . import *
|
||||
|
||||
class Software:
|
||||
def __init__(self):
|
||||
print("Hi!")
|
@ -1,9 +1,7 @@
|
||||
from pathlib import Path
|
||||
import shutil, git, os, subprocess, glob
|
||||
from rich import console, progress
|
||||
from .logger import Logger
|
||||
|
||||
ROOT_DIR = Path(os.path.abspath(__file__)).parent.parent
|
||||
from . import *
|
||||
|
||||
class GitRemoteProgress(git.RemoteProgress):
|
||||
OP_CODES = [
|
||||
@ -140,11 +138,12 @@ class Sources:
|
||||
|
||||
def git_work_get_hash_remote(self):
|
||||
if (self.type == "branch"):
|
||||
exit(1)
|
||||
Logger.error("Unsupported source type!")
|
||||
elif (self.type == "head"):
|
||||
exit(1)
|
||||
tags = self.repo_bare.git.ls_remote("origin", "HEAD")
|
||||
return tags.split('\t')[0]
|
||||
elif (self.type == "commit"):
|
||||
exit(1)
|
||||
Logger.error("Unsupported source type!")
|
||||
elif (self.type == "tag"):
|
||||
tags = self.repo_bare.git.ls_remote("--tags", "origin", f"tags/{self.version}")
|
||||
return tags.split('\t')[0]
|
||||
@ -205,12 +204,12 @@ class Sources:
|
||||
Logger.build(f"Compile...")
|
||||
work_cfg_name = f"{self.work_dir}/.config"
|
||||
cfg_or = Path(cfg_name)
|
||||
cfg_wr = Path(cfg_name)
|
||||
cfg_wr = Path(work_cfg_name)
|
||||
if (cfg_or.is_file()):
|
||||
# copy configuration, if exists
|
||||
shutil.copyfile(cfg_name, work_cfg_name)
|
||||
opts.insert(0, "make")
|
||||
opts.append("-j16")
|
||||
opts.append("-j8")
|
||||
p = subprocess.Popen(opts, cwd=self.work_dir)
|
||||
p.wait()
|
||||
if (p.returncode != 0):
|
||||
|
@ -1,9 +1,6 @@
|
||||
import json, os
|
||||
from pathlib import Path
|
||||
from .sources import Sources
|
||||
from .logger import Logger
|
||||
|
||||
ROOT_DIR = Path(os.path.abspath(__file__)).parent.parent
|
||||
from . import *
|
||||
|
||||
class Target:
|
||||
def __init__(self, meta_js):
|
||||
@ -29,19 +26,15 @@ class Target:
|
||||
res.append(t)
|
||||
return res
|
||||
|
||||
def __parse_variables(self, string, variables):
|
||||
for var_d in variables:
|
||||
string = string.replace("%{"+var_d[0]+"}%", var_d[1])
|
||||
#out_dir
|
||||
return string
|
||||
|
||||
def load_detail(self, board_name, detail_js, variables):
|
||||
def load_detail(self, board_name, detail_js, parse_variables):
|
||||
self.board_name = board_name
|
||||
self.sources.init_source_path(board_name)
|
||||
self.sources.set_git_params(detail_js["version"], detail_js["version_type"])
|
||||
self.target = detail_js["target"]
|
||||
self.version = detail_js["version"]
|
||||
self.config_name = f"{ROOT_DIR}/cfg/{board_name}/{self.name}_{self.version}"
|
||||
self.config_name = f"{ROOT_DIR}/cfg/{board_name}/{self.name}"
|
||||
if (self.version != "") and (self.version != "@"):
|
||||
self.config_name += f"_{self.version}"
|
||||
if ("patch_dir" in detail_js):
|
||||
self.patch_dir = detail_js["patch_dir"]
|
||||
else:
|
||||
@ -51,13 +44,13 @@ class Target:
|
||||
else:
|
||||
self.dep_names = []
|
||||
if ("makeopts" in detail_js):
|
||||
self.makeopts = self.__parse_variables(detail_js["makeopts"], variables)
|
||||
self.makeopts = parse_variables(detail_js["makeopts"])
|
||||
else:
|
||||
self.makeopts = ""
|
||||
_artifacts = detail_js["artifacts"]
|
||||
self.artifacts = []
|
||||
for art in _artifacts:
|
||||
art["file"] = self.__parse_variables(art["file"], variables)
|
||||
art["file"] = parse_variables(art["file"])
|
||||
self.artifacts.append(art)
|
||||
|
||||
def source_sync(self):
|
||||
|
3
software/software.json
Normal file
3
software/software.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"user": "klipper"
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
QEMU_AARCH64_FILTER="\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
|
||||
if [ ! -f "/proc/sys/fs/binfmt_misc/qemu-${CARCH}" ]
|
||||
then
|
||||
# only aarch64 is supported
|
||||
sudo sh -c "printf '%s\n' ':qemu-${CARCH}:M::${QEMU_AARCH64_FILTER}:/usr/bin/qemu-${CARCH}:' > /proc/sys/fs/binfmt_misc/register"
|
||||
fi
|
29730
tmp/excl.lst
29730
tmp/excl.lst
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user