@@ -49,7 +49,6 @@ config_path="${compile_path}/tools/config"
4949script_path=" ${compile_path} /tools/script"
5050kernel_patch_path=" ${compile_path} /tools/patch"
5151armbian_path=" ${compile_path} /tools/armbian"
52- armbian_file=" ${armbian_path} /armbian.img"
5352output_path=" ${compile_path} /output"
5453chroot_path=" ${output_path} /chroot"
5554chroot_file=" ${chroot_path} /chroot_armbian.img"
@@ -269,7 +268,7 @@ toolchain_check() {
269268 fi
270269
271270 # Download armbian
272- if [[ ! -f " ${armbian_file } " ]]; then
271+ if [[ ! -s " ${armbian_path} / ${armbian_rootfs_file }" ]]; then
273272 echo -e " ${INFO} Start downloading Armbian rootfs file [ ${armbian_rootfs_file} ]..."
274273 rm -rf ${armbian_path} && mkdir -p ${armbian_path}
275274
@@ -278,17 +277,7 @@ toolchain_check() {
278277 curl -fsSL " ${dev_repo} /${armbian_rootfs_file} " -o " ${armbian_path} /${armbian_rootfs_file} "
279278 [[ " ${?} " -eq " 0" ]] && break || sleep 60
280279 done
281- [[ " ${?} " -eq " 0" ]] || error_msg " Armbian file download failed"
282-
283- # Decompress the Armbian rootfs file
284- tar -xJf ${armbian_path} /${armbian_rootfs_file} -C ${armbian_path}
285-
286- # Change other names to armbian.img
287- [[ -f " ${armbian_file} " ]] || mv -f ${armbian_path} /* .img ${armbian_file}
288-
289- # Delete download file
290- rm -f ${armbian_path} /${armbian_rootfs_file}
291- [[ -f " ${armbian_file} " ]] || error_msg " There is no Armbian rootfs file: [ ${armbian_file} ]"
280+ [[ -s " ${armbian_path} /${armbian_rootfs_file} " ]] || error_msg " Armbian file download failed"
292281 fi
293282
294283 # Set the default path
@@ -470,13 +459,31 @@ get_kernel_source() {
470459 [[ " ${auto_patch} " == " true" || " ${auto_patch} " == " yes" ]] && apply_patch
471460}
472461
462+ unmount_armbian () {
463+ echo -e " ${STEPS} Unmounting Armbian chroot"
464+ tag_rootfs=" ${chroot_path} /root"
465+ cd ${current_path}
466+
467+ sync && sleep 3
468+ umount ${tag_rootfs} /dev/fd 2> /dev/null
469+ umount ${tag_rootfs} /dev/pts 2> /dev/null
470+ umount ${tag_rootfs} /dev 2> /dev/null
471+ umount ${tag_rootfs} /proc 2> /dev/null
472+ umount ${tag_rootfs} /boot 2> /dev/null
473+ umount ${tag_rootfs} 2> /dev/null
474+ losetup -D 2> /dev/null
475+ }
476+
473477chroot_armbian () {
474478 cd ${current_path}
475479 echo -e " ${STEPS} Create chroot..."
476480 echo -e " ${INFO} Current space usage: \n$( df -hT ${chroot_path} ) \n"
477481
482+ # Extract the armbian rootfs file
478483 rm -f ${chroot_file}
479- cp -f ${armbian_file} ${chroot_file}
484+ [[ -d " ${chroot_path} /root" ]] || mkdir -p ${chroot_path} /root
485+ tar -xJf ${armbian_path} /${armbian_rootfs_file} -O > " ${chroot_file} "
486+ [[ " ${?} " -eq " 0" && -s " ${chroot_file} " ]] || error_msg " Armbian rootfs file extraction failed."
480487
481488 # Mount the armbian system
482489 tag_rootfs=" ${chroot_path} /root"
@@ -545,7 +552,6 @@ chroot_armbian() {
545552 echo -e " ${INFO} Copy the [ ubuntu_chroot_armbian.sh ] script to the armbian system..."
546553 cp -f ${script_path} /ubuntu_chroot_armbian.sh ${tag_rootfs} /root
547554 chmod +x ${tag_rootfs} /root/ubuntu_chroot_armbian.sh
548- sync && sleep 3
549555 # echo -e "${INFO} Kernel copy results in the [ ${tag_rootfs}/root ] directory: \n$(ls -l ${tag_rootfs}/root) \n"
550556
551557 # Enter the armbian system to generate /boot/uInitrd-${kernel_outname} file
@@ -555,8 +561,10 @@ chroot_armbian() {
555561 mount --bind /dev/pts ${tag_rootfs} /dev/pts
556562 mount --bind /proc/$$ /fd ${tag_rootfs} /dev/fd
557563 chmod 0666 ${tag_rootfs} /dev/null
564+ sync && sleep 3
558565
559- trap unmount_armbian SIGINT # Always unmount armbian on exit
566+ # Always unmount armbian on exit
567+ trap unmount_armbian SIGINT
560568 chroot ${tag_rootfs} /bin/bash -c " /root/ubuntu_chroot_armbian.sh ${kernel_outname} "
561569 if [[ " ${?} " -ne " 0" || ! -f " ${tag_rootfs} /boot/uInitrd-${kernel_outname} " ]]; then
562570 unmount_armbian
@@ -579,21 +587,6 @@ chroot_armbian() {
579587 unmount_armbian
580588}
581589
582- unmount_armbian () {
583- echo -e " ${STEPS} Unmounting Armbian chroot"
584- tag_rootfs=" ${chroot_path} /root"
585- cd ${current_path}
586-
587- sync && sleep 3
588- umount ${tag_rootfs} /dev/fd 2> /dev/null
589- umount ${tag_rootfs} /dev/pts 2> /dev/null
590- umount ${tag_rootfs} /dev 2> /dev/null
591- umount ${tag_rootfs} /proc 2> /dev/null
592- umount ${tag_rootfs} /boot 2> /dev/null
593- umount ${tag_rootfs} 2> /dev/null
594- losetup -D 2> /dev/null
595- }
596-
597590compile_env () {
598591 cd ${current_path}
599592 echo -e " ${STEPS} Start checking local compilation environments..."
0 commit comments