summaryrefslogtreecommitdiff
path: root/docs/example_hook_cpiogz
blob: dcd1416896ff455b34205c6e5f5132441831a92a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh

#
# The environment contains at least:
#
#  CONFDIR -- usually /etc/mkinitramfs, can be set on mkinitramfs
#		 command line.
#
#  DESTDIR -- The staging directory where we are building the image.
#
# TODO: Decide what environment variables are meaningful and defined
#	in this context, then document them as part of the interface.
#
# TODO: Write a common header for these examples or move this
#	documentation to a man page and reference it here. :-)
#

#
# List the soft prerequisites here.  This is a space separated list of
# names, of scripts that are in the same directory as this one, that
# must be run before this one can be.
#
PREREQ=""

prereqs()
{
	echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

#
# Source the 'hook-functions' scriptlet (for 'catenate_cpiogz'):
#
. /usr/share/initramfs-tools/hook-functions

#
# Lets pretend it has a conffile (think debconf), and we source it
# here.  Don't make debconf lookup calls here.  The postinst for the
# package owning this hook script should have done that and configured
# the "/etc/default/conffile" already.
#
# TODO: How does the package ensure that it's installed BEFORE the
#	corresponding 'linux-image' package?  Can it declare that, in
#	the case where it's an add-on that the 'linux-image' is not
#	aware of?  This might be an apt and dpkg issue.
#	
#	* Eg. an optional usplash or suspend2ui_fbsplash package.
#
. /etc/default/mypackage-initramfs

#
# Also pretend that we only include our initramfs overlay if an opion
# is not "no", and the 'linux-image' package we are generating this
# initramfs for matches the version this script's package is designed
# for.  Just for example; pretend this example mkinitramfs hook script
# is part of a 'linux-image' or 'xxx-modules' package.
#
if [ "$MYOPTION" != "no" -a "$version" = "2.6.12+ss2.1.9.1" ]; then
	catenate_cpiogz /usr/lib/mypackage/initramfs.cpio.gz
fi

#
# In this case, there does not have to be an (eg.):
#
#   "/etc/mkinitramfs/init-top/mypackage"
#
# ... since that script is probably inside of the initramfs overlay
# already.  If it's a conffile though, it does not belong in there,
# and should be placed in the appropriate location inside of
# "/etc/mkinitramfs".  Remember that if it needs access to the
# settings in our "/etc/default/mypackage-initramfs", then that file
# must also get copied into a location inside of ${DESTDIR} by this
# hook script in order to make it available inside of the initramfs
# environment.
#

exit 0