The first line of the commit message is too long. Please just use a
short summary for the first line, then put the rest of the comment
into a new paragraph separated by a newline.

On 11/06/2017 12:19 PM, Frank Scheiner wrote:
> The NVRAM is (re)configured explicitly after the call to `grub-install`
> because `grub-install` uses and configures a wrong OF path (thanks to
> `ofpathname`). As it doesn't work the way `grub-install` does it
> currently, I tried to support the NVRAM defaults, which are to boot from
> the first found tbxi file in a "blessed" directory AFAIK:
> 
> ```
> boot-device = hd:,\\:tbxi
> boot-command = mac-boot
> ```
> 
> Automatic boot is currently disabled to allow for easy manual changes in
> OpenFirmware in case of any problems during boot. The system will end up
> in OpenFirmware after reboot.

Why that? I assume most people would expect the machine to be able to
boot automatically after installing Linux. It should work as it does
with Yaboot, i.e. the machine boots automatically.

> ---
>  debian/changelog |   3 ++
>  grub-installer   | 113 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 116 insertions(+)
> 
> diff --git a/debian/changelog b/debian/changelog
> index d3da6e9..b68c451 100644
> --- a/debian/changelog
> +++ b/debian/changelog
> @@ -9,6 +9,9 @@ grub-installer (1.147) UNRELEASED; urgency=medium
>        d-i/yaboot-installer).
>      - Handle HFS file systems (format, mount, unmount, permanent mount).
>      - Create and configure the missing CHRP boot script.
> +    - Adapt grub-install parameters and finally perform GRUB installation.
> +      Make CHRP script bootable by OpenFirmware. Configure NVRAM defaults
> +      but do not boot automatically.
>  
>   -- Frank Scheiner <[email protected]>  Thu, 06 Nov 2017 08:42:00 +0200
>  
> diff --git a/grub-installer b/grub-installer
> index 3f1c606..ad2f38a 100755
> --- a/grub-installer
> +++ b/grub-installer
> @@ -434,6 +434,98 @@ nw_create_boot_script()
>  
>       return
>  }
> +
> +nw_make_boot_script_of_bootable()
> +{
> +     local offs_part="$1"
> +     local hfs_path="$2"
> +     local boot_script_name="$3"
> +
> +     local self="nw_make_boot_script_of_bootable"
> +     local exit_code=0
> +
> +     # create script for in-target Operation
> +     cat > ${ROOT}/tmp/make_boot_script_of_bootable <<-EOF
> +             #!/bin/sh
> +             if hmount "$offs_part"; then
> +                     # Set file type of boot script to tbxi and "bless" 
> directory
> +                     hattrib -t tbxi -c UNIX 
> "${hfs_path}:${boot_script_name}" && \\
> +                     hattrib -b "${hfs_path}"
> +                     if [ $? -ne 0 ]; then
> +                             humount
> +                             exit 1
> +                     else
> +                             humount
> +                             exit 0
> +                     fi
> +             else
> +                     exit 2
> +             fi
> +     EOF
> +
> +     chmod +x ${ROOT}/tmp/make_boot_script_of_bootable
> +
> +     in-target /tmp/make_boot_script_of_bootable || exit_code=$?
> +
> +     if [ $exit_code -eq 0 ]; then
> +             info "$self: Operation suceeded."
> +             #rm ${ROOT}/tmp/make_boot_script_of_bootable
> +             return 0
> +     elif [ $exit_code -eq 1 ]; then
> +             error "$self: Operation failed." 1>&2
> +             return 1
> +     elif [ $exit_code -eq 2 ]; then
> +             error "$self: Couldn't hmount \"$offs_part\"" 1>&2
> +             return 1
> +     fi
> +}
> +
> +nw_backup_nvram_contents()
> +{
> +     local self="nw_backup_nvram_contents"
> +     local nvram_backup="${ROOT}/root/nvram_backup"
> +
> +     if in-target nvram --print-config > "$nvram_backup"; then
> +             info "$self: Original NVRAM contents backed up to $nvram_backup"
> +             return 0
> +     else
> +             error "$self: Original NVRAM contents couldn't be backed up to 
> $nvram_backup" 1>&2
> +             return 1
> +     fi
> +}
> +
> +nw_configure_nvram()
> +{
> +     local self="nw_configure_nvram"
> +
> +     # `boot-device`
> +     # boot file of type tbxi from "blessed" directory
> +     if in-target nvram --update-config boot-device='hd:,\\:tbxi'; then
> +             info "$self: Configured \"boot-device\" to \"hd:,\\:tbxi\""
> +     else
> +             error "$self: Couldn't configure \"boot-device\" to 
> \"hd:,\\:tbxi\"" 1>&2
> +             return 1
> +     fi
> +
> +     # `boot-command`
> +     if in-target nvram --update-config boot-command='mac-boot'; then
> +             info "$self: Configured \"boot-command\" to \"mac-boot\""
> +             return 0 # do not reconfigure `auto-boot?` currently
> +     else
> +             error "$self: Couldn't configure \"boot-command\" to 
> \"mac-boot\"" 1>&2
> +             return 1
> +     fi
> +
> +     # `auto-boot?`
> +     if in-target nvram --update-config 'auto-boot?'='true'; then
> +             info "$self: Configured \"auto-boot?\" to \"true\""
> +             return 0
> +     else
> +             error "$self: Couldn't configure \"auto-boot?\" to \"true\"" 
> 1>&2
> +             return 1
> +     fi
> +}
> +
>  ARCH="$(archdetect)"
>  info "architecture: $ARCH"

Seeing that we are adding so many additional functions for NewWorld, it
might be a good idea to have those moved into a separate file which
is sourced in the grub-installler script.

> @@ -1280,6 +1372,9 @@ if [ -z "$frdisk" ]; then
>                       # see: https://github.com/esnowberg/grub2-sparc/wiki
>                       grub_install_params="$grub_install_params 
> --skip-fs-probe"
>                       ;;
> +                 powerpc/powermac_newworld|ppc64/powermac_newworld)
> +                     grub_install_params="$grub_install_params 
> --macppc-directory=$NW_OFFS_MOUNT_POINT"
> +                     ;;
>               esac
>  
>               if [ "$grub_version" = "grub" ] ; then
> @@ -1291,6 +1386,24 @@ if [ -z "$frdisk" ]; then
>  
>               CODE=0
>               case $ARCH:$grub_package in
> +                 
> powerpc/powermac_newworld:grub-ieee1275|ppc64/powermac_newworld:grub-ieee1275)
> +                     nw_backup_nvram_contents || true
> +                     info "Running $chroot $ROOT grub-install 
> $grub_install_params"
> +                     log-output -t grub-installer $chroot $ROOT grub-install 
> $grub_install_params || CODE=$?
> +                     # Unmount OFFS before using `hattrib` in the next step 
> so all
> +                     # changes in the file system are written back and are 
> visible
> +                     # to `hattrib` later on.
> +                     nw_unmount_offs "$offs_part"
> +                     # HFS path from [1] adapted for use with `hattrib`. 
> `BootX` as
> +                     # installed by `grub-install` later is located in the 
> same HFS
> +                     # path as the `grub.elf` referenced in `BootX`
> +                     #
> +                     # [1]: 
> http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/boot/powerpc/grub.chrp.in?id=446794de8da4329ea532cbee4ca877bcafd0e534
> +                     nw_make_boot_script_of_bootable "$offs_part" 
> "bootstrap:System:Library:CoreServices" "BootX" || exit 1
> +                     # Mount OFFS again before continuing
> +                     nw_mount_offs "$offs_part"
> +                     nw_configure_nvram || true
> +                     ;;
>                   
> *:grub|*:grub-pc|*:grub-efi*|sparc/*:grub-ieee1275|sparc64/*:grub-ieee1275|powerpc/*:grub-ieee1275|ppc64/*:grub-ieee1275|ppc64el/*:grub-ieee1275)
>                       info "Running $chroot $ROOT grub-install 
> $grub_install_params \"$bootdev\""
>                       log-output -t grub-installer $chroot $ROOT grub-install 
> $grub_install_params "$bootdev" || CODE=$?
> 


-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Reply via email to