Skip to content

Commit dfe3809

Browse files
committed
Update validate.sh to have proper centralized cleanup that will prevent disk space issues
Signed-off-by: Teoh Suh Haw <suh.haw.teoh@intel.com>
1 parent 0770484 commit dfe3809

1 file changed

Lines changed: 53 additions & 5 deletions

File tree

validate.sh

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ else
3636
echo "QEMU boot tests will be skipped"
3737
fi
3838

39+
# Centralized cleanup function for image files
40+
cleanup_image_files() {
41+
local cleanup_type="${1:-all}" # Options: all, raw, extracted
42+
43+
case "$cleanup_type" in
44+
"raw")
45+
echo "Cleaning up raw image files from build directories..."
46+
sudo rm -rf ./tmp/*/imagebuild/*/*.raw 2>/dev/null || true
47+
;;
48+
"extracted")
49+
echo "Cleaning up extracted image files in current directory..."
50+
rm -f *.raw 2>/dev/null || true
51+
;;
52+
"all"|*)
53+
echo "Cleaning up all temporary image files..."
54+
sudo rm -rf ./tmp/*/imagebuild/*/*.raw 2>/dev/null || true
55+
rm -f *.raw 2>/dev/null || true
56+
;;
57+
esac
58+
}
59+
3960
run_qemu_boot_test() {
4061
local IMAGE_PATTERN="$1"
4162
if [ -z "$IMAGE_PATTERN" ]; then
@@ -125,11 +146,8 @@ run_qemu_boot_test() {
125146
result=1
126147
fi
127148
128-
# Clean up extracted raw file
129-
if [ -f \"\$RAW_IMAGE\" ]; then
130-
echo \"Cleaning up extracted image file: \$RAW_IMAGE\"
131-
rm -f \"\$RAW_IMAGE\"
132-
fi
149+
# Clean up extracted raw file using centralized function
150+
cleanup_image_files extracted
133151
134152
# Return to original directory
135153
cd \"\$ORIGINAL_DIR\"
@@ -262,6 +280,8 @@ build_azl3_raw_image() {
262280
echo "QEMU boot test FAILED for AZL3 raw image"
263281
exit 1
264282
fi
283+
# Clean up after QEMU test to free space
284+
cleanup_image_files raw
265285
fi
266286
else
267287
echo "AZL3 raw Image build failed."
@@ -313,6 +333,8 @@ build_emt3_raw_image() {
313333
echo "QEMU boot test FAILED for EMT3 raw image"
314334
exit 1
315335
fi
336+
# Clean up after QEMU test to free space
337+
cleanup_image_files raw
316338
fi
317339
else
318340
echo "EMT3 raw Image build failed."
@@ -326,7 +348,25 @@ build_emt3_iso_image() {
326348
echo "Ensuring we're in the working directory before starting builds..."
327349
cd "$WORKING_DIR"
328350
echo "Current working directory: $(pwd)"
351+
352+
# Check available disk space
353+
echo "Checking available disk space..."
354+
df -h .
355+
356+
# Check if xorriso is available
357+
if ! command -v xorriso &> /dev/null; then
358+
echo "WARNING: xorriso not found. Installing xorriso..."
359+
sudo apt-get update && sudo apt-get install -y xorriso
360+
fi
361+
362+
# Add more verbose output and error handling
363+
echo "Running EMT3 ISO build with detailed output..."
329364
output=$( sudo -S ./build/os-image-composer build image-templates/emt3-x86_64-minimal-iso.yml 2>&1)
365+
366+
# Print the full output for debugging
367+
echo "Build output:"
368+
echo "$output"
369+
330370
# Check for the success message in the output
331371
if echo "$output" | grep -q "image build completed successfully"; then
332372
echo "EMT3 iso Image build passed."
@@ -363,6 +403,8 @@ build_elxr12_raw_image() {
363403
echo "QEMU boot test FAILED for ELXR12 raw image"
364404
exit 1
365405
fi
406+
# Clean up after QEMU test to free space
407+
cleanup_image_files raw
366408
fi
367409
else
368410
echo "ELXR12 raw Image build failed."
@@ -412,6 +454,8 @@ build_elxr12_immutable_raw_image() {
412454
echo "QEMU boot test FAILED for ELXR12 immutable raw image"
413455
exit 1
414456
fi
457+
# Clean up after QEMU test to free space
458+
cleanup_image_files raw
415459
fi
416460
else
417461
echo "ELXR12 immutable raw Image build failed."
@@ -437,6 +481,8 @@ build_emt3_immutable_raw_image() {
437481
echo "QEMU boot test FAILED for EMT3 immutable raw image"
438482
exit 1
439483
fi
484+
# Clean up after QEMU test to free space
485+
cleanup_image_files raw
440486
fi
441487
else
442488
echo "EMT3 immutable raw Image build failed."
@@ -462,6 +508,8 @@ build_azl3_immutable_raw_image() {
462508
echo "QEMU boot test FAILED for AZL3 immutable raw image"
463509
exit 1
464510
fi
511+
# Clean up after QEMU test to free space
512+
cleanup_image_files raw
465513
fi
466514
else
467515
echo "AZL3 immutable raw Image build failed."

0 commit comments

Comments
 (0)