@@ -50,6 +50,7 @@ CROSS_COMPILE=arm-none-linux-gnueabihf-
5050
5151# Build options
5252FAST_BUILD=0
53+ CONTINUE_BUILD=0
5354SPECIFIC_STAGE=" "
5455
5556# Parse arguments
@@ -59,6 +60,10 @@ while [[ $# -gt 0 ]]; do
5960 FAST_BUILD=1
6061 shift
6162 ;;
63+ --continue)
64+ CONTINUE_BUILD=1
65+ shift
66+ ;;
6267 --stage)
6368 SPECIFIC_STAGE=" $2 "
6469 shift 2
@@ -82,6 +87,7 @@ Usage: $0 [OPTIONS]
8287
8388Options:
8489 --fast-build Pass --fast-build to linux build (skip distclean)
90+ --continue Continue from existing release-latest (skip completed stages)
8591 --stage N Run only specific stage (1-4)
8692 --help, -h Show this help message
8793
@@ -99,6 +105,8 @@ Examples:
99105 $0 --stage 1 # Build U-Boot only
100106 $0 --fast-build # Build all with fast build mode
101107 $0 --stage 2 --fast-build # Build Linux with fast build mode
108+ $0 --continue # Continue from existing build (skip completed stages)
109+ $0 --continue --stage 4 # Continue and run only Stage 4
102110 DEFAULT_DEVICE_TREE=custom-dtb $0 # Use custom device tree
103111
104112Output directory: ${BUILD_OUTPUT_DIR} /
@@ -237,14 +245,6 @@ create_symlinks() {
237245 fi
238246
239247 log_info " Symlinks created in ${images_dir} /"
240-
241- # Export NFS rootfs for debugging
242- log_info " Exporting NFS rootfs..."
243- local nfs_dir=" ${PROJECT_ROOT} /rootfs/nfs"
244- rm -rf " ${nfs_dir} "
245- mkdir -p " $( dirname " ${nfs_dir} " ) "
246- ln -sf " ${BUILD_OUTPUT_DIR} /rootfs" " ${nfs_dir} "
247- log_info " + rootfs/nfs/ -> ${BUILD_OUTPUT_DIR} /rootfs/ (NFS export ready)"
248248}
249249
250250# Show final summary
@@ -273,11 +273,32 @@ show_summary() {
273273 fi
274274 log_info " "
275275 log_info " To use the rootfs:"
276- log_info " 1. Export via NFS: ${BUILD_OUTPUT_DIR} /rootfs "
277- log_info " 2. Or copy to SD card"
276+ log_info " - For NFS mount: bash scripts/manual_mount_nfs.sh "
277+ log_info " - Or copy to SD card"
278278 log_info " "
279279}
280280
281+ # Check if a stage has already been completed
282+ is_stage_completed () {
283+ local stage=$1
284+
285+ case " ${stage} " in
286+ 1)
287+ [[ -f " ${BUILD_OUTPUT_DIR} /uboot/u-boot-dtb.imx" ]]
288+ ;;
289+ 2)
290+ [[ -f " ${BUILD_OUTPUT_DIR} /linux/arch/arm/boot/zImage" ]]
291+ ;;
292+ 3)
293+ [[ -f " ${BUILD_OUTPUT_DIR} /busybox/busybox" && -f " ${BUILD_OUTPUT_DIR} /rootfs/bin/busybox" ]]
294+ ;;
295+ 4)
296+ # Stage 4 completion is hard to verify, assume incomplete
297+ false
298+ ;;
299+ esac
300+ }
301+
281302# Main build process
282303main () {
283304 log_info " ========================================="
@@ -306,18 +327,27 @@ main() {
306327 log_info " "
307328
308329 # Create build output directory
309- # If release-latest exists, rename it to release-{datetime}
330+ # If release-latest exists, handle based on mode
310331 # Note: Stage 4 should not clear the folder, as it depends on previous stages
311- if [[ -d " ${BUILD_OUTPUT_DIR} " && " ${SPECIFIC_STAGE} " != " 4" ]]; then
312- local datetime=$( date +%Y%m%d-%H%M%S)
313- local archive_dir=" ${PROJECT_ROOT} /out/release-${datetime} "
314- log_info " Archiving existing ${BUILD_OUTPUT_DIR} -> ${archive_dir} "
315- mv " ${BUILD_OUTPUT_DIR} " " ${archive_dir} "
332+ if [[ -d " ${BUILD_OUTPUT_DIR} " ]]; then
333+ if [[ ${CONTINUE_BUILD} -eq 1 ]]; then
334+ log_info " Continuing from existing build: ${BUILD_OUTPUT_DIR} "
335+ elif [[ " ${SPECIFIC_STAGE} " != " 4" ]]; then
336+ local datetime=$( date +%Y%m%d-%H%M%S)
337+ local archive_dir=" ${PROJECT_ROOT} /out/release-${datetime} "
338+ log_info " Archiving existing ${BUILD_OUTPUT_DIR} -> ${archive_dir} "
339+ mv " ${BUILD_OUTPUT_DIR} " " ${archive_dir} "
340+ fi
316341 fi
317342 mkdir -p " ${BUILD_OUTPUT_DIR} "
318343
319344 # Run stages
320345 for stage in " ${stages[@]} " ; do
346+ if [[ ${CONTINUE_BUILD} -eq 1 ]] && is_stage_completed " ${stage} " ; then
347+ log_info " Skipping stage ${stage} (already completed)"
348+ continue
349+ fi
350+
321351 case " ${stage} " in
322352 1) stage_1_uboot ;;
323353 2) stage_2_linux ;;
0 commit comments