Compare commits

...

33 Commits
029 ... 030

Author SHA1 Message Date
Harald Hoyer
951cedf8cb Revert "systemd: add systemd-fsck-root.service"
This reverts commit 35857f556c.
2013-07-17 15:05:30 +02:00
Harald Hoyer
0baf97618d AUTHORS: update 2013-07-17 14:58:44 +02:00
Harald Hoyer
8642792c3e NEWS: update 2013-07-17 14:58:35 +02:00
Harald Hoyer
5bbfd48475 dracut: do not enable early microcode inclusion by default 2013-07-17 14:36:34 +02:00
Harald Hoyer
c33488feb1 rename sosreport to rdsosreport
Renamed sosreport to rdsosreport to differ from the sosreport tool on
the real root.
2013-07-17 14:31:59 +02:00
Harald Hoyer
18e61d3d41 rename dracut-nohostonly and dracut-norescue rpm subpackages
dracut-nohostonly -> dracut-config-generic
dracut-norescue   -> dracut
                  -> dracut-config-rescue
2013-07-17 13:02:58 +02:00
Harald Hoyer
fbf717086e dmraid: let dmraid setup the partitions 2013-07-17 12:07:19 +02:00
Harald Hoyer
5a6a98f875 do not wait_for_dev for the root device
it's specified on the kernel command line
2013-07-17 12:03:01 +02:00
Harald Hoyer
35857f556c systemd: add systemd-fsck-root.service 2013-07-17 12:00:04 +02:00
Harald Hoyer
a6865e6897 rootfs-block: do not touch root-fsck
in systemd environments, we use systemd in the initramfs
2013-07-17 11:58:55 +02:00
Harald Hoyer
55068924f7 i18n: do not moan about missing kbd directory 2013-07-17 11:58:17 +02:00
Harald Hoyer
16addb86fc base: remove RD_TIMESTAMP 2013-07-17 11:26:55 +02:00
Konrad Rzeszutek Wilk
5f2c30d9bc dracut.sh: Support early microcode loading.
On Wed, Jul 10, 2013 at 10:58:15AM -0400, Konrad Rzeszutek Wilk wrote:
> On Wed, Jul 10, 2013 at 09:37:11AM +0200, Harald Hoyer wrote:
> > On 07/10/2013 02:29 AM, Yu, Fenghua wrote:
> > >> From: Konrad Rzeszutek Wilk [mailto:konrad.wilk@oracle.com]
> > >> Sent: Tuesday, July 09, 2013 12:24 PM
> > >> Implement it per Linux kernel Documentation/x86/early-microcode.txt
> > >> (from v3.11-rc0):
> > [...]
> > > This patch works fine with one microcode blob in binary format. There are situations that the microcode is not delivered in one blob in binary format:
> > >
> > > First, each microcode patch is one file instead all microcode patches are in one big blob. Secondly, old delivered microcode file is in ascii format.
> > >
> > > To handle those formats, additional code needs to convert the formats into one big binary microcode blob. I'm not sure if we should consider the code and if we should put the code in dracut.
> > >
> > > Thanks.
> > >
> > > -Fenghua
> > >
> >
> >
> > $ ls /lib/firmware/amd-ucode
> > microcode_amd.bin  microcode_amd_fam15h.bin  microcode_amd_solaris.bin
>
> Right, so all of those blobs (for AMD) get stuck in AuthenticAMD.bin.
>
> > $ ls /lib/firmware/intel-ucode
> > 06-03-02  06-06-00  06-07-02  06-08-0a  06-0b-04  06-0f-06  06-16-01  06-1c-02
> > 06-25-02  06-2d-07  0f-01-02  0f-02-09  0f-04-03  0f-04-0a
> > 06-05-00  06-06-05  06-07-03  06-09-05  06-0d-06  06-0f-07  06-17-06  06-1c-0a
> > 06-25-05  06-2f-02  0f-02-04  0f-03-02  0f-04-04  0f-06-02
> > 06-05-01  06-06-0a  06-08-01  06-0a-00  06-0e-08  06-0f-0a  06-17-07  06-1d-01
> > 06-26-01  06-3a-09  0f-02-05  0f-03-03  0f-04-07  0f-06-04
> > 06-05-02  06-06-0d  06-08-03  06-0a-01  06-0e-0c  06-0f-0b  06-17-0a  06-1e-04
> > 06-2a-07  0f-00-07  0f-02-06  0f-03-04  0f-04-08  0f-06-05
> > 06-05-03  06-07-01  06-08-06  06-0b-01  06-0f-02  06-0f-0d  06-1a-04  06-1e-05
> > 06-2d-06  0f-00-0a  0f-02-07  0f-04-01  0f-04-09  0f-06-08
>
> And all of those get catted in GenuineIntel.bin.
>
> >
> > Also, for [[ $hostonly ]], we only want to add the current running CPU microcode.
>
> <nods> Will do that. Are you OK with me adding some of this CPU detection logic
> in dracut-functions.sh?

This is still RFC, as I had not done the --no-compress logic (or tested it).
Please see if this is OK:

>From 5f853d2ececd4cadff648e22cb9c9287a01a9783 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Tue, 9 Jul 2013 13:57:01 -0400
Subject: [PATCH] dracut.sh: Support early microcode loading.

Implement it per Linux kernel Documentation/x86/early-microcode.txt
(from v3.11-rc0):

<start>
Early load microcode
====================
By Fenghua Yu <fenghua.yu@intel.com>

Kernel can update microcode in early phase of boot time. Loading microcode early
can fix CPU issues before they are observed during kernel boot time.

Microcode is stored in an initrd file. The microcode is read from the initrd
file and loaded to CPUs during boot time.

The format of the combined initrd image is microcode in cpio format followed by
the initrd image (maybe compressed). Kernel parses the combined initrd image
during boot time. The microcode file in cpio name space is:
on Intel: kernel/x86/microcode/GenuineIntel.bin
on AMD  : kernel/x86/microcode/AuthenticAMD.bin

During BSP boot (before SMP starts), if the kernel finds the microcode file in
the initrd file, it parses the microcode and saves matching microcode in memory.
If matching microcode is found, it will be uploaded in BSP and later on in all
APs.

The cached microcode patch is applied when CPUs resume from a sleep state.

There are two legacy user space interfaces to load microcode, either through
/dev/cpu/microcode or through /sys/devices/system/cpu/microcode/reload file
in sysfs.

In addition to these two legacy methods, the early loading method described
here is the third method with which microcode can be uploaded to a system's
CPUs.

The following example script shows how to generate a new combined initrd file in
/boot/initrd-3.5.0.ucode.img with original microcode microcode.bin and
original initrd image /boot/initrd-3.5.0.img.

mkdir initrd
cd initrd
mkdir -p kernel/x86/microcode
cp ../microcode.bin kernel/x86/microcode/GenuineIntel.bin (or AuthenticAMD.bin)
find . | cpio -o -H newc >../ucode.cpio
cd ..
cat ucode.cpio /boot/initrd-3.5.0.img >/boot/initrd-3.5.0.ucode.img
<end>

That is what we do in the patch. Furthermoere there is also
an off-switch: "no-early-microcode" to disable it.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
[v1: Support --host-only parameter]
2013-07-15 14:06:40 +02:00
Harald Hoyer
c00f8e05a6 dracut.sh: correct dropindirs_sort 2013-07-12 10:35:49 +02:00
Harald Hoyer
85231e1ff3 base/module-setup.sh: do not add devs to initqueue/finished
when need-initqueue is not set in systemd mode
2013-07-12 10:15:10 +02:00
Harald Hoyer
88396c383c base/module-setup.sh: do not include systemd-timestamp
when using systemd in the initramfs
2013-07-12 10:14:15 +02:00
Harald Hoyer
df03141dbc dracut-cmdline.service: remove Before: systemd-vconsole-setup.service 2013-07-12 09:47:24 +02:00
Harald Hoyer
bf9cdc472c systemd/module-setup.sh: create emtpy /etc/machine-id
Even in hostonly mode, if none was found on the system.
2013-07-11 12:15:17 +02:00
Harald Hoyer
02b5c8e3a3 dracut.sh: unset all LC_* and LANG
saves 10% of time :-)
2013-07-05 16:27:34 +02:00
Harald Hoyer
f734347ae7 modules.d/10i18n/module-setup.sh: handle empty vconsole.conf
if /etc/vconsole.conf exists and is empty, then do not install anything.
2013-07-05 15:48:40 +02:00
Harald Hoyer
4aca0017e8 terminfo: only install l/linux v/vt100 and v/vt220 2013-07-05 15:32:58 +02:00
Harald Hoyer
1e057b352a add PARTLABEL and PARTUUID 2013-07-05 15:32:38 +02:00
Harald Hoyer
431b86c8e9 masterkey/module-setup.sh:check() check for $hostonly rather than "-h" 2013-07-04 12:31:31 +02:00
Harald Hoyer
b093aa2dc7 beautified shell code
checked with shellcheck http://www.shellcheck.net/about.html
2013-07-04 12:31:15 +02:00
Harald Hoyer
32bd2fbb4c use "rm --" to guard against filenames beginning with "-" 2013-06-28 10:31:18 +02:00
Harald Hoyer
1d84d6940e TEST-04-FULL-SYSTEMD/test.sh: dlfgjlkdfjgldfj 2013-06-28 10:22:27 +02:00
Harald Hoyer
87ae968810 test/run-qemu: specify the kernel 2013-06-28 10:21:42 +02:00
Harald Hoyer
f13deabd22 systemd/module-setup.sh: add slices.target 2013-06-28 09:58:03 +02:00
Harald Hoyer
0d59a84b53 TEST-04-FULL-SYSTEMD: call xargs with "-r" 2013-06-26 09:16:04 +02:00
Harald Hoyer
68cb510f18 systemd: add system.slice unit 2013-06-26 09:15:34 +02:00
Harald Hoyer
5e60145449 use findmnt with "--source" or "--target"
This avoids hanging on stale NFS mounts, which are not part of the boot
process.

https://bugzilla.redhat.com/show_bug.cgi?id=975401
2013-06-24 12:47:53 +02:00
Harald Hoyer
282e0583b0 udev-rules: add 75-net-description.rules
we need IMPORT{builtin}="net_id" for the persistent network names
2013-06-18 17:54:30 +02:00
WANG Chao
32d115f385 selinux: umount $NEWROOT/dev and its submounts
$NEWROOT/dev and its submounts should be umounted after we use it.
Otherwise it fails other scripts that umount /sysroot only.

Signed-off-by: WANG Chao <chaowang@redhat.com>
2013-06-18 08:56:11 +02:00
97 changed files with 703 additions and 507 deletions

View File

@@ -26,7 +26,7 @@ case "$1" in
ret=$?
;;
remove)
rm -f "$3"/initrd
rm -f -- "$3"/initrd
ret=$?
;;
esac

13
AUTHORS
View File

@@ -1,9 +1,9 @@
Harald Hoyer <harald@redhat.com>
Victor Lowther <victor.lowther@gmail.com>
Amadeusz Żołnowski <aidecoe@aidecoe.name>
Will Woods <wwoods@redhat.com>
Philippe Seewer <philippe.seewer@bfh.ch>
Warren Togami <wtogami@redhat.com>
Will Woods <wwoods@redhat.com>
Jeremy Katz <katzj@redhat.com>
David Dillow <dave@thedillows.org>
Dave Young <dyoung@redhat.com>
@@ -18,8 +18,11 @@ John Reiser <jreiser@bitwagon.com>
Luca Berra <bluca@vodka.it>
Daniel Drake <dsd@laptop.org>
Dan Horák <dhorak@redhat.com>
WANG Chao <chaowang@redhat.com>
Leho Kraav <leho@kraav.com>
Baoquan He <bhe@redhat.com>
Brian C. Lane <bcl@redhat.com>
Kamil Rytarowski <n54@gmx.com>
Marc Grimme <grimme@atix.de>
Chao Wang <chaowang@redhat.com>
Frederic Crozat <fcrozat@suse.com>
@@ -29,6 +32,7 @@ Roberto Sassu <roberto.sassu@polito.it>
Anton Blanchard <anton@samba.org>
Bill Nottingham <notting@redhat.com>
David Cantrell <dcantrell@redhat.com>
Dennis Gilmore <dennis@ausil.us>
Jon Ander Hernandez <jonan.h@gmail.com>
Juan RP <xtraeme@gmail.com>
Lance Albertson <lance@osuosl.org>
@@ -36,23 +40,22 @@ Marian Ganisin <mganisin@redhat.com>
Michael Ploujnikov <plouj@somanetworks.com>
Peter Rajnoha <prajnoha@redhat.com>
Radek Vykydal <rvykydal@redhat.com>
WANG Chao <chaowang@redhat.com>
Wim Muskee <wimmuskee@gmail.com>
Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Alan Pevec <apevec@redhat.com>
Baoquan He <bhe@redhat.com>
Colin Walters <walters@verbum.org>
Dennis Gilmore <dennis@ausil.us>
Frederick Grose <fgrose@sugarlabs.org>
Ian Dall <ian@beware.dropbear.id.au>
James Buren <ryuo@frugalware.org>
Joey Boggs <jboggs@redhat.com>
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mike Snitzer <snitzer@redhat.com>
Przemysław Rudy <prudy1@o2.pl>
Stefan Reimer <it@startux.de>
Thomas Lange <lange@informatik.uni-koeln.de>
Vivek Goyal <vgoyal@redhat.com>
Vladislav Bogdanov <bubble@hoster-ok.com>
Adam Williamson <awilliam@redhat.com>
Alexander Todorov <atodorov@redhat.com>
Andy Lutomirski <luto@mit.edu>
Anssi Hannula <anssi@mageia.org>
@@ -62,6 +65,7 @@ Christian Heinz <christian.ch.heinz@gmail.com>
Cong Wang <amwang@redhat.com>
Dave Jones <davej@redhat.com>
Dave Young <dave@redhat.com>
Dennis Schridde <devurandom@gmx.net>
Duane Griffin <duaneg@dghda.com>
Glen Gray <slaine@slaine.org>
Hermann Gausterer <git-dracut-2012@mrq1.org>
@@ -70,7 +74,6 @@ Jan Stodola <jstodola@redhat.com>
Jiri Pirko <jiri@resnulli.us>
Joe Lawrence <Joe.Lawrence@stratus.com>
Kevin Yung <Kevin.Yung@myob.com>
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Lars R. Damerow <lars@pixar.com>
Lennert Buytenhek <buytenh@wantstofly.org>
Lubomir Rintel <lkundrak@v3.sk>

View File

@@ -82,7 +82,7 @@ dracut.html: dracut.asc $(manpages)
--stringparam html.stylesheet \
http://docs.fedoraproject.org/en-US/Common_Content/css/default.css \
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
rm dracut.xml
rm -f -- dracut.xml
install: dracut-version.sh
mkdir -p $(DESTDIR)$(pkglibdir)
@@ -164,9 +164,9 @@ dracut-$(VERSION).tar.bz2: doc
mkdir -p dracut-$(VERSION)
for i in $(manpages) dracut.html dracut-version.sh; do [ "$${i%/*}" != "$$i" ] && mkdir -p "dracut-$(VERSION)/$${i%/*}"; cp "$$i" "dracut-$(VERSION)/$$i"; done
tar --owner=root --group=root -rf dracut-$(VERSION).tar $$(find dracut-$(VERSION) -type f)
rm -fr dracut-$(VERSION).tar.bz2 dracut-$(VERSION)
rm -fr -- dracut-$(VERSION).tar.bz2 dracut-$(VERSION)
bzip2 -9 dracut-$(VERSION).tar
rm -f dracut-$(VERSION).tar
rm -f -- dracut-$(VERSION).tar
rpm: dracut-$(VERSION).tar.bz2
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
@@ -175,7 +175,7 @@ rpm: dracut-$(VERSION).tar.bz2
(cd "$$rpmbuild"; rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr -- "$$rpmbuild"; ls *.rpm )
syncheck:
@ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \

16
NEWS
View File

@@ -1,3 +1,19 @@
dracut-030
==========
- support new persistent network interface names
- fix findmnt calls, prevents hang on stale NFS mounts
- add systemd.slice and slice.target units
- major shell cleanup
- support root=PARTLABEL= and root=PARTUUID=
- terminfo: only install l/linux v/vt100 and v/vt220
- unset all LC_* and LANG, 10% faster
- fixed dependency loop for dracut-cmdline.service
- do not wait_for_dev for the root devices
- do not wait_for_dev for devices, if dracut-initqueue is not needed
- support early microcode loading with --early-microcode
- dmraid, let dmraid setup its own partitions
- sosreport renamed to rdsosreport
dracut-029
==========
- wait for IPv6 autoconfiguration

View File

@@ -33,7 +33,8 @@ _dracut() {
--lvmconf --nolvmconf --debug --profile --verbose --quiet
--local --hostonly --no-hostonly --fstab --help --bzip2 --lzma
--xz --no-compress --gzip --list-modules --show-modules --keep
--printsize --regenerate-all --noimageifnotneeded'
--printsize --regenerate-all --noimageifnotneeded --early-microcode
--no-early-microcode'
[ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
--omit-drivers --modules --omit --drivers --filesystems --install

View File

@@ -118,11 +118,11 @@ fi
images+=($@)
dinfo "Using base image $baseimage"
cat "$baseimage" > "$outfile"
cat -- "$baseimage" > "$outfile"
for i in "${images[@]}"; do
dinfo "Appending $i"
cat "$i" >> "$outfile"
cat -- "$i" >> "$outfile"
done
dinfo "Created $outfile"

View File

@@ -39,13 +39,13 @@ strstr() { [[ $1 = *$2* ]]; }
# search in the usual places to find the binary.
find_binary() {
if [[ -z ${1##/*} ]]; then
if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then
echo $1
if [[ -x $1 ]] || { [[ "$1" == *.so* ]] && ldd "$1" &>/dev/null; }; then
printf "%s\n" "$1"
return 0
fi
fi
type -P ${1##*/}
type -P "${1##*/}"
}
if ! [[ $dracutbasedir ]]; then
@@ -65,7 +65,7 @@ fi
# Detect lib paths
if ! [[ $libdirs ]] ; then
if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \
if [[ "$(ldd /bin/sh)" == */lib64/* ]] &>/dev/null \
&& [[ -d /lib64 ]]; then
libdirs+=" /lib64"
[[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64"
@@ -83,7 +83,7 @@ fi
srcmods="/lib/modules/$kernel/"
[[ $drivers_dir ]] && {
if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then
if vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1
fi
@@ -115,19 +115,21 @@ dracut_need_initqueue() {
}
dracut_module_included() {
strstr "$mods_to_load $modules_loaded" "$@"
[[ "$mods_to_load $modules_loaded" == *$@* ]]
}
# Create all subdirectories for given path without creating the last element.
# $1 = path
mksubdirs() { [[ -e ${1%/*} ]] || mkdir -m 0755 -p ${1%/*}; }
mksubdirs() {
[[ -e ${1%/*} ]] || mkdir -m 0755 -p -- "${1%/*}"
}
# Version comparision function. Assumes Linux style version scheme.
# $1 = version a
# $2 = comparision op (gt, ge, eq, le, lt, ne)
# $3 = version b
vercmp() {
local _n1=(${1//./ }) _op=$2 _n2=(${3//./ }) _i _res
local _n1=${1//./ } _op=$2 _n2=${3//./ } _i _res
for ((_i=0; ; _i++))
do
@@ -152,7 +154,7 @@ vercmp() {
# is_func <command>
# Check whether $1 is a function.
is_func() {
[[ $(type -t $1) = "function" ]]
[[ "$(type -t "$1")" = "function" ]]
}
# Function prints global variables in format name=value line by line.
@@ -160,10 +162,10 @@ is_func() {
print_vars() {
local _var _value
for _var in $@
for _var in "$@"
do
_value=$(eval echo \$$_var)
[[ ${_value} ]] && echo "${_var}=\"${_value}\""
eval printf -v _value "%s" "\$$_var"
[[ ${_value} ]] && printf '%s="%s"\n' "$_var" "$_value"
done
}
@@ -204,7 +206,7 @@ convert_abs_rel() {
__abssize=${#__absolute[@]}
__cursize=${#__current[@]}
while [[ ${__absolute[__level]} == ${__current[__level]} ]]
while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]
do
(( __level++ ))
if (( __level > __abssize || __level > __cursize ))
@@ -234,7 +236,7 @@ convert_abs_rel() {
echo "$__newpath"
}
if strstr "$(ln --help)" "--relative"; then
if [[ "$(ln --help)" == *--relative* ]]; then
ln_r() {
ln -sfnr "${initdir}/$1" "${initdir}/$2"
}
@@ -243,7 +245,7 @@ else
local _source=$1
local _dest=$2
[[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
ln -sfn $(convert_abs_rel "${_dest}" "${_source}") "${initdir}/${_dest}"
ln -sfn -- "$(convert_abs_rel "${_dest}" "${_source}")" "${initdir}/${_dest}"
}
fi
@@ -257,42 +259,51 @@ get_persistent_dev() {
[[ $i == /dev/mapper/mpath* ]] && continue
_tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
if [ "$_tmp" = "$_dev" ]; then
echo $i
printf -- "%s" "$i"
return
fi
done
}
# get_fs_env <device>
# Get and set the ID_FS_TYPE and ID_FS_UUID variable from udev for a device.
# Get and set the ID_FS_TYPE variable from udev for a device.
# Example:
# $ get_fs_env /dev/sda2; echo $ID_FS_TYPE; echo $ID_FS_UUID
# $ get_fs_env /dev/sda2; echo $ID_FS_TYPE
# ext4
# 551a39aa-4ae9-4e70-a262-ef665cadb574
get_fs_env() {
local evalstr
local found
[[ $1 ]] || return
unset ID_FS_TYPE
unset ID_FS_UUID
if evalstr=$(udevadm info --query=env --name=$1 \
if ID_FS_TYPE=$(udevadm info --query=env --name="$1" \
| { while read line; do
strstr "$line" "DEVPATH" && found=1;
strstr "$line" "ID_FS_TYPE=" && { echo $line; exit 0;}
[[ "$line" == DEVPATH\=* ]] && found=1;
if [[ "$line" == ID_FS_TYPE\=* ]]; then
printf "%s" "${line#ID_FS_TYPE=}";
exit 0;
fi
done; [[ $found ]] && exit 0; exit 1; }) ; then
eval $evalstr
[[ $ID_FS_TYPE ]] && return 0
if [[ $ID_FS_TYPE ]]; then
printf "%s" "$ID_FS_TYPE"
return 0
fi
return 1
fi
# Fallback, if we don't have udev information
if find_binary blkid >/dev/null; then
eval $(blkid -o udev $1 \
ID_FS_TYPE=$(blkid -u filesystem -o export -- "$1" \
| while read line; do
strstr "$line" "ID_FS_TYPE=" && echo $line;
if [[ "$line" == TYPE\=* ]]; then
printf "%s" "${line#TYPE=}";
exit 0;
fi
done)
[[ $ID_FS_TYPE ]] && return 0
if [[ $ID_FS_TYPE ]]; then
printf "%s" "$ID_FS_TYPE"
return 0
fi
fi
return 1
}
@@ -303,10 +314,9 @@ get_fs_env() {
# $ get_maj_min /dev/sda2
# 8:2
get_maj_min() {
local _dev
_dev=$(stat -L -c '$((0x%t)):$((0x%T))' "$1" 2>/dev/null)
_dev=$(eval "echo $_dev")
echo $_dev
local _maj _min
read _maj _min < <(stat -L -c '%t %T' "$1" 2>/dev/null)
printf "%s" "$((0x$_maj)):$((0x$_min))"
}
# find_block_device <mountpoint>
@@ -340,7 +350,7 @@ find_block_device() {
echo $_dev
return 0
fi
done < <(findmnt -e -v -n -o 'MAJ:MIN,SOURCE' "$_find_mpt")
done < <(findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt")
fi
# fall back to /etc/fstab
@@ -362,7 +372,7 @@ find_block_device() {
echo $_dev
return 0
fi
done < <(findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' "$_find_mpt")
done < <(findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt")
return 1
}
@@ -384,7 +394,7 @@ find_mp_fstype() {
[[ $_fs = "autofs" ]] && continue
echo -n $_fs
return 0
done < <(findmnt -e -v -n -o 'FSTYPE' "$1")
done < <(findmnt -e -v -n -o 'FSTYPE' --target "$1")
fi
while read _fs; do
@@ -392,7 +402,7 @@ find_mp_fstype() {
[[ $_fs = "autofs" ]] && continue
echo -n $_fs
return 0
done < <(findmnt --fstab -e -v -n -o 'FSTYPE' "$1")
done < <(findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1")
return 1
}
@@ -406,10 +416,28 @@ find_mp_fstype() {
# $ find_dev_fstype /dev/sda2;echo
# ext4
find_dev_fstype() {
local _x _mpt _majmin _dev _fs _maj _min _find_dev
local _find_dev _fs
_find_dev="$1"
[[ "$_find_dev" = /dev* ]] || _find_dev="/dev/block/$_find_dev"
find_mp_fstype "$_find_dev"
if [[ $use_fstab != yes ]]; then
while read _fs; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
echo -n $_fs
return 0
done < <(findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev")
fi
while read _fs; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
echo -n $_fs
return 0
done < <(findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev")
return 1
}
# finds the major:minor of the block device backing the root filesystem.
@@ -643,7 +671,7 @@ else
# We never overwrite the target if it exists.
inst_simple() {
[[ -f "$1" ]] || return 1
strstr "$1" "/" || return 1
[[ "$1" == */* ]] || return 1
local _src=$1 _target="${2:-$1}"
[[ -L $_src ]] && { inst_symlink $_src $_target; return $?; }
@@ -672,7 +700,7 @@ else
# same as above, but specialized for symlinks
inst_symlink() {
local _src=$1 _target=${2:-$1} _realsrc
strstr "$1" "/" || return 1
[[ "$1" == */* ]] || return 1
[[ -L $1 ]] || return 1
[[ -L $initdir/$_target ]] && return 0
_realsrc=$(readlink -f "$_src")
@@ -693,7 +721,7 @@ else
# is referenced.
inst_library() {
local _src="$1" _dest=${2:-$1} _lib _reallib _symlink
strstr "$1" "/" || return 1
[[ "$1" == */* ]] || return 1
[[ -e $initdir/$_dest ]] && return 0
if [[ -L $_src ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then
@@ -745,7 +773,7 @@ else
continue
fi
if [[ $_line =~ not\ found ]]; then
if [[ $_line == *not\ found* ]]; then
dfatal "Missing a shared library required by $_bin."
dfatal "Run \"ldd $_bin\" to find out what it is."
dfatal "$_line"
@@ -831,7 +859,7 @@ rev_lib_symlinks() {
local fn="$1" orig="$(readlink -f "$1")" links=''
[[ ${fn} =~ .*\.so\..* ]] || return 1
[[ ${fn} == *.so.* ]] || return 1
until [[ ${fn##*.} == so ]]; do
fn="${fn%.*}"
@@ -985,7 +1013,7 @@ inst_hook() {
dfatal "Cannot install a hook ($3) that does not exist."
dfatal "Aborting initrd creation."
exit 1
elif ! strstr "$hookdirs" "$1"; then
elif ! [[ "$hookdirs" == *$1* ]]; then
dfatal "No such hook type $1. Aborting initrd creation."
exit 1
fi
@@ -1103,6 +1131,7 @@ module_check() {
_ret=$?
else
unset check depends install installkernel
check() { true; }
. $_moddir/module-setup.sh
is_func check || return 0
[ $_forced -ne 0 ] && unset hostonly
@@ -1130,8 +1159,8 @@ module_check_mount() {
_ret=$?
else
unset check depends install installkernel
check() { false; }
. $_moddir/module-setup.sh
is_func check || return 1
check 0
_ret=$?
unset check depends install installkernel
@@ -1154,8 +1183,8 @@ module_depends() {
return $?
else
unset check depends install installkernel
depends() { true; }
. $_moddir/module-setup.sh
is_func depends || return 0
depends
_ret=$?
unset check depends install installkernel
@@ -1175,8 +1204,8 @@ module_install() {
return $?
else
unset check depends install installkernel
install() { true; }
. $_moddir/module-setup.sh
is_func install || return 0
install
_ret=$?
unset check depends install installkernel
@@ -1196,8 +1225,8 @@ module_installkernel() {
return $?
else
unset check depends install installkernel
. $_moddir/module-setup.sh
is_func installkernel || return 0
installkernel() { true; }
. $_moddir/module-setup.sh
installkernel
_ret=$?
unset check depends install installkernel
@@ -1217,20 +1246,20 @@ check_mount() {
[ "${#host_fs_types[*]}" -le 0 ] && return 1
# If we are already scheduled to be loaded, no need to check again.
strstr " $mods_to_load " " $_mod " && return 0
strstr " $mods_checked_as_dep " " $_mod " && return 1
[[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
[[ " $mods_checked_as_dep " == *\ $_mod\ * ]] && return 1
# This should never happen, but...
[[ -d $_moddir ]] || return 1
[[ $2 ]] || mods_checked_as_dep+=" $_mod "
if strstr " $omit_dracutmodules " " $_mod "; then
if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then
dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!"
return 1
fi
if strstr " $dracutmodules $add_dracutmodules $force_add_dracutmodules" " $_mod "; then
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
module_check_mount $_mod; ret=$?
# explicit module, so also accept ret=255
@@ -1249,9 +1278,9 @@ check_mount() {
for _moddep in $(module_depends $_mod); do
# handle deps as if they were manually added
strstr " $add_dracutmodules " " $_moddep " || \
[[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
add_dracutmodules+=" $_moddep "
strstr " $force_add_dracutmodules " " $_moddep " || \
[[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also
if ! check_module $_moddep; then
@@ -1260,7 +1289,7 @@ check_mount() {
fi
done
strstr " $mods_to_load " " $_mod " || \
[[ " $mods_to_load " == *\ $_mod\ * ]] || \
mods_to_load+=" $_mod "
return 0
@@ -1276,21 +1305,21 @@ check_module() {
local _ret
local _moddep
# If we are already scheduled to be loaded, no need to check again.
strstr " $mods_to_load " " $_mod " && return 0
strstr " $mods_checked_as_dep " " $_mod " && return 1
[[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
[[ " $mods_checked_as_dep " == *\ $_mod\ * ]] && return 1
# This should never happen, but...
[[ -d $_moddir ]] || return 1
[[ $2 ]] || mods_checked_as_dep+=" $_mod "
if strstr " $omit_dracutmodules " " $_mod "; then
if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then
dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!"
return 1
fi
if strstr " $dracutmodules $add_dracutmodules $force_add_dracutmodules" " $_mod "; then
if strstr " $force_add_dracutmodules" " $_mod"; then
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
if [[ " $force_add_dracutmodules " == *\ $_mod\ * ]]; then
module_check $_mod 1; ret=$?
else
module_check $_mod 0; ret=$?
@@ -1310,9 +1339,9 @@ check_module() {
for _moddep in $(module_depends $_mod); do
# handle deps as if they were manually added
strstr " $add_dracutmodules " " $_moddep " || \
[[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
add_dracutmodules+=" $_moddep "
strstr " $force_add_dracutmodules " " $_moddep " || \
[[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also
if ! check_module $_moddep; then
@@ -1321,7 +1350,7 @@ check_module() {
fi
done
strstr " $mods_to_load " " $_mod " || \
[[ " $mods_to_load " == *\ $_mod\ * ]] || \
mods_to_load+=" $_mod "
return 0
@@ -1344,8 +1373,8 @@ for_each_module_dir() {
_modcheck="$add_dracutmodules $force_add_dracutmodules"
[[ $dracutmodules != all ]] && _modcheck="$m $dracutmodules"
for _mod in $_modcheck; do
strstr "$mods_to_load" "$_mod" && continue
strstr "$omit_dracutmodules" "$_mod" && continue
[[ " $mods_to_load " == *\ $_mod\ * ]] && continue
[[ " $omit_dracutmodules " == *\ $_mod\ * ]] && continue
derror "dracut module '$_mod' cannot be found or installed."
done
}
@@ -1490,18 +1519,20 @@ dracut_kernel_post() {
exit 1
fi
[[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr "$DRACUT_KERNEL_LAZY_HASHDIR"
[[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr -- "$DRACUT_KERNEL_LAZY_HASHDIR"
}
module_is_host_only() (
module_is_host_only() { (
local _mod=$1
_mod=${_mod##*/}
_mod=${_mod%.ko}
[[ "$add_drivers" =~ " ${_mod} " ]] && return 0
[[ " $add_drivers " == *\ ${_mod}\ * ]] && return 0
# check if module is loaded
[[ -d $(echo /sys/module/${_mod//-/_}|{ read a b; echo $a; }) ]] && return 0
for i in /sys/module/${_mod//-/_}; do
[[ -d $i ]] && return 0
done
# check if module is loadable on the current kernel
# this covers the case, where a new module is introduced
@@ -1510,22 +1541,23 @@ module_is_host_only() (
modinfo -F filename "$_mod" &>/dev/null || return 0
return 1
)
)
}
find_kernel_modules_by_path () (
find_kernel_modules_by_path () {
local _OLDIFS
[[ -f $srcmods/modules.dep ]] || return 0
[[ -f "$srcmods/modules.dep" ]] || return 0
_OLDIFS=$IFS
IFS=:
while read a rest; do
[[ $a = */$1/* ]] || continue
echo $srcmods/$a
done < $srcmods/modules.dep
printf "%s\n" "$srcmods/$a"
done < "$srcmods/modules.dep"
IFS=$_OLDIFS
return 0
)
}
find_kernel_modules () {
find_kernel_modules_by_path drivers
@@ -1635,3 +1667,36 @@ instmods() {
_ret=$?
return $_ret
}
# get_cpu_vendor
# Only two values are returned: AMD or Intel
get_cpu_vendor ()
{
if grep -qE AMD /proc/cpuinfo; then
printf "AMD"
fi
if grep -qE Intel /proc/cpuinfo; then
printf "Intel"
fi
}
# get_host_ucode
# Get the hosts' ucode file based on the /proc/cpuinfo
get_ucode_file ()
{
local family=`grep -E "cpu family" /proc/cpuinfo | head -1 | sed s/.*:\ //`
local model=`grep -E "model" /proc/cpuinfo |grep -v name | head -1 | sed s/.*:\ //`
local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
# If family greater or equal than 0x15
if [[ $family -ge 21 ]]; then
printf "microcode_amd_fam15h.bin"
else
printf "microcode_amd.bin"
fi
fi
if [[ "$(get_cpu_vendor)" == "Intel" ]]; then
# The /proc/cpuinfo are in decimal.
printf "%02x-%02x-%02x" ${family} ${model} ${stepping}
fi
}

View File

@@ -17,13 +17,13 @@ cd /run/initramfs
[ -f .need_shutdown -a -f "$IMG" ] || exit 1
if zcat "$IMG" | cpio -id --quiet >/dev/null; then
rm .need_shutdown
rm -f -- .need_shutdown
elif xzcat "$IMG" | cpio -id --quiet >/dev/null; then
rm .need_shutdown
rm -f -- .need_shutdown
else
# something failed, so we clean up
echo "Unpacking of $IMG to /run/initramfs failed" >&2
rm -f /run/initramfs/shutdown
rm -f -- /run/initramfs/shutdown
exit 1
fi

View File

@@ -31,10 +31,10 @@ early userspace.
For a complete list of kernel command line options see *dracut.cmdline*(7).
If you are dropped to an emergency shell, while booting your initramfs,
the file _/run/initramfs/sosreport.txt_ is created, which can be safed to a
the file _/run/initramfs/rdsosreport.txt_ is created, which can be safed to a
(to be mounted by hand) partition (usually /boot) or a USB stick.
Additional debugging info can be produced by adding **rd.debug** to the kernel command line.
_/run/initramfs/sosreport.txt_ contains all logs and the output of some tools.
_/run/initramfs/rdsosreport.txt_ contains all logs and the output of some tools.
It should be attached to any report about dracut problems.
EXAMPLE

View File

@@ -489,7 +489,7 @@ dracut shell commands are printed as they are executed
----
# journalctl -ab
----
. With dracut >= 025 the file /run/initramfs/sosreport.txt is generated, which contains all the logs and the output of all significant tools, which are mentioned later.
. With dracut >= 025 the file /run/initramfs/rdsosreport.txt is generated, which contains all the logs and the output of all significant tools, which are mentioned later.
If you want to save that output, simply mount /boot by hand or insert an USB stick and mount that.
Then you can store the output for later inspection.

View File

@@ -128,10 +128,10 @@ Misc
[[dracutkerneldebug]]
Debug
~~~~~
If you are dropped to an emergency shell, the file _/run/initramfs/sosreport.txt_ is created,
If you are dropped to an emergency shell, the file _/run/initramfs/rdsosreport.txt_ is created,
which can be safed to a (to be mounted by hand) partition (usually /boot) or a USB stick.
Additional debugging info can be produced by adding **rd.debug** to the kernel command line.
_/run/initramfs/sosreport.txt_ contains all logs and the output of some tools.
_/run/initramfs/rdsosreport.txt_ contains all logs and the output of some tools.
It should be attached to any report about dracut problems.
**rd.info**::

View File

@@ -15,4 +15,3 @@ systemdsystemconfdir=/etc/systemd/system
udevdir=/usr/lib/udev
add_dracutmodules+=" systemd "
hostonly="yes"
dracut_rescue_image="yes"

233
dracut.sh
View File

@@ -91,6 +91,8 @@ Creates initial ramdisk images for preloading modules
firmwares, separated by :
--kernel-only Only install kernel drivers and firmware files
--no-kernel Do not install kernel drivers and firmware files
--early-microcode Combine early microcode with ramdisk
--no-early-microcode Do not combine early microcode with ramdisk
--kernel-cmdline [PARAMETERS] Specify default kernel command line parameters
--strip Strip binaries in the initramfs
--nostrip Do not strip binaries in the initramfs
@@ -213,7 +215,7 @@ pop() {
if [[ "$__resultvar" ]]; then
eval $__resultvar="'$_value'"
else
echo "$_value"
printf "%s" "$_value"
fi
eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
return 0
@@ -237,24 +239,26 @@ read_arg() {
fi
}
dropindirs_sort()
{
suffix=$1; shift
args=("$@")
files=$(
while (( $# > 0 )); do
for i in ${1}/*${suffix}; do
[[ -f $i ]] && echo ${i##*/}
local suffix=$1; shift
local -a files
local f d
readarray -t files < <(
for d in "$@"; do
for i in "$d/"*"$suffix"; do
if [[ -e "$i" ]]; then
printf "%s\n" "${i##*/}"
fi
done
shift
done | sort -Vu
)
for f in $files; do
for d in "${args[@]}"; do
if [[ -f "$d/$f" ]]; then
echo "$d/$f"
for f in "${files[@]}"; do
for d in "$@"; do
if [[ -e "$d/$f" ]]; then
printf "%s\n" "$d/$f"
continue 2
fi
done
@@ -376,6 +380,8 @@ while :; do
-f|--force) force=yes;;
--kernel-only) kernel_only="yes"; no_kernel="no";;
--no-kernel) kernel_only="no"; no_kernel="yes";;
--early-microcode) early_microcode="yes";;
--no-early-microcode) early_microcode="no";;
--strip) do_strip_l="yes";;
--nostrip) do_strip_l="no";;
--hardlink) do_hardlink_l="yes";;
@@ -392,8 +398,8 @@ while :; do
-q|--quiet) ((verbosity_mod_l--));;
-l|--local)
allowlocal="yes"
[[ -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] \
&& dracutbasedir="$(readlink -f ${0%/*})"
[[ -f "$(readlink -f "${0%/*}")/dracut-functions.sh" ]] \
&& dracutbasedir="$(readlink -f "${0%/*}")"
;;
-H|--hostonly|--host-only)
hostonly_l="yes" ;;
@@ -450,12 +456,12 @@ done
if [[ $regenerate_all == "yes" ]]; then
ret=0
if [[ $kernel ]]; then
echo "--regenerate-all cannot be called with a kernel version" >&2
printf -- "--regenerate-all cannot be called with a kernel version\n" >&2
exit 1
fi
if [[ $outfile ]]; then
echo "--regenerate-all cannot be called with a image file" >&2
printf -- "--regenerate-all cannot be called with a image file\n" >&2
exit 1
fi
@@ -468,7 +474,7 @@ if [[ $regenerate_all == "yes" ]]; then
cd /lib/modules
for i in *; do
[[ -f $i/modules.builtin ]] || continue
dracut --kver=$i "${dracut_args[@]}"
dracut --kver="$i" "${dracut_args[@]}"
((ret+=$?))
done
exit $ret
@@ -498,6 +504,10 @@ for i in /usr/sbin /sbin /usr/bin /bin; do
fi
done
export PATH="${NPATH#:}"
unset LC_MESSAGES
unset LC_CTYPE
export LC_ALL=C
export LANG=C
unset NPATH
unset LD_LIBRARY_PATH
unset GREP_OPTIONS
@@ -519,13 +529,19 @@ export DRACUT_LOG_LEVEL=warning
# if we were not passed a config file, try the default one
if [[ ! -f $conffile ]]; then
[[ $allowlocal ]] && conffile="$dracutbasedir/dracut.conf" || \
if [[ $allowlocal ]]; then
conffile="$dracutbasedir/dracut.conf"
else
conffile="/etc/dracut.conf"
fi
fi
if [[ ! -d $confdir ]]; then
[[ $allowlocal ]] && confdir="$dracutbasedir/dracut.conf.d" || \
if [[ $allowlocal ]]; then
confdir="$dracutbasedir/dracut.conf.d"
else
confdir="/etc/dracut.conf.d"
fi
fi
# source our config file
@@ -643,8 +659,7 @@ case $compress in
bzip2) compress="bzip2 -9";;
lzma) compress="lzma -9";;
xz) compress="xz --check=crc32 --lzma2=dict=1MiB";;
gzip) command -v pigz > /dev/null 2>&1 && compress="pigz -9" || \
compress="gzip -9";;
gzip) compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
esac
if [[ $_no_compress_l = "cat" ]]; then
compress="cat"
@@ -654,14 +669,21 @@ fi
[[ $hostonly != "-h" ]] && unset hostonly
readonly TMPDIR="$tmpdir"
readonly initdir=$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)
readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)"
[ -d "$initdir" ] || {
echo "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXX failed." >&2
printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXX failed." >&2
exit 1
}
if [[ $early_microcode = yes ]]; then
readonly microcode_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_microcode.XXXXXX)"
[ -d "$microcode_dir" ] || {
printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_microcode.XXXXXX failed." >&2
exit 1
}
fi
# clean up after ourselves no matter how we die.
trap 'ret=$?;[[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f "$outfile.$$";[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf "$initdir";exit $ret; };' EXIT
trap 'ret=$?;[[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; exit $ret; };' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
@@ -671,9 +693,9 @@ export DRACUT_RESOLVE_LAZY="1"
if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
. $dracutbasedir/dracut-functions.sh
else
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
printf "%s\n" "dracut: Cannot find $dracutbasedir/dracut-functions.sh." >&2
printf "%s\n" "dracut: Are you running from a git checkout?" >&2
printf "%s\n" "dracut: Try passing -l as an argument to $0" >&2
exit 1
fi
@@ -682,16 +704,15 @@ if ! $DRACUT_INSTALL ${initdir+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null;
unset DRACUT_RESOLVE_LAZY
export DRACUT_RESOLVE_DEPS=1
fi
rm -fr ${initdir}/*
rm -fr -- ${initdir}/*
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
. $dracutbasedir/dracut-version.sh
fi
# Verify bash version, current minimum is 3.1
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.'
if (( BASH_VERSINFO[0] < 4 )); then
dfatal 'You need at least Bash 4 to use dracut, sorry.'
exit 1
fi
@@ -728,7 +749,7 @@ fi
omit_drivers_corrected=""
for d in $omit_drivers; do
strstr " $drivers $add_drivers " " $d " && continue
[[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
omit_drivers_corrected+="$d|"
done
omit_drivers="${omit_drivers_corrected%|}"
@@ -736,7 +757,7 @@ unset omit_drivers_corrected
# prepare args for logging
for ((i=0; i < ${#dracut_args[@]}; i++)); do
strstr "${dracut_args[$i]}" " " && \
[[ "${dracut_args[$i]}" == *\ * ]] && \
dracut_args[$i]="\"${dracut_args[$i]}\""
#" keep vim happy
done
@@ -747,7 +768,7 @@ ddebug "Executing: $0 ${dracut_args[@]}"
[[ -d $mod ]] || continue;
[[ -e $mod/install || -e $mod/installkernel || \
-e $mod/module-setup.sh ]] || continue
echo ${mod##*/??}
printf "%s\n" "${mod##*/??}"
done
exit 0
}
@@ -789,7 +810,7 @@ chmod 755 "$initdir"
if [[ $hostonly ]]; then
for i in /sys /proc /run /dev; do
if ! findmnt "$i" &>/dev/null; then
if ! findmnt --target "$i" &>/dev/null; then
dwarning "Turning off host-only mode: '$i' is not mounted!"
unset hostonly
fi
@@ -810,22 +831,23 @@ for line in "${fstab_lines[@]}"; do
done
for f in $add_fstab; do
[ -e $f ] || continue
[[ -e $f ]] || continue
while read dev rest; do
push host_devs $dev
done < $f
push host_devs "$dev"
done < "$f"
done
for dev in $add_device; do
push host_devs "$dev"
done
if (( ${#add_device_l[@]} )); then
while pop add_device_l val; do
add_device+=" $val "
push host_devs "$val"
done
fi
for dev in $add_device; do
push host_devs $dev
done
if [[ $hostonly ]]; then
# in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types
@@ -841,7 +863,9 @@ if [[ $hostonly ]]; then
"/boot";
do
mountpoint "$mp" >/dev/null 2>&1 || continue
push host_devs $(readlink -f "/dev/block/$(find_block_device "$mp")")
_dev="$(readlink -f "/dev/block/$(find_block_device "$mp")")"
[[ "$_mp" == "/" ]] && root_dev="$_dev"
push host_devs "$_dev"
done
while read dev type rest; do
@@ -864,40 +888,41 @@ if [[ $hostonly ]]; then
[[ $_o == *swap* ]] && continue 2
done < /etc/crypttab
push host_devs $(readlink -f $dev)
push host_devs "$(readlink -f "$dev")"
break
done < /etc/fstab
done < /proc/swaps
fi
_get_fs_type() (
_get_fs_type() { (
[[ $1 ]] || return
if [[ -b $1 ]] && get_fs_env $1; then
echo "$(readlink -f $1) $ID_FS_TYPE"
if [[ -b /dev/block/$1 ]] && ID_FS_TYPE=$(get_fs_env "/dev/block/$1"); then
printf "%s\n" "$(readlink -f "/dev/block/$1")" "$ID_FS_TYPE"
return 1
fi
if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then
echo "$(readlink -f /dev/block/$1) $ID_FS_TYPE"
if [[ -b $1 ]] && ID_FS_TYPE=$(get_fs_env "$1"); then
printf "%s\n" "$(readlink -f "$1")" "$ID_FS_TYPE"
return 1
fi
if fstype=$(find_dev_fstype $1); then
echo "$1 $fstype"
if fstype=$(find_dev_fstype "$1"); then
printf "%s\n" "$1" "$fstype"
return 1
fi
return 1
)
) }
for dev in "${host_devs[@]}"; do
while read key val; do
while read key; do
read val
host_fs_types["$key"]="$val"
done < <(
_get_fs_type $dev
check_block_and_slaves_all _get_fs_type $(get_maj_min $dev)
_get_fs_type "$dev"
check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
)
done
[[ -d $udevdir ]] \
|| udevdir=$(pkg-config udev --variable=udevdir 2>/dev/null)
|| 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
@@ -923,7 +948,7 @@ fi
export initdir dracutbasedir dracutmodules \
fw_dir drivers_dir debug no_kernel kernel_only \
omit_drivers mdadmconf lvmconf \
omit_drivers mdadmconf lvmconf root_dev \
use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug host_fs_types host_devs sshkey add_fstab \
@@ -938,7 +963,7 @@ export initdir dracutbasedir dracutmodules \
if [[ $prefix ]]; then
for d in bin etc lib sbin tmp usr var $libdirs; do
strstr "$d" "/" && continue
[[ "$d" == */* ]] && continue
ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
done
fi
@@ -993,25 +1018,28 @@ mods_to_load=""
for_each_module_dir check_module
for_each_module_dir check_mount
strstr "$mods_to_load" "fips" && export DRACUT_FIPS_MODE=1
[[ "$mods_to_load " == *01fips\ * ]] && export DRACUT_FIPS_MODE=1
_isize=0 #initramfs size
modules_loaded=" "
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
_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" || \
if [[ "$mods_to_load" == *\ $_d_mod\ * ]]; then
if [[ $show_modules = yes ]]; then
printf "%s\n" "$_d_mod"
else
dinfo "*** Including module: $_d_mod ***"
if [[ $kernel_only = yes ]]; then
module_installkernel $_d_mod || {
fi
if [[ $kernel_only == yes ]]; then
module_installkernel "$_d_mod" || {
dfatal "installkernel failed in module $_d_mod"
exit 1
}
else
module_install $_d_mod
module_install "$_d_mod"
if [[ $no_kernel != yes ]]; then
module_installkernel $_d_mod || {
module_installkernel "$_d_mod" || {
dfatal "installkernel failed in module $_d_mod"
exit 1
}
@@ -1023,8 +1051,8 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
#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_delta=$((_isize_new - _isize))
printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
_isize=$_isize_new
fi
fi
@@ -1033,7 +1061,7 @@ unset moddir
for i in $modules_loaded; do
mkdir -p $initdir/lib/dracut
echo "$i" >> $initdir/lib/dracut/modules.txt
printf "%s\n" "$i" >> $initdir/lib/dracut/modules.txt
done
dinfo "*** Including modules done ***"
@@ -1068,24 +1096,24 @@ if [[ $no_kernel != yes ]]; then
fi
if [[ $kernel_only != yes ]]; then
(( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]}
(( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]}
[[ $kernel_cmdline ]] && echo "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
[[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
while pop fstab_lines line; do
echo "$line 0 0" >> "${initdir}/etc/fstab"
printf "%s\n" "$line 0 0" >> "${initdir}/etc/fstab"
done
for f in $add_fstab; do
cat $f >> "${initdir}/etc/fstab"
cat "$f" >> "${initdir}/etc/fstab"
done
if [ -d ${initdir}/$systemdutildir ]; then
mkdir -p ${initdir}/etc/conf.d
{
echo "systemdutildir=\"$systemdutildir\""
echo "systemdsystemunitdir=\"$systemdsystemunitdir\""
echo "systemdsystemconfdir=\"$systemdsystemconfdir\""
printf "%s\n" "systemdutildir=\"$systemdutildir\""
printf "%s\n" "systemdsystemunitdir=\"$systemdsystemunitdir\""
printf "%s\n" "systemdsystemconfdir=\"$systemdsystemconfdir\""
} > ${initdir}/etc/conf.d/systemd.conf
fi
@@ -1094,7 +1122,7 @@ if [[ $kernel_only != yes ]]; then
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}
| xargs -r -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} --
dinfo "*** Resolving executable dependencies done***"
fi
fi
@@ -1139,12 +1167,12 @@ if [[ $kernel_only != yes ]]; then
fi
fi
if (($maxloglvl >= 5)); then
if (( maxloglvl >= 5 )); then
ddebug "Listing sizes of included files:"
du -c "$initdir" | sort -n | ddebug
fi
PRELINK_BIN=$(command -v prelink)
PRELINK_BIN="$(command -v prelink)"
if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then
dinfo "*** Installing prelink files ***"
@@ -1152,9 +1180,9 @@ if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
else
dinfo "*** Pre-linking files ***"
dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf
chroot "$initdir" $PRELINK_BIN -a
rm -f "$initdir"/$PRELINK_BIN
rm -fr "$initdir"/etc/prelink.*
chroot "$initdir" "$PRELINK_BIN" -a
rm -f -- "$initdir/$PRELINK_BIN"
rm -fr -- "$initdir"/etc/prelink.*
dinfo "*** Pre-linking files done ***"
fi
fi
@@ -1186,7 +1214,7 @@ if [[ $do_strip = yes ]] ; then
&& ! [[ -e "/lib64/hmaccalc/${f##*/}.hmac" ]] \
&& ! [[ -e "/lib/fipscheck/${f##*/}.hmac" ]] \
&& ! [[ -e "/lib64/fipscheck/${f##*/}.hmac" ]]; then
echo -n "$f"; echo -n -e "\000"
printf "%s\000" "$f";
fi
done | xargs -r -0 strip -g 2>/dev/null
else
@@ -1199,20 +1227,49 @@ if [[ $do_strip = yes ]] ; then
find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
| while read -r -d $'\0' f; do
SIG=$(tail -c 28 "$f")
[[ $SIG == '~Module signature appended~' ]] || { echo -n "$f"; echo -n -e "\000"; }
[[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
done | xargs -r -0 strip -g
dinfo "*** Stripping files done ***"
fi
rm -f "$outfile"
if [[ $early_microcode = yes ]]; then
dinfo "*** Generating early-microcode cpio image ***"
ucode_dir=(amd-ucode intel-ucode)
ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
_dest_dir="$microcode_dir/d/kernel/x86/microcode"
_dest_idx="0 1"
mkdir -p $_dest_dir
if [[ $hostonly ]]; then
[[ $(get_cpu_vendor) == "AMD" ]] && _dest_idx="0"
[[ $(get_cpu_vendor) == "Intel" ]] && _dest_idx="1"
fi
for idx in $_dest_idx; do
_fw=${ucode_dir[$idx]}
for _fwdir in $fw_dir; do
if [[ -d $_fwdir && -d $_fwdir/$_fw ]]; then
_src="*"
dinfo "*** Constructing ${ucode_dest[$idx]} ****"
if [[ $hostonly ]]; then
_src=$(get_ucode_file)
fi
cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
fi
done
done
(cd "$microcode_dir/d"; find . | cpio -o -H newc --quiet >../ucode.cpio)
fi
rm -f -- "$outfile"
dinfo "*** Creating image file ***"
if [[ $early_microcode = yes ]]; then
# The microcode blob is _before_ the initramfs blob, not after
mv $microcode_dir/ucode.cpio $outfile.$$
fi
if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
$compress > "$outfile.$$"; ); then
$compress >> "$outfile.$$"; ); then
dfatal "dracut: creation of $outfile.$$ failed"
exit 1
fi
mv $outfile.$$ $outfile
mv -- "$outfile.$$" "$outfile"
dinfo "*** Creating image file done ***"
dinfo "Wrote $outfile:"

View File

@@ -76,6 +76,10 @@ Provides: mkinitrd = 2.6.1
Obsoletes: dracut-kernel < 005
Provides: dracut-kernel = %{version}-%{release}
Obsoletes: dracut <= 029
Obsoletes: dracut-norescue
Provides: dracut-horescue
Requires: bash >= 4
Requires: coreutils
Requires: cpio
@@ -158,20 +162,23 @@ Requires: libcap
This package requires everything which is needed to build an
initramfs with dracut, which drops capabilities.
%package nohostonly
%package config-generic
Summary: dracut configuration to turn off hostonly image generation
Requires: %{name} = %{version}-%{release}
Obsoletes: dracut-nohostonly
Provides: dracut-nohostonly
%description nohostonly
%description config-generic
This package provides the configuration to turn off the host specific initramfs
generation with dracut.
generation with dracut and generates a generic image by default.
%package norescue
Summary: dracut configuration to turn off rescue image generation
%package config-rescue
Summary: dracut configuration to turn on rescue image generation
Requires: %{name} = %{version}-%{release}
Obsoletes: dracut <= 029
%description norescue
This package provides the configuration to turn off the rescue initramfs
%description config-rescue
This package provides the configuration to turn on the rescue initramfs
generation with dracut.
%package tools
@@ -202,7 +209,7 @@ make %{?_smp_mflags}
%install
%if 0%{?fedora} || 0%{?rhel}
rm -rf $RPM_BUILD_ROOT
rm -rf -- $RPM_BUILD_ROOT
%endif
make %{?_smp_mflags} install \
DESTDIR=$RPM_BUILD_ROOT \
@@ -211,26 +218,26 @@ make %{?_smp_mflags} install \
echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dracut-version.sh
%if 0%{?fedora} == 0 && 0%{?rhel} == 0 && 0%{?suse_version} == 0
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni
%endif
%if %{defined _unitdir}
# for systemd, better use systemd-bootchart
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00bootchart
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00bootchart
%endif
# we do not support dash in the initramfs
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00dash
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00dash
# remove gentoo specific modules
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash
%if %{defined _unitdir}
# with systemd IMA and selinux modules do not make sense
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/96securityfs
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/97masterkey
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98integrity
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/96securityfs
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/97masterkey
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98integrity
%endif
mkdir -p $RPM_BUILD_ROOT/boot/dracut
@@ -249,8 +256,8 @@ install -m 0644 dracut.conf.d/suse.conf.example $RPM_BUILD_ROOT%{dracutlibdir}
%endif
%if 0%{?fedora} <= 12 && 0%{?rhel} < 6 && 0%{?suse_version} <= 9999
rm $RPM_BUILD_ROOT%{_bindir}/mkinitrd
rm $RPM_BUILD_ROOT%{_bindir}/lsinitrd
rm -f -- $RPM_BUILD_ROOT%{_bindir}/mkinitrd
rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
%endif
%if 0%{?fedora} || 0%{?rhel} > 6
@@ -258,8 +265,8 @@ rm $RPM_BUILD_ROOT%{_bindir}/lsinitrd
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-nohostonly.conf
echo 'dracut_rescue_image="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-norescue.conf
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%endif
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
@@ -270,7 +277,7 @@ mkdir -p $RPM_BUILD_ROOT/sbin
ln -s /usr/bin/dracut $RPM_BUILD_ROOT/sbin/dracut
%clean
rm -rf $RPM_BUILD_ROOT
rm -rf -- $RPM_BUILD_ROOT
%files
%defattr(-,root,root,0755)
@@ -384,8 +391,6 @@ rm -rf $RPM_BUILD_ROOT
%endif
%if 0%{?fedora} || 0%{?rhel} > 6
%{_prefix}/lib/kernel/install.d/50-dracut.install
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%files network
@@ -426,12 +431,16 @@ rm -rf $RPM_BUILD_ROOT
%dir /var/lib/dracut
%dir /var/lib/dracut/overlay
%files nohostonly
%files config-generic
%defattr(-,root,root,0755)
%{dracutlibdir}/dracut.conf.d/02-nohostonly.conf
%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
%files norescue
%files config-rescue
%defattr(-,root,root,0755)
%{dracutlibdir}/dracut.conf.d/02-norescue.conf
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%if 0%{?fedora} || 0%{?rhel} > 6
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%changelog

View File

@@ -126,7 +126,7 @@ if (( ${#filenames[@]} > 0 )); then
for f in ${!filenames[@]}; do
[[ $nofileinfo ]] || echo "initramfs:/$f"
[[ $nofileinfo ]] || echo "========================================================================"
$CAT $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
$CAT -- $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
((ret+=$?))
[[ $nofileinfo ]] || echo "========================================================================"
[[ $nofileinfo ]] || echo
@@ -134,16 +134,16 @@ if (( ${#filenames[@]} > 0 )); then
else
echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
echo "========================================================================"
version=$($CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null)
version=$($CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/dracut-*' 2>/dev/null)
((ret+=$?))
echo "$version with dracut modules:"
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'usr/lib/dracut/modules.txt' 2>/dev/null
$CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- 'usr/lib/dracut/modules.txt' 2>/dev/null
((ret+=$?))
echo "========================================================================"
if [ "$sorted" -eq 1 ]; then
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
$CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
else
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9
$CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -k9
fi
((ret+=$?))
echo "========================================================================"

View File

@@ -3,7 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif getarg boot= >/dev/null; then
. /sbin/fips.sh
if mount_boot; then

View File

@@ -3,7 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif ! [ -f /tmp/fipsdone ]; then
. /sbin/fips.sh
mount_boot

View File

@@ -15,6 +15,12 @@ mount_boot()
UUID=*)
boot="/dev/disk/by-uuid/${boot#UUID=}"
;;
PARTUUID=*)
boot="/dev/disk/by-partuuid/${boot#PARTUUID=}"
;;
PARTLABEL=*)
boot="/dev/disk/by-partlabel/${boot#PARTLABEL=}"
;;
/dev/*)
;;
*)
@@ -44,7 +50,7 @@ mount_boot()
info "Mounting $boot as /boot"
mount -oro "$boot" /boot || return 1
elif [ -d "$NEWROOT/boot" ]; then
rm -fr /boot
rm -fr -- /boot
ln -sf "$NEWROOT/boot" /boot
fi
}

View File

@@ -12,6 +12,15 @@ depends() {
}
install() {
if dracut_module_included "systemd"; then
[[ -f /etc/vconsole.conf ]] || return 0
unset FONT
unset KEYMAP
. /etc/vconsole.conf
# if vconsole.conf has no settings, do not include anything
[[ $FONT ]] || [[ $KEYMAP ]] || return 0
fi
dracut_install -o $systemdutildir/systemd-vconsole-setup
KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps
DEFAULT_FONT="${i18n_default_font:-LatArCyrHeb-16}"
@@ -102,7 +111,7 @@ install() {
done
# remove unnecessary files
rm -f "${initdir}${kbddir}/consoletrans/utflist"
rm -f -- "${initdir}${kbddir}/consoletrans/utflist"
find "${initdir}${kbddir}/" -name README\* -delete
find "${initdir}${kbddir}/" -name '*.gz' -print -quit \
| while read line; do
@@ -212,12 +221,6 @@ install() {
kbddir=''
done
[[ ${kbddir} ]] || {
derror "Directories ${KBDSUBDIRS//,/, } not found. Please" \
"inform us about the issue including your OS name and version."
return 1
}
[[ -f $I18N_CONF && -f $VCONFIG_CONF ]] || \
[[ ! ${hostonly} || ${i18n_vars} ]] || {
derror 'i18n_vars not set! Please set up i18n_vars in ' \

View File

@@ -36,7 +36,7 @@ if [ -f /etc/locale.conf ]; then
fi
if [ -n "$DRACUT_SYSTEMD" ]; then
rm -f /etc/udev/rules.d/10-console.rules
rm -f /lib/udev/rules.d/10-console.rules
rm -f /lib/udev/console_init
rm -f -- /etc/udev/rules.d/10-console.rules
rm -f -- /lib/udev/rules.d/10-console.rules
rm -f -- /lib/udev/console_init
fi

View File

@@ -56,22 +56,22 @@ if ! needconvert; then
fi
testfile="$ROOT/.usrmovecheck$$"
rm -f "$testfile"
rm -f -- "$testfile"
> "$testfile"
if [[ ! -e "$testfile" ]]; then
echo "Cannot write to $ROOT/"
exit 1
fi
rm -f "$testfile"
rm -f -- "$testfile"
testfile="$ROOT/usr/.usrmovecheck$$"
rm -f "$testfile"
rm -f -- "$testfile"
> "$testfile"
if [[ ! -e "$testfile" ]]; then
echo "Cannot write to $ROOT/usr/"
exit 1
fi
rm -f "$testfile"
rm -f -- "$testfile"
find_mount() {
local dev mnt etc wanted_dev
@@ -108,11 +108,11 @@ cleanup() {
for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \
"$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \
"$ROOT/usr/lib64"; do
[[ -d "${dir}.usrmove-new" ]] && rm -fr "${dir}.usrmove-new"
[[ -d "${dir}.usrmove-new" ]] && rm -fr -- "${dir}.usrmove-new"
if [[ -d "${dir}.usrmove-old" ]]; then
mv "$dir" "${dir}.del~"
mv "${dir}.usrmove-old" "$dir"
rm -fr "${dir}.del~"
rm -fr -- "${dir}.del~"
fi
done
}
@@ -126,7 +126,7 @@ set -e
# merge / and /usr in new dir in /usr
for dir in bin sbin lib lib64; do
rm -rf "$ROOT/usr/${dir}.usrmove-new"
rm -rf -- "$ROOT/usr/${dir}.usrmove-new"
[[ -L "$ROOT/$dir" ]] && continue
[[ -d "$ROOT/$dir" ]] || continue
echo "Make a copy of \`$ROOT/usr/$dir'."
@@ -150,7 +150,7 @@ done
for dir in bin sbin lib lib64; do
[[ -d "$ROOT/usr/${dir}.usrmove-new" ]] || continue
echo "Switch to new \`$ROOT/usr/$dir'."
rm -fr "$ROOT/usr/${dir}.usrmove-old"
rm -fr -- "$ROOT/usr/${dir}.usrmove-old"
mv "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-old"
mv "$ROOT/usr/${dir}.usrmove-new" "$ROOT/usr/$dir"
done
@@ -160,7 +160,7 @@ for dir in bin sbin lib lib64; do
[[ -L "$ROOT/$dir" ]] && continue
[[ -d "$ROOT/$dir" ]] || continue
echo "Create \`$ROOT/$dir' symlink."
rm -rf "$ROOT/${dir}.usrmove-old" || :
rm -fr -- "$ROOT/${dir}.usrmove-old" || :
mv "$ROOT/$dir" "$ROOT/${dir}.usrmove-old"
ln -sfn usr/$dir "$ROOT/$dir"
done
@@ -178,9 +178,9 @@ done
for dir in bin sbin lib lib64; do
[[ -d "$ROOT/usr/${dir}.usrmove-old~" ]] \
&& rm -rf "$ROOT/usr/${dir}.usrmove-old~" || :
&& rm -rf -- "$ROOT/usr/${dir}.usrmove-old~" || :
[[ -d "$ROOT/${dir}.usrmove-old~" ]] \
&& rm -rf "$ROOT/${dir}.usrmove-old~" || :
&& rm -rf -- "$ROOT/${dir}.usrmove-old~" || :
done
for dir in lib lib64; do

View File

@@ -9,7 +9,7 @@ setup_interface() {
bcast=$new_broadcast_address
gw=${new_routers%%,*}
domain=$new_domain_name
search=$(printf "$new_domain_search")
search=$(printf -- "$new_domain_search")
namesrv=$new_domain_name_servers
hostname=$new_host_name
@@ -89,7 +89,7 @@ case $reason in
[ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
echo "> /tmp/setup_net_$netif.ok"
echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
echo "rm -f $hookdir/initqueue/setup_net_$netif.sh"
echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
} > $hookdir/initqueue/setup_net_$netif.sh
echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh

View File

@@ -105,7 +105,7 @@ ifdown() {
ip link set $netif down
ip addr flush dev $netif
echo "#empty" > /etc/resolv.conf
rm -f /tmp/net.$netif.did-setup
rm -f -- /tmp/net.$netif.did-setup
# TODO: send "offline" uevent?
}

View File

@@ -76,7 +76,7 @@ source_hook netroot $netif
# Run the handler; don't store the root, it may change from device to device
# XXX other variables to export?
if $handler $netif $netroot $NEWROOT; then
rm -f $hookdir/initqueue/finished/dhcp.sh
rm -f -- $hookdir/initqueue/finished/dhcp.sh
# Network rootfs mount successful - save interface info for ifcfg etc.
save_netinfo $netif
fi

View File

@@ -23,7 +23,7 @@ fetch_url() {
local handler="$(get_url_handler $url)"
[ -n "$handler" ] || return 254
[ -n "$url" ] || return 255
$handler "$url" "$outloc"
"$handler" "$url" "$outloc"
}
# get_url_handler URL
@@ -64,7 +64,7 @@ curl_fetch_url() {
local url="$1" outloc="$2"
echo "$url" > /proc/self/fd/0
if [ -n "$outloc" ]; then
curl $curl_args --output "$outloc" "$url" || return $?
curl $curl_args --output "$outloc" -- "$url" || return $?
else
local outdir="$(mkuniqdir /tmp curl_fetch_url)"
( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
@@ -106,18 +106,18 @@ nfs_fetch_url() {
local filepath="${path%/*}" filename="${path##*/}" mntdir=""
# skip mount if server:/filepath is already mounted
mntdir=$(nfs_already_mounted $server $path)
mntdir=$(nfs_already_mounted "$server" "$path")
if [ -z "$mntdir" ]; then
local mntdir="$(mkuniqdir /run nfs_mnt)"
mount_nfs $nfs:$server:$filepath${options:+:$options} $mntdir
mount_nfs "$nfs:$server:$filepath${options:+:$options}" "$mntdir"
# lazy unmount during pre-pivot hook
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l $mntdir
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l -- "$mntdir"
fi
if [ -z "$outloc" ]; then
outloc="$mntdir/$filename"
else
cp -f "$mntdir/$filename" "$outloc" || return $?
cp -f -- "$mntdir/$filename" "$outloc" || return $?
fi
[ -f "$outloc" ] || return 253
if [ -z "$2" ]; then echo "$outloc" ; fi

View File

@@ -167,7 +167,7 @@ function dasd_settle_all() {
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$env{INTERFACE} /sbin/cmsifup $env{INTERFACE}"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules
# remove the default net rules
rm -f /etc/udev/rules.d/91-default-net.rules
rm -f -- /etc/udev/rules.d/91-default-net.rules
[[ -f /etc/udev/rules.d/90-net.rules ]] \
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules
udevadm control --reload

View File

@@ -2,7 +2,7 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# close everything which is not busy
rm -f /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1
rm -f -- /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1
if ! getarg rd.luks.uuid -d rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS >/dev/null 2>&1; then
while true; do

View File

@@ -4,7 +4,7 @@
if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then
info "rd.luks=0: removing cryptoluks activation"
rm -f /etc/udev/rules.d/70-luks.rules
rm -f -- /etc/udev/rules.d/70-luks.rules
else
{
echo 'SUBSYSTEM!="block", GOTO="luks_end"'

View File

@@ -27,8 +27,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
for s in $SETS; do
if [ "${s##$r}" != "$s" ]; then
info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
[ -e "/dev/mapper/$s" ] && kpartx -a "/dev/mapper/$s" 2>&1 | vinfo
dmraid -ay -i --rm_partitions "$s" 2>&1 | vinfo
udevsettle
fi
done
@@ -37,8 +36,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
# scan and activate all DM RAIDS
for s in $SETS; do
info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo
[ -e "/dev/mapper/$s" ] && kpartx -a "/dev/mapper/$s" 2>&1 | vinfo
dmraid -ay -i --rm_partitions "$s" 2>&1 | vinfo
done
fi

View File

@@ -24,7 +24,7 @@ do_iso_scan() {
mount -t auto -o ro "$dev" "/run/initramfs/isoscan" || continue
if [ -f "/run/initramfs/isoscan/$isofile" ]; then
losetup -f "/run/initramfs/isoscan/$isofile"
rm -f "$job"
rm -f -- "$job"
exit 0
else
umount "/run/initramfs/isoscan"

View File

@@ -34,6 +34,14 @@ case "$liveroot" in
root="${root#live:}"
root="live:/dev/disk/by-uuid/${root#UUID=}"
rootok=1 ;;
live:PARTUUID=*|PARTUUID=*) \
root="${root#live:}"
root="live:/dev/disk/by-partuuid/${root#PARTUUID=}"
rootok=1 ;;
live:PARTLABEL=*|PARTLABEL=*) \
root="${root#live:}"
root="live:/dev/disk/by-partlabel/${root#PARTLABEL=}"
rootok=1 ;;
live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
root="${root#live:}"
root="liveiso:${root}"

View File

@@ -125,7 +125,7 @@ if [ -z "$LVS" -o -n "$VGS" ]; then
fi
if [ "$lvmwritten" ]; then
rm -f /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
fi
unset lvmwritten

View File

@@ -34,7 +34,7 @@ install() {
eval $(udevadm info --query=property --name=$1 | egrep '(DM_VG_NAME|DM_LV_NAME|DM_UDEV_DISABLE_DISK_RULES_FLAG)=')
[[ "$DM_UDEV_DISABLE_DISK_RULES_FLAG" = "1" ]] && return 1
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 1
if ! strstr " ${_activated[*]} " " ${DM_VG_NAME}/${DM_LV_NAME} "; then
if ! [[ " ${_activated[*]} " == *\ ${DM_VG_NAME}/${DM_LV_NAME}\ * ]]; then
if ! [[ $kernel_only ]]; then
echo " rd.lvm.lv=${DM_VG_NAME}/${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
fi

View File

@@ -2,7 +2,7 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if [ -e /etc/lvm/lvm.conf ] && ! getargbool 1 rd.lvm.conf -d -n rd_NO_LVMCONF; then
rm -f /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
fi
LV_DEVS="$(getargs rd.lvm.vg -d rd_LVM_VG=) $(getargs rd.lvm.lv -d rd_LVM_LV=)"
@@ -10,7 +10,7 @@ LV_DEVS="$(getargs rd.lvm.vg -d rd_LVM_VG=) $(getargs rd.lvm.lv -d rd_LVM_LV=)"
if ! getargbool 1 rd.lvm -d -n rd_NO_LVM \
|| ( [ -z "$LV_DEVS" ] && ! getargbool 0 rd.auto ); then
info "rd.lvm=0: removing LVM activation"
rm -f /etc/udev/rules.d/64-lvm*.rules
rm -f -- /etc/udev/rules.d/64-lvm*.rules
else
for dev in $LV_DEVS; do
wait_for_dev "/dev/$dev"

View File

@@ -32,11 +32,11 @@ fi
if [ -e /etc/mdadm.conf ] && getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
udevproperty rd_MDADMCONF=1
rm -f $hookdir/pre-pivot/*mdraid-cleanup.sh
rm -f -- $hookdir/pre-pivot/*mdraid-cleanup.sh
fi
if ! getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
rm -f /etc/mdadm/mdadm.conf /etc/mdadm.conf
rm -f -- /etc/mdadm/mdadm.conf /etc/mdadm.conf
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
fi

View File

@@ -7,6 +7,6 @@ if [ -e /etc/multipath.conf ]; then
multipathd -B || multipathd
need_shutdown
else
rm /etc/udev/rules.d/??-multipath.rules 2>/dev/null
rm -- /etc/udev/rules.d/??-multipath.rules 2>/dev/null
fi

View File

@@ -21,6 +21,6 @@ echo options: $options
mount.cifs //$server/$path $NEWROOT -o $options && { [ -e /dev/root ] || ln -s null /dev/root ; }
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/cifs.sh
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm -f -- "$job"' > $hookdir/initqueue/cifs.sh
# force udevsettle to break
> $hookdir/initqueue/work

View File

@@ -4,7 +4,7 @@
for dasd_arg in $(getargs rd.dasd= -d rd_DASD= DASD=); do
(
IFS=","
set $dasd_arg
set -- $dasd_arg
echo "$@" | normalize_dasd_arg >> /etc/dasd.conf
)
done

View File

@@ -10,19 +10,21 @@ check() {
# If hostonly was requested, fail the check if we are not actually
# booting from root.
is_iscsi() (
is_iscsi() {
local _dev=$1
[[ -L /sys/dev/block/$_dev ]] || return
cd "$(readlink -f /sys/dev/block/$_dev)"
[[ -L "/sys/dev/block/$_dev" ]] || return
cd "$(readlink -f "/sys/dev/block/$_dev")"
until [[ -d sys || -d iscsi_session ]]; do
cd ..
done
[[ -d iscsi_session ]]
)
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
pushd . >/dev/null
for_each_host_dev_and_slaves is_iscsi || return 1
popd >/dev/null
}
return 0
}

View File

@@ -21,7 +21,7 @@ mount_nfs $root $NEWROOT $netif && { [ -e /dev/root ] || ln -s null /dev/root ;
[ -f $NEWROOT/etc/fstab ] && cat $NEWROOT/etc/fstab > /dev/null
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/nfs.sh
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm -- "$job"' > $hookdir/initqueue/nfs.sh
# force udevsettle to break
> $hookdir/initqueue/work

View File

@@ -17,6 +17,8 @@ case "$resume" in
resume="/dev/disk/by-uuid/${resume#UUID=}" ;;
PARTUUID=*) \
resume="/dev/disk/by-partuuid/${resume#PARTUUID=}" ;;
PARTLABEL=*) \
resume="/dev/disk/by-partlabel/${resume#PARTLABEL=}" ;;
esac
if splash=$(getarg splash=); then
@@ -55,10 +57,10 @@ if [ -n "$resume" ]; then
${resume#/dev/};
} >> /etc/udev/rules.d/99-resume.rules
printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm "$job" "%s/initqueue/timeout/resume.sh"; }\n' \
printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm -f -- "$job" "%s/initqueue/timeout/resume.sh"; }\n' \
"$resume" "$resume" "$hookdir" >> $hookdir/initqueue/settled/resume.sh
printf 'warn "Cancelling resume operation. Device not found."; cancel_wait_for_dev /dev/resume; rm "$job" "%s/initqueue/settled/resume.sh";' \
printf 'warn "Cancelling resume operation. Device not found."; cancel_wait_for_dev /dev/resume; rm -f -- "$job" "%s/initqueue/settled/resume.sh";' \
"$hookdir" >> $hookdir/initqueue/timeout/resume.sh
wait_for_dev "/dev/resume"

View File

@@ -115,7 +115,6 @@ mount_root() {
umount "$NEWROOT"
fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
_ret=$?
[ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck
ran_fsck=1
fi
@@ -130,8 +129,8 @@ mount_root() {
fi
if ! getargbool 0 rd.skipfsck; then
[ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null
[ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2>/dev/null
fi
}

View File

@@ -16,6 +16,10 @@ case "$root" in
root="${root#block:}"
root="block:/dev/disk/by-partuuid/${root#PARTUUID=}"
rootok=1 ;;
block:PARTLABEL=*|PARTLABEL=*)
root="${root#block:}"
root="block:/dev/disk/by-partlabel/${root#PARTLABEL=}"
rootok=1 ;;
/dev/*)
root="block:${root}"
rootok=1 ;;

View File

@@ -10,7 +10,9 @@ install() {
done
if [ -d ${_terminfodir} ]; then
inst_dir "$_terminfodir"
cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_terminfodir}" "$_terminfodir"/*
for i in "l/linux" "v/vt100" "v/vt220"; do
inst_dir "$_terminfodir/${i%/*}"
cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_terminfodir}/${i%/*}" "$_terminfodir/$i"
done
fi
}

View File

@@ -31,7 +31,7 @@ install() {
60-pcmcia.rules \
50-udev.rules 95-late.rules \
50-firmware.rules \
80-net-name-slot.rules \
75-net-description.rules 80-net-name-slot.rules \
"$moddir/59-persistent-storage.rules" \
"$moddir/61-persistent-storage.rules"

View File

@@ -66,8 +66,8 @@ mount_root() {
info "Remounting ${root#virtfs:} with -o ${rflags}"
mount -t ${rootfs} -o "$rflags" "${root#virtfs:}" "$NEWROOT" 2>&1 | vinfo
[ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null
[ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2>/dev/null
}
if [ -n "$root" -a -z "${root%%virtfs:*}" ]; then

View File

@@ -5,6 +5,6 @@
SECURITYFSDIR="/sys/kernel/security"
export SECURITYFSDIR
if ! findmnt "${SECURITYFSDIR}" >/dev/null 2>&1; then
if ! findmnt --target "${SECURITYFSDIR}" >/dev/null 2>&1; then
mount -t securityfs -o nosuid,noexec,nodev securityfs ${SECURITYFSDIR} >/dev/null 2>&1
fi

View File

@@ -4,7 +4,7 @@
if ! getargbool 1 biosdevname; then
info "biosdevname=0: removing biosdevname network renaming"
udevproperty UDEV_BIOSDEVNAME=
rm -f /etc/udev/rules.d/71-biosdevname.rules
rm -f -- /etc/udev/rules.d/71-biosdevname.rules
else
info "biosdevname=1: activating biosdevname network renaming"
udevproperty UDEV_BIOSDEVNAME=1

View File

@@ -3,7 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
[ "$1" = "-h" ] && {
[[ $hostonly ]] && {
[ -x "/bin/keyctl" ] || return 1
}

View File

@@ -48,6 +48,7 @@ rd_load_policy()
[ -e "$NEWROOT"/.autorelabel ] && LANG=C /usr/sbin/setenforce 0
mount --rbind /dev "$NEWROOT/dev"
LANG=C chroot "$NEWROOT" /sbin/restorecon -R /dev
umount -R "$NEWROOT/dev"
return 0
fi

View File

@@ -12,7 +12,6 @@ Description=dracut cmdline hook
Documentation=man:dracut-cmdline.service(8)
DefaultDependencies=no
Before=dracut-pre-udev.service
Before=systemd-vconsole-setup.service
After=systemd-journald.socket
Wants=systemd-journald.socket
ConditionPathExists=/etc/initrd-release

View File

@@ -57,6 +57,10 @@ case "$root" in
root="${root#block:}"
root="block:/dev/disk/by-partuuid/${root#PARTUUID=}"
rootok=1 ;;
block:PARTLABEL=*|PARTLABEL=*)
root="${root#block:}"
root="block:/dev/disk/by-partlabel/${root#PARTLABEL=}"
rootok=1 ;;
/dev/*)
root="block:${root}"
rootok=1 ;;

View File

@@ -21,7 +21,7 @@ Environment=DRACUT_SYSTEMD=1
Environment=NEWROOT=/sysroot
WorkingDirectory=/
ExecStart=/bin/dracut-emergency
ExecStopPost=-/bin/rm -f /.console_lock
ExecStopPost=-/bin/rm -f -- /.console_lock
Type=oneshot
StandardInput=tty-force
StandardOutput=inherit

View File

@@ -19,12 +19,12 @@ source_hook "$hook"
if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
echo
sosreport
rdsosreport
echo
echo
echo 'Entering emergency mode. Exit the shell to continue.'
echo 'Type "journalctl" to view system logs.'
echo 'You might want to save "/run/initramfs/sosreport.txt" to a USB stick or /boot'
echo 'You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot'
echo 'after mounting them and attach it to a bug report.'
echo
echo
@@ -36,6 +36,6 @@ else
exit 1
fi
/bin/rm -f /.console_lock
/bin/rm -f -- /.console_lock
exit 0

View File

@@ -30,7 +30,7 @@ while :; do
check_finished && break
if [ -f $hookdir/initqueue/work ]; then
rm $hookdir/initqueue/work
rm -f -- "$hookdir/initqueue/work"
fi
for job in $hookdir/initqueue/*.sh; do

View File

@@ -26,7 +26,7 @@ while :; do
usable_root "$NEWROOT" && break;
warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
umount "$NEWROOT"
rm -f "$f"
rm -f -- "$f"
fi
done

View File

@@ -23,6 +23,6 @@ source_hook cleanup
getarg rd.break -d rdbreak && emergency_shell -n switch_root "Break before switch_root"
# remove helper symlink
[ -h /dev/root ] && rm -f /dev/root
[ -h /dev/root ] && rm -f -- /dev/root
exit 0

View File

@@ -24,7 +24,7 @@ install() {
# exit 1
# fi
if strstr "$prefix" "/run/"; then
if [[ "$prefix" == /run/* ]]; then
dfatal "systemd does not work with a prefix, which contains \"/run\"!!"
exit 1
fi
@@ -39,6 +39,7 @@ install() {
$systemdutildir/systemd-journald \
$systemdutildir/systemd-sysctl \
$systemdutildir/systemd-modules-load \
$systemdutildir/systemd-vconsole-setup \
$systemdutildir/system-generators/systemd-fstab-generator \
$systemdsystemunitdir/cryptsetup.target \
$systemdsystemunitdir/emergency.target \
@@ -67,6 +68,7 @@ install() {
$systemdsystemunitdir/swap.target \
$systemdsystemunitdir/timers.target \
$systemdsystemunitdir/paths.target \
$systemdsystemunitdir/umount.target \
$systemdsystemunitdir/systemd-ask-password-console.path \
$systemdsystemunitdir/systemd-udevd-control.socket \
$systemdsystemunitdir/systemd-udevd-kernel.socket \
@@ -103,7 +105,9 @@ install() {
$systemdsystemunitdir/initrd-udevadm-cleanup-db.service \
$systemdsystemunitdir/initrd-parse-etc.service \
\
$systemdsystemunitdir/umount.target \
$systemdsystemunitdir/slices.target \
$systemdsystemunitdir/system.slice \
\
journalctl systemctl echo swapoff systemd-cgls
dracut_install -o \
@@ -144,10 +148,10 @@ install() {
_mods=$(modules_load_get /etc/modules-load.d)
[[ $_mods ]] && instmods $_mods
else
if ! [[ -e "$initdir/etc/machine-id" ]]; then
> "$initdir/etc/machine-id"
fi
fi
if ! [[ -e "$initdir/etc/machine-id" ]]; then
> "$initdir/etc/machine-id"
fi
# install adm user/group for journald

View File

@@ -18,7 +18,7 @@ Environment=NEWROOT=/sysroot
WorkingDirectory=/
ExecStartPre=-/bin/plymouth quit
ExecStart=-/bin/sh -i -l
ExecStopPost=-/bin/rm -f /.console_lock
ExecStopPost=-/bin/rm -f -- /.console_lock
ExecStopPost=-/usr/bin/systemctl --fail --no-block default
Type=idle
StandardInput=tty-force

View File

@@ -54,9 +54,9 @@ killall_proc_mountpoint() {
case $_pid in
*[!0-9]*) continue;;
esac
[ -e /proc/$_pid/exe ] || continue
[ -e /proc/$_pid/root ] || continue
strstr "$(ls -l /proc/$_pid /proc/$_pid/fd 2>/dev/null)" "$1" && kill -9 $_pid
[ -e "/proc/$_pid/exe" ] || continue
[ -e "/proc/$_pid/root" ] || continue
strstr "$(ls -l -- '/proc/$_pid' '/proc/$_pid/fd' 2>/dev/null)" "$1" && kill -9 "$_pid"
done
}
@@ -107,7 +107,7 @@ _dogetarg() {
continue
fi
_val=${_o#*=};
_val="${_o#*=}"
_doecho=1
fi
done
@@ -145,7 +145,7 @@ getarg() {
_deprecated=0
shift 2;;
*) if [ -z "$_newoption" ]; then
_newoption=$1
_newoption="$1"
fi
if _dogetarg $1; then
if [ "$_deprecated" = "1" ]; then
@@ -173,9 +173,9 @@ getargbool() {
local _b
unset _b
local _default
_default=$1; shift
_default="$1"; shift
_b=$(getarg "$@")
[ $? -ne 0 -a -z "$_b" ] && _b=$_default
[ $? -ne 0 -a -z "$_b" ] && _b="$_default"
if [ -n "$_b" ]; then
[ $_b = "0" ] && return 1
[ $_b = "no" ] && return 1
@@ -201,14 +201,14 @@ getargnum() {
local _b
unset _b
local _default _min _max
_default=$1; shift
_min=$1; shift
_max=$1; shift
_default="$1"; shift
_min="$1"; shift
_max="$1"; shift
_b=$(getarg "$1")
[ $? -ne 0 -a -z "$_b" ] && _b=$_default
if [ -n "$_b" ]; then
isdigit "$_b" && _b=$(($_b)) && \
[ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return
[ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return
fi
echo $_default
}
@@ -219,7 +219,7 @@ _dogetargs() {
unset _o
unset _found
_getcmdline
_key=$1
_key="$1"
set --
for _o in $CMDLINE; do
if [ "$_o" = "$_key" ]; then
@@ -364,7 +364,7 @@ source_hook() {
check_finished() {
local f
for f in $hookdir/initqueue/finished/*.sh; do
for f in $hookdir/initqueue/finished/*.sh; do
[ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0
{ [ -e "$f" ] && ( . "$f" ) ; } || return 1
done
@@ -387,7 +387,7 @@ die() {
echo "warn dracut: FATAL: \"$*\"";
echo "warn dracut: Refusing to continue";
} >> $hookdir/emergency/01-die.sh
[ -d /run/initramfs ] || mkdir -p /run/initramfs
[ -d /run/initramfs ] || mkdir -p -- /run/initramfs
> /run/initramfs/.die
emergency_shell
exit 1
@@ -572,13 +572,16 @@ nfsroot_to_var() {
# TOOD: symlinks
udevmatch() {
case "$1" in
UUID=????????-????-????-????-????????????|LABEL=*)
UUID=????????-????-????-????-????????????|LABEL=*|PARTLABEL=*|PARTUUID=????????-????-????-????-????????????)
printf 'ENV{ID_FS_%s}=="%s"' "${1%%=*}" "${1#*=}"
;;
UUID=*)
printf 'ENV{ID_FS_UUID}=="%s*"' "${1#*=}"
;;
/dev/?*) printf 'KERNEL=="%s"' "${1#/dev/}" ;;
PARTUUID=*)
printf 'ENV{ID_FS_PARTUUID}=="%s*"' "${1#*=}"
;;
/dev/?*) printf -- 'KERNEL=="%s"' "${1#/dev/}" ;;
*) return 255 ;;
esac
}
@@ -754,7 +757,7 @@ inst_hook() {
if [ -n "$onetime" ]; then
{
echo '[ -e "$_job" ] && rm "$_job"'
echo '[ -e "$_job" ] && rm -f -- "$_job"'
echo "$_exe $@"
} > "/tmp/$$-${_job}.sh"
else
@@ -867,12 +870,12 @@ cancel_wait_for_dev()
{
local _name
_name="$(str_replace "$1" '/' '\\x2f')"
rm -f "$hookdir/initqueue/finished/devexists-${_name}.sh"
rm -f "$hookdir/emergency/80-${_name}.sh"
rm -f -- "$hookdir/initqueue/finished/devexists-${_name}.sh"
rm -f -- "$hookdir/emergency/80-${_name}.sh"
if [ -n "$DRACUT_SYSTEMD" ]; then
_name=$(dev_unit_name "$1")
rm -f ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device
rm -f ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
rm -f -- ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device
rm -f -- ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
/sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload
fi
}
@@ -921,7 +924,7 @@ wait_for_loginit()
fi
setdebug
rm -f /run/initramfs/loginit.pipe /run/initramfs/loginit.pid
rm -f -- /run/initramfs/loginit.pipe /run/initramfs/loginit.pid
}
_emergency_shell()
@@ -931,13 +934,13 @@ _emergency_shell()
> /.console_lock
echo "PS1=\"$_name:\\\${PWD}# \"" >/etc/profile
systemctl start dracut-emergency.service
rm -f /etc/profile
rm -f /.console_lock
rm -f -- /etc/profile
rm -f -- /.console_lock
else
debug_off
echo
/sbin/sosreport
echo 'You might want to save "/run/initramfs/sosreport.txt" to a USB stick or /boot'
/sbin/rdsosreport
echo 'You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot'
echo 'after mounting them and attach it to a bug report.'
if ! RD_DEBUG= getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then
echo

View File

@@ -37,13 +37,6 @@ fi
RD_DEBUG=""
. /lib/dracut-lib.sh
if [ -x $systemdutildir/systemd-timestamp ]; then
RD_TIMESTAMP=$($systemdutildir/systemd-timestamp)
else
read RD_TIMESTAMP _tmp < /proc/uptime
unset _tmp
fi
setdebug
if ! ismounted /dev; then
@@ -85,7 +78,7 @@ if ! ismounted /run; then
mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
cp -a /run/* /newrun >/dev/null 2>&1
mount --move /newrun /run
rm -fr /newrun
rm -fr -- /newrun
fi
trap "action_on_fail Signal caught!" 0
@@ -174,7 +167,7 @@ while :; do
check_finished && break
if [ -f $hookdir/initqueue/work ]; then
rm $hookdir/initqueue/work
rm -f -- $hookdir/initqueue/work
fi
for job in $hookdir/initqueue/*.sh; do
@@ -237,7 +230,7 @@ while :; do
usable_root "$NEWROOT" && break;
warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
umount "$NEWROOT"
rm -f "$f"
rm -f -- "$f"
fi
done
@@ -317,7 +310,7 @@ for i in $(export -p); do
esac
done
. /tmp/export.orig 2>/dev/null || :
rm -f /tmp/export.orig
rm -f -- /tmp/export.orig
initargs=""
read CLINE </proc/cmdline
@@ -356,7 +349,7 @@ fi
wait_for_loginit
# remove helper symlink
[ -h /dev/root ] && rm -f /dev/root
[ -h /dev/root ] && rm -f -- /dev/root
getarg rd.break -d rdbreak && emergency_shell -n switch_root "Break before switch_root"
info "Switching root"

View File

@@ -46,7 +46,7 @@ shift
[ -x "$exe" ] || exe=$(command -v $exe)
{
[ -n "$onetime" ] && echo '[ -e "$job" ] && rm "$job"'
[ -n "$onetime" ] && echo '[ -e "$job" ] && rm -f -- "$job"'
[ -n "$env" ] && echo "$env"
echo "$exe $@"
} > "/tmp/$$-${job}.sh"

View File

@@ -14,7 +14,7 @@ exec 6>/run/initramfs/init.log
while read line; do
if [ "$line" = "DRACUT_LOG_END" ]; then
rm -f /run/initramfs/loginit.pipe
rm -f -- /run/initramfs/loginit.pipe
exit 0
fi
echo "<31>dracut: $line" >&5

View File

@@ -43,7 +43,7 @@ install() {
inst_script "$moddir/init.sh" "/init"
inst_script "$moddir/initqueue.sh" "/sbin/initqueue"
inst_script "$moddir/loginit.sh" "/sbin/loginit"
inst_script "$moddir/sosreport.sh" "/sbin/sosreport"
inst_script "$moddir/rdsosreport.sh" "/sbin/rdsosreport"
[ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
mkdir -m 0755 -p ${initdir}/lib/dracut
@@ -60,7 +60,11 @@ install() {
fi
mkdir -p "${initdir}/var"
dracut_install -o $systemdutildir/systemd-timestamp
if ! dracut_module_included "systemd"; then
dracut_install -o $systemdutildir/systemd-timestamp
fi
if [[ $realinitpath ]]; then
for i in $realinitpath; do
echo "rd.distroinit=$i"
@@ -99,21 +103,24 @@ install() {
ln -sf initrd-release $initdir/etc/os-release
## save host_devs which we need bring up
(
if dracut_module_included "systemd"; then
DRACUT_SYSTEMD=1
fi
PREFIX="$initdir"
if [[ -f "$initdir/lib/dracut/need-initqueue" ]] || ! dracut_module_included "systemd"; then
(
if dracut_module_included "systemd"; then
DRACUT_SYSTEMD=1
fi
PREFIX="$initdir"
. "$moddir/dracut-lib.sh"
. "$moddir/dracut-lib.sh"
for _dev in ${host_devs[@]}; do
_pdev=$(get_persistent_dev $_dev)
for _dev in ${host_devs[@]}; do
[[ "$_dev" == "$root_dev" ]] && continue
_pdev=$(get_persistent_dev $_dev)
case "$_pdev" in
/dev/?*) wait_for_dev $_pdev;;
*) ;;
esac
done
)
case "$_pdev" in
/dev/?*) wait_for_dev $_pdev;;
*) ;;
esac
done
)
fi
}

View File

@@ -1,10 +1,10 @@
#!/bin/sh
echo 'Generating "/run/initramfs/sosreport.txt"'
echo 'Generating "/run/initramfs/rdsosreport.txt"'
[ -d /run/initramfs ] || mkdir -p /run/initramfs
exec >/run/initramfs/sosreport.txt 2>&1
exec >/run/initramfs/rdsosreport.txt 2>&1
set -x

View File

@@ -76,7 +76,7 @@ install() {
_helpers="$fscks"
fi
if strstr "$_helpers" e2fsck && [ -e /etc/e2fsck.conf ]; then
if [[ "$_helpers" == *e2fsck* ]] && [ -e /etc/e2fsck.conf ]; then
inst_simple /etc/e2fsck.conf
fi

View File

@@ -86,7 +86,7 @@ _check_shutdown() {
[ -e "$__f" ] || continue
( . "$__f" $1 )
if [ $? -eq 0 ]; then
rm -f $__f
rm -f -- $__f
__s=0
fi
done

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes

View File

@@ -20,7 +20,7 @@ test_run() {
}
test_setup() {
rm -f $TESTDIR/root.ext3
rm -f -- $TESTDIR/root.ext3
# Create the blank file to use as a root filesystem
dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
@@ -66,7 +66,7 @@ test_setup() {
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes

View File

@@ -1,7 +1,7 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on a ext3 filesystem"
KVERSION=${KVERSION-$(uname -r)}
KVERSION="${KVERSION-$(uname -r)}"
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
@@ -16,7 +16,7 @@ test_run() {
}
test_setup() {
rm -f $TESTDIR/root.ext3
rm -f -- $TESTDIR/root.ext3
# Create the blank file to use as a root filesystem
dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
@@ -62,7 +62,7 @@ test_setup() {
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes

View File

@@ -45,8 +45,8 @@ test_run() {
}
test_setup() {
rm -f $TESTDIR/root.btrfs
rm -f $TESTDIR/usr.btrfs
rm -f -- $TESTDIR/root.btrfs
rm -f -- $TESTDIR/usr.btrfs
# Create the blank file to use as a root filesystem
dd if=/dev/null of=$TESTDIR/root.btrfs bs=1M seek=160
dd if=/dev/null of=$TESTDIR/usr.btrfs bs=1M seek=160
@@ -101,7 +101,7 @@ test_setup() {
# echo $TESTDIR/overlay
# echo $TESTDIR/initramfs.makeroot
#exit 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
$testdir/run-qemu \
-hda $TESTDIR/root.btrfs \
@@ -126,7 +126,7 @@ test_setup() {
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes

View File

@@ -8,7 +8,7 @@ export KVERSION=${KVERSION-$(uname -r)}
#DEBUGFAIL="rd.shell rd.break"
#DEBUGFAIL="rd.shell"
#DEBUGOUT="quiet systemd.log_level=debug systemd.log_target=console loglevel=77 rd.info rd.debug"
DEBUGOUT="loglevel=0 systemd.log_level=debug"
DEBUGOUT="loglevel=0 "
client_run() {
local test_name="$1"; shift
local client_opts="$*"
@@ -21,7 +21,7 @@ client_run() {
-hdb $TESTDIR/usr.btrfs \
-hdc $TESTDIR/result \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-net none \
-append "root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
@@ -46,8 +46,8 @@ test_run() {
}
test_setup() {
rm -f $TESTDIR/root.btrfs
rm -f $TESTDIR/usr.btrfs
rm -f -- $TESTDIR/root.btrfs
rm -f -- $TESTDIR/usr.btrfs
# Create the blank file to use as a root filesystem
dd if=/dev/null of=$TESTDIR/root.btrfs bs=1M seek=320
dd if=/dev/null of=$TESTDIR/usr.btrfs bs=1M seek=320
@@ -72,7 +72,7 @@ test_setup() {
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
mount dmesg ifconfig dhclient mkdir cp ping dhclient \
umount strace less setsid tree systemctl
umount strace less setsid tree systemctl reset
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
@@ -87,12 +87,17 @@ test_setup() {
inst /lib/systemd/systemd-remount-fs
inst /lib/systemd/system/systemd-journal-flush.service
inst /etc/sysconfig/init
inst /lib/systemd/system/slices.target
inst /lib/systemd/system/system.slice
dracut_install -o /lib/systemd/system/dracut*
# make a journal directory
mkdir -p $initdir/var/log/journal
# install some basic config files
dracut_install -o \
/etc/machine-id \
/etc/adjtime \
/etc/sysconfig/init \
/etc/passwd \
/etc/shadow \
@@ -106,10 +111,6 @@ test_setup() {
# we want an empty environment
> $initdir/etc/environment
> $initdir/etc/machine-id
# set the hostname
echo systemd-testsuite > $initdir/etc/hostname
# setup the testsuite target
cat >$initdir/etc/systemd/system/testsuite.target <<EOF
@@ -203,7 +204,7 @@ EOF
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
ddebug "Strip binaeries"
find "$initdir" -perm +111 -type f | xargs strip --strip-unneeded | ddebug
find "$initdir" -perm +111 -type f | xargs -r strip --strip-unneeded | ddebug
# copy depmod files
inst /lib/modules/$kernel/modules.order
@@ -242,13 +243,12 @@ EOF
# echo $TESTDIR/overlay
# echo $TESTDIR/initramfs.makeroot
#exit 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
$testdir/run-qemu \
-hda $TESTDIR/root.btrfs \
-hdb $TESTDIR/usr.btrfs \
-m 256M -smp 2 -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1
@@ -263,11 +263,12 @@ EOF
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd" \
-I "/etc/machine-id /etc/hostname" \
-o "dash network plymouth lvm mdraid resume crypt i18n caps dm terminfo usrmount" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -1,6 +1,5 @@
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
[ -b "/dev/mapper/$2" ] && exit 0
echo -n test >/keyfile
/sbin/cryptsetup luksOpen $1 $2 </keyfile
/sbin/cryptsetup luksOpen "$1" "$2" </keyfile

View File

@@ -20,7 +20,7 @@ test_run() {
test_setup() {
DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
# Create the blank file to use as a root filesystem
rm -f $DISKIMAGE
rm -f -- $DISKIMAGE
dd if=/dev/null of=$DISKIMAGE bs=1M seek=40
kernel=$KVERSION
@@ -64,7 +64,7 @@ test_setup() {
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-hda $DISKIMAGE \

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -60,7 +60,7 @@ test_setup() {
-m "dash lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda $TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \

View File

@@ -6,7 +6,7 @@ trap 'poweroff -f' EXIT
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -55,7 +55,7 @@ test_run() {
test_setup() {
# Create the blank file to use as a root filesystem
rm -f $TESTDIR/root.ext2
rm -f -- $TESTDIR/root.ext2
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=40
dd if=/dev/null of=$TESTDIR/disk1.img bs=1M seek=20
dd if=/dev/null of=$TESTDIR/disk2.img bs=1M seek=20
@@ -100,7 +100,7 @@ test_setup() {
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \

View File

@@ -4,7 +4,7 @@ set -x
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -55,7 +55,7 @@ test_run() {
test_setup() {
# Create the blank file to use as a root filesystem
rm -f $TESTDIR/root.ext2
rm -f -- $TESTDIR/root.ext2
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=80
kernel=$KVERSION
@@ -97,7 +97,7 @@ test_setup() {
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda $TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \

View File

@@ -19,7 +19,7 @@ test_run() {
test_setup() {
# Create the blank file to use as a root filesystem
DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
rm -f $DISKIMAGE
rm -f -- $DISKIMAGE
dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024
kernel=$KVERSION
@@ -62,7 +62,7 @@ test_setup() {
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \

View File

@@ -1,7 +1,7 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on a LiveCD dmsquash filesystem"
KVERSION=${KVERSION-$(uname -r)}
KVERSION="${KVERSION-$(uname -r)}"
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell rd.break"
@@ -15,47 +15,47 @@ test_check() {
}
test_run() {
$testdir/run-qemu \
"$testdir"/run-qemu \
-boot order=d \
-cdrom $TESTDIR/livecd.iso \
-hda $TESTDIR/root.img \
-cdrom "$TESTDIR"/livecd.iso \
-hda "$TESTDIR"/root.img \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-net none -kernel /boot/vmlinuz-"$KVERSION" \
-append "root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.img || return 1
-initrd "$TESTDIR"/initramfs.testing
grep -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/root.img || return 1
}
test_setup() {
mkdir -p $TESTDIR/overlay
mkdir -p -- "$TESTDIR"/overlay
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-functions.sh
export initdir="$TESTDIR"/overlay
. "$basedir"/dracut-functions.sh
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
dd if=/dev/zero of=$TESTDIR/root.img count=100
dd if=/dev/zero of="$TESTDIR"/root.img count=100
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
sudo $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "debug dmsquash-live" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
mkdir -p $TESTDIR/root-source
kernel=$KVERSION
mkdir -p -- "$TESTDIR"/root-source
kernel="$KVERSION"
# Create what will eventually be our root filesystem onto an overlay
(
export initdir=$TESTDIR/root-source
. $basedir/dracut-functions.sh
export initdir="$TESTDIR"/root-source
. "$basedir"/dracut-functions.sh
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
mount dmesg ifconfig dhclient mkdir cp ping dhclient \
umount strace less
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
[[ -f ${_terminfodir}/l/linux ]] && break
done
dracut_install -o ${_terminfodir}/l/linux
dracut_install -o "${_terminfodir}"/l/linux
inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
dracut_install grep syslinux isohybrid
@@ -64,12 +64,12 @@ test_setup() {
done
inst_simple /etc/os-release
inst ./test-init.sh /sbin/init
inst $TESTDIR/initramfs.testing "/boot/initramfs-$KVERSION.img"
inst /boot/vmlinuz-$KVERSION
inst "$TESTDIR"/initramfs.testing "/boot/initramfs-$KVERSION.img"
inst /boot/vmlinuz-"$KVERSION"
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
(cd "$initdir"; mkdir -p -- dev sys proc etc var/run tmp )
cp -a -- /etc/ld.so.conf* "$initdir"/etc
sudo ldconfig -r -- "$initdir"
)
python create.py -d -c livecd-fedora-minimal.ks
return 0
@@ -79,4 +79,4 @@ test_cleanup() {
return 0
}
. $testdir/test-functions
. "$testdir"/test-functions

View File

@@ -187,7 +187,7 @@ test_nfsv4() {
test_run() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
rm -f -- $TESTDIR/server.pid
fi
if ! run_server; then
@@ -202,7 +202,7 @@ test_run() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
rm -f -- $TESTDIR/server.pid
fi
return $ret
@@ -327,7 +327,7 @@ test_setup() {
mkdir -p $TESTDIR/mnt/nfs/tftpboot/nfs4-5
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
# Make an overlay with needed tools for the test harness
(
@@ -356,7 +356,7 @@ test_setup() {
test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
rm -f -- $TESTDIR/server.pid
fi
}

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
mkfs.ext3 -j -F /dev/sda && \
mkdir -p /sysroot && \

View File

@@ -84,7 +84,7 @@ test_run() {
ret=$?
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
rm -f -- $TESTDIR/server.pid
fi
return $ret
}
@@ -135,7 +135,7 @@ test_setup() {
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
@@ -154,7 +154,7 @@ test_setup() {
-append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
rm $TESTDIR/client.img
rm -- $TESTDIR/client.img
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-functions.sh
@@ -210,7 +210,7 @@ test_setup() {
)
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
@@ -223,7 +223,7 @@ test_setup() {
test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
rm -f -- $TESTDIR/server.pid
fi
}

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
echo -n test >keyfile
cryptsetup -q luksFormat /dev/sdb /keyfile

View File

@@ -181,7 +181,7 @@ client_run() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
rm -f -- $TESTDIR/server.pid
fi
}
@@ -229,7 +229,7 @@ make_encrypted_root() {
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
@@ -276,7 +276,7 @@ make_client_root() {
)
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
}
make_server_root() {
@@ -321,7 +321,7 @@ make_server_root() {
)
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
}
test_setup() {
@@ -366,7 +366,7 @@ test_setup() {
kill_server() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
rm -f -- $TESTDIR/server.pid
fi
}

View File

@@ -13,20 +13,20 @@ run_server() {
# Start server first
echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
fsck -a $TESTDIR/server.ext3 || return 1
fsck -a "$TESTDIR"/server.ext3 || return 1
$testdir/run-qemu \
-hda $TESTDIR/server.ext3 \
-hda "$TESTDIR"/server.ext3 \
-m 512M -smp 2 \
-display none \
-net socket,listen=127.0.0.1:12350 \
-net nic,macaddr=52:54:01:12:34:56,model=e1000 \
${SERIAL+-serial $SERIAL} \
${SERIAL+-serial "$SERIAL"} \
-watchdog i6300esb -watchdog-action poweroff \
-kernel /boot/vmlinuz-$KVERSION \
-kernel /boot/vmlinuz-"$KVERSION" \
-append "loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
-initrd "$TESTDIR"/initramfs.server \
-pidfile "$TESTDIR"/server.pid -daemonize || return 1
sudo chmod 644 -- "$TESTDIR"/server.pid || return 1
# Cleanup the terminal if we have one
tty -s && stty sane
@@ -46,22 +46,22 @@ client_test() {
echo "CLIENT TEST START: $test_name"
# Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
if ! dd if=/dev/zero of=$TESTDIR/client.img bs=1M count=1; then
if ! dd if=/dev/zero of="$TESTDIR"/client.img bs=1M count=1; then
echo "Unable to make client sda image" 1>&2
return 1
fi
$testdir/run-qemu -hda $TESTDIR/client.img -m 512M -smp 2 -nographic \
$testdir/run-qemu -hda "$TESTDIR"/client.img -m 512M -smp 2 -nographic \
-net socket,connect=127.0.0.1:12350 \
-net nic,macaddr=52:54:00:12:34:$mac1,model=e1000 \
-net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \
-net nic,macaddr=52:54:00:12:34:$mac3,model=e1000 \
-watchdog i6300esb -watchdog-action poweroff \
-kernel /boot/vmlinuz-$KVERSION \
-kernel /boot/vmlinuz-"$KVERSION" \
-append "$cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console loglevel=7" \
-initrd $TESTDIR/initramfs.testing
-initrd "$TESTDIR"/initramfs.testing
if [[ $? -ne 0 ]] || ! grep -F -m 1 -q OK $TESTDIR/client.img; then
if [[ $? -ne 0 ]] || ! grep -F -m 1 -q OK -- "$TESTDIR"/client.img; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
return 1
fi
@@ -69,7 +69,7 @@ client_test() {
for i in $check ; do
echo $i
if ! grep -F -m 1 -q $i $TESTDIR/client.img; then
if ! grep -F -m 1 -q $i -- "$TESTDIR"/client.img; then
echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
return 1
fi
@@ -129,20 +129,20 @@ test_client() {
test_setup() {
# Make server root
dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=60
mke2fs -j -F $TESTDIR/server.ext3
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=60
mke2fs -j -F -- "$TESTDIR"/server.ext3
mkdir -- "$TESTDIR"/mnt
sudo mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
(
export initdir=$TESTDIR/mnt
. $basedir/dracut-functions.sh
export initdir="$TESTDIR"/mnt
. "$basedir"/dracut-functions.sh
(
cd "$initdir";
mkdir -p dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 var/lib/rpcbind var/lib/nfs
mkdir -p -- dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 -- var/lib/rpcbind var/lib/nfs
)
for _f in modules.builtin.bin modules.builtin; do
@@ -161,9 +161,9 @@ test_setup() {
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
[ -f "${_terminfodir}"/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
dracut_install -o "${_terminfodir}"/l/linux
type -P portmap >/dev/null && dracut_install portmap
type -P rpcbind >/dev/null && dracut_install rpcbind
[ -f /etc/netconfig ] && dracut_install /etc/netconfig
@@ -194,27 +194,27 @@ test_setup() {
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
cp -a -- /etc/ld.so.conf* "$initdir"/etc
sudo ldconfig -r -- "$initdir"
dracut_kernel_post
)
# Make client root inside server root
(
export initdir=$TESTDIR/mnt/nfs/client
. $basedir/dracut-functions.sh
export initdir="$TESTDIR"/mnt/nfs/client
. "$basedir"/dracut-functions.sh
dracut_install sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep ls
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
[[ -f ${_terminfodir}/l/linux ]] && break
done
dracut_install -o ${_terminfodir}/l/linux
dracut_install -o "${_terminfodir}"/l/linux
inst_simple /etc/os-release
inst ./client-init.sh /sbin/init
(
cd "$initdir"
mkdir -p dev sys proc etc run
mkdir -p var/lib/nfs/rpc_pipefs
mkdir -p -- dev sys proc etc run
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst /etc/passwd /etc/passwd
@@ -225,47 +225,47 @@ test_setup() {
inst_libdir_file 'libnfsidmap/*.so*'
inst_libdir_file 'libnfsidmap*.so*'
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
cp -a /etc/ld.so.conf* $initdir/etc
cp -a -- /etc/ld.so.conf* "$initdir"/etc
sudo ldconfig -r "$initdir"
)
sudo umount $TESTDIR/mnt
rm -fr $TESTDIR/mnt
sudo umount "$TESTDIR"/mnt
rm -fr -- "$TESTDIR"/mnt
# Make an overlay with needed tools for the test harness
(
export initdir=$TESTDIR/overlay
. $basedir/dracut-functions.sh
export initdir="$TESTDIR"/overlay
. "$basedir"/dracut-functions.sh
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
-m "dash udev-rules base rootfs-block debug kernel-modules watchdog" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
-f $TESTDIR/initramfs.server $KVERSION || return 1
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
# Make client's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
-o "plymouth" \
-a "debug" \
-d "af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
}
kill_server() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
rm -f $TESTDIR/server.pid
if [[ -s "$TESTDIR"/server.pid ]]; then
sudo kill -TERM -- $(cat "$TESTDIR"/server.pid)
rm -f -- "$TESTDIR"/server.pid
fi
}
@@ -273,4 +273,4 @@ test_cleanup() {
kill_server
}
. $testdir/test-functions
. "$testdir"/test-functions

View File

@@ -14,8 +14,8 @@ test_run() {
mkdir -p "$rootdir/sys"
mkdir -p "$rootdir/dev"
trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf "$rootdir"; }; exit $ret;' EXIT
trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf "$rootdir"; }; exit 1;' SIGINT
trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit $ret;' EXIT
trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; }; exit 1;' SIGINT
mount --bind /proc "$rootdir/proc"
mount --bind /sys "$rootdir/sys"

View File

@@ -1,9 +1,9 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 61-dmraid-imsm.rules 64-md-raid.rules 65-md-incremental-imsm.rules 65-md-incremental.rules 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
rm "/etc/udev/rules.d/$x"
rm -f -- "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
# dmraid does not want symlinks in --disk "..."

View File

@@ -47,9 +47,9 @@ test_setup() {
# return 1
# Create the blank file to use as a root filesystem
rm -f $TESTDIR/root.ext2
rm -f $TESTDIR/disk1
rm -f $TESTDIR/disk2
rm -f -- $TESTDIR/root.ext2
rm -f -- $TESTDIR/disk1
rm -f -- $TESTDIR/disk2
dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=1
dd if=/dev/null of=$TESTDIR/disk1 bs=1M seek=80
dd if=/dev/null of=$TESTDIR/disk2 bs=1M seek=80
@@ -92,7 +92,7 @@ test_setup() {
-m "dash lvm mdraid dmraid udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
rm -rf -- $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-hda $TESTDIR/root.ext2 \

View File

@@ -14,4 +14,15 @@ $(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS="-kernel-kqemu "
echo "Please install kvm or qemu." >&2
exit 1
}
exec sudo $BIN $ARGS "$@"
KVERSION=${KVERSION-$(uname -r)}
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
else
VMLINUZ="/boot/vmlinuz-${KVERSION}"
fi
exec sudo $BIN $ARGS -kernel $VMLINUZ "$@"

View File

@@ -46,8 +46,8 @@ while (($# > 0)); do
--clean)
echo "TEST CLEANUP: $TEST_DESCRIPTION"
test_cleanup
rm -fr "$TESTDIR"
rm -f .testdir
rm -fr -- "$TESTDIR"
rm -f -- .testdir
exit $?;;
--all)
check_root
@@ -63,8 +63,8 @@ while (($# > 0)); do
test_setup && test_run
ret=$?
test_cleanup
rm -fr "$TESTDIR"
rm -f .testdir
rm -fr -- "$TESTDIR"
rm -f -- .testdir
exit $ret
) </dev/null >test.log 2>&1
else
@@ -73,15 +73,15 @@ while (($# > 0)); do
test_setup && test_run
ret=$?
test_cleanup
rm -fr "$TESTDIR"
rm -f .testdir
rm -fr -- "$TESTDIR"
rm -f -- .testdir
exit $ret
) </dev/null 2>&1 | tee test.log
fi
ret=$?
set +o pipefail
if [ $ret -eq 0 ]; then
rm test.log
rm -- test.log
SETCOLOR_SUCCESS
echo "[OK]"
SETCOLOR_NORMAL