Hi! This patch makes grub-installer work on powerpc / Open Firmware. Please let me know what you think.
Note that I only tested it on Efika. Other platforms might need some adjustments. -- Robert Millan My spam trap is [EMAIL PROTECTED] Note: this address is only intended for spam harvesters. Writing to it will get you added to my black list.
Index: grub-installer/debian/control =================================================================== --- grub-installer/debian/control (revision 48014) +++ grub-installer/debian/control (working copy) @@ -7,7 +7,7 @@ XS-Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/arch/i386/grub-installer Package: grub-installer -Architecture: i386 hurd-i386 amd64 kfreebsd-i386 kfreebsd-amd64 +Architecture: i386 hurd-i386 amd64 kfreebsd-i386 kfreebsd-amd64 powerpc Provides: bootable-system Depends: cdebconf-udeb, kernel-installer, created-fstab, di-utils (>= 1.15), di-utils-mapdevfs, os-prober, partman-utils XB-Installer-Menu-Item: 7300 Index: grub-installer/debian/grub-installer.templates =================================================================== --- grub-installer/debian/grub-installer.templates (revision 48014) +++ grub-installer/debian/grub-installer.templates (working copy) @@ -90,7 +90,7 @@ Type: boolean Default: true _Description: GRUB installation failed. Continue anyway? - The grub package failed to install into /target/. Installing GRUB + The ${GRUB} package failed to install into /target/. Installing GRUB as a boot loader is a required step. The install problem might however be unrelated to GRUB, so continuing the installation may be possible. @@ -119,6 +119,19 @@ becomes unbootable. You're advised not to try this in production environments. +Template: grub-installer/grub_not_mature_on_this_platform +Type: boolean +Default: false +# This is suitable for testing grub2 only. Do not translate it! +Description: Install GRUB? + GRUB 2 is the next generation of GNU GRUB, the bootloader that is commonly + used on i386/amd64 PCs. It is now also available for ${ARCH}. + . + It has interesting new features but is still experimental software. If you + choose to install it, you should be prepared for breakage, and have an idea + on how to recover your system if it becomes unbootable. You're advised not to + try this in production environments. + Template: grub-installer/progress/title Type: text _Description: Installing GRUB boot loader @@ -129,7 +142,7 @@ Template: grub-installer/progress/step_install Type: text -_Description: Installing the 'grub' package... +_Description: Installing the '${GRUB}' package... Template: grub-installer/progress/step_bootdev Type: text Index: grub-installer/grub-installer =================================================================== --- grub-installer/grub-installer (revision 48014) +++ grub-installer/grub-installer (working copy) @@ -32,6 +32,9 @@ log "info: $@" } +ARCH="$(archdetect)" +info "architecture: $ARCH" + get_serial_console() { # Get the last 'console=' entry (if none, the whole string is returned) local defconsole="$(sed -e 's/.*\(console=[^ ]*\).*/\1/' /proc/cmdline)" @@ -233,6 +236,13 @@ bootfstype=$(findfstype /boot) [ -n "$bootfstype" ] || bootfstype="$(findfstype /)" +case $ARCH in + powerpc/*) + offs=$(findfs /boot/grub) + [ -n "$offs" ] || error "GRUB requires that the OF partition is mounted in /boot/grub" 1>&2 + ;; +esac + # This code to set disc_offered was taken from lilo-installer rootfs_nodevfs=$(mapdevfs $rootfs) bootfs_nodevfs=$(mapdevfs $bootfs) @@ -273,10 +283,38 @@ info "Identified partition label for $bootfs: $bootfslabel" -# Default to GRUB Legacy -grub_version="grub" -menu_file="menu.lst" +case $ARCH in + i386/mac|amd64/mac) + # Note: depends on partman-efi to load the efivars module! + if [ -d /sys/firmware/efi ]; then + # This point can't be reached (yet). See debian/isinstallable. + grub_version="grub-efi" + else + # On PC/BIOS, default to GRUB Legacy + grub_version="grub" + fi + ;; + i386/*|amd64/*) + # On PC/BIOS, default to GRUB Legacy + grub_version="grub" + ;; + powerpc/*) + grub_version="grub-of" + ;; +esac +case $ARCH in + powerpc/*) + db_subst grub-installer/grub_not_mature_on_this_platform ARCH "`echo $ARCH | sed -e s,/.*,,g`" + db_input low grub-installer/grub_not_mature_on_this_platform || [ $? -eq 30 ] + db_go || true + db_get grub-installer/grub_not_mature_on_this_platform + if [ "$RET" != true ]; then + exit 10 + fi + ;; +esac + case "$bootfstype:$bootfslabel" in *:loop) # Serial ATA RAID partition, currently only grub is supported @@ -287,8 +325,9 @@ exit 10 ;; *:gpt) - grub_version="grub2" - menu_file="grub.cfg" + if [ "$grub_version" = "grub" ] ; then + grub_version="grub-pc" + fi ;; xfs:*) # Warn user that grub on xfs is not safe and let them back out to @@ -301,16 +340,25 @@ fi ;; *:*) - db_input low grub-installer/grub2_instead_of_grub_legacy || [ $? -eq 30 ] - db_go || true - db_get grub-installer/grub2_instead_of_grub_legacy - if [ "$RET" = true ]; then - grub_version="grub2" - menu_file="grub.cfg" + if [ "$grub_version" = "grub" ] ; then + db_input low grub-installer/grub2_instead_of_grub_legacy || [ $? -eq 30 ] + db_go || true + db_get grub-installer/grub2_instead_of_grub_legacy + if [ "$RET" = true ]; then + grub_version="grub-pc" + fi fi ;; esac +case $grub_version in + grub) menu_file="menu.lst" ;; + *) menu_file="grub.cfg" ;; +esac + +db_subst grub-installer/progress/step_install GRUB "$grub_version" +db_subst grub-installer/apt-install-failed GRUB "$grub_version" + db_progress START 0 6 grub-installer/progress/title db_progress INFO grub-installer/progress/step_install @@ -318,11 +366,14 @@ # apt-install passes --no-remove to apt, but grub{,2} conflict each other, so # we need to purge them first to support users who try grub2 and then switch # to grub legacy, or vice-versa -if [ "$grub_version" = grub ]; then - log-output -t grub-installer $chroot $ROOT dpkg -P grub2 -else +case "$grub_version" in + grub) + log-output -t grub-installer $chroot $ROOT dpkg -P grub-pc + ;; + grub-pc) log-output -t grub-installer $chroot $ROOT dpkg -P grub -fi + ;; +esac if ! apt-install $grub_version ; then info "Calling 'apt-install $grub_version' failed" @@ -479,20 +530,30 @@ # Install grub on each space separated disk in the list bootdevs="$bootdev" for bootdev in $bootdevs; do + grub_install_params= if ! is_floppy "$bootdev"; then if $chroot $ROOT grub-install -h 2>&1 | grep -q no-floppy; then info "grub-install supports --no-floppy" - floppyparam="--no-floppy" + grub_install_params="$grub_install_params --no-floppy" else info "grub-install does not support --no-floppy" fi fi - - info "Running $chroot $ROOT grub-install --recheck $floppyparam \"$bootdev\"" - if log-output -t grub-installer $chroot $ROOT grub-install --recheck $floppyparam "$bootdev"; then + + if [ "$ARCH" = "powerpc/chrp_pegasos" ] ; then + # nvram is broken here + grub_install_params="$grub_install_params --no-nvram" + fi + + if [ "$grub_version" = "grub" ] ; then + grub_install_params="$grub_install_params --recheck" + fi + + info "Running $chroot $ROOT grub-install $grub_install_params \"$bootdev\"" + if log-output -t grub-installer $chroot $ROOT grub-install $grub_install_params "$bootdev"; then info "grub-install ran successfully" else - error "Running 'grub-install --recheck $floppyparam \"$bootdev\"' failed." + error "Running 'grub-install $grub_install_params \"$bootdev\"' failed." db_subst grub-installer/grub-install-failed BOOTDEV "$bootdev" db_input critical grub-installer/grub-install-failed || [ $? -eq 30 ] db_go || true @@ -550,6 +611,7 @@ fi # Set up a password if asked +if [ "$grub_version" = "grub" ] ; then db_input low grub-installer/password || true if ! db_go; then # back up to menu @@ -574,6 +636,7 @@ chmod o-r $ROOT/boot/grub/$menu_file rm -f /tmp/menu.lst.password fi +fi user_params=$(echo $(user-params)) || true if [ "$user_params" ]; then @@ -593,7 +656,7 @@ ) >$ROOT/boot/grub/$menu_file.new mv $ROOT/boot/grub/$menu_file.new $ROOT/boot/grub/$menu_file ;; - grub2) + grub-pc) if grep -q "^GRUB_TERMINAL=" $ROOT/etc/default/grub; then sed -i $ROOT/etc/default/grub -e "s/^\(GRUB_TERMINAL\)=.*/\1=serial/g" else @@ -625,7 +688,8 @@ if [ -n "$grubdrive" ]; then case $grub_version in grub) grub_write_chain ;; - grub2) grub2_write_chain ;; + grub-pc | grub-efi) + grub2_write_chain ;; esac fi ;; @@ -658,7 +722,7 @@ params="$(echo "$entry" | cut -d : -f6-) $serial" case $grub_version in grub) grub_write_linux ;; - grub2) grub2_write_linux ;; + *) grub2_write_linux ;; esac IFS="$newline" done @@ -671,7 +735,7 @@ # Use the standard hurd boilerplate to boot it. case $grub_version in grub) grub_write_hurd ;; - grub2) grub2_write_hurd ;; + *) grub2_write_hurd ;; esac ;; *) @@ -689,7 +753,7 @@ grub) cat $tmpfile >> $ROOT/boot/grub/$menu_file ;; - grub2) + *) cat > $ROOT/etc/grub.d/30_otheros << EOF #!/bin/sh exec tail -n +3 \$0