Is udpkg --configure another package from postinst OK? (flash-kernel-installer from grub-installer)
Ian Campbell
ijc at hellion.org.uk
Sun Jan 12 12:11:39 UTC 2014
In order to use the grub arm-uboot support something needs to arrange
for the grub kernel to be loaded from u-boot on the various platforms,
which in turn requires some platform specific knowledge (load addresses,
partitions and the like). Since flash-kernel already has a bunch of
infrastructure for this I thought it might be good to reuse it rather
than reinventing that wheel in grub-installer (or upstream grub).
I changed grub-installer's XB-Installer-Menu-Item to 7200 (from 7400) so
it would come before flash-kernel-installer (also 7400) and added to the
grub-installer postinst (bit WIP, especially the error handling):
@@ -829,6 +837,17 @@ EOF
fi
+case $ARCH:$grub_package in
+ *:grub-uboot)
+ log "Installing flash-kernel-installer"
+ ANNA_VERBOSE=1 anna-install flash-kernel-installer || error "failed to install flash-kernel-installer"
+ log "Configuring flash-kernel-installer"
+ udpkg --force-configure --configure flash-kernel-installer || error "failed to configure flash-kernel-installer"
+ ;;
+ *)
+ log "ARCH:PKG is $ARCH:$grub_package"
+esac
+
# Split a device name into a disk device name and a partition number, if
# possible.
split_device () {
(full WIP patches to grub-installer and flash-kernel, which are working
on Calxeda Midway, are appended)
Just doing anna-install was not sufficient, I think because once
grub-installer's postinst finishes the top-level bootable-system
dependency is satisfied so main-menu sees no reason to configure
flash-kernel too.
Is this call to udpkg allowable? codesearch seems to suggest that the
idiom is not very widespread, only kickseed and cdrom-checker use it.
Another approach might be to split bootable-system into two parts
(perhaps only on armhf) e.g. stage1 (==flash-kernel) and stage2
(==grub).
It's worth mentioning that unless the grub-kernel can be made
relocatable it may turn out that grub-installer needs some platform
specific knowledge (the grub load address, see [0]) anyway. Leif was
going to investigate -fpie but if that doesn't pan out then I wonder if
grub-installer can/should share the flash-kernel db or if it should go
its own way? Ideally only one place would need updating for each
platform.
[0] http://lists.gnu.org/archive/html/grub-devel/2013-12/msg00415.html
Ian.
===WIP: grub-installer===
diff --git a/debian/control b/debian/control
index 571459a..a4a8c34 100644
--- a/debian/control
+++ b/debian/control
@@ -8,10 +8,10 @@ Vcs-Browser: http://anonscm.debian.org/gitweb/?p=d-i/grub-installer.git
Vcs-Git: git://anonscm.debian.org/d-i/grub-installer.git
Package: grub-installer
-Architecture: i386 hurd-i386 amd64 kfreebsd-i386 kfreebsd-amd64 powerpc mipsel
+Architecture: i386 hurd-i386 amd64 kfreebsd-i386 kfreebsd-amd64 powerpc mipsel armhf
XB-Subarchitecture: ${subarch}
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: 7400
+XB-Installer-Menu-Item: 7200
Package-Type: udeb
Description: Install GRUB on a hard disk
diff --git a/grub-installer b/grub-installer
index 71e10c8..dbb46ad 100755
--- a/grub-installer
+++ b/grub-installer
@@ -327,6 +327,10 @@ case $ARCH in
i386/*|amd64/*)
grub_package="grub-pc"
;;
+ armhf/*)
+ # XXX detect and handle EFI too
+ grub_package="grub-uboot"
+ ;;
powerpc/*)
grub_package="grub-ieee1275"
experimental_arch
@@ -753,6 +757,10 @@ if [ -z "$frdisk" ]; then
fi
fi
+ #if [ "$ARCH" = "armhf/XXX" ] ; then
+ # grub_install_params="$grub_install_params -T 0xLOADADDRESS"
+ #fi
+
if [ "$ARCH" = "powerpc/chrp_pegasos" ] ; then
# nvram is broken here
grub_install_params="$grub_install_params --no-nvram"
@@ -829,6 +837,17 @@ EOF
fi
+case $ARCH:$grub_package in
+ *:grub-uboot)
+ log "Installing flash-kernel-installer"
+ ANNA_VERBOSE=1 anna-install flash-kernel-installer || error "failed to install flash-kernel-installer"
+ log "Configuring flash-kernel-installer"
+ udpkg --force-configure --configure flash-kernel-installer || error "failed to configure flash-kernel-installer"
+ ;;
+ *)
+ log "ARCH:PKG is $ARCH:$grub_package"
+esac
+
# Split a device name into a disk device name and a partition number, if
# possible.
split_device () {
===WIP: flash-kernel===
diff --git a/bootscript/bootscr.calxeda b/bootscript/bootscr.calxeda
new file mode 100644
index 0000000..4d925e2
--- /dev/null
+++ b/bootscript/bootscr.calxeda
@@ -0,0 +1,4 @@
+echo "Loading Debian Grub ..."
+${fs}load ${devtype} ${devnum} ${kernel_addr_r} ${prefix}/grub/arm-uboot/core.img
+bootm ${kernel_addr_r} - ${fdt_addr}
+
diff --git a/db/all.db b/db/all.db
index 76e99fd..95e503e 100644
--- a/db/all.db
+++ b/db/all.db
@@ -40,6 +40,13 @@ Boot-Initrd-Path: /boot/initrd.buffalo
Required-Packages: u-boot-tools
Bootloader-Sets-Root: yes
+Machine: Calxeda ECX-2000
+Method: grub
+Required-Packages: u-boot-tools
+Boot-Script-Path: /boot/boot.scr
+U-Boot-Script-Name: bootscr.calxeda
+Bootloader-Sets-Root: no
+
Machine: D-Link DNS-323
Kernel-Flavors: orion5x
Machine-Id: 1542
diff --git a/debian/control b/debian/control
index f8bfa67..bdd1378 100644
--- a/debian/control
+++ b/debian/control
@@ -29,7 +29,7 @@ Section: debian-installer
Priority: standard
Package-Type: udeb
Architecture: armel armhf
-XB-Subarchitecture: iop32x ixp4xx kirkwood orion5x s3c24xx mx5
+XB-Subarchitecture: iop32x ixp4xx kirkwood orion5x s3c24xx mx5 generic
Provides: bootable-system
Depends: cdebconf-udeb, installed-base
XB-Installer-Menu-Item: 7300
diff --git a/debian/flash-kernel-installer.isinstallable b/debian/flash-kernel-installer.isinstallable
index ce85af3..0d75039 100755
--- a/debian/flash-kernel-installer.isinstallable
+++ b/debian/flash-kernel-installer.isinstallable
@@ -20,8 +20,14 @@ case "`archdetect`" in
arm*/s3c24xx)
exit 0
;;
+ armhf/generic)
+ logger -t flash-kernel-installer armhf/generic is installable
+ # XXX check db for /proc/device-tree/model?
+ exit 0
+ ;;
# Don't activate it by default
*)
+ logger -t flash-kernel-installer `archdetect` is installable
exit 1
;;
esac
diff --git a/functions b/functions
index 66e9738..54c84ba 100644
--- a/functions
+++ b/functions
@@ -488,13 +492,29 @@ case "$method" in
fi
android_flash "$part"
;;
+ "grub")
+ grub="/boot/grub/arm-uboot/core.img"
+ # Address to load to:
+ # ukaddr="$(get_machine_field "$machine" "U-Boot-Kernel-Address")" || :
+ # Script address: (needed?)
+ # usaddr="$(get_machine_field "$machine" "U-Boot-Script-Address")" || :
+ # Name of the input script:
+ # usname="$(get_machine_field "$machine" "U-Boot-Script-Name")" || :
+ # File to load
+ ugrubname="$(get_machine_field "$machine" "U-Boot-Grub-Name")" || ugrubname="/boot/grub/arm-uboot/core.img"
+ # Script output path:
+ # boot_script_path="$(get_machine_field "$machine" "Boot-Script-Path")" || :
+ boot_script_path="$boot_mnt_dir/$boot_script_path"
+ boot_script="$BOOTSCRIPTS_DIR/$usname"
+ mkimage_script "$usaddr" "grub boot script" "$boot_script" \
+ "$tmpdir/boot.scr"
+ boot_script="$tmpdir/boot.scr"
+ backup_and_install "$boot_script" "$boot_script_path"
+ ;;
"generic")
kernel="$kfile"
initrd="$ifile"
if [ -n "$machine_id" ]; then
[...snip some unrelated local hacks...]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-grub-devel/attachments/20140112/67921e7e/attachment.sig>
More information about the Pkg-grub-devel
mailing list