~ubuntu-branches/ubuntu/utopic/initramfs-tools/utopic

« back to all changes in this revision

Viewing changes to hook-functions

  • Committer: Bazaar Package Importer
  • Author(s): Michael Prokop, Martin Michlmayr, Ferenc Wagner, Colin Watson, maximilian attems, 969f8fd, Michael Prokop
  • Date: 2010-06-18 12:28:04 UTC
  • mto: This revision was merged to the branch mainline in revision 206.
  • Revision ID: james.westby@ubuntu.com-20100618122804-ioma0owf209ecwek
Tags: 0.97
[ Martin Michlmayr ]
* [e65ee48] Produce an error when root cannot be determined with
  MODULES=dep
* [bb66fc2] hook-functions/init/scripts/local: add support for ubifs.
  (Closes: #582858) - thanks to Martin Michlmayr <tbm@cyrius.com>

[ Ferenc Wagner ]
* [1d66ae1] scripts/nfs: cleanup retry logic

[ Colin Watson ]
* [3054e3e] initramfs-tools: work around 'find -printf %Y' bug

[ maximilian attems ]
* [a8a5ce4] script: Add update-initramfs.conf to bug report
* [cc6077a] update-initramfs: Fix another unbound variable (Closes:
  #583695)
* [b1f74e6] get_fstype: reference blkid in comment - thanks to
  Christoph Anton Mitterer <calestyo@scientia.net>
* [eb93a7e] pre_mountroot(): reduce timeout to 30 seconds
* [38563fe] scripts/functions: On panic change to tty1 if chvt around
  - thanks to Colin Watson <cjwatson@ubuntu.com>
* [2031379] mkinitramfs: No point in hardcoding busybox path
* [68c87cd] mkinitramfs: check syntax of boot and hook scripts
* [ae02e4b] scripts/functions: beautify a bit reduce_satisfied()
* [22d996c] maintainer doc: use git commands without the dash
* [6147641] nfsmount: more small cleanups
* [e967b03] mkinitramfs, lsinitramfs: Better error message for
  non-GNU getopt
* Add lsinitramfs (to list content of an initramfs image) ([a39db63]
  [969f8fd] [fafede5] [2f3eb88])

[ Michael Prokop ]
* [2a8c990] hook-functions/mkinitramfs/update-initramfs: consequently
  output error messages to stderr
* [04b8619] init: display warning message if devtmpfs could not be
  mounted. - thanks to Ferenc Wagner <wferi@niif.hu>
* [60afd2a] code cleanup: drop trailing whitespaces.
* [ab28c77] code cleanup: consequently replace spaces in indentions
  with tabs to unify coding stile
* [3a02c6f] code cleanup: consequently use "W:" for warnings.
* [b1fff5e] add bash-completion for update-initramfs (Closes: #537139)
  - thanks to Stéphane Jourdois <stephane@jourdois.fr>
* [5697c3b] hook-functions: replace awk calls with sed in
  dep_add_modules() (Closes: #585991) - thanks to Thorsten Glaser
  <tg@mirbsd.de>
* [7afab22] debian/script: append /proc/mdstat (iff present) to
  bugreports
* [5b565be] scripts/functions: allow hooks to abort build (Closes:
  #396388)
* [528ba78] hook-functions: do not install ubi module by default via
  auto_add_modules()
* [ecb8416] lsinitramfs: be more defensive against cmdline options
* [2ff4ba2] scripts/functions: fix usage of test for script execution
* [74f71c9] scripts/functions: fix another sh -n usage and fix typo
* [91f5947] hook-functions: install virtio_pci module if
  /sys/bus/virtio is present and using modules=dep (Closes: #585992) -
  thanks to Vincent Danjean <vdanjean@debian.org>
* [d25f610] slightly improve manpage lsinitramfs.8
* Provide maintainer-notes.html, being "Maintainer documentation for
  initramfs-tools" ([7fc1ee5] [afafea4] [e506ee7] [d53a839] [6af23c2])

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
catenate_cpiogz() {
4
4
        # Sanity check
5
5
        if [ ! -e "${1}" ]; then
6
 
                echo "W:catenate_cpiogz: arg1='${1}' does not exist." >&2
 
6
                echo "W: catenate_cpiogz: arg1='${1}' does not exist." >&2
7
7
                return
8
8
        fi
9
9
 
29
29
{
30
30
        # Sanity check
31
31
        if [ ! -e "${1}" ]; then
32
 
                echo "W:add_modules_from_file: arg1='${1}' does not exist." >&2
 
32
                echo "W: add_modules_from_file: arg1='${1}' does not exist." >&2
33
33
                return
34
34
        fi
35
35
 
72
72
                                # /proc/modules exists
73
73
                                if [ ! -e /proc/modules ] ; then
74
74
                                        continue
75
 
                                fi
 
75
                                fi
76
76
 
77
77
                                if grep -q "^$(basename "${kmod}" .ko)[[:space:]]" \
78
78
                                /proc/modules \
127
127
 
128
128
        # Copy the dependant libraries
129
129
        for x in $(ldd ${src} 2>/dev/null | sed -e '
130
 
            /\//!d;
131
 
            /linux-gate/d;
132
 
            /=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};
133
 
            s/[[:blank:]]*\([^[:blank:]]*\) (.*)/\1/' 2>/dev/null); do
 
130
                /\//!d;
 
131
                /linux-gate/d;
 
132
                /=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};
 
133
                s/[[:blank:]]*\([^[:blank:]]*\) (.*)/\1/' 2>/dev/null); do
134
134
 
135
135
                # Try to use non-optimised libraries where possible.
136
136
                # We assume that all HWCAP libraries will be in tls,
166
166
        if [ "${verbose}" = "y" ]; then
167
167
                echo "Copying module directory ${dir}"
168
168
                if [ $# -ge 1 ]; then
169
 
                    echo "(excluding $*)"
 
169
                        echo "(excluding $*)"
170
170
                fi
171
171
        fi
172
172
        while [ $# -ge 1 ]; do
183
183
{
184
184
        local driver_path module
185
185
        device_path="$1"
186
 
        
 
186
 
187
187
        while [ "${device_path}" != "/sys" ]; do
188
188
                sys_walk_modalias ${device_path}
189
189
                driver_path="$(readlink -f ${device_path}/driver/module)"
220
220
 
221
221
        # require mounted sysfs
222
222
        if [ ! -d /sys/devices/ ]; then
223
 
                echo "mkinitramfs: MODULES dep requires mounted sysfs on /sys"
 
223
                echo "mkinitramfs: MODULES dep requires mounted sysfs on /sys" >&2
224
224
                exit 1
225
225
        fi
226
226
 
227
227
        # findout root block device + fstype
228
228
        eval "$(mount | awk '/\/dev\// {if ($3 == "/") {print "root=" $1 "\nFSTYPE=" $5; exit}}')"
 
229
        if [ -z "$root" ]; then
 
230
                echo "mkinitramfs: failed to determine root device" >&2
 
231
                echo "mkinitramfs: workaround is MODULES=most" >&2
 
232
                echo "Error please report bug on initramfs-tools and include the output of 'mount'" >&2
 
233
                exit 1
 
234
        fi
229
235
 
230
236
        # handle ubifs and return since ubifs root is a char device but
231
237
        # most of the commands below only work with block devices.
232
238
        if [ "${FSTYPE}" = "ubifs" ]; then
233
239
                manual_add_modules "${FSTYPE}"
 
240
                # add some modules required by ubifs on which it doesn's depend
 
241
                manual_add_modules deflate
 
242
                manual_add_modules zlib
 
243
                manual_add_modules lzo
234
244
                return
235
245
        fi
236
246
 
246
256
        if [ "${FSTYPE}" = "unknown" ]; then
247
257
                FSTYPE=$(blkid -o value -s TYPE "${root}")
248
258
                if [  -z "${FSTYPE}" ]; then
249
 
                        echo "mkinitramfs: unknown fstype on root ${root}"
250
 
                        echo "mkinitramfs: workaround is MODULES=most" 
251
 
                        echo "Error please report bug on initramfs-tools" 
252
 
                exit 1
 
259
                        echo "mkinitramfs: unknown fstype on root ${root}" >&2
 
260
                        echo "mkinitramfs: workaround is MODULES=most" >&2
 
261
                        echo "Error please report bug on initramfs-tools" >&2
 
262
                        exit 1
253
263
                fi
254
264
        fi
255
265
 
267
277
                done
268
278
                # lvm on md or luks on md
269
279
                if [ "${block#md}" != "${block}" ]; then
270
 
                        block=$(grep "^${block}" /proc/mdstat | \
271
 
                                awk "{gsub(/^${block} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
272
 
                        block="${block%%\[*}"
 
280
                        block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^'${block}' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
273
281
                fi
274
282
                # luks or lvm on cciss or ida
275
283
                if [ "${block#cciss}" != "${block}" ] \
281
289
        # md root new naming scheme /dev/md/X
282
290
        elif [ "${root#/dev/md/}" != "${root}" ]; then
283
291
                root=${root#/dev/md/}
284
 
                block=$(grep "^md${root}" /proc/mdstat | \
285
 
                        awk "{gsub(/^md${root} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
286
 
                block="${block%%\[*}"
287
292
                # drop the partition number only for sdX and hdX devices
288
293
                # and keep it for other devices like loop#, dm-# devices
289
 
                case "$block" in
290
 
                        sd*) block=${block%%[0-9]*};;
291
 
                        hd*) block=${block%%[0-9]*};;
292
 
                esac
 
294
                block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^md'$root' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
293
295
        # md root /dev/mdX
294
296
        elif [ "${root#/dev/md}" != "${root}" ]; then
295
297
                root=${root#/dev/md}
296
 
                block=$(grep "^md${root}" /proc/mdstat | \
297
 
                        awk "{gsub(/^md${root} : .* (multipath|linear|raid[[:digit:]]+)\ /,\"\")};1")
298
 
                block="${block%%\[*}"
299
298
                # drop the partition number only for sdX and hdX devices
300
299
                # and keep it for other devices like loop#, dm-# devices
301
 
                case "$block" in
302
 
                        sd*) block=${block%%[0-9]*};;
303
 
                        hd*) block=${block%%[0-9]*};;
304
 
                esac
305
 
 
 
300
                block=$(sed -ne 's/multipath/[/' -e 's/linear/[/' -e 's/raid[0-9][0-9]*/[/' -e 's/\([hs]d[a-z][a-z]*\)[0-9][0-9]*/\1/g' -e '/^md'$root' :/s/^[^[]*\[ \([^\[]*\)\[.*$/\1/p' </proc/mdstat)
306
301
        # cciss device
307
302
        elif [ "${root#/dev/cciss/}" != "${root}" ]; then
308
303
                block=${root#/dev/cciss/*}
343
338
 
344
339
        # Error out if /sys lack block dev
345
340
        if [ -z "${block}" ] || [ ! -e /sys/block/${block} ]; then
346
 
                echo "mkinitramfs: for root ${root} missing ${block} /sys/block/ entry"
347
 
                echo "mkinitramfs: workaround is MODULES=most" 
348
 
                echo "mkinitramfs: Error please report the bug" 
 
341
                echo "mkinitramfs: for root ${root} missing ${block} /sys/block/ entry" >&2
 
342
                echo "mkinitramfs: workaround is MODULES=most" >&2
 
343
                echo "mkinitramfs: Error please report the bug" >&2
349
344
                exit 1
350
345
        fi
351
346
 
370
365
                manual_add_modules mmc_block
371
366
        fi
372
367
 
 
368
        if [ -e /sys/bus/virtio ] ; then
 
369
                manual_add_modules virtio_pci
 
370
        fi
 
371
 
373
372
        if [ -e /sys/bus/i2o/devices/ ]; then
374
373
                force_load i2o_block
375
374
                force_load i2o_config
424
423
        block)
425
424
                copy_modules_dir kernel/drivers/block
426
425
        ;;
 
426
        ubi)
 
427
                for x in deflate zlib lzo ubi ubifs; do
 
428
                        manual_add_modules "${x}"
 
429
                done
 
430
        ;;
427
431
        ieee1394)
428
432
                for x in ohci1394 sbp2; do
429
433
                        manual_add_modules "${x}"
525
529
        fi
526
530
        set_initlist
527
531
        for cm_x in ${initlist:-}; do
528
 
                # sed: keep last line starting with MINKVER=,
529
 
                #      remove MINKVER= and trailing space
 
532
                # sed:  keep last line starting with MINKVER=,
 
533
                #       remove MINKVER= and trailing space
530
534
                minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}")
531
535
                if [ -z "${tmp}" ]; then
532
536
                        continue