From 46f71a7a10f5e309df33e84ae36631f4907b3069 Mon Sep 17 00:00:00 2001 From: yafen Date: Tue, 24 Nov 2020 23:30:29 +0800 Subject: [PATCH 1/5] cat /proc/mounts&workdir bug fix --- scripts/build-image-common.sh | 17 ++++++++++------- scripts/build-image.sh | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index 4a5bf31..d24cd4d 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -129,8 +129,6 @@ INSTALL_PACKAGES(){ done } -trap 'UMOUNT_ALL' EXIT - prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} @@ -259,7 +257,7 @@ prepare(){ update_firmware_app(){ LOG "update firmware and app begin..." - cd "${run_dir}" + cd "${run_dir}/" ######## firmware if [[ ! -d firmware ]]; then git clone --depth=1 https://github.com/raspberrypi/firmware @@ -365,7 +363,7 @@ make_kernel(){ update_kernel(){ LOG "update kernel begin..." - cd "${run_dir}" + cd "${run_dir}/" kernel_dir="" for file in `ls` do @@ -458,7 +456,7 @@ update_kernel(){ make_rootfs(){ LOG "make rootfs for ${repo_file} begin..." - cd "${run_dir}" + cd "${run_dir}/" if [[ -d ${rootfs_dir} ]]; then UMOUNT_ALL rm -rf ${rootfs_dir} @@ -524,8 +522,9 @@ make_rootfs(){ make_img(){ LOG "make ${img_file} begin..." + device="" LOSETUP_D_IMG - cd "${run_dir}" + cd "${run_dir}/" size=`du -sh --block-size=1MiB ${rootfs_dir} | cut -f 1 | xargs` size=$(($size+1150)) losetup -D @@ -591,7 +590,7 @@ make_img(){ fi fi done - cd "${run_dir}" + cd "${run_dir}/" sync sleep 10 LOSETUP_D_IMG @@ -627,6 +626,9 @@ OS_NAME=openEuler cur_dir=$(cd $(dirname $0);pwd) run_dir=${cur_dir} +if [ "x${run_dir}" == "x/" ]; then + run_dir="" +fi tmp_dir=${cur_dir}/tmp buildid=$(date +%Y%m%d%H%M%S) @@ -642,6 +644,7 @@ CONFIG_STANDARD_LIST=${euler_dir}/standardlist CONFIG_FULL_LIST=${euler_dir}/fulllist img_spec="" +trap 'UMOUNT_ALL' EXIT UMOUNT_ALL prepare IFS=$'\n' diff --git a/scripts/build-image.sh b/scripts/build-image.sh index aca250e..326e4f0 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -115,8 +115,6 @@ INSTALL_PACKAGES(){ done } -trap 'UMOUNT_ALL' EXIT - prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} @@ -286,6 +284,7 @@ make_rootfs(){ make_img(){ LOG "make ${img_file} begin..." + device="" LOSETUP_D_IMG size=`du -sh --block-size=1MiB ${rootfs_dir} | cut -f 1 | xargs` size=$(($size+1100)) @@ -380,7 +379,17 @@ fi OS_NAME=openEuler -workdir=$(cd "$(dirname $workdir)"; pwd)/$(basename $workdir) +if [ "x${workdir}" == "x./" ]; then + workdir=${cur_dir} +fi +if [ "x${workdir}" == "x/" ]; then + workdir="" +elif [ "x$(dirname $workdir)" == "x/" ]; then + workdir=/$(basename $workdir) +else + workdir=$(cd "$(dirname $workdir)"; pwd)/$(basename $workdir) +fi + rootfs_dir=${workdir}/raspi_output/rootfs root_mnt=${workdir}/raspi_output/root boot_mnt=${workdir}/raspi_output/boot @@ -396,6 +405,7 @@ img_spec="" builddate=$(date +%Y%m%d) +trap 'UMOUNT_ALL' EXIT UMOUNT_ALL prepare IFS=$'\n' -- Gitee From 93b30170e7724db5d8a92bcb08ba0d08c0c1a88e Mon Sep 17 00:00:00 2001 From: yafen Date: Wed, 25 Nov 2020 11:28:00 +0800 Subject: [PATCH 2/5] update kernel conflict&download openEuler-release.rpm fail --- scripts/build-image-common.sh | 7 +++++++ scripts/build-image.sh | 1 + 2 files changed, 8 insertions(+) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index d24cd4d..e6513d6 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -210,6 +210,7 @@ prepare(){ mkdir ${cur_dir}/log fi LOG "prepare begin..." + dnf clean all dnf makecache dnf install -y bison flex openssl-devel bc wget dnf-plugins-core tar parted dosfstools grep bash xz kpartx @@ -399,6 +400,7 @@ update_kernel(){ fi fi cd "${kernel_dir}" + make distclean cur_branch=`git branch | grep \*` cur_branch=${cur_branch##*\ } exist_branch=0 @@ -433,7 +435,12 @@ update_kernel(){ ERROR "no ${kernel_branch} found." exit 1 else + set +e git pull origin ${kernel_branch} # git_rst=`xxx` + if [ $? -ne 0 ]; then + git reset --hard remotes/origin/${kernel_branch} + fi + set -e make_kernel ${kernel_dir} fi # if [[ ${git_rst} = Already* ]]; then diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 326e4f0..49306d7 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -183,6 +183,7 @@ prepare(){ mkdir -p ${log_dir} fi LOG "prepare begin..." + dnf clean all dnf makecache dnf install -y dnf-plugins-core tar parted dosfstools grep bash xz kpartx -- Gitee From f45cba337779f7fd5e3bd9c5f3ff1688a0b95b24 Mon Sep 17 00:00:00 2001 From: yafen Date: Wed, 25 Nov 2020 14:46:14 +0800 Subject: [PATCH 3/5] sha256sum img_file bug fix --- scripts/build-image-common.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index e6513d6..c121295 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -70,11 +70,11 @@ parseargs() } ERROR(){ - echo `date` - ERROR, $* | tee -a ${cur_dir}/log/log_${builddate}.log + echo `date` - ERROR, $* | tee -a ${log_dir}/log_${builddate}.log } LOG(){ - echo `date` - INFO, $* | tee -a ${cur_dir}/log/log_${builddate}.log + echo `date` - INFO, $* | tee -a ${log_dir}/log_${builddate}.log } UMOUNT_ALL(){ @@ -204,20 +204,16 @@ prepare(){ img_name=${img_name}.img fi fi - img_file=${run_dir}/img/${builddate}/${img_name} + img_file=${img_dir}/${img_name} - if [ ! -d ${cur_dir}/log ]; then - mkdir ${cur_dir}/log + if [ ! -d ${log_dir} ]; then + mkdir ${log_dir} fi LOG "prepare begin..." dnf clean all dnf makecache dnf install -y bison flex openssl-devel bc wget dnf-plugins-core tar parted dosfstools grep bash xz kpartx - if [ ! -d ${run_dir}/img ]; then - mkdir ${run_dir}/img - fi - repo_info_names=`cat ${repo_file} | grep "^\["` repo_baseurls=`cat ${repo_file} | grep "^baseurl="` index=1 @@ -250,8 +246,8 @@ prepare(){ wget https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules -P ${tmp_dir}/ wget https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/plain/regulatory.db.p7s -P ${tmp_dir}/ wget https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git/plain/regulatory.db -P ${tmp_dir}/ - if [ ! -d ${run_dir}/img/${builddate} ]; then - mkdir -p ${run_dir}/img/${builddate} + if [ ! -d ${img_dir} ]; then + mkdir -p ${img_dir} fi LOG "prepare end." } @@ -602,15 +598,18 @@ make_img(){ sleep 10 LOSETUP_D_IMG rm ${run_dir}/rootfs.tar + rm -rf ${rootfs_dir} + losetup -D + pushd ${img_dir} if [ -f ${img_file} ]; then sha256sum $(basename ${img_file}) > ${img_file}.sha256sum xz -T 20 -z -c ${img_file} > ${img_file}.xz sha256sum $(basename ${img_file}.xz) > ${img_file}.xz.sha256sum LOG "made sum files for ${img_file}" fi + popd # rm -rf ${output_dir} - rm -rf ${rootfs_dir} - losetup -D + LOG "write ${img_file} done." LOG "make ${img_file} end." } @@ -636,10 +635,13 @@ run_dir=${cur_dir} if [ "x${run_dir}" == "x/" ]; then run_dir="" fi -tmp_dir=${cur_dir}/tmp buildid=$(date +%Y%m%d%H%M%S) builddate=${buildid:0:8} + +tmp_dir=${cur_dir}/tmp +log_dir=${cur_dir}/log +img_dir=${run_dir}/img/${builddate} output_dir=${run_dir}/output rootfs_dir=${run_dir}/rootfs_${builddate} root_mnt=${run_dir}/root -- Gitee From f605679deae32d7224d86f870a402c8344111956 Mon Sep 17 00:00:00 2001 From: yafen Date: Wed, 25 Nov 2020 18:51:44 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build-image-common.sh | 23 ----------------------- scripts/build-image.sh | 6 ------ 2 files changed, 29 deletions(-) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index c121295..d05da11 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -230,7 +230,6 @@ prepare(){ done set +e os_release_name=${OS_NAME}-release - # yumdownloader --downloaddir=${tmp_dir} ${os_release_name} -c ${repo_file} dnf ${repo_info} --disablerepo="*" --downloaddir=${tmp_dir}/ download ${os_release_name} if [ $? != 0 ]; then ERROR "Fail to download ${os_release_name}!" @@ -439,21 +438,6 @@ update_kernel(){ set -e make_kernel ${kernel_dir} fi - # if [[ ${git_rst} = Already* ]]; then - # echo "updated." - # if [ ! -d ${run_dir}/output ]; then - # make_kernel ${kernel_dir} - # else - # output_dir=${run_dir}/output - # fi - # elif [[ ${git_rst} = fatal* ]]; then - # echo "get newest kernel failed!!!" - # ERROR "get newest kernel failed!!!" - # exit 1 - # else - # cd "${kernel_dir}" - # make_kernel ${kernel_dir} - # fi LOG "update kernel end." } @@ -475,9 +459,6 @@ make_rootfs(){ mkdir -p ${rootfs_dir}/etc/yum.repos.d fi cp ${repo_file} ${rootfs_dir}/etc/yum.repos.d/tmp.repo - # dnf --installroot=${rootfs_dir}/ install dnf --nogpgcheck -y #--repofrompath=${repo_file_name},${rootfs_dir}/etc/yum.repos.d/${repo_file_name} - # dnf --installroot=${rootfs_dir}/ makecache - # dnf --installroot=${rootfs_dir}/ install -y alsa-utils wpa_supplicant vim net-tools iproute iputils NetworkManager openssh-server passwd hostname ntp bluez pulseaudio-module-bluetooth set +e if [ $img_spec == "headless" ]; then INSTALL_PACKAGES $CONFIG_RPM_LIST @@ -540,8 +521,6 @@ make_img(){ LOG "after losetup: ${device}" trap 'LOSETUP_D_IMG' EXIT LOG "image ${img_file} created and mounted as ${device}" - # loopX=`kpartx -va ${device} | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1` - # LOG "after kpartx: ${loopX}" kpartx -va ${device} loopX=${device##*\/} partprobe ${device} @@ -608,8 +587,6 @@ make_img(){ LOG "made sum files for ${img_file}" fi popd - # rm -rf ${output_dir} - LOG "write ${img_file} done." LOG "make ${img_file} end." } diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 49306d7..563e7d1 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -210,7 +210,6 @@ prepare(){ done set +e os_release_name=${OS_NAME}-release - # yumdownloader --downloaddir=${tmp_dir} ${os_release_name} -c ${repo_file} dnf ${repo_info} --disablerepo="*" --downloaddir=${tmp_dir}/ download ${os_release_name} if [ $? != 0 ]; then ERROR "Fail to download ${os_release_name}!" @@ -242,10 +241,7 @@ make_rootfs(){ mkdir -p ${rootfs_dir}/etc/yum.repos.d fi cp ${repo_file} ${rootfs_dir}/etc/yum.repos.d/tmp.repo - # dnf --installroot=${rootfs_dir}/ install dnf --nogpgcheck -y # --repofrompath=tmp,${rootfs_dir}/etc/yum.repos.d/tmp.repo --disablerepo="*" dnf --installroot=${rootfs_dir}/ makecache - # dnf --installroot=${rootfs_dir}/ install -y alsa-utils wpa_supplicant vim net-tools iproute iputils NetworkManager openssh-server passwd hostname ntp bluez pulseaudio-module-bluetooth - # dnf --installroot=${rootfs_dir}/ install -y raspberrypi-kernel raspberrypi-firmware openEuler-repos set +e if [ $img_spec == "headless" ]; then INSTALL_PACKAGES $CONFIG_RPM_LIST @@ -299,8 +295,6 @@ make_img(){ LOG "after losetup: ${device}" trap 'LOSETUP_D_IMG' EXIT LOG "image ${img_file} created and mounted as ${device}" - # loopX=`kpartx -va ${device} | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1` - # LOG "after kpartx: ${loopX}" kpartx -va ${device} loopX=${device##*\/} partprobe ${device} -- Gitee From 41179e3a033a1c1ce626864d7af325bba8367d45 Mon Sep 17 00:00:00 2001 From: yafen Date: Thu, 26 Nov 2020 15:32:33 +0800 Subject: [PATCH 5/5] normalize workdir --- README.en.md | 4 ++ README.md | 4 ++ scripts/build-image-common.sh | 73 ++++++++++++++++++----------------- scripts/build-image.sh | 23 +++++------ 4 files changed, 54 insertions(+), 50 deletions(-) diff --git a/README.en.md b/README.en.md index 69e15d1..5540387 100644 --- a/README.en.md +++ b/README.en.md @@ -221,6 +221,8 @@ Run the following command to build an image: `sudo bash build-image-common.sh -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO -s SPEC --cores N` +After building the image, you can find the image in `raspi_output_common/img/` of the directory in which the script resides as shown in the script output. + The meaning of each parameter: 1. -n, --name IMAGE_NAME @@ -316,6 +318,8 @@ Run the following command to build an image: `sudo bash build-image-docker.sh -d DOCKER_FILE -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO --cores N` +After building the image, you can find the image in `raspi_output_common/img/` of the directory in which the script resides. + Caution, before running the script, you need to install Docker. The script will automatically import the Docker image into the local system according to the script's parameter: DOCKER_FILE. In addition to the parameter DOCKER_FILE, the other parameters are the same as the corresponding parameters in [Build on host](#Build-on-host): diff --git a/README.md b/README.md index 3833520..5be59b0 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,8 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community `sudo bash build-image-common.sh -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO -s SPEC --cores N` +脚本运行结束后,会提示镜像的存储位置,镜像默认保存在脚本运行所在目录的 `raspi_output_common/img/` 下。 + 各个参数意义: 1. -n, --name IMAGE_NAME @@ -318,6 +320,8 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community `sudo bash build-image-docker.sh -d DOCKER_FILE -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO --cores N` +脚本运行结束后,镜像默认保存在脚本运行所在目录的 `raspi_output_common/img/` 下。 + 注意!!!运行该脚本前,需安装 Docker 运行环境。该脚本会自动将 DOCKER_FILE 参数对应的 Docker 镜像导入本机系统中。 除参数 DOCKER_FILE 外,剩余参数与[主机上构建](#主机上构建)中对应参数一致: diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index d05da11..9e1ed89 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -70,11 +70,11 @@ parseargs() } ERROR(){ - echo `date` - ERROR, $* | tee -a ${log_dir}/log_${builddate}.log + echo `date` - ERROR, $* | tee -a ${log_dir}/${builddate}.log } LOG(){ - echo `date` - INFO, $* | tee -a ${log_dir}/log_${builddate}.log + echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log } UMOUNT_ALL(){ @@ -159,7 +159,7 @@ prepare(){ if [ "x$repo_file" == "x" ] ; then echo `date` - ERROR, \"-r REPO_INFO or --repo REPO_INFO\" missing. help 2 - elif [ "x${repo_file:0:4}" = "xhttp" ]; then + elif [ "x${repo_file:0:4}" == "xhttp" ]; then if [ "x${repo_file:0-5}" == "x.repo" ]; then wget ${repo_file} -P ${tmp_dir}/ repo_file_name=${repo_file##*/} @@ -207,7 +207,7 @@ prepare(){ img_file=${img_dir}/${img_name} if [ ! -d ${log_dir} ]; then - mkdir ${log_dir} + mkdir -p ${log_dir} fi LOG "prepare begin..." dnf clean all @@ -253,7 +253,7 @@ prepare(){ update_firmware_app(){ LOG "update firmware and app begin..." - cd "${run_dir}/" + cd "${workdir}" ######## firmware if [[ ! -d firmware ]]; then git clone --depth=1 https://github.com/raspberrypi/firmware @@ -359,12 +359,12 @@ make_kernel(){ update_kernel(){ LOG "update kernel begin..." - cd "${run_dir}/" + cd "${workdir}" kernel_dir="" for file in `ls` do if [[ ${file} = ${kernel_name} && -d ${file}/.git ]]; then - kernel_dir=${run_dir}/${file} + kernel_dir=${workdir}/${file} break fi done @@ -377,7 +377,7 @@ update_kernel(){ ERROR "clone ${kernel_name} failed." exit 1 fi - kernel_dir=${run_dir}/${kernel_name} + kernel_dir=${workdir}/${kernel_name} else cd "${kernel_name}" remote_url_exist=`git remote -v | grep "origin"` @@ -443,12 +443,10 @@ update_kernel(){ make_rootfs(){ LOG "make rootfs for ${repo_file} begin..." - cd "${run_dir}/" if [[ -d ${rootfs_dir} ]]; then UMOUNT_ALL rm -rf ${rootfs_dir} fi - mkdir ${rootfs_dir} mkdir -p ${rootfs_dir}/var/lib/rpm rpm --root ${rootfs_dir} --initdb rpm -ivh --nodeps --root ${rootfs_dir}/ ${os_release_name} @@ -479,16 +477,16 @@ make_rootfs(){ fi cp ${euler_dir}/ifup-eth0 $rootfs_dir/etc/sysconfig/network-scripts/ifup-eth0 mkdir -p ${rootfs_dir}/lib/firmware ${rootfs_dir}/usr/bin ${rootfs_dir}/lib/udev/rules.d ${rootfs_dir}/lib/systemd/system - cp bluez-firmware/broadcom/* ${rootfs_dir}/lib/firmware/ - cp -r firmware-nonfree/brcm/ ${rootfs_dir}/lib/firmware/ + cp ${workdir}/bluez-firmware/broadcom/* ${rootfs_dir}/lib/firmware/ + cp -r ${workdir}/firmware-nonfree/brcm/ ${rootfs_dir}/lib/firmware/ mv ${rootfs_dir}/lib/firmware/BCM43430A1.hcd ${rootfs_dir}/lib/firmware/brcm/ mv ${rootfs_dir}/lib/firmware/BCM4345C0.hcd ${rootfs_dir}/lib/firmware/brcm/ cp ${tmp_dir}/regulatory.db* ${rootfs_dir}/lib/firmware/ cp ${tmp_dir}/*.rules ${rootfs_dir}/lib/udev/rules.d/ - cp pi-bluetooth/usr/bin/* ${rootfs_dir}/usr/bin/ - cp pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules ${rootfs_dir}/lib/udev/rules.d/ - cp pi-bluetooth/debian/pi-bluetooth.bthelper\@.service ${rootfs_dir}/lib/systemd/system/bthelper\@.service - cp pi-bluetooth/debian/pi-bluetooth.hciuart.service ${rootfs_dir}/lib/systemd/system/hciuart.service + cp ${workdir}/pi-bluetooth/usr/bin/* ${rootfs_dir}/usr/bin/ + cp ${workdir}/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules ${rootfs_dir}/lib/udev/rules.d/ + cp ${workdir}/pi-bluetooth/debian/pi-bluetooth.bthelper\@.service ${rootfs_dir}/lib/systemd/system/bthelper\@.service + cp ${workdir}/pi-bluetooth/debian/pi-bluetooth.hciuart.service ${rootfs_dir}/lib/systemd/system/hciuart.service cp -r ${output_dir}/lib/modules ${rootfs_dir}/lib/ mkdir -p ${rootfs_dir}/usr/share/licenses/raspi cp ${euler_dir}/License/* ${rootfs_dir}/usr/share/licenses/raspi/ @@ -508,7 +506,6 @@ make_img(){ LOG "make ${img_file} begin..." device="" LOSETUP_D_IMG - cd "${run_dir}/" size=`du -sh --block-size=1MiB ${rootfs_dir} | cut -f 1 | xargs` size=$(($size+1150)) losetup -D @@ -544,7 +541,7 @@ make_img(){ echo "UUID=${fstab_array[1]} /boot vfat defaults,noatime 0 0" >> ${rootfs_dir}/etc/fstab echo "UUID=${fstab_array[2]} swap swap defaults,noatime 0 0" >> ${rootfs_dir}/etc/fstab - cp -rf --preserve=mode,timestamps --no-preserve=ownership ${run_dir}/firmware/boot/* ${boot_mnt}/ + cp -rf --preserve=mode,timestamps --no-preserve=ownership ${workdir}/firmware/boot/* ${boot_mnt}/ pushd ${boot_mnt}/ rm -f *.dtb cmdline.txt kernel.img kernel7.img kernel7l.img cp ${euler_dir}/config.txt ./ @@ -554,13 +551,15 @@ make_img(){ cp --preserve=mode,timestamps --no-preserve=ownership ${output_dir}/*.dtb ${boot_mnt}/ cp --preserve=mode,timestamps --no-preserve=ownership ${output_dir}/overlays/* ${boot_mnt}/overlays/ - if [ -f ${run_dir}/rootfs.tar ]; then - rm ${run_dir}/rootfs.tar + if [ -f ${tmp_dir}/rootfs.tar ]; then + rm ${tmp_dir}/rootfs.tar fi - cd ${rootfs_dir} - tar cpf ${run_dir}/rootfs.tar . - cd ${root_mnt} - tar xpf ${run_dir}/rootfs.tar -C . + pushd ${rootfs_dir} + rm -rf boot + tar cpf ${tmp_dir}/rootfs.tar . + popd + pushd ${root_mnt} + tar xpf ${tmp_dir}/rootfs.tar -C . for tmpdir in `ls ${output_dir}/lib/modules` do if [ -d ./lib/modules/${tmpdir} ]; then @@ -572,11 +571,11 @@ make_img(){ fi fi done - cd "${run_dir}/" + popd sync sleep 10 LOSETUP_D_IMG - rm ${run_dir}/rootfs.tar + rm ${tmp_dir}/rootfs.tar rm -rf ${rootfs_dir} losetup -D pushd ${img_dir} @@ -608,21 +607,23 @@ OS_NAME=openEuler cur_dir=$(cd $(dirname $0);pwd) -run_dir=${cur_dir} -if [ "x${run_dir}" == "x/" ]; then - run_dir="" +workdir=${cur_dir} +if [ "x${workdir}" == "x/" ]; then + workdir=/raspi_output_common +else + workdir=${workdir}/raspi_output_common fi buildid=$(date +%Y%m%d%H%M%S) builddate=${buildid:0:8} -tmp_dir=${cur_dir}/tmp -log_dir=${cur_dir}/log -img_dir=${run_dir}/img/${builddate} -output_dir=${run_dir}/output -rootfs_dir=${run_dir}/rootfs_${builddate} -root_mnt=${run_dir}/root -boot_mnt=${run_dir}/boot +tmp_dir=${workdir}/tmp +log_dir=${workdir}/log +img_dir=${workdir}/img +output_dir=${workdir}/output +rootfs_dir=${workdir}/rootfs +root_mnt=${workdir}/root +boot_mnt=${workdir}/boot euler_dir=${cur_dir}/config-common CONFIG_RPM_LIST=${euler_dir}/rpmlist diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 563e7d1..54d4479 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -230,7 +230,6 @@ make_rootfs(){ UMOUNT_ALL rm -rf ${rootfs_dir} fi - mkdir -p ${rootfs_dir} mkdir -p ${rootfs_dir}/var/lib/rpm rpm --root ${rootfs_dir} --initdb rpm -ivh --nodeps --root ${rootfs_dir}/ ${os_release_name} @@ -374,23 +373,19 @@ fi OS_NAME=openEuler -if [ "x${workdir}" == "x./" ]; then - workdir=${cur_dir} -fi +workdir=$(cd $workdir; pwd) if [ "x${workdir}" == "x/" ]; then - workdir="" -elif [ "x$(dirname $workdir)" == "x/" ]; then - workdir=/$(basename $workdir) + workdir=/raspi_output else - workdir=$(cd "$(dirname $workdir)"; pwd)/$(basename $workdir) + workdir=${workdir}/raspi_output fi -rootfs_dir=${workdir}/raspi_output/rootfs -root_mnt=${workdir}/raspi_output/root -boot_mnt=${workdir}/raspi_output/boot -tmp_dir=${workdir}/raspi_output/tmp -log_dir=${workdir}/raspi_output/log -img_dir=${workdir}/raspi_output/img +tmp_dir=${workdir}/tmp +log_dir=${workdir}/log +img_dir=${workdir}/img +rootfs_dir=${workdir}/rootfs +root_mnt=${workdir}/root +boot_mnt=${workdir}/boot euler_dir=${cur_dir}/config CONFIG_RPM_LIST=${euler_dir}/rpmlist -- Gitee