Skip to content

Commit

Permalink
Merge ihexon/ovm-builder main branch (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihexon authored Dec 24, 2024
1 parent 80b0ded commit 47eeeb2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 35 deletions.
2 changes: 1 addition & 1 deletion layers/macos_arm64/etc/default/grub
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ GRUB_TIMEOUT=0
GRUB_DISABLE_SUBMENU=y
GRUB_DISABLE_RECOVERY=true
GRUB_TERMINAL=console
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyAMA0 modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4"
GRUB_CMDLINE_LINUX_DEFAULT="console=VM_CONSOLE_DEVICE modules=sd-mod,usb-storage,ext4 quiet rootfstype=ext4"
2 changes: 1 addition & 1 deletion layers/macos_arm64/etc/inittab
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ tty6::respawn:/sbin/getty 38400 tty6
::shutdown:/sbin/openrc shutdown

# enable login on alternative console
ttyAMA0::respawn:/sbin/getty -L 0 ttyAMA0 vt100
VM_CONSOLE_DEVICE::respawn:/sbin/getty -L 0 VM_CONSOLE_DEVICE vt100
1 change: 1 addition & 0 deletions subfunc/boot_raw_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ boot_raw_x86_64() {
--library-path "$output/qemu_bins/lib" \
"$output/qemu_bins/bin/qemu-system-x86_64" \
-nographic -cpu max -smp 4 -m 2G \
-bios "$output/qemu_bins/share/qemu/edk2-x86_64-code.fd" \
-netdev user,id=net0,restrict=n,hostfwd=tcp:127.0.0.1:10025-:22 \
-device e1000,netdev=net0 \
-device virtio-balloon-pci,id=balloon0 \
Expand Down
2 changes: 2 additions & 0 deletions subfunc/install_qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
x86_64_loader_ld="ld-linux-x86-64.so.2"
arm64_loader_ld="ld-linux-aarch64.so.1"

sudo -E apt install wget

host_arch=$(uname -m)
if [[ $host_arch == aarch64 ]] || [[ $host_arch == arm64 ]]; then
host_arch=arm64
Expand Down
23 changes: 4 additions & 19 deletions target_builder/macos_amd64
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ preinstalled_packages="
tzdata
"
bootable_url="https://github.com/oomol/builded/releases/download/v1.5/alpine_uefi_bootable-x86_64.img.zst"
sha1sum="fc62a59289a3f4721bb7d44730ca5a631c592531"
# the alpine_uefi_bootable.img.zst has ROOTFS and EFI partition
rootfs_part_uuid="1db9dd50-085d-4d38-a911-ea4446d29875"
efi_part_uuid="4cc17f62-ab8d-4593-b787-8a7bffd6b1ad"
rootfs_part_uuid="4f1bfa20-73e8-4885-ab4b-1f9e67332f79"
efi_part_uuid="F41A-23A6"
bootable_file_zst="alpine_uefi_bootable.img.zst"

clean_mapping() {
Expand All @@ -51,7 +50,7 @@ bootstrap_alpine() {
# Mapping the part into /dev/mapper/loopNpN
kpartx -av ${bootable_file}
mount -m -U $rootfs_part_uuid ./target_rootfs
mount -m -U $efi_part_uuid ./target_rootfs/boot
mount -m -U $efi_part_uuid ./target_rootfs/boot/efi

echo http://dl-cdn.alpinelinux.org/alpine/v3.20/community >>"$output/target_rootfs/etc/apk/repositories"
set +ex
Expand Down Expand Up @@ -200,17 +199,6 @@ pack_rootfs() {
}
}

bootimage() {
cd "$workspace" || {
echo "Failed to change dir to workspace"
exit 100
}

output=$output workspace=$workspace bash +x ./subfunc/boot_raw_disk.sh "$output/$bootable_file" x86_64 || {
echo "Error: boot $output/$bootable_file failed"
exit 100
}
}

try_ssh_into_vm() {
while true; do
Expand Down Expand Up @@ -238,13 +226,10 @@ echo "workspace: $workspace"
echo "output: $output"
clean_mapping
bootstrap_alpine
#copy_layer
copy_layer
umount_rootfs
clean_mapping

# Final stage: boot raw disk and do update-grub
bootimage >/tmp/vm_boot_log 2>&1 &
tail -f /tmp/vm_boot_log &
try_ssh_into_vm
pack_rootfs
exit 0
14 changes: 0 additions & 14 deletions target_builder/macos_arm64
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,6 @@ pack_rootfs() {
}
}

bootimage() {
cd "$workspace" || {
echo "Failed to change dir to workspace"
exit 100
}

output=$output workspace=$workspace bash +x ./subfunc/boot_raw_disk.sh "$output/$bootable_file" arm64 || {
echo "Error: boot $output/$bootable_file failed"
exit 100
}
}

try_ssh_into_vm() {
while true; do
Expand Down Expand Up @@ -242,8 +231,5 @@ umount_rootfs
clean_mapping

# Final stage: boot raw disk and do update-grub
bootimage >/tmp/vm_boot_log 2>&1 &
tail -f /tmp/vm_boot_log &
try_ssh_into_vm
pack_rootfs
exit 0

0 comments on commit 47eeeb2

Please sign in to comment.