diff --git a/build.py b/build.py index 3f242452bb05b8a8ec977321bc6bdb265a6edff0..5cfdd40f2fa7eb0c90ada2aba57ab53519030581 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 1e8486522d42d492ddae68f13dd784be9acf4f42..f8d0727dfd30d1564aa386a7cd1d81743b4e2535 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 9813ad98b0ed4e754a5a7bc60f3a0b4eeca4a691..5ac0e9e87ac1c4ef16eb5d779cf3788feb1ab443 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 2dbdb6ecc1c416c5f5104f493ec43d9bff631a3f..e84c18ebcc2045c966b7e940166380a9ed04e11b 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 0000000000000000000000000000000000000000..ac83f9ce1c2697d838988dd3d60cce93933cb799 --- /dev/null +++ b/script/step/make_devstation_iso.sh @@ -0,0 +1,171 @@ +#!/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 + + # 缩减镜像大小 + 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 + # 创建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=1000MB count=4 +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" + # rpmlist中文字体 + echo "\nwqy-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 + 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 85ae66926019cd9f57247be08034047652ebd123..6489d0a62dbaa7f2d99a4721cf311cbb9f49fa3e 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 0000000000000000000000000000000000000000..f32a7cbe02d154bcead21371b33ae2cc2a9c46cd --- /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} +}