From ef7a56c365ed83da57527faf74de24338caf75c1 Mon Sep 17 00:00:00 2001 From: wangchong1995924 <15229716099@163.com> Date: Thu, 26 Sep 2024 16:06:50 +0800 Subject: [PATCH 1/5] support make_devstation_iso --- build.py | 11 +-- script/common_function.sh | 1 + script/make_version.sh | 2 +- script/setup_env.sh | 10 +++ script/step/make_devstation_iso.sh | 125 +++++++++++++++++++++++++++++ script/tools/chroot.sh | 36 +++++++++ script/tools/create_compile_env.sh | 35 ++++++++ 7 files changed, 214 insertions(+), 6 deletions(-) create mode 100755 script/step/make_devstation_iso.sh create mode 100755 script/tools/create_compile_env.sh diff --git a/build.py b/build.py index 3f24245..5cfdd40 100644 --- a/build.py +++ b/build.py @@ -18,7 +18,7 @@ PARAMS = ['all', 'set_release_dir', 'update_release_info', 'build_and_wait', 'ma 'make_compile_env_storage', 'make_euleros_certdb', 'make_vm_qcow2', 'make_compile_tools', 'make_images_slim', 'make_tools_lib_storage', 'make_container_tools', 'make_tools_debug_tools', 'make_upgrade_patch', 'make_tools_dockertools', 'make_other_tools', 'upload_to_cmc', 'make_upload_cmc_image', 'make_iso_everything', - 'make_iso_everysrc', 'make_debug_everything', 'push_lts_dir', 'make_netinst_iso', 'get_epol_rpms', 'make_edge_iso', 'make_desktop_iso', 'make_riscv64_qemu_image'] + 'make_iso_everysrc', 'make_debug_everything', 'push_lts_dir', 'make_netinst_iso', 'get_epol_rpms', 'make_edge_iso', 'make_desktop_iso', 'make_riscv64_qemu_image', 'make_devstation_iso'] class Build(object): @@ -106,10 +106,10 @@ class Build(object): if os.system(cmd) != 0: logger.error("build fail") return -1 - cmd = "bash -x reset_release_server_ip.sh" - if os.system(cmd) != 0: - logger.error("build fail") - return -1 + #cmd = "bash -x reset_release_server_ip.sh" + #if os.system(cmd) != 0: + # logger.error("build fail") + # return -1 code = trace_execute("bash {0} {1}".format( self.local_build_shell_path, step), env=self.env, logger=logger) if code != 0 and code != "0": @@ -141,6 +141,7 @@ def usage(): print("* make_iso *") print("* make_edge_iso *") print("* make_desktop_iso *") + print("* make_devstation_iso *") print("* make_netinst_iso *") print("* make_iso_everysrc *") print("* make_iso_everything *") diff --git a/script/common_function.sh b/script/common_function.sh index 1e84865..f8d0727 100644 --- a/script/common_function.sh +++ b/script/common_function.sh @@ -105,3 +105,4 @@ source "${BUILD_SCRIPT_DIR}"/step/make_desktop_iso.sh source "${BUILD_SCRIPT_DIR}"/step/make_iso_everything.sh source "${BUILD_SCRIPT_DIR}"/step/make_debug_everything.sh source "${BUILD_SCRIPT_DIR}"/step/make_iso_everysrc.sh +source "${BUILD_SCRIPT_DIR}"/step/make_devstation_iso.sh diff --git a/script/make_version.sh b/script/make_version.sh index 9813ad9..5ac0e9e 100644 --- a/script/make_version.sh +++ b/script/make_version.sh @@ -40,7 +40,7 @@ function usage() echo "$(basename $0) [script_name|all]" } -export ALL_SCRIPT=('make_hmi' 'make_iso' 'make_docker_image' 'make_raspi_image' 'make_riscv64_qemu_image' 'make_microvm_image' 'make_iso_everything' 'make_iso_everysrc' 'make_debug_everything' 'make_netinst_iso' 'get_epol_rpms' 'make_edge_iso' 'make_desktop_iso' 'make_riscv64_image') +export ALL_SCRIPT=('make_hmi' 'make_iso' 'make_docker_image' 'make_raspi_image' 'make_riscv64_qemu_image' 'make_microvm_image' 'make_iso_everything' 'make_iso_everysrc' 'make_debug_everything' 'make_netinst_iso' 'get_epol_rpms' 'make_edge_iso' 'make_desktop_iso' 'make_riscv64_image' 'make_devstation_iso') [[ "${DEBUG}" -eq 1 ]] && set -x arg1="$1" diff --git a/script/setup_env.sh b/script/setup_env.sh index 2dbdb6e..e84c18e 100644 --- a/script/setup_env.sh +++ b/script/setup_env.sh @@ -67,4 +67,14 @@ gpgcheck=0 EOF +if [ -n "${THIRD_REPO}" ];then + cat>>${REPO_CONF}<<-EOF1 +[THIRD_REPO] +name=THIRD_REPO +baseurl=${THIRD_REPO} +enabled=1 +gpgcheck=0 + +EOF1 +fi cat ${REPO_CONF} diff --git a/script/step/make_devstation_iso.sh b/script/step/make_devstation_iso.sh new file mode 100755 index 0000000..2b21f62 --- /dev/null +++ b/script/step/make_devstation_iso.sh @@ -0,0 +1,125 @@ +#!/bin/bash +# Author: zhengxuye +# Copyright Huawei Technologies Co., Ltd. 2010-2018. All rights reserved. +set -e + +###################### +# 构建iso镜像 +# Globals: +# Arguments: +# Returns: +###################### +function make_devstation_iso() +{ + chroot_run "cd /home; bash make_version.sh make_devstation_iso_inchroot" +} +###################### +# 在chroot中构建iso镜像 +# Globals: +# Arguments: +# Returns: +###################### +function make_devstation_iso_inchroot() +{ + get_version + release_dir=$(get_release_dir) + TIME_DIR="${release_dir#${HTTP_DIR}}" + TIME=${TIME_DIR##*/} + TIME=${TIME#"${version}"-} + yum_conf="${BUILD_SCRIPT_DIR}/config/repo_conf/repofile.conf" + yum clean all -c "${yum_conf}" + if rpm -q oemaker &> /dev/null; then + yum remove oemaker -y + fi + if rpm -q lorax &> /dev/null; then + yum remove lorax -y + fi + yum install oemaker lorax -y -c "${yum_conf}" + cd /opt/oemaker + #sed -i "/^%pre/i repo --name=\"EPOL\" --baseurl=${EPOL_PROJECT_REPO}\nrepo --name=\"other\" --baseurl=${THIRD_REPO}" config/$ARCH/livecd/livecd_$ARCH.ks + sed -i "/^%pre/i repo --name=\"everything\" --baseurl=http://121.36.84.172/dailybuild/EBS-openEuler-24.09/rc7_openeuler-2024-09-28-08-34-02/everything/${ARCH}\nrepo --name=\"epol\" --baseurl=http://121.36.84.172/dailybuild/EBS-openEuler-24.09/rc7_openeuler-2024-09-28-08-34-02/EPOL/main/${ARCH}" config/$ARCH/livecd/livecd_$ARCH.ks + + sed -i 's/part \/ --fstype="ext4" --size=40000/part \/ --fstype="ext4" --size=4000/' config/$ARCH/livecd/livecd_$ARCH.ks + sed -i '/%post/a \ +touch /etc/yum.repos.d/local.repo\n\ +cat << EOF > /etc/yum.repos.d/local.repo\n\ +[local-repo]\n\ +name=local\n\ +baseurl=file:///run/initramfs/live\n\ +enabled=1\n\ +gpgcheck=0\n\ +EOF\n\ +echo "zh_CN.UTF-8" > /etc/locale.conf\n\ +systemctl enable calamares\n\ +' config/$ARCH/livecd/livecd_$ARCH.ks + + echo -e "\ncalamares\ncalamares-devel\ncalamares-interactiveterminal\ncalamares-libs\ncalamares-plasmalnf\nkpmcore\nkpmcore-devel" >> config/$ARCH/livecd/rpmlist + sed -i '/python3-bind/d' config/$ARCH/livecd/rpmlist + cat config/$ARCH/livecd/livecd_$ARCH.ks + REPOS=`echo "${THIRD_REPO}" | sed 's/[ \t]*$//g'` + set +e + num=0 + set +u + while [ "${num}" -lt 3 ] + do + bash -x oemaker -t livecd -p ${PRODUCTS} -v "${OS_VERSION}" -r "" -s "${REPOS}" + if [ $? -eq 0 ];then + break + elif [ $? -eq 133 ]; then + sleep 60 + ((num=num+1)) + continue + else + log_error "make_iso fail" + break + fi + done + if [ "${num}" -ge 3 ]; then + log_error "retry make_iso fail" + fi + + cd /result + livecd_iso=$(ls *.iso) + mkdir -p /mnt/iso /mnt/iso_cp + mount $livecd_iso /mnt/iso + cp -rf /mnt/iso/* /mnt/iso_cp/ + umount /mnt/iso + + volume_id=$(isoinfo -d -i $livecd_iso | grep "Volume id" | awk '{print $NF}') + + mkdir /mnt/iso_cp/Packages + cd /mnt/iso_cp/Packages + if [ "$ARCH" == "x86_64" ]; then + yumdownloader yum iproute dhcp openssh grub2 kernel bash coreutils grub2-pc passwd sudo xorg-* gnome-* --alldeps --resolve -c "${yum_conf}" + else + yumdownloader yum iproute dhcp openssh grub2-efi kernel bash coreutils efibootmgr passwd sudo xorg-* gnome-* --alldeps --resolve -c "${yum_conf}" + fi + cd /result + mkdir /mnt/iso_cp/repodata + cp /opt/oemaker/config/${ARCH}/normal.xml /mnt/iso_cp/repodata/ + createrepo -d -g /mnt/iso_cp/repodata/normal.xml /mnt/iso_cp + iso_name="${PRODUCTS}-${OS_VERSION}-DevStation-${ARCH}-dvd.iso" + + if [ "$ARCH" == "x86_64" ]; then + mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot -allow-leading-dots -no-bak -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -V "$volume_id" -o /result/${iso_name} /mnt/iso_cp + else + mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot -allow-leading-dots -no-bak -b EFI/BOOT/BOOTAA64.EFI -c boot.catalog -no-emul-boot -boot-load-size 4 -boot-info-table -V "$volume_id" -o /result/${iso_name} /mnt/iso_cp + fi + set -e + cd "/result" + + TGZ_NAME=$(ls ${iso_name}) + if [ x"${TGZ_NAME}" == x'' ]; then log_error "can not find iso";fi + create_checksum "${TGZ_NAME}" + iso_rpmlist="${OS_NAME}-${OS_VERSION}-DevStation-${ARCH}.rpmlist" + mkdir temp && mount *"${ARCH}"-dvd.iso temp + cd temp/Packages + ls *.rpm > "../../${iso_rpmlist}" + cd ../.. + umount temp + [ -n temp ] && rm -rf temp + RELEASE_DIR="${release_dir}/devStation/$ARCH" + SSH_CMD="mkdir -p ${RELEASE_DIR}" + sshcmd "${SSH_CMD}" + sshscp "${TGZ_NAME} ${TGZ_NAME}${SHA256SUM} ${iso_rpmlist}" "${RELEASE_DIR}" +} diff --git a/script/tools/chroot.sh b/script/tools/chroot.sh index 85ae669..6489d0a 100644 --- a/script/tools/chroot.sh +++ b/script/tools/chroot.sh @@ -86,6 +86,7 @@ function chroot_clean() umount "${OPENEULER_CHROOT_PATH}/sys" umount "${OPENEULER_CHROOT_PATH}/dev/pts" umount "${OPENEULER_CHROOT_PATH}/dev" + umount "${OPENEULER_CHROOT_PATH}/mnt/sysroot" rm -rf "${OPENEULER_CHROOT_PATH}" fi if [ -d "${OPENEULER_CHROOT_PATH}" ]; then @@ -119,3 +120,38 @@ function chroot_run_bep() chroot "${OPENEULER_CHROOT_PATH}" /bin/bash --login -c "$@" chroot_clean } +#!/bin/bash + + +init_compile_env() +{ + if rpm -q envmaker &> /dev/null; then + yum remove -y envmaker + fi + yum install envmaker -y -c ${REPO_CONF} + if [ $? -ne 0 ];then + echo "install envmaker error." + exit 1 + fi + + repo_conf="/opt/envmaker/config/${ARCH}/openEuler_repo.conf" + env_file_name="openEuler_compile_env_${ARCH}-1.0.0.tar.gz" + + cd /opt/envmaker/ + cp ${REPO_CONF} ${repo_conf} + bash envmaker.sh -p openEuler_compile_env_${ARCH} -v 1.0.0 + if [ $? -ne 0 ];then + echo "make compile env failed" + exit 1 + fi + + cd "/opt/envmaker/result/$(date +%Y)"* + if [ ! -s "${env_file_name}" ];then + echo "make compile env failed." + exit 1 + fi + + tar -xf openEuler_compile_env_${ARCH}-1.0.0.tar.gz -C / + cp "/etc/resolv.conf" "${root_path}/etc/" + cp -a "${LKP_SRC}/"* ${chroot_lkp} +} diff --git a/script/tools/create_compile_env.sh b/script/tools/create_compile_env.sh new file mode 100755 index 0000000..f32a7cb --- /dev/null +++ b/script/tools/create_compile_env.sh @@ -0,0 +1,35 @@ +#!/bin/bash + + +init_compile_env() +{ + if rpm -q envmaker &> /dev/null; then + yum remove -y envmaker + fi + yum install envmaker -y -c ${REPO_CONF} + if [ $? -ne 0 ];then + echo "install envmaker error." + exit 1 + fi + + repo_conf="/opt/envmaker/config/${ARCH}/openEuler_repo.conf" + env_file_name="openEuler_compile_env_${ARCH}-1.0.0.tar.gz" + + cd /opt/envmaker/ + cp ${REPO_CONF} ${repo_conf} + bash envmaker.sh -p openEuler_compile_env_${ARCH} -v 1.0.0 + if [ $? -ne 0 ];then + echo "make compile env failed" + exit 1 + fi + + cd "/opt/envmaker/result/$(date +%Y)"* + if [ ! -s "${env_file_name}" ];then + echo "make compile env failed." + exit 1 + fi + + tar -xf openEuler_compile_env_${ARCH}-1.0.0.tar.gz -C / + cp "/etc/resolv.conf" "${root_path}/etc/" + cp -a "${LKP_SRC}/"* ${chroot_lkp} +} -- Gitee From f69fba3d389ff23b2c6154d6e3bc10d7e4db8cc6 Mon Sep 17 00:00:00 2001 From: Yingjiahui Date: Mon, 30 Sep 2024 15:26:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=BC=A9=E5=87=8Frootfs=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/step/make_devstation_iso.sh | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/script/step/make_devstation_iso.sh b/script/step/make_devstation_iso.sh index 2b21f62..73e68c2 100755 --- a/script/step/make_devstation_iso.sh +++ b/script/step/make_devstation_iso.sh @@ -53,6 +53,60 @@ echo "zh_CN.UTF-8" > /etc/locale.conf\n\ systemctl enable calamares\n\ ' config/$ARCH/livecd/livecd_$ARCH.ks + # 缩减镜像大小 + if [[ ${ARCH} == "aarch64" ]];then + tmpl_name="aarch64" + elif [[ ${ARCH} == "x86_64" ]];then + tmpl_name="x86" + fi + CONFIG_FILE="/opt/oemaker/config/${ARCH}/livecd/live/${tmpl_name}.tmpl" + REDUCE_SIZE_SCRIPT="/opt/oemaker/reduce_size_of_rootfs.sh" + # 检查并编辑tmpl文件 + if [ -f "$CONFIG_FILE" ]; then + sed -i '/## install kernels/i\runcmd cp ${outroot}/../../reduce_size_of_rootfs.sh ${outroot}/\nruncmd ${outroot}/reduce_size_of_rootfs.sh' "$CONFIG_FILE" + else + echo "Error: $CONFIG_FILE not found!" + exit 1 + fi + + # 检查并编辑tmpl文件 + if [ -f "$CONFIG_FILE" ]; then + sed -i '/## install kernels/i\runcmd cp ${outroot}/../../reduce_size_of_rootfs.sh ${outroot}/\nruncmd ${outroot}/reduce_size_of_rootfs.sh' "$CONFIG_FILE" + else + echo "Error: $CONFIG_FILE not found!" + exit 1 + fi + + # 创建reduce_size_of_rootfs.sh + cat < "$REDUCE_SIZE_SCRIPT" +#!/bin/bash + +cd "\$(dirname "\$0")" +mkdir -p tmp_fs old_fs new_fs +mount LiveOS/squashfs.img old_fs +cp old_fs/* new_fs/ -rf +mount new_fs/LiveOS/rootfs.img tmp_fs + +dd if=/dev/zero of=rootfs.img bs=900MB count=1 +lo=\$(losetup -f) +losetup \${lo} rootfs.img +mke2fs -t ext4 \${lo} +mkdir tmp_dir +mount \${lo} tmp_dir +cp tmp_fs/* tmp_dir/ -rf +umount tmp_fs +umount tmp_dir +mkdir -p squ_dir/LiveOS +mv -f rootfs.img squ_dir/LiveOS + +mksquashfs squ_dir/ squashfs.img -comp xz +umount old_fs +mv -f squashfs.img LiveOS/squashfs.img +rm -rf old_fs new_fs tmp_fs +REDUCE_EOF + # 赋予脚本权限 + chmod +x "$REDUCE_SIZE_SCRIPT" + echo -e "\ncalamares\ncalamares-devel\ncalamares-interactiveterminal\ncalamares-libs\ncalamares-plasmalnf\nkpmcore\nkpmcore-devel" >> config/$ARCH/livecd/rpmlist sed -i '/python3-bind/d' config/$ARCH/livecd/rpmlist cat config/$ARCH/livecd/livecd_$ARCH.ks -- Gitee From 9deaa9b95cd6650d355fb0ca97342018f68ceb84 Mon Sep 17 00:00:00 2001 From: Yingjiahui Date: Mon, 30 Sep 2024 15:51:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?rpmlist=E5=A2=9E=E5=8A=A0=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/step/make_devstation_iso.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/step/make_devstation_iso.sh b/script/step/make_devstation_iso.sh index 73e68c2..cc74fcb 100755 --- a/script/step/make_devstation_iso.sh +++ b/script/step/make_devstation_iso.sh @@ -106,7 +106,8 @@ rm -rf old_fs new_fs tmp_fs REDUCE_EOF # 赋予脚本权限 chmod +x "$REDUCE_SIZE_SCRIPT" - + # rpmlist中文字体 + echo "wqy-zenhei-fonts" >> config/$ARCH/livecd/rpmlist echo -e "\ncalamares\ncalamares-devel\ncalamares-interactiveterminal\ncalamares-libs\ncalamares-plasmalnf\nkpmcore\nkpmcore-devel" >> config/$ARCH/livecd/rpmlist sed -i '/python3-bind/d' config/$ARCH/livecd/rpmlist cat config/$ARCH/livecd/livecd_$ARCH.ks -- Gitee From 9c34d39519d9b7af3cb300098de95db200a48b03 Mon Sep 17 00:00:00 2001 From: Yingjiahui Date: Mon, 30 Sep 2024 15:55:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/step/make_devstation_iso.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/script/step/make_devstation_iso.sh b/script/step/make_devstation_iso.sh index cc74fcb..f772584 100755 --- a/script/step/make_devstation_iso.sh +++ b/script/step/make_devstation_iso.sh @@ -68,15 +68,6 @@ systemctl enable calamares\n\ echo "Error: $CONFIG_FILE not found!" exit 1 fi - - # 检查并编辑tmpl文件 - if [ -f "$CONFIG_FILE" ]; then - sed -i '/## install kernels/i\runcmd cp ${outroot}/../../reduce_size_of_rootfs.sh ${outroot}/\nruncmd ${outroot}/reduce_size_of_rootfs.sh' "$CONFIG_FILE" - else - echo "Error: $CONFIG_FILE not found!" - exit 1 - fi - # 创建reduce_size_of_rootfs.sh cat < "$REDUCE_SIZE_SCRIPT" #!/bin/bash -- Gitee From 89a489f2b0c678c64324e8f584c893b0257d5711 Mon Sep 17 00:00:00 2001 From: Yingjiahui Date: Mon, 30 Sep 2024 17:06:14 +0800 Subject: [PATCH 5/5] =?UTF-8?q?rootfs.img=20=E5=A4=A7=E5=B0=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/step/make_devstation_iso.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/step/make_devstation_iso.sh b/script/step/make_devstation_iso.sh index f772584..a0d1300 100755 --- a/script/step/make_devstation_iso.sh +++ b/script/step/make_devstation_iso.sh @@ -78,7 +78,7 @@ mount LiveOS/squashfs.img old_fs cp old_fs/* new_fs/ -rf mount new_fs/LiveOS/rootfs.img tmp_fs -dd if=/dev/zero of=rootfs.img bs=900MB count=1 +dd if=/dev/zero of=rootfs.img bs=1000MB count=4 lo=\$(losetup -f) losetup \${lo} rootfs.img mke2fs -t ext4 \${lo} -- Gitee