Fix. K1 image works

This commit is contained in:
2025-09-05 15:14:00 +08:00
parent c8c0a8405d
commit 4d9c2137cf
14 changed files with 29 additions and 38 deletions

View File

@@ -9,6 +9,7 @@ RUN yum install -y \
findutils \
gdisk \
gzip \
mtools \
rsync \
tar \
util-linux \

View File

@@ -1,31 +0,0 @@
#!/usr/bin/env sh
cat << EOF > "${ROOTFS_DIR}/usr/local/sbin/oerv-firstboot.sh"
#!/usr/bin/env sh
echo "OERV first-time booting helper."
ROOT_PART="\$(findmnt -no SOURCE /)"
ROOT_PARTNUM="\$(lsblk -pr -no partn \${ROOT_PART})"
ROOT_DISK="\$(lsblk -p -no pkname \${ROOT_PART})"
sgdisk -e "\${ROOT_DISK}"
echo "Yes" | parted ---pretend-input-tty "\${ROOT_DISK}" resizepart "\${ROOT_PARTNUM}" 100%
partprobe
resize2fs "\${ROOT_PART}"
EOF
chmod 550 "${ROOTFS_DIR}/usr/local/sbin/oerv-firstboot.sh"
cat << EOF > "${ROOTFS_DIR}/etc/systemd/system/oerv-firstboot.service"
[Unit]
Before=systemd-user-sessions.service
ConditionPathExists=/etc/systemd/system/multi-user.target.wants/oerv-firstboot.service
Requires=-.mount
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/oerv-firstboot.sh
ExecStartPost=/usr/bin/rm /etc/systemd/system/multi-user.target.wants/oerv-firstboot.service
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
chmod 644 "${ROOTFS_DIR}/etc/systemd/system/oerv-firstboot.service"
ln -s "/etc/systemd/system/oerv-firstboot.service" "${ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants/oerv-firstboot.service"

View File

@@ -1,3 +1,3 @@
# Provide esos.elf for early kernel direct filesystem lookup
install_items+= /lib/firmware/esos.elf
install_items+=" /lib/firmware/esos.elf "

View File

@@ -7,6 +7,7 @@ U_BOOT_PROMPT="2"
U_BOOT_MENU_LABEL="${PRETTY_NAME}"
# tty enabled on both serial0 and fbdev
U_BOOT_PARAMETERS="rootwait rw earlycon=sbi console=tty0 console=ttyS0,115200 rd.multipath=0"
U_BOOT_ROOT=$($get_fs_uuid_by_mountpoint /)
U_BOOT_ROOT=root=UUID="$($get_fs_uuid_by_mountpoint /)"
U_BOOT_SEPARATE_BOOT="true"
U_BOOT_FDT_DIR="/dtb-"
EOF

View File

@@ -1 +0,0 @@
../../../24.03-lts-sp1/userspace/base/post.d/

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env sh
cat << EOF | chroot "${ROOTFS_DIR}" passwd root
openEuler12#$
openEuler12#$
EOF

View File

@@ -0,0 +1,4 @@
#!/usr/bin/env sh
echo openeuler-riscv64 >> "${ROOTFS_DIR}/etc/hostname"
echo "127.0.0.1 openeuler-riscv64" >> "${ROOTFS_DIR}/etc/hosts"

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env sh
cat "${ROOTFS_DIR}/usr/share/zoneinfo/Asia/Shanghai" > "${ROOTFS_DIR}/etc/localtime"

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env sh
touch "${ROOTFS_DIR}/etc/fstab"

View File

@@ -41,7 +41,7 @@ generate_bsp() {
# Prepare pre-built rootfs
ROOTFS_DIR="$(mktemp -d)"
logi "Extracting pre-built rootfs to ${ROOTFS_DIR}"
tar -xf "${ROOTFS_ARCHIVE}" -C "${ROOTFS_DIR}"
logcmd tar -xvf "${ROOTFS_ARCHIVE}" -C "${ROOTFS_DIR}"
setup_repo

View File

@@ -11,8 +11,8 @@ filesystem_validate_uuid_ext4() {
filesystem_set_uuid_ext4() {
device="${1}"
uuid="${2}"
if ! filesystem_validate_uuid_vfat "${uuid}"; then
loge "Invalid vfat serial number: ${uuid}"
if ! filesystem_validate_uuid_ext4 "${uuid}"; then
loge "Invalid ext4 serial number: ${uuid}"
exit 1
fi
tune2fs -U "${uuid}" "${device}"

View File

@@ -27,8 +27,12 @@ prepare_fs_blocks() {
fi
fs_content="${FS_IMG_DIR}/$(echo "${fs_mountpoint}" | tr '/' ':').${fs_format}"
eval "FILESYSTEM_${fs_idx}_CONTENT=${fs_content}"
truncate -s "${fs_size}" "${fs_content}"
"filesystem_make_fs_${fs_format}" "${fs_content}"
fs_uuid="FILESYSTEM_${fs_idx}_UUID"
fs_uuid="${!fs_uuid}"
"filesystem_set_uuid_${fs_format}" "${fs_content}" "${fs_uuid}"
logi "Mounting \"${fs_mountpoint}\" at \"${ROOTFS_MNT}${fs_mountpoint}\""
mkdir -p "${ROOTFS_MNT}${fs_mountpoint}"

View File

@@ -48,7 +48,7 @@ parse_image_layout_impl_partitioned_disk_table_GUID() {
logi "Parsing GUID table"
# reserve space for table header
curr_part_offset=${GUID_TABLE_RESV_SIZE}
curr_part_offset="(( ((curr_part_offset - 1) / GUID_TABLE_ALIGNMENT + 1) * GUID_TABLE_ALIGNMENT ))"
curr_part_offset="$(( ((curr_part_offset - 1) / GUID_TABLE_ALIGNMENT + 1) * GUID_TABLE_ALIGNMENT ))"
has_flex_size_part=false
for part_idx in $(seq 1 99); do
if eval "[ -z \"\${PARTITION_${part_idx}_USAGE+x}\" ]"; then