added x86 arches
This commit is contained in:
parent
607e5ded7a
commit
5defa8b4a6
44
boot.sh
44
boot.sh
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
|
||||
##############################################################################
|
||||
# this is a convenience script to start a created VM
|
||||
# this is a convenience script to start a parabola VM using qemu
|
||||
##############################################################################
|
||||
|
||||
# common directories
|
||||
@ -57,7 +57,18 @@ check_kernel_arch() {
|
||||
|
||||
[ "x$machine" != "xno" ] && return
|
||||
|
||||
# no elf header? maybe arm?
|
||||
# check if the kernel arch can be gathered from objdump
|
||||
|
||||
echo -n "checking for kernel binary header ... "
|
||||
set -o pipefail
|
||||
machine=$(objdump -f "$kernel" 2>/dev/null | grep architecture: | awk '{print $2}' | tr -d ',') \
|
||||
|| machine=no
|
||||
set +o pipefail
|
||||
echo "$machine"
|
||||
|
||||
[ "x$machine" != "xno" ] && return
|
||||
|
||||
# no usable binary headers? maybe arm?
|
||||
|
||||
echo -n "checking for ARM boot executable ... "
|
||||
local is_arm=no
|
||||
@ -67,16 +78,14 @@ check_kernel_arch() {
|
||||
|
||||
[ "x$machine" != "xno" ] && return
|
||||
|
||||
# no idea, just bail.
|
||||
# no idea; bail.
|
||||
|
||||
error "unable to extract kernel arch from image"
|
||||
return "$ERROR_MISSING"
|
||||
}
|
||||
|
||||
qemu_setargs_arm() {
|
||||
qemu_args=(
|
||||
-snapshot
|
||||
-nographic
|
||||
qemu_args+=(
|
||||
-machine vexpress-a9
|
||||
-cpu cortex-a9
|
||||
-m 1G
|
||||
@ -89,9 +98,7 @@ qemu_setargs_arm() {
|
||||
}
|
||||
|
||||
qemu_setargs_riscv64() {
|
||||
qemu_args=(
|
||||
-snapshot
|
||||
-nographic
|
||||
qemu_args+=(
|
||||
-machine virt
|
||||
-m 2G
|
||||
-kernel "$1"/bbl
|
||||
@ -105,6 +112,20 @@ qemu_setargs_riscv64() {
|
||||
)
|
||||
}
|
||||
|
||||
qemu_setargs_i386() {
|
||||
qemu_setargs_x86_64 "$@"
|
||||
}
|
||||
|
||||
qemu_setargs_x86_64() {
|
||||
qemu_args+=(
|
||||
-m 2G
|
||||
-kernel "$1"/vmlinuz-linux-libre
|
||||
-initrd "$1"/initramfs-linux-libre.img
|
||||
-append "console=ttyS0 rw root=/dev/sda3"
|
||||
-drive file="$2"
|
||||
)
|
||||
}
|
||||
|
||||
boot_from_image() {
|
||||
[ -f "$1" ] || die "$1: image does not exist"
|
||||
|
||||
@ -122,12 +143,15 @@ boot_from_image() {
|
||||
case "$machine" in
|
||||
RISC-V) arch=riscv64 ;;
|
||||
ARM) arch=arm ;;
|
||||
i386) arch=i386 ;;
|
||||
i386:*) arch=x86_64 ;;
|
||||
*) error "unrecognized machine '$machine'"
|
||||
return "$ERROR_UNSPECIFIED" ;;
|
||||
esac
|
||||
|
||||
qemu_args=()
|
||||
qemu_args=(-snapshot -nographic)
|
||||
"qemu_setargs_$arch" "$TOPBUILDDIR"/mnt "$1" "$loopdev"
|
||||
qemu_arch_is_foreign "$arch" || qemu_args+=(-enable-kvm)
|
||||
QEMU_AUDIO_DRV=none "qemu-system-$arch" "${qemu_args[@]}"
|
||||
}
|
||||
|
||||
|
46
src/qemu.sh
46
src/qemu.sh
@ -40,6 +40,14 @@ qemu_img_partition_and_mount_for_armv7h() {
|
||||
}
|
||||
|
||||
qemu_img_partition_and_mount_for_riscv64() {
|
||||
qemu_img_partition_and_mount_for_x86_64 "$@"
|
||||
}
|
||||
|
||||
qemu_img_partition_and_mount_for_i686() {
|
||||
qemu_img_partition_and_mount_for_x86_64 "$@"
|
||||
}
|
||||
|
||||
qemu_img_partition_and_mount_for_x86_64() {
|
||||
parted -s "$1" \
|
||||
mklabel gpt \
|
||||
mkpart primary ext2 1MiB 513MiB \
|
||||
@ -74,17 +82,31 @@ qemu_img_lorelease() {
|
||||
losetup -d "$1"
|
||||
}
|
||||
|
||||
qemu_setup_user_static() {
|
||||
qemu_arch_is_foreign() {
|
||||
# borrowed from /usr/bin/librechroot
|
||||
local setarch interpreter
|
||||
case "$ARCH" in
|
||||
armv7h) setarch=armv7l; interpreter=/usr/bin/qemu-arm- ;;
|
||||
*) setarch="$ARCH"; interpreter=/usr/bin/qemu-"$ARCH"- ;;
|
||||
local setarch
|
||||
case "$1" in
|
||||
arm*) setarch=armv7l ;;
|
||||
*) setarch="$1" ;;
|
||||
esac
|
||||
|
||||
if ! setarch "$setarch" /bin/true 2>/dev/null; then
|
||||
echo -n "checking if arch '$1' is foreign ... "
|
||||
local need_qemu=no
|
||||
setarch "$setarch" /bin/true 2>/dev/null || need_qemu=yes
|
||||
echo "$need_qemu"
|
||||
|
||||
[ "x$need_qemu" == "xyes" ] || return
|
||||
}
|
||||
|
||||
qemu_setup_user_static() {
|
||||
local interpreter
|
||||
case "$ARCH" in
|
||||
armv7h) interpreter=/usr/bin/qemu-arm- ;;
|
||||
*) interpreter=/usr/bin/qemu-"$ARCH"- ;;
|
||||
esac
|
||||
|
||||
if qemu_arch_is_foreign "$ARCH"; then
|
||||
# target arch can't execute natively, pacstrap is going to need help by qemu
|
||||
# Make sure that qemu-static is set up with binfmt_misc
|
||||
if [[ -z $(grep -l -F \
|
||||
-e "interpreter $interpreter" \
|
||||
-r -- /proc/sys/fs/binfmt_misc 2>/dev/null \
|
||||
@ -104,7 +126,7 @@ qemu_cleanup_user_static() {
|
||||
rm -f "$1"/usr/bin/qemu-*
|
||||
}
|
||||
|
||||
qemu_img_finalize_for_arm() {
|
||||
qemu_img_finalize_for_armv7h() {
|
||||
true
|
||||
}
|
||||
|
||||
@ -114,6 +136,14 @@ qemu_img_finalize_for_riscv64() {
|
||||
-O "$1"/boot/bbl
|
||||
}
|
||||
|
||||
qemu_img_finalize_for_i686() {
|
||||
true
|
||||
}
|
||||
|
||||
qemu_img_finalize_for_x86_64() {
|
||||
true
|
||||
}
|
||||
|
||||
qemu_make_image() {
|
||||
msg "preparing parabola qemu image for $ARCH"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user