From 41dad4693e05306327104838cb1cfb012d37f2bd Mon Sep 17 00:00:00 2001 From: alichinese Date: Fri, 17 Oct 2025 17:52:38 +0800 Subject: [PATCH] oebridge: add 3591rc build template * add 3591rc build template and add oebridge-extra-command.tmp file for some action after complete rootfs used root user Signed-off-by: alichinese --- .oebuild/platform/3591rc.yaml | 9 +++ .../aarch64/3591rc-oebridge-systemd.yaml | 26 +++++++ bsp/meta-hisilicon/conf/machine/3591rc.conf | 23 +++++++ .../recipes-core/images/bsp-3591rc.inc | 0 .../images/files/oebridge-extra-command.sh | 20 ++++++ .../recipes-core/images/image-3591rc.inc | 13 ++++ .../images/openeuler-image.bbappend | 2 + .../packagegroup-oebridge.bbappend | 3 + .../recipes-kernel/linux/linux-3591rc.inc | 0 .../linux/linux-openeuler.bbappend | 2 +- meta-openeuler/classes/image-oebridge.bbclass | 68 ++++++++++++------- .../elfutils/elfutils_%.bbappend | 2 + .../python/python3-attrs_%.bbappend | 2 + .../libyaml/libyaml_%.bbappend | 2 + .../recipes-support/sqlite/sqlite3_%.bbappend | 2 + 15 files changed, 150 insertions(+), 24 deletions(-) create mode 100644 .oebuild/platform/3591rc.yaml create mode 100644 .oebuild/samples/aarch64/3591rc-oebridge-systemd.yaml create mode 100644 bsp/meta-hisilicon/conf/machine/3591rc.conf create mode 100644 bsp/meta-hisilicon/recipes-core/images/bsp-3591rc.inc create mode 100644 bsp/meta-hisilicon/recipes-core/images/files/oebridge-extra-command.sh create mode 100644 bsp/meta-hisilicon/recipes-core/images/image-3591rc.inc create mode 100644 bsp/meta-hisilicon/recipes-core/packagegroups/packagegroup-oebridge.bbappend create mode 100644 bsp/meta-hisilicon/recipes-kernel/linux/linux-3591rc.inc diff --git a/.oebuild/platform/3591rc.yaml b/.oebuild/platform/3591rc.yaml new file mode 100644 index 00000000000..3a942d9144d --- /dev/null +++ b/.oebuild/platform/3591rc.yaml @@ -0,0 +1,9 @@ +type: platform + +machine: 3591rc + +toolchain_type: EXTERNAL_TOOLCHAIN:aarch64 + +layers: + - yocto-meta-openeuler/bsp/meta-hisilicon + - yocto-meta-openembedded/meta-multimedia diff --git a/.oebuild/samples/aarch64/3591rc-oebridge-systemd.yaml b/.oebuild/samples/aarch64/3591rc-oebridge-systemd.yaml new file mode 100644 index 00000000000..b0462de41f0 --- /dev/null +++ b/.oebuild/samples/aarch64/3591rc-oebridge-systemd.yaml @@ -0,0 +1,26 @@ +build_in: docker +machine: 3591rc +toolchain_type: EXTERNAL_TOOLCHAIN:aarch64 +cache_src_dir: +no_layer: false +repos: +- yocto-poky +- yocto-meta-openembedded +local_conf: |+ + INIT_MANAGER = "systemd" + + DISTRO_FEATURES:append = " oebridge " + SERVER_MIRROR = "https://mirrors.tuna.tsinghua.edu.cn/openeuler" + SERVER_VERSION = "openEuler-24.03-LTS" + GLIBC_GENERATE_LOCALES:append = "en_US.UTF-8 zh_CN.UTF-8 " + +layers: [] +docker_param: + image: swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container:latest + parameters: -itd --network host + volumns: + - /dev/net/tun:/dev/net/tun + command: bash +bitbake_cmds: +- bitbake openeuler-image +- bitbake openeuler-image -c do_populate_sdk diff --git a/bsp/meta-hisilicon/conf/machine/3591rc.conf b/bsp/meta-hisilicon/conf/machine/3591rc.conf new file mode 100644 index 00000000000..c5868fa581d --- /dev/null +++ b/bsp/meta-hisilicon/conf/machine/3591rc.conf @@ -0,0 +1,23 @@ +# Description: Machine description for little-endian aarch64 + +require conf/machine/include/qemu.inc + +MACHINE_FEATURES += "efi" +DEFAULTTUNE = "aarch64" +require conf/machine/include/qemu-aarch64-common.inc + +# arm and arm64 both support -mlittle-endian so no +# need to consider compat32. +TUNE_CCARGS .= " -mlittle-endian" + +DEFAULTTUNE:virtclass-multilib-lib32 = "armv7a" +PACKAGE_EXTRA_ARCHS:tune-armv7a += " armv7a" +PACKAGE_EXTRA_ARCHS:virtclass-multilib-lib32 = "armv7a" + +require conf/multilib.conf +# for qemu-aarch64,don't enable multilib lib32 support, +# by default everything is 64 bit +MULTILIBS ?= "" +DEFAULTTUNE:virtclass-multilib-ilp32 =. "aarch64_ilp32:" +export ROOTFS_PACKAGE_ARCH = "aarch64" +export ROOTFS_PACKAGE_ARCH:virtclass-multilib-lib32 = "armv7l" diff --git a/bsp/meta-hisilicon/recipes-core/images/bsp-3591rc.inc b/bsp/meta-hisilicon/recipes-core/images/bsp-3591rc.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bsp/meta-hisilicon/recipes-core/images/files/oebridge-extra-command.sh b/bsp/meta-hisilicon/recipes-core/images/files/oebridge-extra-command.sh new file mode 100644 index 00000000000..329ce40ef5c --- /dev/null +++ b/bsp/meta-hisilicon/recipes-core/images/files/oebridge-extra-command.sh @@ -0,0 +1,20 @@ +USER_NAME='HwHiAiUser' +SYS_USER='HwSysUser' +DM_USER='HwDmUser' +BASE_USER='HwBaseUser' +groupadd -g 1000 ${USER_NAME} +useradd -u 1000 -g ${USER_NAME} -s /bin/bash -m -d /home/${USER_NAME} ${USER_NAME} +groupadd -g 1100 ${SYS_USER} +useradd -u 1100 -g ${SYS_USER} -s /sbin/nologin ${SYS_USER} +groupadd -g 1101 ${DM_USER} +useradd -u 1101 -g ${DM_USER} -s /sbin/nologin ${DM_USER} +groupadd -g 1102 ${BASE_USER} +useradd -u 1102 -g ${BASE_USER} -s /sbin/nologin ${BASE_USER} +usermod -aG ${BASE_USER} ${DM_USER} +usermod -aG ${BASE_USER} ${USER_NAME} +usermod -aG ${USER_NAME} ${DM_USER} +usermod -aG ${DM_USER} ${USER_NAME} +usermod -aG ${USER_NAME} ${BASE_USER} +mkdir -p /usr/local/Ascend/ +chmod 777 /usr/local +chmod 777 /usr/local/Ascend/ \ No newline at end of file diff --git a/bsp/meta-hisilicon/recipes-core/images/image-3591rc.inc b/bsp/meta-hisilicon/recipes-core/images/image-3591rc.inc new file mode 100644 index 00000000000..f90e62f5bc4 --- /dev/null +++ b/bsp/meta-hisilicon/recipes-core/images/image-3591rc.inc @@ -0,0 +1,13 @@ +OEBRIDGE_PIP_LISTS = " \ +protobuf>=3.13.0 \ +psutil>=5.7.0 \ +numpy>=1.13.3 \ +scipy>=1.4.1 \ +decorator>=4.4.0 \ +sympy>=1.5.1 \ +cffi>=1.12.3 \ +absl-py \ +attrs \ +" + +IMAGE_INSTALL += " libyaml elfutils sqlite3 " diff --git a/bsp/meta-hisilicon/recipes-core/images/openeuler-image.bbappend b/bsp/meta-hisilicon/recipes-core/images/openeuler-image.bbappend index dac2e55b882..13f2571902f 100644 --- a/bsp/meta-hisilicon/recipes-core/images/openeuler-image.bbappend +++ b/bsp/meta-hisilicon/recipes-core/images/openeuler-image.bbappend @@ -1 +1,3 @@ require recipes-core/images/image-${MACHINE}.inc + +OEBRIDGE_EXTRA_FILE_PATH := "${THISDIR}/files/oebridge-extra-command.sh" diff --git a/bsp/meta-hisilicon/recipes-core/packagegroups/packagegroup-oebridge.bbappend b/bsp/meta-hisilicon/recipes-core/packagegroups/packagegroup-oebridge.bbappend new file mode 100644 index 00000000000..41d89f6023d --- /dev/null +++ b/bsp/meta-hisilicon/recipes-core/packagegroups/packagegroup-oebridge.bbappend @@ -0,0 +1,3 @@ +INSTALL_PKG_LISTS:append = " \ +${@bb.utils.contains('MACHINE', '3591rc', 'gcc', '', d)} \ +" \ No newline at end of file diff --git a/bsp/meta-hisilicon/recipes-kernel/linux/linux-3591rc.inc b/bsp/meta-hisilicon/recipes-kernel/linux/linux-3591rc.inc new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bsp/meta-hisilicon/recipes-kernel/linux/linux-openeuler.bbappend b/bsp/meta-hisilicon/recipes-kernel/linux/linux-openeuler.bbappend index 3a719c99d94..00fc692dd58 100644 --- a/bsp/meta-hisilicon/recipes-kernel/linux/linux-openeuler.bbappend +++ b/bsp/meta-hisilicon/recipes-kernel/linux/linux-openeuler.bbappend @@ -1,4 +1,4 @@ # add COMPATIBLE_MACHINE -COMPATIBLE_MACHINE = "hi3093|hieulerpi1|hiedge1|hipico" +COMPATIBLE_MACHINE = "hi3093|hieulerpi1|hiedge1|hipico|3591rc" require recipes-kernel/linux/${@bb.utils.contains('DISTRO_FEATURES', 'mpu_solution', 'linux-hi3093-mpu.inc', 'linux-${MACHINE}.inc', d)} diff --git a/meta-openeuler/classes/image-oebridge.bbclass b/meta-openeuler/classes/image-oebridge.bbclass index 3495723a751..742c4404d7b 100644 --- a/meta-openeuler/classes/image-oebridge.bbclass +++ b/meta-openeuler/classes/image-oebridge.bbclass @@ -204,34 +204,56 @@ fakeroot python do_dnf_install_pkgs(){ else: bb.error("openEuler.repo not found") + if d.getVar('OEBRIDGE_EXTRA_FILE_PATH'): + temp_file_path = f"{d.getVar('OEBRIDGE_EXTRA_FILE_PATH')}" + run_cmd_with_cwd(f"cp {temp_file_path} rootfs", d.getVar("WORKDIR")) + # do some prepare action + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 cp -rfP rootfs temp/", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"getfacl -R rootfs > temp/rootfs_permission", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"find rootfs -type l -printf '%u:%g %p\n' > temp/rootfs_softlink", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo setfacl --restore=rootfs_permission", d.getVar("WORKDIR")+"/temp") + run_cmd_with_cwd(f"cat rootfs_softlink | while read -r o p;do PSEUDO_UNLOAD=1 sudo chown -h \"$o\" \"$p\"; done", d.getVar("WORKDIR")+"/temp") + if len(real_list) > 0: - run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 cp -rfP rootfs temp/", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"getfacl -R rootfs > temp/rootfs_permission", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"find rootfs -type l -printf '%u:%g %p\n' > temp/rootfs_softlink", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo setfacl --restore=rootfs_permission", d.getVar("WORKDIR")+"/temp") - run_cmd_with_cwd(f"cat rootfs_softlink | while read -r o p;do PSEUDO_UNLOAD=1 sudo chown -h \"$o\" \"$p\"; done", d.getVar("WORKDIR")+"/temp") real_list_str = " ".join(real_list) run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs dnf install \ {real_list_str} -y --nogpgcheck --setopt=sslverify=0 --nobest", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo getfacl -R rootfs > ../rootfs_permission", d.getVar("WORKDIR")+"/temp") - run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo find rootfs -type l -printf '%u:%g %p\n' > ../rootfs_softlink", d.getVar("WORKDIR")+"/temp") - res = subprocess.run("stat -c '%u:%g' temp", - shell=True, - stderr=subprocess.PIPE, - stdout=subprocess.PIPE, - cwd=d.getVar("WORKDIR"), - text=True) - if res.returncode != 0: - bb.fatal(res.stderr) - ugid = res.stdout.strip() - run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs chown -R {ugid} /", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs chmod -R 777 /", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo rm -f temp/rootfs/root/.bash_history", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"rm -rf ./rootfs", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"cp -rfP temp/rootfs ./", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"setfacl --restore=rootfs_permission", d.getVar("WORKDIR")) - run_cmd_with_cwd(f"cat rootfs_softlink | while read -r o p;do chown -h \"$o\" \"$p\"; done", d.getVar("WORKDIR")) + + if os.path.exists(os.path.join(d.getVar("WORKDIR"), "temp/rootfs/oebridge-extra-command.sh")): + # 从WORKDIR复制oebridge_extra_command.sh到rootfs + image_rootfs = d.getVar("IMAGE_ROOTFS") + # 给oebridge_extra_command.sh添加可执行权限 + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs chmod +x /oebridge-extra-command.sh", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs /oebridge-extra-command.sh", d.getVar("WORKDIR")) + # 删除oebridge_extra_command.sh + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs rm -f /oebridge-extra-command.sh", d.getVar("WORKDIR")) + + oebridge_pip_list = d.getVar('OEBRIDGE_PIP_LISTS',"").split("\n") + if len(oebridge_pip_list) > 0: + oebridge_pip_list_str = " ".join(oebridge_pip_list) + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs pip3 install {oebridge_pip_list_str} -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple", d.getVar("WORKDIR")) + + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo getfacl -R rootfs > ../rootfs_permission", d.getVar("WORKDIR")+"/temp") + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo find rootfs -type l -printf '%u:%g %p\n' > ../rootfs_softlink", d.getVar("WORKDIR")+"/temp") + res = subprocess.run("stat -c '%u:%g' temp", + shell=True, + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + cwd=d.getVar("WORKDIR"), + text=True) + if res.returncode != 0: + bb.fatal(res.stderr) + ugid = res.stdout.strip() + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs chown -R {ugid} /", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo chroot temp/rootfs chmod -R 777 /", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"PSEUDO_UNLOAD=1 sudo rm -f temp/rootfs/root/.bash_history", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"rm -rf ./rootfs", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"cp -rfP temp/rootfs ./", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"setfacl --restore=rootfs_permission", d.getVar("WORKDIR")) + run_cmd_with_cwd(f"cat rootfs_softlink | while read -r o p;do chown -h \"$o\" \"$p\"; done", d.getVar("WORKDIR")) + + subprocess.run(f"rm -f rootfs/oebridge-extra-command.tmp", shell=True, text=True) } python do_run_post_action(){ diff --git a/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend b/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend index 68e4fa1d400..4f37289551d 100644 --- a/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend +++ b/meta-openeuler/recipes-devtools/elfutils/elfutils_%.bbappend @@ -24,3 +24,5 @@ SRC_URI[sha256sum] = "df76db71366d1d708365fc7a6c60ca48398f14367eb2b8954efc889714 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504 \ file://debuginfod/debuginfod-client.c;endline=27;md5=7eb69ae4d5654e590c840538256a7bfe \ " + +ASSUME_PROVIDE_PKGS = "elfutils-libelf-devel" diff --git a/meta-openeuler/recipes-devtools/python/python3-attrs_%.bbappend b/meta-openeuler/recipes-devtools/python/python3-attrs_%.bbappend index 006bc2f0439..ae8b76b8487 100644 --- a/meta-openeuler/recipes-devtools/python/python3-attrs_%.bbappend +++ b/meta-openeuler/recipes-devtools/python/python3-attrs_%.bbappend @@ -12,3 +12,5 @@ SRC_URI:remove = " \ file://0001-conftest.py-disable-deadline.patch \ file://run-ptest \ " + +ASSUME_PROVIDE_PKGS = "python3-attrs" \ No newline at end of file diff --git a/meta-openeuler/recipes-support/libyaml/libyaml_%.bbappend b/meta-openeuler/recipes-support/libyaml/libyaml_%.bbappend index 6009f8c5618..8c3c4fbf12e 100644 --- a/meta-openeuler/recipes-support/libyaml/libyaml_%.bbappend +++ b/meta-openeuler/recipes-support/libyaml/libyaml_%.bbappend @@ -5,3 +5,5 @@ SRC_URI += " \ file://backport-Improve-CMake-build-system.patch \ file://backport-CVE-2024-3205-Fix-emitter-states-handling-when-write_indicator-fails.patch \ " + +ASSUME_PROVIDE_PKGS = "libyaml" diff --git a/meta-openeuler/recipes-support/sqlite/sqlite3_%.bbappend b/meta-openeuler/recipes-support/sqlite/sqlite3_%.bbappend index bb23136b7cc..d33bd8d0849 100644 --- a/meta-openeuler/recipes-support/sqlite/sqlite3_%.bbappend +++ b/meta-openeuler/recipes-support/sqlite/sqlite3_%.bbappend @@ -9,3 +9,5 @@ SRC_URI = " \ " SRC_URI[sha256sum] = "7abcfd161c6e2742ca5c6c0895d1f853c940f203304a0b49da4e1eca5d088ca6" + +ASSUME_PROVIDE_PKGS = "sqlite" \ No newline at end of file -- Gitee