2008-12-18 23:59:55 +03:00
#!/bin/bash
2010-09-10 17:23:06 +04:00
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
2011-05-10 13:39:10 +04:00
#
2008-12-18 01:51:15 +03:00
# Generator script for a dracut initramfs
# Tries to retain some degree of compatibility with the command line
# of the various mkinitrd implementations out there
#
2009-02-13 15:41:50 +03:00
2010-09-10 17:23:06 +04:00
# Copyright 2005-2010 Red Hat, Inc. All rights reserved.
2009-07-24 17:12:47 +04:00
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
2008-12-11 00:32:21 +03:00
2011-03-07 14:54:47 +03:00
# store for logging
2012-07-03 16:20:51 +04:00
dracut_args = ( " $@ " )
2009-05-19 18:47:03 +04:00
2012-06-18 14:51:21 +04:00
set -o pipefail
2009-05-19 18:47:03 +04:00
usage( ) {
2012-05-22 16:28:34 +04:00
[ [ $dracutbasedir ] ] || dracutbasedir = /usr/lib/dracut
if [ [ -f $dracutbasedir /dracut-version.sh ] ] ; then
. $dracutbasedir /dracut-version.sh
fi
2009-05-19 18:47:03 +04:00
# 80x25 linebreak here ^
2010-09-10 17:23:06 +04:00
cat << EOF
2012-07-03 16:20:51 +04:00
Usage: $0 [ OPTION] ... [ <initramfs> [ <kernel-version>] ]
Version: $DRACUT_VERSION
Creates initial ramdisk images for preloading modules
-h, --help Display all options
If a [ LIST] has multiple arguments, then you have to put these in quotes.
For example:
# dracut --add-drivers "module1 module2" ...
EOF
}
long_usage( ) {
[ [ $dracutbasedir ] ] || dracutbasedir = /usr/lib/dracut
if [ [ -f $dracutbasedir /dracut-version.sh ] ] ; then
. $dracutbasedir /dracut-version.sh
fi
# 80x25 linebreak here ^
cat << EOF
Usage: $0 [ OPTION] ... [ <initramfs> [ <kernel-version>] ]
2012-05-22 16:28:34 +04:00
Version: $DRACUT_VERSION
2009-05-19 18:47:03 +04:00
Creates initial ramdisk images for preloading modules
2012-07-20 13:34:40 +04:00
--kver [ VERSION] Set kernel version to [ VERSION] .
2009-05-24 06:10:52 +04:00
-f, --force Overwrite existing initramfs file.
2009-05-19 18:47:03 +04:00
-m, --modules [ LIST] Specify a space-separated list of dracut modules to
call when building the initramfs. Modules are located
2011-11-23 12:42:10 +04:00
in /usr/lib/dracut/modules.d.
2009-05-24 06:10:52 +04:00
-o, --omit [ LIST] Omit a space-separated list of dracut modules.
2009-07-02 13:32:32 +04:00
-a, --add [ LIST] Add a space-separated list of dracut modules.
2009-05-19 18:47:03 +04:00
-d, --drivers [ LIST] Specify a space-separated list of kernel modules to
2009-09-09 19:02:37 +04:00
exclusively include in the initramfs.
2012-02-15 17:53:18 +04:00
--add-drivers [ LIST] Specify a space-separated list of kernel
2009-09-09 19:02:37 +04:00
modules to add to the initramfs.
2012-02-15 17:53:18 +04:00
--omit-drivers [ LIST] Specify a space-separated list of kernel
modules not to add to the initramfs.
2009-11-03 13:50:55 +03:00
--filesystems [ LIST] Specify a space-separated list of kernel filesystem
modules to exclusively include in the generic
initramfs.
2011-05-10 13:39:10 +04:00
-k, --kmoddir [ DIR] Specify the directory, where to look for kernel
2009-07-24 15:09:57 +04:00
modules
2011-05-10 13:39:10 +04:00
--fwdir [ DIR] Specify additional directories, where to look for
2009-07-22 14:43:26 +04:00
firmwares, separated by :
--kernel-only Only install kernel drivers and firmware files
--no-kernel Do not install kernel drivers and firmware files
2012-10-04 21:23:19 +04:00
--kernel-cmdline [ PARAMETERS] Specify default kernel command line parameters
2010-05-07 12:44:30 +04:00
--strip Strip binaries in the initramfs
--nostrip Do not strip binaries in the initramfs ( default)
2012-06-30 13:34:46 +04:00
--hardlink Hardlink files in the initramfs ( default)
--nohardlink Do not hardlink files in the initramfs
2011-04-20 18:47:40 +04:00
--prefix [ DIR] Prefix initramfs files with [ DIR]
--noprefix Do not prefix initramfs files ( default)
2009-09-15 11:00:13 +04:00
--mdadmconf Include local /etc/mdadm.conf
--nomdadmconf Do not include local /etc/mdadm.conf
2009-09-18 13:40:12 +04:00
--lvmconf Include local /etc/lvm/lvm.conf
2010-09-10 17:23:06 +04:00
--nolvmconf Do not include local /etc/lvm/lvm.conf
2011-10-08 00:23:51 +04:00
--fscks [ LIST] Add a space-separated list of fsck helpers.
--nofscks Inhibit installation of any fsck helpers.
2012-07-26 18:44:09 +04:00
--ro-mnt Mount / and /usr read-only by default.
2009-05-19 18:47:03 +04:00
-h, --help This message
2009-05-20 11:03:01 +04:00
--debug Output debug information of the build process
2011-08-12 15:24:25 +04:00
--profile Output profile information of the build process
2011-03-15 21:37:45 +03:00
-L, --stdlog [ 0-6] Specify logging level ( to standard error)
0 - suppress any messages
1 - only fatal errors
2 - all errors
3 - warnings
4 - info ( default)
5 - debug info ( here starts lots of output)
6 - trace info ( and even more)
2011-03-16 23:24:30 +03:00
-v, --verbose Increase verbosity level ( default is info( 4) )
-q, --quiet Decrease verbosity level ( default is info( 4) )
2009-05-19 18:47:03 +04:00
-c, --conf [ FILE] Specify configuration file to use.
Default: /etc/dracut.conf
2011-05-10 13:39:10 +04:00
--confdir [ DIR] Specify configuration directory to use *.conf files
2010-09-10 17:23:06 +04:00
from. Default: /etc/dracut.conf.d
2012-03-26 16:28:35 +04:00
--tmpdir [ DIR] Temporary directory to be used instead of default
/var/tmp.
2009-05-19 18:47:03 +04:00
-l, --local Local mode. Use modules from the current working
directory instead of the system-wide installed in
2011-11-23 12:42:10 +04:00
/usr/lib/dracut/modules.d.
2009-05-19 18:47:03 +04:00
Useful when running dracut from a git checkout.
2010-08-06 15:54:34 +04:00
-H, --hostonly Host-Only mode: Install only what is needed for
2009-05-19 18:47:03 +04:00
booting the local host instead of a generic host.
2012-07-21 15:03:56 +04:00
-N, --no-hostonly Disables Host-Only mode
2010-08-06 15:54:34 +04:00
--fstab Use /etc/fstab to determine the root device.
2011-12-15 17:36:37 +04:00
--add-fstab [ FILE] Add file to the initramfs fstab
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
Mount device [ DEV] on mountpoint [ MP] with filesystem
[ FSTYPE] and options [ FSOPTS] in the initramfs
2012-08-23 07:02:24 +04:00
--device "[DEV]" Bring up [ DEV] in initramfs
2009-05-19 18:47:03 +04:00
-i, --include [ SOURCE] [ TARGET]
2009-05-24 06:10:52 +04:00
Include the files in the SOURCE directory into the
Target directory in the final initramfs.
2011-05-10 13:39:10 +04:00
If SOURCE is a file, it will be installed to TARGET
2011-03-09 23:50:04 +03:00
in the final initramfs.
2009-05-24 06:10:52 +04:00
-I, --install [ LIST] Install the space separated list of files into the
initramfs.
2010-08-14 23:23:25 +04:00
--gzip Compress the generated initramfs using gzip.
2010-09-10 17:23:06 +04:00
This will be done by default, unless another
compression option or --no-compress is passed.
2010-08-14 23:23:25 +04:00
--bzip2 Compress the generated initramfs using bzip2.
2010-09-10 17:23:06 +04:00
Make sure your kernel has bzip2 decompression support
compiled in, otherwise you will not be able to boot.
--lzma Compress the generated initramfs using lzma.
2011-05-10 13:39:10 +04:00
Make sure your kernel has lzma support compiled in,
2010-09-10 17:23:06 +04:00
otherwise you will not be able to boot.
2011-03-19 18:48:19 +03:00
--xz Compress the generated initramfs using xz.
Make sure that your kernel has xz support compiled
in, otherwise you will not be able to boot.
--compress [ COMPRESSION] Compress the generated initramfs with the
passed compression program. Make sure your kernel
2011-05-10 13:39:10 +04:00
knows how to decompress the generated initramfs,
2011-03-19 18:48:19 +03:00
otherwise you will not be able to boot.
2010-08-14 23:23:25 +04:00
--no-compress Do not compress the generated initramfs. This will
2010-09-10 17:23:06 +04:00
override any other compression options.
2010-09-17 10:36:26 +04:00
--list-modules List all available dracut modules.
2011-03-25 17:56:51 +03:00
-M, --show-modules Print included module' s name to standard output during
build.
2011-05-20 22:08:13 +04:00
--keep Keep the temporary initramfs for debugging purposes
2012-05-21 12:37:06 +04:00
--printsize Print out the module install size
2011-12-26 10:29:21 +04:00
--sshkey [ SSHKEY] Add ssh key to initramfs ( use with ssh-client module)
2012-01-23 14:26:17 +04:00
If [ LIST] has multiple arguments, then you have to put these in quotes.
2012-07-03 16:20:51 +04:00
2012-01-23 14:26:17 +04:00
For example:
2012-07-03 16:20:51 +04:00
# dracut --add-drivers "module1 module2" ...
2010-09-10 17:23:06 +04:00
EOF
2009-05-19 18:47:03 +04:00
}
2011-03-10 17:58:42 +03:00
# function push()
# push values to a stack
# $1 = stack variable
# $2.. values
# example:
# push stack 1 2 "3 4"
push( ) {
2012-07-03 16:20:51 +04:00
local _i
2011-03-10 17:58:42 +03:00
local __stack = $1 ; shift
2012-07-03 16:20:51 +04:00
for _i in " $@ " ; do
eval ${ __stack } '[${#' ${ __stack } '[@]}]="$_i"'
2011-03-10 17:58:42 +03:00
done
}
# function pop()
# pops the last value from a stack
# assigns value to second argument variable
# or echo to stdout, if no second argument
# $1 = stack variable
# $2 = optional variable to store the value
# example:
# pop stack val
# val=$(pop stack)
pop( ) {
local __stack = $1 ; shift
2011-05-10 13:39:10 +04:00
local __resultvar = $1
2012-07-03 16:20:51 +04:00
local _value;
2011-03-10 17:58:42 +03:00
# check for empty stack
eval '[[ ${#' ${ __stack } '[@]} -eq 0 ]] && return 1'
2012-07-03 16:20:51 +04:00
eval _value = '${' ${ __stack } '[${#' ${ __stack } '[@]}-1]}'
2011-03-10 17:58:42 +03:00
if [ [ " $__resultvar " ] ] ; then
2012-07-03 16:20:51 +04:00
eval $__resultvar = " ' $_value ' "
2011-03-10 17:58:42 +03:00
else
2012-07-03 16:20:51 +04:00
echo " $_value "
2011-03-10 17:58:42 +03:00
fi
eval unset ${ __stack } '[${#' ${ __stack } '[@]}-1]'
return 0
}
2010-08-14 23:23:26 +04:00
# Little helper function for reading args from the commandline.
# it automatically handles -a b and -a=b variants, and returns 1 if
# we need to shift $3.
read_arg( ) {
# $1 = arg name
# $2 = arg value
# $3 = arg parameter
local rematch = '^[^=]*=(.*)$'
if [ [ $2 = ~ $rematch ] ] ; then
2010-09-10 17:23:06 +04:00
read " $1 " <<< " ${ BASH_REMATCH [1] } "
2010-08-14 23:23:26 +04:00
else
2010-09-10 17:23:06 +04:00
read " $1 " <<< " $3 "
# There is no way to shift our callers args, so
# return 1 to indicate they should do it instead.
return 1
2010-08-14 23:23:26 +04:00
fi
}
2011-03-16 23:24:30 +03:00
verbosity_mod_l = 0
2012-06-15 13:11:30 +04:00
unset kernel
unset outfile
2011-03-10 17:55:02 +03:00
2012-07-03 16:20:51 +04:00
# Workaround -i, --include taking 2 arguments
set -- " ${ @/--include/++include } "
# This prevents any long argument ending with "-i"
# -i, like --opt-i but I think we can just prevent that
set -- " ${ @/%-i/++include } "
TEMP = $( unset POSIXLY_CORRECT; getopt \
2012-07-21 15:03:56 +04:00
-o "a:m:o:d:I:k:c:L:fvqlHhMN" \
2012-07-20 13:34:40 +04:00
--long kver: \
2012-07-03 16:20:51 +04:00
--long add: \
--long force-add: \
--long add-drivers: \
--long omit-drivers: \
--long modules: \
--long omit: \
--long drivers: \
--long filesystems: \
--long install: \
--long fwdir: \
--long libdirs: \
--long fscks: \
--long add-fstab: \
--long mount: \
2012-08-23 07:02:24 +04:00
--long device: \
2012-07-03 16:20:51 +04:00
--long nofscks: \
2012-07-26 18:44:09 +04:00
--long ro-mnt \
2012-07-03 16:20:51 +04:00
--long kmoddir: \
--long conf: \
--long confdir: \
--long tmpdir: \
--long stdlog: \
--long compress: \
--long prefix: \
--long force \
--long kernel-only \
--long no-kernel \
2012-10-04 21:23:19 +04:00
--long kernel-cmdline: \
2012-07-03 16:20:51 +04:00
--long strip \
--long nostrip \
--long hardlink \
--long nohardlink \
--long noprefix \
--long mdadmconf \
--long nomdadmconf \
--long lvmconf \
--long nolvmconf \
--long debug \
--long profile \
--long sshkey: \
--long verbose \
--long quiet \
--long local \
--long hostonly \
--long no-hostonly \
--long fstab \
--long help \
--long bzip2 \
--long lzma \
--long xz \
--long no-compress \
--long gzip \
--long list-modules \
--long show-modules \
--long keep \
--long printsize \
-- " $@ " )
if ( ( $? != 0 ) ) ; then
usage
exit 1
fi
eval set -- " $TEMP "
while :; do
case $1 in
2012-07-20 13:34:40 +04:00
--kver) kernel = " $2 " ; shift; ;
2012-07-03 16:20:51 +04:00
-a| --add) push add_dracutmodules_l " $2 " ; shift; ;
--force-add) push force_add_dracutmodules_l " $2 " ; shift; ;
--add-drivers) push add_drivers_l " $2 " ; shift; ;
--omit-drivers) push omit_drivers_l " $2 " ; shift; ;
-m| --modules) push dracutmodules_l " $2 " ; shift; ;
-o| --omit) push omit_dracutmodules_l " $2 " ; shift; ;
-d| --drivers) push drivers_l " $2 " ; shift; ;
--filesystems) push filesystems_l " $2 " ; shift; ;
-I| --install) push install_items_l " $2 " ; shift; ;
--fwdir) push fw_dir_l " $2 " ; shift; ;
--libdirs) push libdirs_l " $2 " ; shift; ;
--fscks) push fscks_l " $2 " ; shift; ;
--add-fstab) push add_fstab_l " $2 " ; shift; ;
--mount) push fstab_lines " $2 " ; shift; ;
2012-08-23 07:02:24 +04:00
--device) push host_devs " $2 " ; shift; ;
2012-10-04 21:23:19 +04:00
--kernel-cmdline) push kernel_cmdline_l " $2 " ; shift; ;
2011-10-08 00:23:51 +04:00
--nofscks) nofscks_l = "yes" ; ;
2012-07-26 18:44:09 +04:00
--ro-mnt) ro_mnt_l = "yes" ; ;
2012-07-03 16:20:51 +04:00
-k| --kmoddir) drivers_dir_l = " $2 " ; shift; ;
-c| --conf) conffile = " $2 " ; shift; ;
--confdir) confdir = " $2 " ; shift; ;
--tmpdir) tmpdir_l = " $2 " ; shift; ;
-L| --stdlog) stdloglvl_l = " $2 " ; shift; ;
--compress) compress_l = " $2 " ; shift; ;
--prefix) prefix_l = " $2 " ; shift; ;
2010-09-10 17:23:06 +04:00
-f| --force) force = yes; ;
--kernel-only) kernel_only = "yes" ; no_kernel = "no" ; ;
--no-kernel) kernel_only = "no" ; no_kernel = "yes" ; ;
--strip) do_strip_l = "yes" ; ;
--nostrip) do_strip_l = "no" ; ;
2012-06-30 13:34:46 +04:00
--hardlink) do_hardlink_l = "yes" ; ;
--nohardlink) do_hardlink_l = "no" ; ;
2011-04-20 18:47:40 +04:00
--noprefix) prefix_l = "/" ; ;
2010-08-14 23:23:26 +04:00
--mdadmconf) mdadmconf_l = "yes" ; ;
--nomdadmconf) mdadmconf_l = "no" ; ;
--lvmconf) lvmconf_l = "yes" ; ;
--nolvmconf) lvmconf_l = "no" ; ;
2010-09-10 17:23:06 +04:00
--debug) debug = "yes" ; ;
2011-08-12 15:24:25 +04:00
--profile) profile = "yes" ; ;
2012-07-03 16:20:51 +04:00
--sshkey) sshkey = " $2 " ; shift; ;
2011-03-16 23:24:30 +03:00
-v| --verbose) ( ( verbosity_mod_l++) ) ; ;
-q| --quiet) ( ( verbosity_mod_l--) ) ; ;
2012-05-22 16:28:34 +04:00
-l| --local)
allowlocal = "yes"
[ [ -f " $( readlink -f ${ 0 %/* } ) /dracut-functions.sh " ] ] \
&& dracutbasedir = " $( readlink -f ${ 0 %/* } ) "
; ;
2010-09-10 17:23:06 +04:00
-H| --hostonly) hostonly_l = "yes" ; ;
2012-07-21 15:03:56 +04:00
-N| --no-hostonly) hostonly_l = "no" ; ;
2010-09-10 17:23:06 +04:00
--fstab) use_fstab_l = "yes" ; ;
2012-07-03 16:20:51 +04:00
-h| --help) long_usage; exit 1 ; ;
2011-03-29 13:27:15 +04:00
-i| --include) push include_src " $2 "
2012-07-03 16:20:51 +04:00
shift; ;
2011-03-19 18:48:19 +03:00
--bzip2) compress_l = "bzip2" ; ;
--lzma) compress_l = "lzma" ; ;
--xz) compress_l = "xz" ; ;
--no-compress) _no_compress_l = "cat" ; ;
--gzip) compress_l = "gzip" ; ;
2012-07-03 16:20:51 +04:00
--list-modules) do_list = "yes" ; ;
2011-03-25 17:56:51 +03:00
-M| --show-modules)
show_modules_l = "yes"
; ;
2011-05-20 22:08:13 +04:00
--keep) keep = "yes" ; ;
2012-05-21 12:37:06 +04:00
--printsize) printsize = "yes" ; ;
2012-07-03 16:20:51 +04:00
--) shift; break; ;
*) # should not even reach this point
printf "\n!Unknown option: '%s'\n\n" " $1 " >& 2; usage; exit 1; ;
esac
shift
done
# getopt cannot handle multiple arguments, so just handle "-I,--include"
# the old fashioned way
while ( ( $# > 0) ) ; do
case ${ 1 %%=* } in
++include) push include_src " $2 "
push include_target " $3 "
shift 2; ;
2011-05-10 13:39:10 +04:00
*)
2011-03-29 03:21:56 +04:00
if ! [ [ ${ outfile +x } ] ] ; then
2011-03-10 17:55:02 +03:00
outfile = $1
2011-03-29 13:21:54 +04:00
elif ! [ [ ${ kernel +x } ] ] ; then
2011-03-10 17:55:02 +03:00
kernel = $1
else
2012-07-03 16:20:51 +04:00
printf "\nUnknown arguments: %s\n\n" " $* " >& 2
2011-03-10 17:55:02 +03:00
usage; exit 1;
fi
; ;
2008-12-18 01:51:15 +03:00
esac
2009-02-13 15:41:52 +03:00
shift
2008-12-18 01:51:15 +03:00
done
2012-07-03 16:20:51 +04:00
2011-03-29 13:21:54 +04:00
if ! [ [ $kernel ] ] ; then
2011-03-10 17:55:02 +03:00
kernel = $( uname -r)
fi
2012-07-03 16:20:51 +04:00
if ! [ [ $outfile ] ] ; then
outfile = " /boot/initramfs- $kernel .img "
fi
2009-03-07 13:53:40 +03:00
2012-02-09 16:58:13 +04:00
for i in /usr/sbin /sbin /usr/bin /bin; do
2012-02-07 20:11:58 +04:00
rl = $i
if [ -L " $i " ] ; then
rl = $( readlink -f $i )
fi
2012-07-03 16:20:51 +04:00
if [ [ " $NPATH " != " *: $rl * " ] ] ; then
NPATH += " : $rl "
fi
2012-02-07 20:11:58 +04:00
done
2012-02-09 16:58:13 +04:00
export PATH = " ${ NPATH # : } "
2012-02-08 20:02:17 +04:00
unset NPATH
2011-08-19 10:08:18 +04:00
unset LD_LIBRARY_PATH
2012-01-23 13:10:25 +04:00
unset GREP_OPTIONS
2009-07-02 18:03:39 +04:00
2012-06-29 14:07:44 +04:00
export DRACUT_LOG_LEVEL = warning
2011-05-10 13:39:10 +04:00
[ [ $debug ] ] && {
2012-06-29 14:07:44 +04:00
export DRACUT_LOG_LEVEL = debug
2009-06-05 06:35:31 +04:00
export PS4 = '${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ' ;
set -x
}
2011-08-12 15:24:25 +04:00
[ [ $profile ] ] && {
export PS4 = '+ $(date "+%s.%N") ${BASH_SOURCE}@${LINENO}: ' ;
set -x
debug = yes
}
2011-11-23 12:42:10 +04:00
[ [ $dracutbasedir ] ] || dracutbasedir = /usr/lib/dracut
2009-10-27 11:28:53 +03:00
2009-05-23 06:24:29 +04:00
# if we were not passed a config file, try the default one
2009-10-09 15:15:32 +04:00
if [ [ ! -f $conffile ] ] ; then
2010-08-14 23:23:24 +04:00
[ [ $allowlocal ] ] && conffile = " $dracutbasedir /dracut.conf " || \
conffile = "/etc/dracut.conf"
2009-10-09 15:15:32 +04:00
fi
2009-05-23 06:24:29 +04:00
2010-02-12 13:12:37 +03:00
if [ [ ! -d $confdir ] ] ; then
2010-08-23 13:58:39 +04:00
[ [ $allowlocal ] ] && confdir = " $dracutbasedir /dracut.conf.d " || \
2010-08-14 23:23:24 +04:00
confdir = "/etc/dracut.conf.d"
2010-02-12 13:12:37 +03:00
fi
2010-07-14 03:30:16 +04:00
# source our config file
[ [ -f $conffile ] ] && . " $conffile "
2010-02-12 13:12:37 +03:00
# source our config dir
2010-08-14 23:23:24 +04:00
if [ [ $confdir && -d $confdir ] ] ; then
2011-05-10 13:39:10 +04:00
for f in " $confdir " /*.conf; do
2010-09-10 17:23:06 +04:00
[ [ -e $f ] ] && . " $f "
2010-02-12 13:12:37 +03:00
done
fi
2010-05-03 13:35:10 +04:00
# these optins add to the stuff in the config file
2011-03-20 22:56:17 +03:00
if ( ( ${# add_dracutmodules_l [@] } ) ) ; then
2011-03-10 19:01:10 +03:00
while pop add_dracutmodules_l val; do
add_dracutmodules += " $val "
done
fi
2011-08-01 06:01:23 +04:00
if ( ( ${# force_add_dracutmodules_l [@] } ) ) ; then
while pop force_add_dracutmodules_l val; do
force_add_dracutmodules += " $val "
done
fi
2011-10-08 00:23:51 +04:00
if ( ( ${# fscks_l [@] } ) ) ; then
while pop fscks_l val; do
fscks += " $val "
done
fi
2011-12-15 17:36:37 +04:00
if ( ( ${# add_fstab_l [@] } ) ) ; then
while pop add_fstab_l val; do
add_fstab += " $val "
done
fi
if ( ( ${# fstab_lines_l [@] } ) ) ; then
while pop fstab_lines_l val; do
push fstab_lines $val
done
fi
2011-11-15 20:12:50 +04:00
if ( ( ${# install_items_l [@] } ) ) ; then
while pop install_items_l val; do
2012-02-07 21:26:30 +04:00
install_items += " $val "
2011-11-15 20:12:50 +04:00
done
fi
2009-05-23 06:24:29 +04:00
# these options override the stuff in the config file
2011-03-20 22:56:17 +03:00
if ( ( ${# dracutmodules_l [@] } ) ) ; then
2011-03-10 19:01:10 +03:00
dracutmodules = ''
while pop dracutmodules_l val; do
dracutmodules += " $val "
done
fi
2011-03-20 22:56:17 +03:00
if ( ( ${# omit_dracutmodules_l [@] } ) ) ; then
2011-03-10 19:01:10 +03:00
omit_dracutmodules = ''
while pop omit_dracutmodules_l val; do
omit_dracutmodules += " $val "
done
fi
2011-03-20 22:56:17 +03:00
if ( ( ${# filesystems_l [@] } ) ) ; then
2011-03-10 19:01:10 +03:00
filesystems = ''
while pop filesystems_l val; do
filesystems += " $val "
done
fi
2011-03-20 22:56:17 +03:00
if ( ( ${# fw_dir_l [@] } ) ) ; then
2011-03-10 19:01:10 +03:00
fw_dir = ''
while pop fw_dir_l val; do
fw_dir += " $val "
done
fi
2012-04-10 17:14:38 +04:00
if ( ( ${# libdirs_l [@] } ) ) ; then
libdirs = ''
while pop libdirs_l val; do
libdirs += " $val "
done
fi
2011-03-15 21:37:45 +03:00
[ [ $stdloglvl_l ] ] && stdloglvl = $stdloglvl_l
2011-03-25 17:56:45 +03:00
[ [ ! $stdloglvl ] ] && stdloglvl = 4
2011-03-16 23:24:30 +03:00
stdloglvl = $(( stdloglvl + verbosity_mod_l))
( ( stdloglvl > 6) ) && stdloglvl = 6
( ( stdloglvl < 0) ) && stdloglvl = 0
2009-07-21 19:49:17 +04:00
[ [ $drivers_dir_l ] ] && drivers_dir = $drivers_dir_l
2009-07-24 17:48:20 +04:00
[ [ $do_strip_l ] ] && do_strip = $do_strip_l
2012-06-30 13:34:46 +04:00
[ [ $do_strip ] ] || do_strip = no
[ [ $do_hardlink_l ] ] && do_hardlink = $do_hardlink_l
[ [ $do_hardlink ] ] || do_hardlink = yes
2011-04-20 18:47:40 +04:00
[ [ $prefix_l ] ] && prefix = $prefix_l
[ [ $prefix = "/" ] ] && unset prefix
2009-08-31 13:39:21 +04:00
[ [ $hostonly_l ] ] && hostonly = $hostonly_l
2010-08-06 15:54:34 +04:00
[ [ $use_fstab_l ] ] && use_fstab = $use_fstab_l
2009-09-15 11:00:13 +04:00
[ [ $mdadmconf_l ] ] && mdadmconf = $mdadmconf_l
2009-09-18 13:40:12 +04:00
[ [ $lvmconf_l ] ] && lvmconf = $lvmconf_l
2011-11-23 12:42:10 +04:00
[ [ $dracutbasedir ] ] || dracutbasedir = /usr/lib/dracut
2011-03-29 17:32:34 +04:00
[ [ $fw_dir ] ] || fw_dir = "/lib/firmware/updates /lib/firmware"
2012-03-26 16:28:35 +04:00
[ [ $tmpdir_l ] ] && tmpdir = " $tmpdir_l "
[ [ $tmpdir ] ] || tmpdir = /var/tmp
2011-03-19 18:48:19 +03:00
[ [ $compress_l ] ] && compress = $compress_l
2011-03-25 17:56:51 +03:00
[ [ $show_modules_l ] ] && show_modules = $show_modules_l
2011-10-08 00:23:51 +04:00
[ [ $nofscks_l ] ] && nofscks = "yes"
2012-07-26 18:44:09 +04:00
[ [ $ro_mnt_l ] ] && ro_mnt = "yes"
2009-08-15 23:17:19 +04:00
# eliminate IFS hackery when messing with fw_dir
fw_dir = ${ fw_dir // : / }
2009-03-06 23:06:48 +03:00
2011-03-19 18:48:19 +03:00
# handle compression options.
2011-05-31 15:58:08 +04:00
[ [ $compress ] ] || compress = "gzip"
2011-03-19 18:48:19 +03:00
case $compress in
2011-05-20 01:15:51 +04:00
bzip2) compress = "bzip2 -9" ; ;
2011-03-19 18:48:19 +03:00
lzma) compress = "lzma -9" ; ;
xz) compress = "xz --check=crc32 --lzma2=dict=1MiB" ; ;
2011-05-31 15:58:08 +04:00
gzip) command -v pigz > /dev/null 2>& 1 && compress = "pigz -9" || \
2011-03-19 18:48:19 +03:00
compress = "gzip -9" ; ;
esac
if [ [ $_no_compress_l = "cat" ] ] ; then
compress = "cat"
fi
2009-08-31 13:39:21 +04:00
[ [ $hostonly = yes ] ] && hostonly = "-h"
2009-11-27 16:29:32 +03:00
[ [ $hostonly != "-h" ] ] && unset hostonly
2009-08-31 13:39:21 +04:00
2012-06-27 16:17:46 +04:00
readonly TMPDIR = " $tmpdir "
readonly initdir = $( mktemp --tmpdir= " $TMPDIR / " -d -t initramfs.XXXXXX)
[ -d " $initdir " ] || {
2012-07-09 12:02:35 +04:00
echo " dracut: mktemp --tmpdir=\" $TMPDIR /\" -d -t initramfs.XXXXXX failed. " >& 2
2012-06-27 16:17:46 +04:00
exit 1
}
2012-06-29 14:07:44 +04:00
export DRACUT_KERNEL_LAZY = "1"
export DRACUT_RESOLVE_LAZY = "1"
2012-02-22 13:14:17 +04:00
if [ [ -f $dracutbasedir /dracut-functions.sh ] ] ; then
. $dracutbasedir /dracut-functions.sh
2009-05-19 18:46:33 +04:00
else
2012-06-27 16:17:46 +04:00
echo " dracut: Cannot find $dracutbasedir /dracut-functions.sh. " >& 2
echo "dracut: Are you running from a git checkout?" >& 2
echo " dracut: Try passing -l as an argument to $0 " >& 2
2010-09-10 17:23:06 +04:00
exit 1
2009-05-19 18:46:33 +04:00
fi
2009-05-25 16:09:57 +04:00
2012-07-30 15:02:41 +04:00
inst /bin/sh
if ! $DRACUT_INSTALL ${ initdir +-D " $initdir " } -R " $initdir /bin/sh " & >/dev/null; then
unset DRACUT_RESOLVE_LAZY
export DRACUT_RESOLVE_DEPS = 1
fi
rm -fr ${ initdir } /*
2012-05-22 16:28:34 +04:00
if [ [ -f $dracutbasedir /dracut-version.sh ] ] ; then
. $dracutbasedir /dracut-version.sh
fi
2012-07-30 15:02:41 +04:00
# Verify bash version, current minimum is 3.1
2011-10-11 01:58:05 +04:00
if ( ( ${ BASH_VERSINFO [0] } < 3 ||
( ${ BASH_VERSINFO [0] } = = 3 && ${ BASH_VERSINFO [1] } < 1 ) ) ) ; then
dfatal 'You need at least Bash 3.1 to use dracut, sorry.'
exit 1
fi
2012-02-22 13:14:17 +04:00
dracutfunctions = $dracutbasedir /dracut-functions.sh
2009-03-07 16:01:32 +03:00
export dracutfunctions
2009-03-06 23:06:48 +03:00
2012-02-15 17:53:18 +04:00
if ( ( ${# drivers_l [@] } ) ) ; then
drivers = ''
while pop drivers_l val; do
drivers += " $val "
done
fi
drivers = ${ drivers /-/_ }
if ( ( ${# add_drivers_l [@] } ) ) ; then
while pop add_drivers_l val; do
add_drivers += " $val "
done
fi
add_drivers = ${ add_drivers /-/_ }
if ( ( ${# omit_drivers_l [@] } ) ) ; then
while pop omit_drivers_l val; do
omit_drivers += " $val "
done
fi
omit_drivers = ${ omit_drivers /-/_ }
2012-10-04 21:23:19 +04:00
if ( ( ${# kernel_cmdline_l [@] } ) ) ; then
while pop kernel_cmdline_l val; do
kernel_cmdline += " $val "
done
fi
2012-02-22 19:12:10 +04:00
omit_drivers_corrected = ""
2012-02-15 17:53:18 +04:00
for d in $omit_drivers ; do
strstr " $drivers $add_drivers " " $d " && continue
2012-02-22 19:12:10 +04:00
omit_drivers_corrected += " $d | "
2012-02-15 17:53:18 +04:00
done
2012-02-22 19:12:10 +04:00
omit_drivers = " ${ omit_drivers_corrected %| } "
2012-02-15 17:53:18 +04:00
unset omit_drivers_corrected
2012-07-03 16:20:51 +04:00
# prepare args for logging
for ( ( i = 0; i < ${# dracut_args [@] } ; i++) ) ; do
strstr " ${ dracut_args [ $i ] } " " " && \
dracut_args[ $i ] = " \" ${ dracut_args [ $i ] } \" "
2012-07-06 15:48:05 +04:00
#" keep vim happy
2012-07-03 16:20:51 +04:00
done
ddebug " Executing: $0 ${ dracut_args [@] } "
2011-03-07 14:54:47 +03:00
2010-09-17 10:36:26 +04:00
[ [ $do_list = yes ] ] && {
for mod in $dracutbasedir /modules.d/*; do
[ [ -d $mod ] ] || continue ;
2011-03-09 00:36:38 +03:00
[ [ -e $mod /install || -e $mod /installkernel || \
-e $mod /module-setup.sh ] ] || continue
2010-09-17 10:36:26 +04:00
echo ${ mod ##*/?? }
done
exit 0
}
2009-05-30 07:14:31 +04:00
# This is kinda legacy -- eventually it should go away.
2009-05-23 06:24:29 +04:00
case $dracutmodules in
2009-05-30 07:14:31 +04:00
"" | auto) dracutmodules = "all" ; ;
2009-05-23 06:24:29 +04:00
esac
2009-03-07 14:18:09 +03:00
2010-02-18 20:27:39 +03:00
abs_outfile = $( readlink -f " $outfile " ) && outfile = " $abs_outfile "
2008-12-11 00:32:21 +03:00
2012-06-06 20:20:35 +04:00
[ [ -f $srcmods /modules.dep ] ] || {
dfatal " $srcmods /modules.dep is missing. Did you run depmod? "
exit 1
}
2009-02-13 15:41:54 +03:00
if [ [ -f $outfile && ! $force ] ] ; then
2011-03-16 23:24:30 +03:00
dfatal " Will not override existing initramfs ( $outfile ) without --force "
2008-12-11 00:32:21 +03:00
exit 1
fi
2010-08-14 23:23:24 +04:00
outdir = ${ outfile %/* }
2011-03-24 13:30:23 +03:00
[ [ $outdir ] ] || outdir = "/"
2010-08-14 23:23:24 +04:00
if [ [ ! -d " $outdir " ] ] ; then
2011-03-16 23:24:30 +03:00
dfatal " Can't write $outfile : Directory $outdir does not exist. "
2010-02-18 20:27:39 +03:00
exit 1
2010-08-14 23:23:24 +04:00
elif [ [ ! -w " $outdir " ] ] ; then
2012-07-03 16:20:51 +04:00
dfatal " No permission to write to $outdir . "
2010-02-18 20:27:39 +03:00
exit 1
2010-08-23 13:57:39 +04:00
elif [ [ -f " $outfile " && ! -w " $outfile " ] ] ; then
2011-03-16 23:24:30 +03:00
dfatal " No permission to write $outfile . "
2009-11-19 17:46:09 +03:00
exit 1
fi
2010-09-10 17:23:06 +04:00
# clean up after ourselves no matter how we die.
2011-05-20 22:08:13 +04:00
trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf "$initdir";exit $ret;' EXIT
2010-09-10 17:23:06 +04:00
# clean up after ourselves no matter how we die.
2011-05-10 13:39:10 +04:00
trap 'exit 1;' SIGINT
2008-12-11 00:32:21 +03:00
2009-05-23 06:53:10 +04:00
# Need to be able to have non-root users read stuff (rpcbind etc)
chmod 755 " $initdir "
2011-12-20 10:09:56 +04:00
for line in " ${ fstab_lines [@] } " ; do
set -- $line
#dev mp fs fsopts
2011-12-20 10:09:59 +04:00
push host_devs " $1 "
push host_fs_types " $1 | $3 "
2011-12-20 10:09:56 +04:00
done
for f in $add_fstab ; do
[ -e $f ] || continue
while read dev rest; do
push host_devs $dev
done < $f
done
2011-12-08 13:25:58 +04:00
if [ [ $hostonly ] ] ; then
2011-12-08 13:43:29 +04:00
# in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types
2011-12-08 13:25:58 +04:00
push host_mp \
"/" \
"/etc" \
"/usr" \
"/usr/bin" \
"/usr/sbin" \
"/usr/lib" \
"/usr/lib64" \
"/boot"
for mp in " ${ host_mp [@] } " ; do
mountpoint " $mp " >/dev/null 2>& 1 || continue
2011-12-20 10:09:59 +04:00
push host_devs $( readlink -f " /dev/block/ $( find_block_device " $mp " ) " )
2011-12-08 13:25:58 +04:00
done
fi
2011-12-20 10:09:56 +04:00
_get_fs_type( ) (
[ [ $1 ] ] || return
2011-12-20 10:09:59 +04:00
if [ [ -b $1 ] ] && get_fs_env $1 ; then
2012-03-29 17:14:26 +04:00
echo " $( readlink -f $1 ) | $ID_FS_TYPE "
2011-12-20 10:09:56 +04:00
return 1
fi
2012-01-23 16:49:39 +04:00
if [ [ -b /dev/block/$1 ] ] && get_fs_env /dev/block/$1 ; then
2012-03-29 17:14:26 +04:00
echo " $( readlink -f /dev/block/$1 ) | $ID_FS_TYPE "
2012-01-23 16:49:39 +04:00
return 1
fi
2011-12-20 10:09:56 +04:00
if fstype = $( find_dev_fstype $1 ) ; then
echo " $1 | $fstype "
return 1
fi
return 1
)
for dev in " ${ host_devs [@] } " ; do
unset fs_type
for fstype in $( _get_fs_type $dev ) \
2011-12-20 10:09:59 +04:00
$( check_block_and_slaves _get_fs_type $( get_maj_min $dev ) ) ; do
2011-12-20 10:09:56 +04:00
if ! strstr " ${ host_fs_types [*] } " " $fstype " ; then
push host_fs_types " $fstype "
fi
done
done
2012-06-06 17:12:59 +04:00
[ [ -d $udevdir ] ] \
|| udevdir = $( pkg-config udev --variable= udevdir 2>/dev/null)
if ! [ [ -d " $udevdir " ] ] ; then
[ [ -d /lib/udev ] ] && udevdir = /lib/udev
[ [ -d /usr/lib/udev ] ] && udevdir = /usr/lib/udev
fi
[ [ -d $systemdutildir ] ] \
|| systemdutildir = $( pkg-config systemd --variable= systemdutildir 2>/dev/null)
[ [ -d $systemdsystemunitdir ] ] \
|| systemdsystemunitdir = $( pkg-config systemd --variable= systemdsystemunitdir 2>/dev/null)
if ! [ [ -d " $systemdutildir " ] ] ; then
[ [ -d /lib/systemd ] ] && systemdutildir = /lib/systemd
[ [ -d /usr/lib/systemd ] ] && systemdutildir = /usr/lib/systemd
fi
[ [ -d " $systemdsystemunitdir " ] ] || systemdsystemunitdir = ${ systemdutildir } /system
2012-07-27 18:03:42 +04:00
export initdir dracutbasedir dracutmodules \
2011-03-15 21:37:45 +03:00
fw_dir drivers_dir debug no_kernel kernel_only \
2012-07-27 18:03:42 +04:00
omit_drivers mdadmconf lvmconf \
2012-07-26 18:44:09 +04:00
use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
2011-03-17 14:13:44 +03:00
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
2012-05-22 16:28:34 +04:00
debug host_fs_types host_devs sshkey add_fstab \
2012-07-06 15:49:03 +04:00
DRACUT_VERSION udevdir systemdutildir systemdsystemunitdir \
2012-07-27 18:06:36 +04:00
prefix filesystems drivers
2009-02-13 15:43:24 +03:00
2011-04-11 19:19:41 +04:00
# Create some directory structure first
2011-04-20 18:47:40 +04:00
[ [ $prefix ] ] && mkdir -m 0755 -p " ${ initdir } ${ prefix } "
2011-04-11 19:19:41 +04:00
2011-05-20 01:16:17 +04:00
[ [ -h /lib ] ] || mkdir -m 0755 -p " ${ initdir } ${ prefix } /lib "
2011-04-20 18:47:40 +04:00
[ [ $prefix ] ] && ln -sfn " ${ prefix #/ } /lib " " $initdir /lib "
2011-04-11 19:19:41 +04:00
2011-05-20 01:16:17 +04:00
if [ [ $prefix ] ] ; then
2012-06-08 12:41:59 +04:00
for d in bin etc lib sbin tmp usr var $libdirs ; do
strstr " $d " "/" && continue
2011-05-20 01:16:17 +04:00
ln -sfn " ${ prefix #/ } / ${ d #/ } " " $initdir / $d "
done
fi
if [ [ $kernel_only != yes ] ] ; then
2012-07-31 13:44:40 +04:00
for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/log $libdirs ; do
2011-04-20 18:47:40 +04:00
[ [ -e " ${ initdir } ${ prefix } / $d " ] ] && continue
2012-02-24 00:10:17 +04:00
if [ -L " / $d " ] ; then
inst_symlink " / $d " " ${ prefix } / $d "
2011-05-20 01:16:17 +04:00
else
mkdir -m 0755 -p " ${ initdir } ${ prefix } / $d "
fi
2011-05-10 13:39:10 +04:00
done
2011-04-11 19:19:41 +04:00
2011-09-04 18:38:35 +04:00
for d in dev proc sys sysroot root run run/lock run/initramfs; do
2012-02-24 00:10:17 +04:00
if [ -L " / $d " ] ; then
inst_symlink " / $d "
2011-05-20 01:16:17 +04:00
else
mkdir -m 0755 -p " $initdir / $d "
fi
2009-07-22 14:43:26 +04:00
done
2011-04-11 19:19:41 +04:00
2012-07-31 13:48:03 +04:00
ln -sfn ../run " $initdir /var/run "
ln -sfn ../run/lock " $initdir /var/lock "
2011-07-25 16:28:40 +04:00
else
for d in lib " $libdir " ; do
[ [ -e " ${ initdir } ${ prefix } / $d " ] ] && continue
if [ -h " / $d " ] ; then
inst " / $d " " ${ prefix } / $d "
else
mkdir -m 0755 -p " ${ initdir } ${ prefix } / $d "
fi
done
2009-07-22 14:43:26 +04:00
fi
2009-02-13 15:43:07 +03:00
2012-02-22 19:11:19 +04:00
if [ [ $kernel_only != yes ] ] ; then
mkdir -p " ${ initdir } /etc/cmdline.d "
2012-03-02 17:46:11 +04:00
for _d in $hookdirs ; do
mkdir -m 0755 -p ${ initdir } /lib/dracut/hooks/$_d
done
2012-06-04 16:00:49 +04:00
if [ [ " $UID " = "0" ] ] ; then
2012-06-22 17:49:25 +04:00
[ -c ${ initdir } /dev/null ] || mknod ${ initdir } /dev/null c 1 3
[ -c ${ initdir } /dev/kmsg ] || mknod ${ initdir } /dev/kmsg c 1 11
[ -c ${ initdir } /dev/console ] || mknod ${ initdir } /dev/console c 5 1
2012-06-04 16:00:49 +04:00
fi
2012-02-22 19:11:19 +04:00
fi
2012-02-07 20:24:47 +04:00
2011-12-20 10:09:57 +04:00
mods_to_load = ""
2009-05-30 07:14:31 +04:00
# check all our modules to see if they should be sourced.
# This builds a list of modules that we will install next.
2011-12-20 10:09:57 +04:00
for_each_module_dir check_module
for_each_module_dir check_mount
2012-06-29 14:07:44 +04:00
strstr " $mods_to_load " "fips" && export DRACUT_FIPS_MODE = 1
2012-05-21 12:37:06 +04:00
_isize = 0 #initramfs size
2011-05-02 13:19:12 +04:00
modules_loaded = " "
2009-10-29 12:29:58 +03:00
# source our modules.
2009-10-27 11:28:53 +03:00
for moddir in " $dracutbasedir /modules.d " /[ 0-9] [ 0-9] *; do
2011-05-02 13:19:12 +04:00
_d_mod = ${ moddir ##*/ } ; _d_mod = ${ _d_mod #[0-9][0-9] }
if strstr " $mods_to_load " " $_d_mod " ; then
[ [ $show_modules = yes ] ] && echo " $_d_mod " || \
dinfo " *** Including module: $_d_mod *** "
2010-09-10 17:23:06 +04:00
if [ [ $kernel_only = yes ] ] ; then
2012-05-15 10:19:56 +04:00
module_installkernel $_d_mod || {
dfatal " installkernel failed in module $_d_mod "
exit 1
}
2010-09-10 17:23:06 +04:00
else
2011-05-02 13:19:12 +04:00
module_install $_d_mod
2011-02-02 15:34:58 +03:00
if [ [ $no_kernel != yes ] ] ; then
2012-05-15 10:19:56 +04:00
module_installkernel $_d_mod || {
dfatal " installkernel failed in module $_d_mod "
exit 1
}
2010-09-10 17:23:06 +04:00
fi
fi
2011-05-02 13:19:12 +04:00
mods_to_load = ${ mods_to_load // $_d_mod / }
modules_loaded += " $_d_mod "
2012-05-21 12:37:06 +04:00
#print the module install size
if [ -n " $printsize " ] ; then
_isize_new = $( du -sk ${ initdir } | cut -f1)
_isize_delta = $(( $_isize_new - $_isize ))
echo " $_d_mod install size: ${ _isize_delta } k "
_isize = $_isize_new
fi
2009-05-30 07:14:31 +04:00
fi
2009-02-13 15:43:12 +03:00
done
2009-02-27 03:02:47 +03:00
unset moddir
2012-04-16 15:10:22 +04:00
for i in $modules_loaded ; do
2012-06-12 19:35:49 +04:00
mkdir -p $initdir /lib/dracut
2012-04-16 15:10:22 +04:00
echo " $i " >> $initdir /lib/dracut/modules.txt
done
2011-03-29 16:45:08 +04:00
dinfo "*** Including modules done ***"
2009-01-05 22:40:34 +03:00
2009-02-13 15:43:07 +03:00
## final stuff that has to happen
2012-06-29 14:07:44 +04:00
if [ [ $no_kernel != yes ] ] ; then
2012-07-27 18:03:42 +04:00
if [ [ $drivers ] ] ; then
hostonly = '' instmods $drivers
fi
if [ [ $add_drivers ] ] ; then
hostonly = '' instmods -c $add_drivers
fi
if [ [ $filesystems ] ] ; then
hostonly = '' instmods -c $filesystems
fi
2012-06-29 14:07:44 +04:00
dinfo "*** Installing kernel module dependencies and firmware ***"
dracut_kernel_post
dinfo "*** Installing kernel module dependencies and firmware done ***"
fi
2012-06-27 11:35:39 +04:00
2012-06-30 13:33:19 +04:00
if [ [ $kernel_only != yes ] ] ; then
( ( ${# install_items [@] } > 0 ) ) && dracut_install ${ install_items [@] }
2012-10-04 21:23:19 +04:00
echo " $kernel_cmdline " >> " ${ initdir } /etc/cmdline.d/01-default.conf "
2012-06-30 13:33:19 +04:00
while pop fstab_lines line; do
echo " $line 0 0 " >> " ${ initdir } /etc/fstab "
done
for f in $add_fstab ; do
cat $f >> " ${ initdir } /etc/fstab "
done
if [ [ $DRACUT_RESOLVE_LAZY ] ] && [ [ $DRACUT_INSTALL ] ] ; then
dinfo "*** Resolving executable dependencies ***"
find " $initdir " -type f \
'(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
-not -path '*.ko' -print0 \
| xargs -r -0 $DRACUT_INSTALL ${ initdir +-D " $initdir " } -R ${ DRACUT_FIPS_MODE +-H }
dinfo "*** Resolving executable dependencies done***"
fi
fi
2011-03-10 19:01:10 +03:00
while pop include_src src && pop include_target tgt; do
if [ [ $src && $tgt ] ] ; then
if [ [ -f $src ] ] ; then
inst $src $tgt
else
2011-05-10 13:39:10 +04:00
ddebug " Including directory: $src "
2011-03-10 19:01:10 +03:00
mkdir -p " ${ initdir } / ${ tgt } "
2011-04-11 19:19:41 +04:00
# check for preexisting symlinks, so we can cope with the
2011-04-20 18:47:40 +04:00
# symlinks to $prefix
2011-04-11 19:19:41 +04:00
for i in " $src " /*; do
[ [ -e " $i " || -h " $i " ] ] || continue
s = ${ initdir } /${ tgt } /${ i # $src / }
if [ [ -d " $i " ] ] ; then
if ! [ [ -e " $s " ] ] ; then
mkdir -m 0755 -p " $s "
chmod --reference= " $i " " $s "
fi
2012-07-11 17:25:49 +04:00
cp --reflink= auto --sparse= auto -fa -t " $s " " $i " /*
2011-04-11 19:19:41 +04:00
else
2012-07-11 17:25:49 +04:00
cp --reflink= auto --sparse= auto -fa -t " $s " " $i "
2011-05-10 13:39:10 +04:00
fi
2011-04-11 19:19:41 +04:00
done
2011-03-10 19:01:10 +03:00
fi
2011-03-09 23:50:04 +03:00
fi
2011-03-10 19:01:10 +03:00
done
2009-03-16 12:42:02 +03:00
2012-02-22 19:11:19 +04:00
if [ [ $kernel_only != yes ] ] ; then
2011-04-11 16:38:31 +04:00
# make sure that library links are correct and up to date
for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
2011-12-01 01:48:26 +04:00
[ [ -f $f ] ] && inst_simple " $f "
2011-04-11 16:38:31 +04:00
done
if ! ldconfig -r " $initdir " ; then
if [ [ $UID = 0 ] ] ; then
derror "ldconfig exited ungracefully"
else
derror "ldconfig might need uid=0 (root) for chroot()"
fi
2011-03-16 23:24:30 +03:00
fi
fi
2010-03-05 13:14:28 +03:00
2011-03-16 23:24:30 +03:00
if ( ( $maxloglvl >= 5) ) ; then
ddebug "Listing sizes of included files:"
du -c " $initdir " | sort -n | ddebug
fi
2009-05-15 14:45:58 +04:00
2011-05-10 13:39:10 +04:00
# strip binaries
2009-08-15 07:32:27 +04:00
if [ [ $do_strip = yes ] ] ; then
2012-06-22 17:13:47 +04:00
for p in strip xargs find; do
2010-09-10 17:23:06 +04:00
if ! type -P $p >/dev/null; then
derror " Could not find ' $p '. You should run $0 with '--nostrip'. "
do_strip = no
fi
2009-07-24 17:48:20 +04:00
done
fi
2011-05-02 13:19:12 +04:00
if strstr " $modules_loaded " " fips " && command -v prelink >/dev/null; then
2012-06-29 14:07:44 +04:00
dinfo "*** pre-unlinking files ***"
2012-02-22 15:28:20 +04:00
for dir in " $initdir /bin " \
" $initdir /sbin " \
" $initdir /usr/bin " \
" $initdir /usr/sbin " ; do
[ [ -L " $dir " ] ] && continue
for i in " $dir " /*; do
2012-06-29 14:07:44 +04:00
[ [ -L $i ] ] && continue
2012-02-22 15:28:20 +04:00
[ [ -x $i ] ] && prelink -u $i & >/dev/null
done
2011-05-02 13:19:12 +04:00
done
2012-06-29 14:07:44 +04:00
dinfo "*** pre-unlinking files done ***"
fi
if [ [ $do_strip = yes ] ] ; then
dinfo "*** Stripping files ***"
find " $initdir " -type f \
'(' -perm -0100 -or -perm -0010 -or -perm -0001 \
-or -path '*/lib/modules/*.ko' ')' -print0 \
2012-06-30 13:34:13 +04:00
| xargs -r -0 strip -g 2>/dev/null
2012-06-29 14:07:44 +04:00
dinfo "*** Stripping files done ***"
2011-05-02 13:19:12 +04:00
fi
2012-06-30 13:34:46 +04:00
if [ [ $do_hardlink = yes ] ] ; then
type hardlink & >/dev/null && {
dinfo "*** hardlinking files ***"
hardlink " $initdir " 2>& 1
dinfo "*** hardlinking files done ***"
}
fi
2012-06-29 14:07:44 +04:00
2012-09-27 12:18:29 +04:00
rm -f " $outfile "
2012-06-29 14:07:44 +04:00
dinfo "*** Creating image file ***"
2012-09-27 12:18:29 +04:00
if ! ( umask 077; cd " $initdir " ; find . | cpio -R 0:0 -H newc -o --quiet| \
2011-05-10 13:39:10 +04:00
$compress > " $outfile " ; ) ; then
2011-03-16 23:24:30 +03:00
dfatal " dracut: creation of $outfile failed "
2009-11-19 17:46:09 +03:00
exit 1
2011-05-10 13:39:10 +04:00
fi
2012-06-29 14:07:44 +04:00
dinfo "*** Creating image file done ***"
2011-03-16 23:24:30 +03:00
dinfo " Wrote $outfile : "
dinfo " $( ls -l " $outfile " ) "
2009-05-25 19:45:15 +04:00
2009-05-28 06:41:18 +04:00
exit 0