[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Kernel and initramfs hooks for flash-kernel



Hello,

2011/6/27 Ben Hutchings <ben@decadent.org.uk>:

>>   While I am not entirely sure, I think proper way to add hooks would be:
>>   * one hook triggered by kernel scripts creating uImage from vmlinuz
>> post package installation.
>>   * and other hook triggered by kernel scripts creating uInitrd after
>> initrd- has been created.

> Hook scripts are ordered by name and the 'zz-' prefix is reserved for
> boot loader hooks so they run last.

Right! I knew that one, but I was missing it. Fixing it on my proof of concept.

> The initramfs post-update hooks are supposed to be called by any
> initramfs builder, not just initramfs-tools.

Right, thanks for clarifying.

Renaming hook name with prefix zz- and triggering a reinstall, still
calls update-initramfs with create option, so it does not
run_bootloader preventing hooks to be executed. Why run_bootloader
cannot be called when creating initrd?

I.e.,

root@hf08:~# apt-get --reinstall install linux-image-2.6.39-2+armhf.1-mx5
[..]
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools
2.6.39-2+armhf.1-mx5 /boot/vmlinuz-2.6.39-2+armhf.1-mx5
+ [ -r /etc/initramfs-tools/update-initramfs.conf ]
+ . /etc/initramfs-tools/update-initramfs.conf
+ update_initramfs=yes
+ backup_initramfs=no
+ [ -z 1 ]
+ verbose=0
+ yes=0
+ takeover=0
+ getopts k:cudyvtb:h? flag
+ mode=c
+ getopts k:cudyvtb:h? flag
+ takeover=1
+ getopts k:cudyvtb:h? flag
+ version=2.6.39-2+armhf.1-mx5
+ getopts k:cudyvtb:h? flag
+ BOOTDIR=/boot
+ [ ! -d /boot ]
+ getopts k:cudyvtb:h? flag
+ shift 6
+ [ 0 -ne 0 ]
+ [ -z c ]
+ [ 2.6.39-2+armhf.1-mx5 = all ]
+ [ yes = all ]
+ create
+ [ -z 2.6.39-2+armhf.1-mx5 ]
+ set_initramfs
+ initramfs=/boot/initrd.img-2.6.39-2+armhf.1-mx5
+ [ 1 = 0 ]
+ generate_initramfs
+ echo update-initramfs: Generating /boot/initrd.img-2.6.39-2+armhf.1-mx5
update-initramfs: Generating /boot/initrd.img-2.6.39-2+armhf.1-mx5
+ OPTS=-o
+ [ 0 = 1 ]
+ mkinitramfs -o /boot/initrd.img-2.6.39-2+armhf.1-mx5.new 2.6.39-2+armhf.1-mx5
+ mv -f /boot/initrd.img-2.6.39-2+armhf.1-mx5.new
/boot/initrd.img-2.6.39-2+armhf.1-mx5
+ set_sha1
+ sha1sum /boot/initrd.img-2.6.39-2+armhf.1-mx5

root@hf08:~# cat /etc/initramfs/post-update.d/zz-flash-kernel
#!/bin/sh -e

version="$1"
bootopt=""

# passing the kernel version is required
if [ -z "${version}" ]; then
        echo >&2 "W: flash-kernel: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel
package} did not pass a version number"
        exit 2
fi

# TODO: flash-kernel hardcodes this info, maybe it can take it from here
# absolute file name of kernel image may be passed as a second argument;
# convert initrd to bootable format in the same directory
#if [ -n "$2" ]; then
#       bootdir=$(dirname "$2")
#       bootopt="-b ${bootdir}"
#fi

# avoid running multiple times
if [ -n "$DEB_MAINT_PARAMS" ]; then
        eval set -- "$DEB_MAINT_PARAMS"
        if [ -z "$1" ] || [ "$1" != "configure" ]; then
                exit 0
        fi
fi

# we're good - convert kernel and initramfs to bootable format.
if flash-kernel --supported >/dev/null 2>&1; then
        flash-kernel "${version}" >&2
        return 0
fi

Kind regards,
-- 
 Héctor Orón  -.. . -... .. .- -.   -.. . ...- . .-.. --- .--. . .-.

<free spam>
-- Would you like to make a donation for Debian Conference?
   ** http://debconf11.debconf.org/payments.xhtml **
</free spam>


Reply to: