-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(builder): fix boot failed in CI env
- Loading branch information
Showing
8 changed files
with
94 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,27 +190,33 @@ copy_layer() { | |
sync # must do sync ! | ||
} | ||
|
||
pack_rootfs() { | ||
bootable_file="${bootable_file_zst%.*}" | ||
sha1sum_file="${bootable_file_zst}.sha1sum" | ||
set -x | ||
|
||
umount_rootfs() { | ||
cd $output && { | ||
umount -R ./target_rootfs | ||
} || { | ||
echo "Error: failed to umount $output/target_rootfs" | ||
exit 100 | ||
} && cd $workspace | ||
} | ||
cd $workspace || { | ||
echo "Change dir to workspace failed" | ||
exit 100 | ||
} | ||
} | ||
|
||
pack_rootfs() { | ||
cd $output && { | ||
zstd --force $bootable_file && { | ||
sha1sum "${bootable_file_zst}" >"${sha1sum_file}" | ||
zstd --force alpine_uefi_bootable.img && { | ||
sha1sum alpine_uefi_bootable.img.zst >alpine_uefi_bootable.img.zst.sha1sum | ||
} || { | ||
echo "Error: Compress alpine_uefi_bootable.img failed" | ||
exit 100 | ||
} | ||
} && cd $workspace | ||
set +x | ||
} | ||
|
||
cd "$workspace" || { | ||
echo "Change dir to workspace failed" | ||
exit 100 | ||
} | ||
} | ||
|
||
bootimage() { | ||
|
@@ -230,11 +236,22 @@ if [[ -z $workspace ]] && [[ -z $output ]]; then | |
exit 100 | ||
fi | ||
|
||
echo workspace: $workspace | ||
echo output: $output | ||
echo "workspace: $workspace" | ||
echo "output: $output" | ||
clean_mapping | ||
bootstrap_alpine | ||
#copy_layer | ||
pack_rootfs | ||
umount_rootfs | ||
clean_mapping | ||
bootimage | ||
bootimage >/tmp/vm_boot_log 2>&1 & | ||
while true; do | ||
ssh -o ConnectTimeout=1 -o StrictHostKeyChecking=no -i /tmp/ovm_ssh/ovm_id [email protected] -p10025 "update-grub && sync && halt" && { | ||
echo Update-grub successful | ||
break | ||
} || { | ||
echo "Try ssh into vm again..." | ||
sleep 2 | ||
continue | ||
} | ||
done | ||
pack_rootfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,15 +162,20 @@ copy_layer() { | |
sync # must do sync ! | ||
} | ||
|
||
pack_rootfs() { | ||
set -x | ||
umount_rootfs() { | ||
cd $output && { | ||
umount -R ./target_rootfs | ||
} || { | ||
echo "Error: failed to umount $output/target_rootfs" | ||
exit 100 | ||
} | ||
cd $workspace || { | ||
echo "Change dir to workspace failed" | ||
exit 100 | ||
} | ||
} | ||
|
||
pack_rootfs() { | ||
cd $output && { | ||
zstd --force alpine_uefi_bootable.img && { | ||
sha1sum alpine_uefi_bootable.img.zst >alpine_uefi_bootable.img.zst.sha1sum | ||
|
@@ -179,23 +184,50 @@ pack_rootfs() { | |
exit 100 | ||
} | ||
} | ||
set +x | ||
cd $workspace || { | ||
|
||
cd "$workspace" || { | ||
echo "Change dir to workspace failed" | ||
exit 100 | ||
} | ||
} | ||
|
||
bootimage() { | ||
cd "$workspace" || { | ||
echo "Failed to change dir to workspace" | ||
exit 100 | ||
} | ||
|
||
bootable_file=alpine_uefi_bootable.img | ||
output=$output workspace=$workspace bash +x ./subfunc/boot_raw_disk.sh "$output/$bootable_file" arm64 || { | ||
echo "Error: boot $output/$bootable_file failed" | ||
exit 100 | ||
} | ||
} | ||
|
||
echo "=== Bootstrap Alpine ===" | ||
if [[ -z $workspace ]] && [[ -z $output ]]; then | ||
echo 'Error: $workspace or $output empty' | ||
exit 100 | ||
fi | ||
|
||
echo workspace: $workspace | ||
echo output: $output | ||
echo "workspace: $workspace" | ||
echo "output: $output" | ||
clean_mapping | ||
bootstrap_alpine | ||
copy_layer | ||
pack_rootfs | ||
umount_rootfs | ||
clean_mapping | ||
|
||
# Final stage: boot raw disk and do update-grub | ||
bootimage >/tmp/vm_boot_log 2>&1 & | ||
while true; do | ||
ssh -o ConnectTimeout=1 -o StrictHostKeyChecking=no -i /tmp/ovm_ssh/ovm_id [email protected] -p10025 "update-grub && sync && halt" && { | ||
echo Update-grub successful | ||
break | ||
} || { | ||
echo "Try ssh into vm again..." | ||
sleep 2 | ||
continue | ||
} | ||
done | ||
pack_rootfs |