diff options
| author | Andrew Donnellan <andrew.donnellan@au1.ibm.com> | 2019-03-28 14:03:00 +1100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-05-03 10:00:16 +0200 |
| commit | bfc19a4b19ceba8f9f03d3cde255cd5b1273c650 (patch) | |
| tree | 7c1b06c802b1b0a8c1a489c272daf7e074ea73ca /pkg | |
| parent | 8e54d550ca021089e6426fe3a8ca7bdf6cc9735b (diff) | |
tools/create-gce-image.sh: Generate ppc64le pseries disk images
Add support for generating ppc64le pseries disk images. This will create a
disk image with a PowerPC PReP boot partition at the start, and install
the IEEE1275/OpenFirmware version of GRUB.
If we ever support the powernv platform in the future we're going to have
to do something different here.
Add a command line argument to specify architecture, defaulting to amd64.
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/build/linux_generated.go | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/pkg/build/linux_generated.go b/pkg/build/linux_generated.go index c2cce9457..06fb122b3 100644 --- a/pkg/build/linux_generated.go +++ b/pkg/build/linux_generated.go @@ -10,13 +10,24 @@ set -eux CLEANUP="" trap 'eval " $CLEANUP"' EXIT +IMG_ARCH="${3:-amd64}" + if [ ! -e $1/sbin/init ]; then - echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage" + echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage [arch]" exit 1 fi -if [ "$(basename $2)" != "bzImage" ]; then - echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage" +case "$IMG_ARCH" in + 386|amd64) + KERNEL_IMAGE_BASENAME=bzImage + ;; + ppc64le) + KERNEL_IMAGE_BASENAME=zImage.pseries + ;; +esac + +if [ "$(basename $2)" != "$KERNEL_IMAGE_BASENAME" ]; then + echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage [arch]" exit 1 fi @@ -53,8 +64,18 @@ elif [ "$BLOCK_DEVICE" == "nbd" ]; then sudo qemu-nbd -c $DISKDEV --format=raw disk.raw CLEANUP="sudo qemu-nbd -d $DISKDEV; $CLEANUP" fi -echo -en "o\nn\np\n1\n\n\na\nw\n" | sudo fdisk $DISKDEV -PARTDEV=$DISKDEV"p1" + +case "$IMG_ARCH" in + 386|amd64) + echo -en "o\nn\np\n1\n\n\na\nw\n" | sudo fdisk $DISKDEV + PARTDEV=$DISKDEV"p1" + ;; + ppc64le) + echo -en "g\nn\n1\n2048\n16383\nt\n7\nn\n2\n\n\nw\n" | sudo fdisk $DISKDEV + PARTDEV=$DISKDEV"p2" + ;; +esac + until [ -e $PARTDEV ]; do sleep 1; done sudo -E mkfs.ext4 -O ^resize_inode,^has_journal,ext_attr,extents,huge_file,flex_bg,dir_nlink,sparse_super $PARTDEV mkdir -p disk.mnt @@ -99,7 +120,9 @@ if [ "$SYZ_CMDLINE_FILE" != "" ]; then CMDLINE=$(awk '{printf("%s ", $0)}' $SYZ_CMDLINE_FILE) fi -cat << EOF | sudo tee disk.mnt/boot/grub/grub.cfg +case "$IMG_ARCH" in +386|amd64) + cat << EOF | sudo tee disk.mnt/boot/grub/grub.cfg terminal_input console terminal_output console set timeout=0 @@ -115,5 +138,22 @@ menuentry 'linux' --class gnu-linux --class gnu --class os { linux /vmlinuz root=/dev/sda1 console=ttyS0 earlyprintk=serial vsyscall=native rodata=n oops=panic panic_on_warn=1 nmi_watchdog=panic panic=86400 $CMDLINE } EOF -sudo grub-install --target=i386-pc --boot-directory=disk.mnt/boot --no-floppy $DISKDEV + sudo grub-install --target=i386-pc --boot-directory=disk.mnt/boot --no-floppy $DISKDEV + ;; +ppc64le) + cat << EOF | sudo tee disk.mnt/boot/grub/grub.cfg +terminal_input console +terminal_output console +set timeout=0 +menuentry 'linux' --class gnu-linux --class gnu --class os { + insmod gzio + insmod part_gpt + insmod ext2 + set root='(ieee1275/disk,gpt2)' + linux /vmlinuz root=/dev/sda2 console=ttyS0 earlyprintk=serial rodata=n oops=panic panic_on_warn=1 nmi_watchdog=panic panic=86400 $CMDLINE +} +EOF + sudo grub-install --target=powerpc-ieee1275 --boot-directory=disk.mnt/boot $DISKDEV"p1" + ;; +esac ` |
