Compare commits

..

1 Commits

Author SHA1 Message Date
Harald Hoyer
02844ff664 dracut.sh: add check for invalid configuration files
Emit a warning about possible misconfigured configuration files, where
the spaces around values are missing for +=""

Better report a possible source of problems. We can fix annoying false
positives later.
2019-10-23 14:16:56 +02:00
353 changed files with 4686 additions and 9323 deletions

View File

@@ -1,25 +1,7 @@
; Directory Local Variables
; For more information see (info "(emacs) Directory Variables")
; Sets emacs variables based on mode.
; A list of (major-mode . ((var1 . value1) (var2 . value2)))
; Mode can be nil, which gives default values.
; Characters width is set to 109 for .c and XML but for everything else 79.
; If you update this file make sure to update .vimrc and .editorconfig too.
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((sh-mode
(indent-tabs-mode)
(sh-basic-offset . 4)))
((c-mode . ((fill-column . 109)
(c-basic-offset . 8)
(eval . (c-set-offset 'substatement-open 0))
(eval . (c-set-offset 'statement-case-open 0))
(eval . (c-set-offset 'case-label 0))
(eval . (c-set-offset 'arglist-intro '++))
(eval . (c-set-offset 'arglist-close 0))
(eval . (c-set-offset 'arglist-cont-nonempty '(c-lineup-gcc-asm-reg c-lineup-arglist)))))
(nxml-mode . ((nxml-child-indent . 2)
(fill-column . 109)))
(meson-mode . ((meson-indent-basic . 8)))
(sh-mode . ((sh-basic-offset . 4)
(sh-indentation . 4)))
(awk-mode . ((c-basic-offset . 8)))
(nil . ((indent-tabs-mode . nil)
(tab-width . 8)
(fill-column . 79))) )

View File

@@ -1,29 +0,0 @@
# EditorConfig configuration for dracut
# http://EditorConfig.org
# If you update this file make sure to update .dir-locals.el and .vimrc too.
# Top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file, utf-8 charset
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
# Match config files, set indent to spaces with width of eight.
[*.{c,h}]
indent_style = space
indent_size = 8
# Match config files, set indent to spaces with width of four.
[*.sh]
indent_style = space
indent_size = 4
# Match xml man pages, set indent to spaces with width of two.
[man/*.xml]
indent_style = space
indent_size = 2

9
.github/CODEOWNERS vendored
View File

@@ -1,9 +0,0 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @haraldh @danimo @johannbg

View File

@@ -1,56 +0,0 @@
# Dracut Code of Conduct
This code of conduct outlines our expectations for participants within the Dracut community, as well as steps for reporting unacceptable behavior.
We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored.
Anyone who violates this code of conduct may be banned from the community.
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project maintainer responsible for enforcement Harald Hoyer <harald@redhat.com>.
All complaints will be reviewed and investigated promptly and fairly and will result in a response that is deemed necessary and appropriate to the circumstances.
Project maintainers are obligated to respect the privacy and security of the reporter of any incident.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq.
Translations are available at https://www.contributor-covenant.org/translations.

View File

@@ -1,26 +0,0 @@
---
name: "\U0001F41B Bug report"
about: A report of an error in a recent Dracut version
labels: 'bug'
---
**Describe the bug**
A clear and concise description of what the error is.
**Distribution used**
Which distribution was this behaviour seen in?
**Dracut version**
Which dracut version was this behaviour seen in?
**Init system**
Which init system is being used?
**To Reproduce**
Steps or code to reproduce the behavior.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Additional context**
Add any other context you like about the problem here.

View File

@@ -1,8 +0,0 @@
---
name: "\U0001F4D6 Documentation"
about: Suggest an improvement for documentation in Dracut
labels: 'documents'
---
**Describe the documentation**
A clear and concise description of what should be better documented.

View File

@@ -1,8 +0,0 @@
---
name: "\U00002728 Feature Request"
about: A request for enhancement in Dracut
labels: 'enhancement'
---
**Describe the enhancement**
A clear and concise description of what the enhancement is that you would like to see.

3
.github/SECURITY.md vendored
View File

@@ -1,3 +0,0 @@
Security is very important to us. If you discover any issue regarding security, we'd appreciate a non-public disclosure of
the information, so please disclose the information responsibly by sending an email to Harald Hoyer harald@redhat.com and not by creating a GitHub issue.
We will respond swiftly to fix verifiable security issues with the disclosure being coordinated with distributions and relevant security teams.

296
.github/labeler.yml vendored
View File

@@ -1,296 +0,0 @@
needs review:
- "*"
repository:
- ./*
github:
- .github/*
- .github/**/*
dracut-install:
- install/*
- install/**/*
example:
- examples/*
- examples/**/*
- examples/**/**/*
modules:
- modules.d/*
- modules.d/**/*
bash:
- modules.d/00bash/*
bootchart:
- modules.d/00bootchart/*
dash:
- modules.d/00dash/*
mksh:
- modules.d/00mksh/*
systemd:
- modules.d/00systemd/*
warpclock:
- modules.d/00warpclock/*
fips:
- modules.d/01fips/*
systemd-initrd:
- modules.d/01systemd-initrd/*
caps:
- modules.d/02caps/*
systemd-networkd:
- modules.d/02systemd-networkd/*
modsign:
- modules.d/03modsign/*
rescue:
- modules.d/03rescue/*
watchdog:
- modules.d/04watchdog/*
busybox:
- modules.d/05busybox/*
rngd:
- modules.d/06rngd/*
i18n:
- modules.d/10i18n/*
convertfs:
- modules.d/30convertfs/*
network-legacy:
- modules.d/35network-legacy/*
network-manager:
- modules.d/35network-manager/*
network:
- modules.d/40network/*
ifcfg:
- modules.d/45ifcfg/*
url-lib:
- modules.d/45url-lib/*
drm:
- modules.d/50drm/*
gensplash:
- modules.d/50gensplash/*
plymouth:
- modules.d/50plymouth/*
cms:
- modules.d/80cms/*
lvmmerge:
- modules.d/80lvmmerge/*
cio_ignore:
- modules.d/81cio_ignore/*
btrfs:
- modules.d/90btrfs/*
crypt:
- modules.d/90crypt/*
dm:
- modules.d/90dm/*
dmraid:
- modules.d/90dmraid/*
dmsquash-live:
- modules.d/90dmsquash-live/*
dmsquash-live-ntfs:
- modules.d/90dmsquash-live-ntfs/*
kernel-modules:
- modules.d/90kernel-modules/*
kernel-modules-extra:
- modules.d/90kernel-modules-extra/*
kernel-network-modules:
- modules.d/90kernel-network-modules/*
livenet:
- modules.d/90livenet/*
lvm:
- modules.d/90lvm/*
mdraid:
- modules.d/90mdraid/*
multipath:
- modules.d/90multipath/*
nvdimm:
- modules.d/90nvdimm/*
ppcmac:
- modules.d/90ppcmac/*
qemu:
- modules.d/90qemu/*
qemu-net:
- modules.d/90qemu-net/*
stratis:
- modules.d/90stratis/*
crypt-gpg:
- modules.d/91crypt-gpg/*
crypt-loop:
- modules.d/91crypt-loop/*
zipl:
- modules.d/91zipl/*
cifs:
- modules.d/95cifs/*
dasd:
- modules.d/95dasd/*
dasd_mod:
- modules.d/95dasd_mod/*
dasd_rules:
- modules.d/95dasd_rules/*
dcssblk:
- modules.d/95dcssblk/*
debug:
- modules.d/95debug/*
fcoe:
- modules.d/95fcoe/*
fcoe-uefi:
- modules.d/95fcoe-uefi/*
fstab-sys:
- modules.d/95fstab-sys/*
iscsi:
- modules.d/95iscsi/*
lunmask:
- modules.d/95lunmask/*
nbd:
- modules.d/95nbd/*
nfs:
- modules.d/95nfs/*
nvmf:
- modules.d/95nvmf/*
qeth_rules:
- modules.d/95qeth_rules/*
resume:
- modules.d/95resume/*
rootfs-block:
- modules.d/95rootfs-block/*
ssh-client:
- modules.d/95ssh-client/*
terminfo:
- modules.d/95terminfo/*
udev-rules:
- modules.d/95udev-rules/*
virtfs:
- modules.d/95virtfs/*
zfcp:
- modules.d/95zfcp/*
zfcp_rules:
- modules.d/95zfcp_rules/*
znet:
- modules.d/95znet/*
securityfs:
- modules.d/96securityfs/*
biosdevname:
- modules.d/97biosdevname/*
masterkey:
- modules.d/97masterkey/*
dracut-systemd:
- modules.d/98dracut-systemd/*
ecryptfs:
- modules.d/98ecryptfs/*
integrity:
- modules.d/98integrity/*
pollcdrom:
- modules.d/98pollcdrom/*
selinux:
- modules.d/98selinux/*
syslog:
- modules.d/98syslog/*
usrmount:
- modules.d/98usrmount/*
base:
- modules.d/99base/*
fs-lib:
- modules.d/99fs-lib/*
img-lib:
- modules.d/99img-lib/*
memstrack:
- modules.d/99memstrack/*
shutdown:
- modules.d/99shutdown/*
squash:
- modules.d/99squash/*
uefi-lib:
- modules.d/99uefi-lib/*
test:
- test/*
- test/**/*

View File

@@ -1,10 +0,0 @@
This pull request changes...
## Changes
## Checklist
- [ ] I have tested it locally
- [ ] I have reviewed and updated any documentation if relevant
- [ ] I am providing new code and test(s) for it
Fixes #

21
.github/stale.yml vendored
View File

@@ -1,21 +0,0 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 30
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- documents
- enhancement
- regression
- wiki
- bug
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue is being marked as stale because it has not had any recent activity.
It will be closed if no further activity occurs.
If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days.
Thank you for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View File

@@ -1,48 +0,0 @@
## The test container is created with https://github.com/dracutdevs/fedora-container
name: Fedora-32
on:
push:
branches:
- 'master'
jobs:
test:
runs-on: ubuntu-latest
container:
image: quay.io/haraldh/dracut-fedora:32
options: "-v /dev/kvm:/dev/kvm"
timeout-minutes: 45
strategy:
matrix:
test: [
"01",
"02",
"03",
"04",
"10",
"11",
"12",
"13",
"14",
"15",
"17",
"20",
"21",
"30",
"31",
"35",
"36",
"40",
"41",
]
fail-fast: false
steps:
- name: "Checkout Repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "TEST-${{ matrix.test }}"
run: ./fedora-test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }}

View File

@@ -1,49 +0,0 @@
## The test container is created with https://github.com/dracutdevs/fedora-container
name: Fedora-33
on:
push:
branches:
- 'master'
pull_request:
jobs:
test:
runs-on: ubuntu-latest
container:
image: quay.io/haraldh/dracut-fedora:33
options: "-v /dev/kvm:/dev/kvm"
timeout-minutes: 45
strategy:
matrix:
test: [
"01",
"02",
"03",
"04",
"10",
"11",
"12",
"13",
"14",
"15",
"17",
"20",
"21",
"30",
"31",
"35",
"36",
"40",
"41",
]
fail-fast: false
steps:
- name: "Checkout Repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "TEST-${{ matrix.test }}"
run: ./fedora-test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }}

View File

@@ -1,48 +0,0 @@
## The test container is created with https://github.com/dracutdevs/fedora-container
name: Fedora-latest
on:
push:
branches:
- 'master'
jobs:
test:
runs-on: ubuntu-latest
container:
image: quay.io/haraldh/dracut-fedora:latest
options: "-v /dev/kvm:/dev/kvm"
timeout-minutes: 45
strategy:
matrix:
test: [
"01",
"02",
"03",
"04",
"10",
"11",
"12",
"13",
"14",
"15",
"17",
"20",
"21",
"30",
"31",
"35",
"36",
"40",
"41",
]
fail-fast: false
steps:
- name: "Checkout Repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "TEST-${{ matrix.test }}"
run: ./fedora-test-github.sh "TEST-${{ matrix.test }}" ${{ matrix.test }}

View File

@@ -1,15 +0,0 @@
name: Label the Pull Requests automatically via Cron
on:
schedule:
- cron: '*/15 * * * *'
jobs:
label:
runs-on: ubuntu-18.04
steps:
- uses: paulfantom/periodic-labeler@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
LABEL_MAPPINGS_FILE: .github/labeler.yml

View File

@@ -1,19 +0,0 @@
name: Commisery
on:
pull_request:
types: [edited, opened, synchronize, reopened]
jobs:
commit-message:
name: Conventional Commit Message Checker (Commisery)
runs-on: ubuntu-latest
steps:
- name: Check-out the repo under $GITHUB_WORKSPACE
uses: actions/checkout@v2
- name: Run Commisery
uses: dracutdevs/commisery-action@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull_request: ${{ github.event.number }}

View File

@@ -31,7 +31,3 @@ Lidong Zhong <lidong.zhong@suse.com> <lzhong@suse.com>
Nikoli <nikoli@gmx.us> <nikoli@lavabit.com>
Peter Robinson <pbrobinson@fedoraproject.org> <pbrobinson@gmail.com>
Xunlei Pang <xlpang@redhat.com> <xpang@redhat.com>
Daniel Molkentin <daniel.molkentin@suse.com> <dmolkentin@suse.com>
Thomas Blume <thomas.blume@suse.com> <Thomas.Blume@suse.com>
Brian C. Lane <bcl@redhat.com> <bcl@brianlane.com>
Tomasz Paweł Gajc <tpgxyz@gmail.com> <tpgxyz@gmail.com>

View File

@@ -1,58 +0,0 @@
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# The name of the upstream package
upstream_package_name: dracut
# The upstream tag versioning scheme
upstream_tag_template: "{version}"
# The URL of the upstream project
upstream_project_url: https://github.com/dracutdevs/dracut
# Relative path to a spec file within the upstream repository
specfile_path: dracut.spec
# Name of the downstream package
downstream_package_name: dracut
# The URL of the downstream project
dist_git_base_url: https://src.fedoraproject.org/
# Sync file(s) from upstream repo to dist-git
synced_files:
# The dracut spec file is maintained upstream so we sync it downstream.
- dracut.spec
# We sync the packit file downstream be able to optionally use the sync-from-downstream command
- .packit.yaml
# We want new releases to be automatically built on rawhide and have few jobs
# on copr.
create_pr: false
jobs:
- job: propose_downstream
trigger: release
metadata:
dist_git_branches: master
- job: tests
trigger: pull_request
metadata:
targets:
- fedora-rawhide
- job: copr_build
trigger: pull_request
metadata:
targets:
- fedora-rawhide
- job: copr_build
trigger: commit
metadata:
targets:
- fedora-rawhide
branch: master
owner: "@dracut"
project: Dracut
preserve_project: True

49
.travis.yml Normal file
View File

@@ -0,0 +1,49 @@
language: generic
dist: bionic
sudo: required
services:
- docker
env:
matrix:
- IMAGE=latest
- IMAGE=latest TESTS=01
- IMAGE=latest TESTS=12
- IMAGE=latest TESTS=20
- IMAGE=latest TESTS=50
- IMAGE=latest TESTS=30
- IMAGE=latest TESTS=31
- IMAGE=latest TESTS=60
- IMAGE=latest TESTS=70
- IMAGE=latest TESTS=99
- IMAGE=latest TESTS=02
- IMAGE=latest TESTS=03
- IMAGE=latest TESTS=04
- IMAGE=latest TESTS=10
- IMAGE=latest TESTS=11
- IMAGE=29 TESTS=13
- IMAGE=29 TESTS=14
- IMAGE=latest TESTS=15
- IMAGE=latest TESTS=17
before_script:
- docker pull fedora:$IMAGE
- |
sudo modprobe kvm-intel nested=1 || :
sudo modprobe kvm-amd nested=1 || :
dmesg | tail || :
- git fetch --tags --unshallow
- |
git describe --abbrev=0 --tags || :
git describe --tags || :
script:
- docker run --privileged -it -v $(pwd)/:/dracut fedora:$IMAGE /dracut/fedora-test.sh $IMAGE-$$ "$TESTS"
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/effa917ca3e0ed5fd00e
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always

15
.vimrc
View File

@@ -1,15 +0,0 @@
" Vim can use per directory configuration files like this.
" To enable that feature two lines are needed in your ~/.vimrc
" set exrc " enables per-directory .vimrc files
" set secure " disable unsafe commands in local .vimrc files
" Characters width is set to 109 for .c and XML but for everything else 79.
" If you update this file make sure to update .dir-locals.el & .editorconfig
set tabstop=8
set shiftwidth=8
set expandtab
set makeprg=GCC_COLORS=\ make
set tw=79
au BufRead,BufNewFile *.xml set tw=109 shiftwidth=2 smarttab
au FileType sh set tw=80 shiftwidth=4 smarttab
au FileType c set tw=109

View File

@@ -48,7 +48,6 @@ case "$COMMAND" in
unset noimageifnotneeded
for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
# shellcheck disable=SC1001
if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
noimageifnotneeded="yes"
break

68
51-dracut-rescue-postinst.sh Executable file
View File

@@ -0,0 +1,68 @@
#!/bin/bash
export LANG=C
KERNEL_VERSION="$1"
KERNEL_IMAGE="$2"
[[ -f /etc/os-release ]] && . /etc/os-release
if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
systemd-machine-id-setup
fi
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
[[ $MACHINE_ID ]] || exit 1
[[ -f $KERNEL_IMAGE ]] || exit 1
INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
dropindirs_sort()
{
suffix=$1; shift
args=("$@")
files=$(
while (( $# > 0 )); do
for i in ${1}/*${suffix}; do
[[ -f $i ]] && echo ${i##*/}
done
shift
done | sort -Vu
)
for f in $files; do
for d in "${args[@]}"; do
if [[ -f "$d/$f" ]]; then
echo "$d/$f"
continue 2
fi
done
done
}
# source our config dir
for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
[[ -e $f ]] && . "$f"
done
[[ $dracut_rescue_image != "yes" ]] && exit 0
if [[ ! -f $INITRDFILE ]]; then
dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
((ret+=$?))
fi
if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
cp --reflink=auto "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
((ret+=$?))
fi
new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
((ret+=$?))
exit $ret

View File

@@ -14,8 +14,8 @@ dropindirs_sort()
args=("$@")
files=$(
while (( $# > 0 )); do
for i in "${1}"/*"${suffix}"; do
[[ -f $i ]] && echo "${i##*/}"
for i in ${1}/*${suffix}; do
[[ -f $i ]] && echo ${i##*/}
done
shift
done | sort -Vu
@@ -36,7 +36,7 @@ dropindirs_sort()
if [[ ${KERNEL_INSTALL_MACHINE_ID+x} ]]; then
MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID
elif [[ -f /etc/machine-id ]] ; then
read -r MACHINE_ID < /etc/machine-id
read MACHINE_ID < /etc/machine-id
fi
if ! [[ $MACHINE_ID ]]; then
@@ -80,13 +80,9 @@ case "$COMMAND" in
# source our config dir
for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
if [[ -e $f ]]; then
# shellcheck disable=SC1090
. "$f"
fi
[[ -e $f ]] && . "$f"
done
# shellcheck disable=SC2154
[[ $dracut_rescue_image != "yes" ]] && exit 0
[[ -d "$BOOT_DIR_ABS" ]] || mkdir -p "$BOOT_DIR_ABS"
@@ -105,17 +101,13 @@ case "$COMMAND" in
echo "title $PRETTY_NAME - Rescue Image"
echo "version $KERNEL_VERSION"
echo "machine-id $MACHINE_ID"
echo "options ${BOOT_OPTIONS[*]} rd.auto=1"
echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
echo "linux $BOOT_DIR/linux"
echo "initrd $BOOT_DIR/initrd"
} > "$LOADER_ENTRY"
} > $LOADER_ENTRY
else
if [[ -e "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" ]]; then
cp -aT "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" "$LOADER_ENTRY"
else
cp -aT "${KERNEL_IMAGE%/*}/bls.conf" "$LOADER_ENTRY"
fi
sed -i "s/${KERNEL_VERSION}/0-rescue-${MACHINE_ID}/" "$LOADER_ENTRY"
cp -aT "${KERNEL_IMAGE%/*}/bls.conf" $LOADER_ENTRY
sed -i 's/'$KERNEL_VERSION'/0-rescue-'${MACHINE_ID}'/' $LOADER_ENTRY
fi
((ret+=$?))

127
AUTHORS
View File

@@ -2,123 +2,98 @@ Harald Hoyer <harald@redhat.com>
Victor Lowther <victor.lowther@gmail.com>
Amadeusz Żołnowski <aidecoe@aidecoe.name>
Hannes Reinecke <hare@suse.com>
Daniel Molkentin <daniel.molkentin@suse.com>
Will Woods <wwoods@redhat.com>
Philippe Seewer <philippe.seewer@bfh.ch>
Warren Togami <wtogami@redhat.com>
Jóhann B. Guðmundsson <johannbg@gmail.com>
Kairui Song <kasong@redhat.com>
Dave Young <dyoung@redhat.com>
Jeremy Katz <katzj@redhat.com>
Lukas Nykryn <lnykryn@redhat.com>
David Dillow <dave@thedillows.org>
Lubomir Rintel <lkundrak@v3.sk>
Michal Soltys <soltys@ziu.info>
Colin Guthrie <colin@mageia.org>
Daniel Molkentin <dmolkentin@suse.com>
Amerigo Wang <amwang@redhat.com>
Thomas Renninger <trenn@suse.com>
Lukas Nykryn <lnykryn@redhat.com>
Alexander Tsoy <alexander@tsoy.me>
Martin Wilck <mwilck@suse.de>
Frederick Grose <fgrose@sugarlabs.org>
WANG Chao <chaowang@redhat.com>
Yu Watanabe <watanabe.yu+github@gmail.com>
Andrey Borzenkov <arvidjaar@gmail.com>
Hans de Goede <hdegoede@redhat.com>
Jonathan Lebon <jonathan@jlebon.com>
Peter Jones <pjones@redhat.com>
Andreas Thienemann <andreas@bawue.net>
Peter Robinson <pbrobinson@fedoraproject.org>
Frantisek Sumsal <frantisek@sumsal.cz>
Fabian Vogt <fvogt@suse.com>
Nicolas Chauvet <kwizart@gmail.com>
Zoltán Böszörményi <zboszor@pr.hu>
Colin Walters <walters@verbum.org>
Kairui Song <kasong@redhat.com>
John Reiser <jreiser@bitwagon.com>
Luca Berra <bluca@vodka.it>
Tomasz Paweł Gajc <tpgxyz@gmail.com>
Xunlei Pang <xlpang@redhat.com>
Brian C. Lane <bcl@redhat.com>
Daniel Drake <drake@endlessm.com>
Lubomir Rintel <lkundrak@v3.sk>
Angelo "pallotron" Failla <pallotron@fb.com>
Beniamino Galvani <bgalvani@redhat.com>
Thomas Blume <thomas.blume@suse.com>
Brian C. Lane <bcl@redhat.com>
Ville Skyttä <ville.skytta@iki.fi>
Böszörményi Zoltán <zboszor@pr.hu>
Cristian Rodríguez <crrodriguez@opensuse.org>
Dan Horák <dhorak@redhat.com>
Javier Martinez Canillas <javierm@redhat.com>
Ondrej Mosnacek <omosnace@redhat.com>
Renaud Métrich <rmetrich@redhat.com>
Baoquan He <bhe@redhat.com>
Brendan Germain <brendan.germain@nasdaqomx.com>
Jonas Witschel <diabonas@gmx.de>
Colin Walters <walters@verbum.org>
Leho Kraav <leho@kraav.com>
Moritz Maxeiner <moritz@ucworks.org>
Nathan Rini <nate@ucar.edu>
Radek Vykydal <rvykydal@redhat.com>
David Tardon <dtardon@redhat.com>
Nicolas Chauvet <kwizart@gmail.com>
Ondrej Mosnacek <omosnace@redhat.com>
Fabian Deutsch <fabiand@fedoraproject.org>
Javier Martinez Canillas <javierm@redhat.com>
Kamil Rytarowski <n54@gmx.com>
Lidong Zhong <lidong.zhong@suse.com>
Marc Grimme <grimme@atix.de>
Mike Gilbert <floppym@gentoo.org>
NeilBrown <neilb@suse.de>
Peter Rajnoha <prajnoha@redhat.com>
Radek Vykydal <rvykydal@redhat.com>
Thorsten Behrens <tbehrens@suse.com>
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
q66 <daniel@octaforge.org>
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Adam Williamson <awilliam@redhat.com>
Chao Wang <chaowang@redhat.com>
Frederic Crozat <fcrozat@suse.com>
James Lee <jlee@thestaticvoid.com>
Jesse Keating <jkeating@redhat.com>
Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Martin Wilck <mwilck@suse.de>
Mike Gilbert <floppym@gentoo.org>
Milan Broz <mbroz@redhat.com>
Mimi Zohar <zohar@linux.vnet.ibm.com>
Norbert Lange <norbert.lange@andritz.com>
Roberto Sassu <roberto.sassu@polito.it>
Stefan Reimer <it@startux.de>
Takashi Iwai <tiwai@suse.de>
Adam Williamson <awilliam@redhat.com>
Anton Blanchard <anton@samba.org>
Bill Nottingham <notting@redhat.com>
Chapman Flack <g2@anastigmatix.net>
Chris Leech <cleech@redhat.com>
David Cantrell <dcantrell@redhat.com>
Dennis Gilmore <dennis@ausil.us>
Doan Tran Cong Danh <congdanhqx@gmail.com>
Gaël PORTAY <gael.portay@collabora.com>
Jan Synacek <jsynacek@redhat.com>
Jiri Konecny <jkonecny@redhat.com>
Jon Ander Hernandez <jonan.h@gmail.com>
Juan RP <xtraeme@gmail.com>
Lance Albertson <lance@osuosl.org>
Marcos Mello <marcosfrm@gmail.com>
Marian Ganisin <mganisin@redhat.com>
Matthias Gerstner <matthias.gerstner@suse.de>
Max Resch <resch.max@gmail.com>
Michael Ploujnikov <plouj@somanetworks.com>
Pratyush Anand <panand@redhat.com>
Silvio Fricke <silvio.fricke@gmail.com>
Steven Brudenell <steven.brudenell@gmail.com>
Stig Telfer <stelfer@cray.com>
Thomas Backlund <tmb@mageia.org>
Topi Miettinen <toiwoton@gmail.com>
Vasiliy Tolstov <v.tolstov@selfip.ru>
Wim Muskee <wimmuskee@gmail.com>
tpgxyz <tpgxyz@gmail.com>
Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Alan Pevec <apevec@redhat.com>
Alex Harpin <development@landsofshadow.co.uk>
Alexey Shabalin <shaba@altlinux.org>
Ankit Kumar <ankit@linux.vnet.ibm.com>
Antony Messerli <amesserl@rackspace.com>
Chao Fan <cfan@redhat.com>
Daniel Cordero <dracut@0xdc.io>
Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Daniel Schaal <farbing@web.de>
Denis Silakov <dsilakov@virtuozzo.com>
Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Dusty Mabe <dusty@dustymabe.com>
Erwan Velu <erwan.velu@enovance.com>
Evgeny Vereshchagin <evvers@ya.ru>
Guido Trentalancia <guido@trentalancia.net>
@@ -126,24 +101,15 @@ Hari Bathini <hbathini@linux.vnet.ibm.com>
Ian Dall <ian@beware.dropbear.id.au>
Imran Haider <imran1008@gmail.com>
James Buren <ryuo@frugalware.org>
Jan Macku <jamacku@redhat.com>
Joey Boggs <jboggs@redhat.com>
Julian Wolf <juwolf@suse.com>
Koen Kooi <koen@dominion.thruhere.net>
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Kyle McMartin <kmcmarti@redhat.com>
Luiz Angelo Daros de Luca <luizluca@gmail.com>
Lukas Wunner <lukas@wunner.de>
Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Marko Myllynen <myllynen@redhat.com>
Matthew Thode <mthode@mthode.org>
Michal Koutný <mkoutny@suse.com>
Mike Snitzer <snitzer@redhat.com>
Minfei Huang <mhuang@redhat.com>
Nikoli <nikoli@gmx.us>
Patrick Talbert <ptalbert@redhat.com>
Pedro Monreal <pmgdeb@gmail.com>
Petr Pavlu <petr.pavlu@suse.com>
Pingfan Liu <piliu@redhat.com>
Przemysław Rudy <prudy1@o2.pl>
Robert LeBlanc <robert@leblancnet.us>
@@ -154,29 +120,15 @@ Till Maas <opensource@till.name>
Tony Asleson <tasleson@redhat.com>
Vivek Goyal <vgoyal@redhat.com>
Vladislav Bogdanov <bubble@hoster-ok.com>
Érico Rolim <erico.erc@gmail.com>
наб <nabijaczleweli@nabijaczleweli.xyz>
A. Wilcox <AWilcox@Wilcox-Tech.com>
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Alexander Kurtz <alexander@kurtz.be>
Alexander Miroshnichenko <alex@millerson.name>
Alexander Sosedkin <asosedkin@redhat.com>
Alexander Todorov <atodorov@redhat.com>
Alexey Kodanev <alexey.kodanev@oracle.com>
Andreas Schwab <schwab@suse.de>
Andreas Stieger <astieger@suse.com>
Andrew J. Hesford <ajh@sideband.org>
Andy Lutomirski <luto@mit.edu>
Anjali Kulkarni <anjali.k.kulkarni@oracle.com>
Anssi Hannula <anssi@mageia.org>
Antz <antzz@protonmail.ch>
Arnaud Rebillout <arnaud.rebillout@collabora.com>
Artem Savkov <asavkov@redhat.com>
Attila Bruncsak <bruncsak@users.noreply.github.com>
B. Wilson <x@wilsonb.com>
Ben Howard <ben.howard@redhat.com>
Benjamin Marzinski <bmarzins@redhat.com>
Brandon Philips <brandon@ifup.co>
Bruno E. O. Meneguele <bmeneg@redhat.com>
Bryn M. Reeves <bmr@redhat.com>
Canek Peláez Valdés <caneko@gmail.com>
Carlo Caione <carlo@endlessm.com>
@@ -187,125 +139,90 @@ Dan Fuhry <dfuhry@datto.com>
Dave Jones <davej@redhat.com>
David Disseldorp <ddiss@suse.de>
David Michael <david.michael@coreos.com>
Denis Volkov <denis@simpletexting.net>
Dennis Schridde <devurandom@gmx.net>
Derek Hageman <hageman@inthat.cloud>
Derek Higgins <derekh@redhat.com>
Donovan Tremura <neurognostic@protonmail.ch>
Duane Griffin <duaneg@dghda.com>
Elan Ruusamäe <glen@delfi.ee>
Enno Boland <g@s01.de>
Enzo Matsumiya <ematsumiya@suse.de>
Eugene S. Sobolev <sobolev@protei.ru>
Eugene Syromiatnikov <esyr@redhat.com>
Evgeni Golov <evgeni@golov.de>
Fabian Vogt <fvogt@suse.de>
Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
Florian Gamböck <mail@floga.de>
Frank Deng <frank.deng@oracle.com>
François Cami <fcami@fedoraproject.org>
Gerd von Egidy <gerd.von.egidy@intra2net.com>
Glen Gray <slaine@slaine.org>
GuoChuang <guo.chuang@zte.com.cn>
HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Hendrik Brueckner <brueckner@linux.ibm.com>
Hermann Gausterer <git-dracut-2012@mrq1.org>
Hiroaki Mizuguchi <hiroaki-m@iij.ad.jp>
Hongxu Jia <hongxu.jia@windriver.com>
Hui Wang <john.wanghui@huawei.com>
Ignaz Forster <iforster@suse.com>
Jacob Wen <jian.w.wen@oracle.com>
James Laska <jlaska@redhat.com>
Jan Stodola <jstodola@redhat.com>
Jason Dana <jasondana@quarksecurity.com>
Jens Heise <46450477+heisej@users.noreply.github.com>
Jeremy Linton <lintonrjeremy@gmail.com>
Jiri Pirko <jiri@resnulli.us>
Joe Lawrence <Joe.Lawrence@stratus.com>
Johannes Thumshirn <jthumshirn@suse.com>
Jonas Jonsson <jonas@websystem.se>
Jonas Witschel <diabonas@archlinux.org>
Kevin Yung <Kevin.Yung@myob.com>
Lars R. Damerow <lars@pixar.com>
Lee Duncan <lduncan@suse.com>
Lennert Buytenhek <buytenh@wantstofly.org>
Lianbo Jiang <lijiang@redhat.com>
Lucas C. Villa Real <lucasvr@gmail.com>
Major Hayden <major@mhtx.net>
Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Marian Csontos <mcsontos@redhat.com>
Mark Fasheh <mfasheh@suse.de>
Marko Myllynen <myllynen@redhat.com>
Matt <smoothsailing72@hotmail.com>
Matt Smith <shadowfax@gmx.com>
Matthew Thode <mthode@mthode.org>
Mei Liu <liumbj@linux.vnet.ibm.com>
Michael Chapman <mike@very.puzzling.org>
Michael McCracken <michael.mccracken@gmail.com>
Michal Koutný <mkoutny@suse.com>
Michal Schmidt <mschmidt@redhat.com>
Michal Sekletar <msekleta@redhat.com>
Mike Gorse <mgorse@suse.com>
Moritz 'Morty' Strübe <morty@gmx.net>
Munehiro Matsuda <haro@kgt.co.jp>
Nicolas Porcel <nicolasporcel06@gmail.com>
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Olivier Blin <dev@blino.org>
Ondrej Dubaj <odubaj@redhat.com>
P J P <ppandit@redhat.com>
Paolo Bonzini <pbonzini@redhat.com>
Paul Robins <exp@users.noreply.github.com>
Pavel Zhukov <pzhukov@redhat.com>
Pawel Wieczorkiewicz <pwieczorkiewicz@suse.de>
Pekka Wallendahl <wyrmiyu@gmail.com>
Peter Georg <peter.georg@physik.uni-regensburg.de>
Peter Levine <plevine457@gmail.com>
Petr Tesarik <ptesarik@suse.com>
Petr Vorel <pvorel@suse.cz>
Prarit Bhargava <prarit@redhat.com>
Praveen_Paladugu@Dell.com <Praveen_Paladugu@Dell.com>
Pádraig Brady <P@draigBrady.com>
Quentin Armitage <quentin@armitage.org.uk>
Renaud Métrich <rmetrich@redhat.com>
Robert Buchholz <rbu@goodpoint.de>
Ruben Kerkhof <ruben@rubenkerkhof.com>
Rumbaut Thomas <Thomas.Rumbaut@digipolis.gent>
Rusty Bird <rustybird@openmailbox.org>
Sebastian Mitterle <smitterl@redhat.com>
Sergei Iudin <tsipa740@gmail.com>
Sergey Fionov <fionov@gmail.com>
Shawn W Dunn <sfalken@opensuse.org>
Srinivasa T N <seenutn@linux.vnet.ibm.com>
Stijn Hoop <stijn@sandcat.nl>
Sullivan (CTR), Austin <austin.sullivan.ctr@progeny.net>
Thierry Vignaud <thierry.vignaud@gmail.com>
Thilo Bangert <thilo.bangert@gmx.net>
Thomas Abraham <tabraham@suse.com>
Thomas Blume <thomas.blume@suse.com>
Tobias Geerinckx <tobias.geerinckx@gmail.com>
Tobias Klauser <tklauser@distanz.ch>
Tom Gundersen <teg@jklm.no>
Tomasz Paweł Gajc <tpgxyz@gmail.com>
Tomasz Torcz <tomek@pipebreaker.pl>
Tong Li <tonli@redhat.com>
Vadim Kuznetsov <vadimk@gentoo.org>
Vaughan Cao <vaughan.cao@oracle.com>
Vladius25 <vkorol2509@icloud.com>
Vratislav Podzimek <vpodzime@redhat.com>
Yang Liu <50459973+ly4096x@users.noreply.github.com>
Yanko Kaneti <yaneti@declera.com>
Zhiguo Deng <bjzgdeng@linux.vnet.ibm.com>
Ziyue Yang <ziyang@redhat.com>
foopub <45460217+foopub@users.noreply.github.com>
gaoyi <ymuemc@163.com>
honza801 <honza801@gmail.com>
jbash aka John Bashinski <jbash@velvet.com>
jloeser <jloeser@suse.de>
johannes <johannes.brechtmann@gmail.com>
jonathan-teh <30538043+jonathan-teh@users.noreply.github.com>
leo-lb <lle-bout@zaclys.net>
logan <logancaldwell23@gmail.com>
masem <matej.semian@gmail.com>
maximilian attems <max@stro.at>
mulhern <amulhern@redhat.com>
mwberry <mwberry@users.noreply.github.com>
nabijaczleweli <nabijaczleweli@gmail.com>
privb0x23 <privb0x23@users.noreply.github.com>
realtime-neil <neil@rtr.ai>
tpg <tpgxyz@gmail.com>
xtraeme <xtraeme@voidlinux.eu>
Дамјан Георгиевски <gdamjan@gmail.com>

23
HACKING Normal file
View File

@@ -0,0 +1,23 @@
Right now, most of the testing is done using a qemu/kvm guest and
generating the initramfs on another box but the support is all present
to build for the "running" machine. For the former, you can boot the guest
using qemu's -kernel and -initrd options.
dracut exists and will build an image. It is command-line equivalent
to most mkinitrd implementations and should be pretty straight-forward
to use.
To use, just run dracut with an output file name and, optionally, a
kernel version (it defaults to using the current). The appropriate
modules will be copied over and things should be good to go. If you'd
like to customize the list of modules copied in, edit /etc/dracut.conf
and set
dracutmodules="foo bar baz"
Note that dracut calls functional components in modules.d "modules"
while kernel modules are called "drivers".
Requirements:
* udev
* nfs module: nfs daemon and rpc helper
* iscsi: iscsi

View File

@@ -1,248 +0,0 @@
# Dracut Developer Guidelines
## git
Currently dracut lives on github.com and kernel.org.
* https://github.com/dracutdevs/dracut.git
* https://git.kernel.org/pub/scm/boot/dracut/dracut.git
Pull requests should be filed preferably on github nowadays.
### Commit Messages
Commit messages should answer these questions:
* What?: a short summary of what you changed in the subject line.
* Why?: what the intended outcome of the change is (arguably the most important piece of information that should go into a message).
* How?: if multiple approaches for achieving your goal were available, you also want to explain why you chose the used implementation strategy.
Note that you should not explain how your change achieves your goal in your commit message.
That should be obvious from the code itself.
If you cannot achieve that clarity with the used programming language, use comments within the code instead.
The commit message is primarily the place for documenting the why.
Commit message titles should follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
Format is `<type>[optional scope]: <description>`, where `type` is one of:
* fix: A bug fix
* feat: A new feature
* perf: A code change that improves performance
* refactor: A code change that neither fixes a bug nor adds a feature
* style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
* test: Adding missing tests or correcting existing tests
* docs: Documentation only changes
* revert: Reverts a previous commit
* chore: Other changes that don't modify src or test files
* build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
* ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
`scope` should be the module name (without numbers) or:
* cli: for the dracut command line interface
* rt: for the dracut initramfs runtime logic
* functions: for general purpose dracut functions
Commit messages are checked with [Commisery](https://github.com/tomtom-international/commisery).
## Writing modules
Some general rules for writing modules:
* Use one of the inst family of functions to actually install files
on to the initramfs. They handle mangling the pathnames and (for binaries,
scripts, and kernel modules) installing dependencies as appropriate so
you do not have to.
* Scripts that end up on the initramfs should be POSIX compliant. dracut
will try to use /bin/dash as /bin/sh for the initramfs if it is available,
so you should install it on your system -- dash aims for strict POSIX
compliance to the extent possible.
* Hooks MUST be POSIX compliant -- they are sourced by the init script,
and having a bashism break your user's ability to boot really sucks.
* Generator modules should have a two digit numeric prefix -- they run in
ascending sort order. Anything in the 90-99 range is stuff that dracut
relies on, so try not to break those hooks.
* Hooks must have a .sh extension.
* Generator modules are described in more detail later on.
* We have some breakpoints for debugging your hooks. If you pass 'rdbreak'
as a kernel parameter, the initramfs will drop to a shell just before
switching to a new root. You can pass 'rdbreak=hookpoint', and the initramfs
will break just before hooks in that hookpoint run.
Also, there is an attempt to keep things as distribution-agnostic as
possible. Every distribution has their own tool here and it's not
something which is really interesting to have separate across them.
So contributions to help decrease the distro-dependencies are welcome.
Most of the functionality that dracut implements are actually implemented
by dracut modules. dracut modules live in modules.d, and have the following
structure:
```
dracut_install_dir/modules.d/
00modname/
module-setup.sh
check
<other files as needed by the hook>
```
`00modname`: The name of the module prefixed by a two-digit numeric sort code.
The numeric code must be present and in the range of 00 - 99.
Modules with lower numbers are installed first. This is important
because the dracut install functions (which install files onto
the initrd) refuse to overwrite already installed files. This makes
it easy for an earlier module to override the functionality of a
later module, so that you can have a distro or system specific
module override or modify the functionality of a generic module
without having to patch the more generic module.
`module-setup.sh`:
dracut sources this script to install the functionality that a
module implements onto the initrd. For the most part, this amounts
to copying files from the host system onto the initrd in a controlled
manner.
`install()`:
This function of module-setup.sh is called to install all
non-kernel files. dracut supplies several install functions that are
specialized for different file types. Browse through dracut-functions
fore more details. dracut also provides a $moddir variable if you
need to install a file from the module directory, such as an initrd
hook, a udev rule, or a specialized executable.
`installkernel()`:
This function of module-setup.sh is called to install all
kernel related files.
`check()`:
dracut calls this function to check and see if a module can be installed
on the initrd.
When called without options, check should check to make sure that
any files it needs to install into the initrd from the host system
are present. It should exit with a 0 if they are, and a 1 if they are
not.
When called with $hostonly set, it should perform the same check
that it would without it set, and it should also check to see if the
functionality the module implements is being used on the host system.
For example, if this module handles installing support for LUKS
encrypted volumes, it should return 0 if all the tools to handle
encrpted volumes are available and the host system has the root
partition on an encrypted volume, 1 otherwise.
`depends()`:
This function should output a list of dracut modules
that it relies upon. An example would be the nfs and iscsi modules,
which rely on the network module to detect and configure network
interfaces.
Any other files in the module will not be touched by dracut directly.
You are encouraged to provide a README that describes what the module is for.
### Hooks
init has the following hook points to inject scripts:
`/lib/dracut/hooks/cmdline/*.sh`
scripts for command line parsing
`/lib/dracut/hooks/pre-udev/*.sh`
scripts to run before udev is started
`/lib/dracut/hooks/pre-trigger/*.sh`
scripts to run before the main udev trigger is pulled
`/lib/dracut/hooks/initqueue/*.sh`
runs in parallel to the udev trigger
Udev events can add scripts here with /sbin/initqueue.
If /sbin/initqueue is called with the "--onetime" option, the script
will be removed after it was run.
If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then
this loop can process the jobs in parallel to the udevtrigger.
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
Scripts can remove themselves from the initqueue by "rm $job".
`/lib/dracut/hooks/pre-mount/*.sh`
scripts to run before the root filesystem is mounted
Network filesystems like NFS that do not use device files are an
exception. Root can be mounted already at this point.
`/lib/dracut/hooks/mount/*.sh`
scripts to mount the root filesystem
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
`/lib/dracut/hooks/pre-pivot/*.sh`
scripts to run before latter initramfs cleanups
`/lib/dracut/hooks/cleanup/*.sh`
scripts to run before the real init is executed and the initramfs
disappears
All processes started before should be killed here.
## Testsuite
For the testsuite to work, you will have to install at least the following software packages:
```
dash \
asciidoc \
mdadm \
lvm2 \
dmraid \
cryptsetup \
nfs-utils \
nbd \
dhcp-server \
scsi-target-utils \
iscsi-initiator-utils \
strace \
syslinux \
python-imgcreate \
genisoimage \
btrfs-progs \
kmod-devel \
gcc \
bzip2 \
xz \
tar \
wget \
rpm-build \
${NULL}
```
How to run the testsuite:
```
$ sudo make clean check
```
in verbose mode:
```
$ sudo make V=1 clean check
```
only specific test:
```
$ sudo make TESTS="01 20 40" clean check
```
only runs the 01, 20 and 40 tests.
debug a specific test case:
```
$ cd TEST-01-BASIC
$ sudo make clean setup run
```
... change some kernel parameters ...
```
$ sudo make run
```
to run the test without doing the setup

View File

@@ -1,13 +1,8 @@
-include dracut-version.sh
DRACUT_MAIN_VERSION ?= $(shell env GIT_CEILING_DIRECTORIES=$(CWD)/.. git describe --abbrev=0 --tags --always 2>/dev/null || :)
ifeq ($(DRACUT_MAIN_VERSION),)
DRACUT_MAIN_VERSION = $(DRACUT_VERSION)
endif
DRACUT_FULL_VERSION ?= $(shell env GIT_CEILING_DIRECTORIES=$(CWD)/.. git describe --tags --always 2>/dev/null || :)
ifeq ($(DRACUT_FULL_VERSION),)
DRACUT_FULL_VERSION = $(DRACUT_VERSION)
endif
DRACUT_MAIN_VERSION ?= $(shell [ -d .git ] && git describe --abbrev=0 --tags --always 2>/dev/null || :)
DRACUT_MAIN_VERSION ?= $(DRACUT_VERSION)
GITVERSION ?= $(shell [ -d .git ] && { v=$$(git describe --tags --always 2>/dev/null); [ -n "$$v" ] && [ $${v\#*-} != $$v ] && echo -$${v\#*-}; } )
-include Makefile.inc
@@ -18,7 +13,8 @@ pkglibdir ?= ${libdir}/dracut
sysconfdir ?= ${prefix}/etc
bindir ?= ${prefix}/bin
mandir ?= ${prefix}/share/man
CFLAGS ?= -O2 -g -Wall -std=gnu99 -D_FILE_OFFSET_BITS=64 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
CFLAGS ?= -O2 -g -Wall
CFLAGS += -std=gnu99 -D_FILE_OFFSET_BITS=64 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 $(KMOD_CFLAGS)
bashcompletiondir ?= ${datadir}/bash-completion/completions
pkgconfigdatadir ?= $(datadir)/pkgconfig
@@ -45,13 +41,10 @@ man8pages = dracut.8 \
manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
.PHONY: install clean archive rpm srpm testimage test all check AUTHORS CONTRIBUTORS doc dracut-version.sh
.PHONY: install clean archive rpm srpm testimage test all check AUTHORS doc dracut-version.sh
all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio
%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(KMOD_CFLAGS) $< -o $@
DRACUT_INSTALL_OBJECTS = \
install/dracut-install.o \
install/hashmap.o\
@@ -69,7 +62,7 @@ install/util.o: install/util.c install/util.h install/macro.h install/log.h
install/strv.o: install/strv.c install/strv.h install/util.h install/macro.h install/log.h
install/dracut-install: $(DRACUT_INSTALL_OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(FTS_LIBS) $(KMOD_LIBS)
$(CC) $(LDFLAGS) -o $@ $(DRACUT_INSTALL_OBJECTS) $(LDLIBS) $(KMOD_LIBS)
logtee: logtee.c
$(CC) $(LDFLAGS) -o $@ $<
@@ -99,16 +92,13 @@ endif
%.xml: %.asc
@rm -f -- "$@"
asciidoc -a "version=$(DRACUT_FULL_VERSION)" -d manpage -b docbook -o "$@" $<
asciidoc -d manpage -b docbook -o "$@" $<
dracut.8: dracut.usage.asc dracut.8.asc
dracut.html: dracut.asc $(manpages) dracut.css dracut.usage.asc
@rm -f -- dracut.xml
asciidoc -a "mainversion=$(DRACUT_MAIN_VERSION)" \
-a "version=$(DRACUT_FULL_VERSION)" \
-a numbered \
-d book -b docbook -o dracut.xml dracut.asc
asciidoc -a numbered -d book -b docbook -o dracut.xml dracut.asc
@rm -f -- dracut.html
xsltproc -o dracut.html --xinclude -nonet \
--stringparam custom.css.source dracut.css \
@@ -119,7 +109,7 @@ dracut.html: dracut.asc $(manpages) dracut.css dracut.usage.asc
dracut.pc: Makefile.inc Makefile
@echo "Name: dracut" > dracut.pc
@echo "Description: dracut" >> dracut.pc
@echo "Version: $(DRACUT_FULL_VERSION)" >> dracut.pc
@echo "Version: $(DRACUT_MAIN_VERSION)$(GITVERSION)" >> dracut.pc
@echo "dracutdir=$(pkglibdir)" >> dracut.pc
@echo "dracutmodulesdir=$(pkglibdir)/modules.d" >> dracut.pc
@echo "dracutconfdir=$(pkglibdir)/dracut.conf.d" >> dracut.pc
@@ -189,7 +179,7 @@ endif
dracut-version.sh:
@rm -f dracut-version.sh
@echo "DRACUT_VERSION=$(DRACUT_FULL_VERSION)" > dracut-version.sh
@echo "DRACUT_VERSION=$(DRACUT_MAIN_VERSION)$(GITVERSION)" > dracut-version.sh
clean:
$(RM) *~
@@ -217,7 +207,7 @@ dracut-$(DRACUT_MAIN_VERSION).tar.xz: doc syncheck
rm -f -- dracut-$(DRACUT_MAIN_VERSION).tar
rpm: dracut-$(DRACUT_MAIN_VERSION).tar.xz syncheck
rpmbuild=$$(mktemp -d -p /var/tmp rpmbuild-dracut.XXXXXX); src=$$(pwd); \
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
cp dracut-$(DRACUT_MAIN_VERSION).tar.xz "$$rpmbuild"; \
LC_MESSAGES=C $$src/git2spec.pl $(DRACUT_MAIN_VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
(cd "$$rpmbuild"; \
@@ -284,9 +274,6 @@ efi: all
AUTHORS:
git shortlog --numbered --summary -e |while read a rest || [ -n "$$rest" ]; do echo $$rest;done > AUTHORS
CONTRIBUTORS:
@git shortlog $(DRACUT_MAIN_VERSION).. --numbered --summary -e |while read a rest || [ -n "$$rest" ]; do echo "- $$rest";done
dracut.html.sign: dracut-$(DRACUT_MAIN_VERSION).tar.xz dracut.html
gpg-sign-all dracut-$(DRACUT_MAIN_VERSION).tar.xz dracut.html

View File

@@ -1,444 +1,3 @@
Rendered view: https://github.com/dracutdevs/dracut/blob/master/NEWS.md
dracut-053
==========
#### Bug Fixes
* **dracut.sh:**
* unfreeze /boot on exit ([d87ae137](https://github.com/dracutdevs/dracut/commit/d87ae13721d04a8a2192d896af224ac6965caf70))
* proper return code for inst_multiple in dracut-init.sh ([d437970c](https://github.com/dracutdevs/dracut/commit/d437970c013e3287de263a1e60a117b15239896c))
* **fcoe:**
* rename rd.nofcoe to rd.fcoe ([6f7823bc](https://github.com/dracutdevs/dracut/commit/6f7823bce65dd4b52497dbb94892b637fd06471a))
* rd.nofcoe=0 should disable fcoe ([805b46c2](https://github.com/dracutdevs/dracut/commit/805b46c2a81e04d69fc3af912942568516d05ee7))
* **i18n:**
* get rid of `eval` calls ([5387ed24](https://github.com/dracutdevs/dracut/commit/5387ed24c8b33da1214232d57ab1831e117aaba0))
* create the keyboard symlinks again ([9e1c7f3d](https://github.com/dracutdevs/dracut/commit/9e1c7f3deadd387adaa97b189593b4ba3d7c6d5a))
* **network-manager:**
* run as a service if systemd module is present ([c17c5b76](https://github.com/dracutdevs/dracut/commit/c17c5b7604c8d61dd1c00ee22d44c3a5d7d6dfee))
* rework how NM is started in debug mode ([34c73b33](https://github.com/dracutdevs/dracut/commit/34c73b339baa025dfd8916379c4d191be34a8af5))
* **drm:** skip empty modalias files in drm module setup ([c3f24184](https://github.com/dracutdevs/dracut/commit/c3f241849de6434d063ef92e6880f6b0335c1800))
dracut-052
==========
#### Features
- **dracut:**
- allow overriding the systemctl command for sysroot with `$SYSTEMCTL` for cross compilation
- add additional global variables
Variables like `dbusconfdir` or `systemdnetwork` are now exported
to the individual modules as global variables. If they are not set
in the distribution dracut config files, they are set via `pkg-config`
- A `--no-uefi` option as been added to the CLI options to disable a default `uefi=yes`
set by a configuration file.
- **kernel-modules:** add modules from `drivers/memory` for arm
- **network-legacy:** send dhcp in parallel on all devices via the `single-dhcp` option
- **dbus:** introduce a meta module for dbus
- **dbus-broker:** introduce the dbus-broker module
- **dbus-daemon:** introduce the dbus-daemon module
- **systemd-ask-password:** introduce the systemd-ask-password module
- **systemd-coredump:** introduce the systemd-coredump module
- **systemd-modules-load:** introduce the systemd-modules-load module
- **systemd-repart:** introduce the systemd-repart module
- **systemd-sysctl:** introduce the systemd-sysctl module
- **systemd-sysusers:** introduce the systemd-sysuser module
#### Bug Fixes
- first round of shellcheck for all shell scripts
- revise all module checks to not error out about missing dependencies
- use the top-level `/efi` path to address the EFI partition
- correct the squash quirk
- use `find_binary` instead of other methods, because `find_binary` honors `dracutsysrootdir`
- quote globbing in module-setup.sh for `inst_multiple`
- move ldconfig after library workaround
- do not set cmdline for uefi images unless asked
- **dracut:** don't override `PATH`, if `dracutsysrootdir` is set
- **dracut-functions.sh:** check kernel config from `dracutsysrootdir`
- **dracut-init.sh:** make inst_libdir_file work with `dracutsysrootdir` set
- **dracut-install:** allow globbing for multiple sources
- **06dbus:**
- do not hardcode path to dbus utils
- do not hardcode path to systemd unit
- **uefi** use efivars fs over the deprecated sysfs entries
- **keyring** adding shared keyring mode to systemd unit `dracut-pre-pivot.service`
- **35network-manager:** avoid restarting NetworkManager
- **90kernel-modules:** install generic crypto modules with hostonly unset
- **99squash:** use kernel config instead of modprobe to check modules
- **dbus-daemon:** use uid/gid from sysroot if `dracutsysrootdir` is set
- **kernel-modules:** add reset controllers for arm
- **kernel-network-modules:** also install modules from mdio subdirectory
- **mdraid:**
- remove the `offroot` option (long deprecated)
- add the grow continue service `mdadm-grow-continue`
- **network-legacy:** silent the check for dhcp leaseinfo
- **network-manager:** allow override network manager version
- **plymouth:** install binaries with dependencies
- **shutdown:** add timeout to umount calls
- **watchdog:** fix dependencies in `module-setup.sh`
#### Contributors
- Harald Hoyer <harald@redhat.com>
- Jóhann B. Guðmundsson <johannbg@gmail.com>
- Zoltán Böszörményi <zboszor@pr.hu>
- Alexey Shabalin <shaba@altlinux.org>
- Daniel Molkentin <daniel.molkentin@suse.com>
- Luiz Angelo Daros de Luca <luizluca@gmail.com>
- Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
- Alexander Tsoy <alexander@tsoy.me>
- Anjali Kulkarni <anjali.k.kulkarni@oracle.com>
- Beniamino Galvani <bgalvani@redhat.com>
- David Tardon <dtardon@redhat.com>
- Javier Martinez Canillas <javierm@redhat.com>
- Kairui Song <kasong@redhat.com>
- Lukas Nykryn <lnykryn@redhat.com>
- Matthew Thode <mthode@mthode.org>
- Nicolas Chauvet <kwizart@gmail.com>
- Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
- Ondrej Mosnacek <omosnace@redhat.com>
- Peter Levine <plevine457@gmail.com>
- Petr Pavlu <petr.pavlu@suse.com>
- Vladius25 <vkorol2509@icloud.com>
- Yang Liu <50459973+ly4096x@users.noreply.github.com>
- foopub <45460217+foopub@users.noreply.github.com>
- realtime-neil <neil@rtr.ai>
dracut-051
==========
dracut:
- allow running on a cross-compiled rootfs
dracutsysrootdir is the root directory, file existence checks use it.
DRACUT_LDCONFIG can override ldconfig with a different one that works
on the sysroot with foreign binaries.
DRACUT_LDD can override ldd with a different one that works
with foreign binaries.
DRACUT_TESTBIN can override /bin/sh. A cross-compiled sysroot
may use symlinks that are valid only when running on the target
so a real file must be provided that exist in the sysroot.
DRACUT_INSTALL now supports debugging dracut-install in itself
when run by dracut but without debugging the dracut scripts.
E.g. DRACUT_INSTALL="valgrind dracut-install or
DRACUT_INSTALL="dracut-install --debug".
DRACUT_COMPRESS_BZIP2, DRACUT_COMPRESS_LBZIP2, DRACUT_COMPRESS_LZMA,
DRACUT_COMPRESS_XZ, DRACUT_COMPRESS_GZIP, DRACUT_COMPRESS_PIGZ,
DRACUT_COMPRESS_LZOP, DRACUT_COMPRESS_ZSTD, DRACUT_COMPRESS_LZ4,
DRACUT_COMPRESS_CAT: All of the compression utilities may be
overridden, to support the native binaries in non-standard places.
DRACUT_ARCH overrides "uname -m".
SYSTEMD_VERSION overrides "systemd --version".
The dracut-install utility was overhauled to support sysroot via
a new option -r and fixes for clang-analyze. It supports
cross-compiler-ldd from
https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f
DRACUT_INSTALL_PATH was introduced so dracut-install can work with
a different PATH. In a cross-compiled environment (e.g. Yocto), PATH
points to natively built binaries that are not in the host's /bin,
/usr/bin, etc. dracut-install still needs plain /bin and /usr/bin
that are relative to the cross-compiled sysroot.
DRACUT_INSTALL_LOG_TARGET and DRACUT_INSTALL_LOG_LEVEL were
introduced so dracut-install can use different settings from
DRACUT_LOG_TARGET and DRACUT_LOG_LEVEL.
- don't call fsfreeze on subvol of root file system
- Use TMPDIR (typically /run/user/$UID) if available
- dracut.sh: add check for invalid configuration files
Emit a warning about possible misconfigured configuration files, where
the spaces around values are missing for +=""
- dracut-functions: fix find_binary() to return full path
- dracut.sh: FIPS workaround for openssl-libs on Fedora/RHEL
- dracut.sh: fix early microcode detection logic
- dracut.sh: fix ia32 detection for uefi executables
- dracut.sh: Add --version
- dracut.sh: Add --hostonly-nics option
- EFI Mode: only write kernel cmdline to UEFI binary
- Allow $DRACUT_INSTALL to be not an absolute path
- Don't print when a module is explicitly omitted (by default)
- Remove uses of bash (and bash specific syntax) in runtime scripts
- dracut-init.sh: Add a helper for detect device kernel modules
- dracut-functions.sh: Fix check_block_and_slaves_all
- dracut-functions.sh: add a helper to check if kernel module is available
Documentation
- dracut.cmdline.7.asc: clarify usage of `rd.lvm.vg` and `rd.lvm.lv`
- dracut.conf.5.asc: document how to config --no-compress in the config
- fix CI badges in README.md and fix dracut description
- dracut.modules.7.asc: fix typos
- dracut.modules.7.asc: fix reference to insmodpost module
- Add --version to man page
- Adding code of conduct
- Document initqueue/online hook
dracut-install:
- install: also install post weak dependencies of kernel modules
- install: Globbing support for resolving "firmware:"
mkinitrd:
- use vmlinux regex for ppc*, vmlinuz for i686
mkinitrd-suse:
- fix i586 platform detection
modules:
00systemd:
- skip dependency add for non-existent units
- add missing cryptsetup-related targets
05busybox:
- simplify listing of supported utilities
06rngd:
- install dependant libs too
- Do not start inside container
10i18n:
- i18n: Always install /etc/vconsole.conf
35network-legacy:
- dhclient-script: Fix typo in output of BOUND & BOUND6 cases
- simplify fallback dhcp setup
35network-manager:
- ensure that nm-run.sh is executed when needed
- install libnss DNS and mDNS plugins
- always pull in machinery to read ifcfg files
- set kernel hostname from the command line
- move connection generation to a lib file
40network:
- fix glob matching ipv6 addresses
- net-lib.sh: support infiniband network mac addresses
45url-lib:
- drop NSS if it's not in curl --version
80cms:
- regenerate NetworkManager connections
90btrfs:
- force preload btrfs module
- Install crypto modules in 90kernel-modules
90crypt:
- cryptroot-ask: no warn if /run/cryptsetup exist
- install crypto modules in 90kernel-modules
- try to catch kernel config changes
- fix force on multiple lines
- pull in remote-cryptsetup.target enablement
- cryptroot-ask: unify /etc/crypttab and rd.luks.key
90dmsquash-live:
- iso-scan.sh: Provide an easy reference to iso-scan device
90kernel-modules:
- remove nfit from static module list (see nvdimm module)
- install crypto modules in 90kernel-modules
- add sg kernel module
- add pci_hyperv
- install block drivers more strictly
- install less modules for hostonly mode
- arm: add drivers/hwmon for arm/arm64
90kernel-network-modules
- on't install iscsi related module (use 95iscsi)
90lvm:
- remove unnecessary ${initdir} from lvm_scan.sh
- fix removal of pvscan from udev rules
- do not add newline to cmdline
90multipath:
- add automatic configuration for multipath
(adds 'rd.multipath=default' to use the default config)
- install kpartx's 11-dm-parts.rules
90nvdimm:
- new module for NVDIMM support
90ppcmac:
- respect DRACUT_ARCH, don't exclude ppcle
90qemu-net:
- in hostonly mode, only install if network is needed
- install less module for strict hostonly mode
91zipl:
- parse-zipl.sh: honor SYSTEMD_READY
95cifs:
- pass rootflags to mount
- install new softdeps (sha512, gcm, ccm, aead2)
95dasd:
- only install /etc/dasd.conf if present
95dcssblk:
- fix script permissions
95fcoe:
- fix pre-trigger stage by replacing exit with return in lldpad.sh
- default rd.nofcoe to false
- don't install if there is no FCoE hostonly devices
95iscsi:
- fix missing space when compiling cmdline args
- fix ipv6 target discovery
95nfs:
- only install rpc services for NFS < 4 when hostonly is strict
- Change the order of NFS servers during the boot
(next-server option has higher priority than DHCP-server itself)
- install less module if hostonly mode is strict
95nvmf:
- add module for NVMe-oF
- add NVMe over TCP support
95resume:
- do not resume on iSCSI, FCoE or NBD
95rootfs-block:
- mount-root.sh: fix writing fstab file with missing fsck flag
- only write root argument for block device
95zfcp:
- match simplified rd.zfcp format too
95zfcp_rules:
- parse-zfcp.sh: remove rule existence check
95znet:
- add a rd.znet_ifname= option
98dracut-systemd:
- remove memtrace-ko and rd.memdebug=4 support in dracut
- remove cleanup_trace_mem calls
- dracut-initqueue: Print more useful info in case of timeout
- as of v246 of systemd "syslog" and "syslog-console" switches have been deprecated
- don't wait for root device if remote cryptsetup active
99base:
- dracut-lib.sh: quote variables in parameter expansion patterns
- remove memtrace-ko and rd.memdebug=4 support in dracut
- remove cleanup_trace_mem calls
- see new module 99memstrack
- prevent creating unexpected files on the host when running dracut
99memstrack:
- memstrack is a new tool to track the overall memory usage and
allocation, which can help off load the improve the builtin module
memory tracing function in dracut.
99squash:
- don't hardcode the squash sub directories
- improve pre-requirements check
- check require module earlier, and properly
new modules:
- nvmf
- watchdog-modules
- dbus
- network-wicked
removed modules:
- stratis
test suite:
- use dd from /dev/zero, instead of creating files with a hole
- TEST-03-USR-MOUNT/test.sh: increase loglevel
- TEST-12-RAID-DEG/create-root.sh: more udevadm settle
- TEST-35-ISCSI-MULTI: bump disk space
- TEST-41-NBD-NM/Makefile: should be based on TEST-40-NBD not TEST-20-NFS
- TEST-99: exclude /etc/dnf/* from check
dracut-050
==========
dracut:
- support for running on a cross-compiled rootfs, see README.cross
- add support for creating secureboot signed UEFI images
- use microcode found in packed cpio images
- `-k/--kmodir` must now contain "lib/modules/$KERNEL_VERSION"
use DRACUT_KMODDIR_OVERRIDE=1 to ignore this check
- support the EFI Stub loader's splash image feature.
`--uefi-splash-image <FILE>`
dracut modules:
- remove bashism in various boot scripts
- emergency mode: use sulogin
fcoe:
- add rd.nofcoe option to disable the FCoE module from the command line
10i18n:
- fix keymaps not getting included sometimes
- use eurlatgr as default console font
iscsi:
- add option `rd.iscsi.testroute`
multipath:
- fix udev rules detection of multipath devices
network:
- support NetworkManager
network-legacy:
- fix classless static route parsing
- ifup: fix typo when calling dhclient --timeout
- ifup: nuke pid and lease files if dhclient failed
- fix ip=dhcp,dhcp6
- use $name instead of $env{INTERFACE} (systemd-udevd regression)
shutdown:
- fix for non-systemd reboot/halt/shutdown commands
- set selinux labels
- fix shutdown with console=null
lsinitrd:
- list squash content as well
- handle UEFI created with dracut --uefi
- make lsinitrd usable for images made with Debian mkinitramfs
dracut-install:
- fixed ldd parsing
- install kernel module dependencies of dependencies
- fixed segfault for hashing NULL pointers
- add support for compressed firmware files
- dracut_mkdir(): create parent directories as needed.
configure:
- Find FTS library with --as-needed
test suite:
- lots of cleanups
- add github actions
new modules:
- rngd
- network-manager
- ppcmac - thermal/fan control modules on PowerPC based Macs
dracut-049
==========
lsinitrd:
@@ -461,7 +20,6 @@ livenet:
dmsquash-live:
- Support a flattened squashfs.img
- Remove obsolete osmin.img processing
dracut-systemd:
- Start systemd-vconsole-setup before dracut-cmdline-ask
@@ -651,9 +209,6 @@ nfs:
fips:
- fixed creating path to .hmac of kernel based on BOOT_IMAGE
- turn info calls into fips_info calls
- modprobe failures during manual module loading is not fatal
lunmask:
- add module to handle LUN masking

View File

@@ -1,70 +0,0 @@
Dracut supports running against a sysroot directory that is different
from the actual root (/) directory of the running system. It is most
useful for creating/bootstrapping a new system that may or may not be
using the same CPU architecture as the host system, i.e. building a
whole Linux system with a cross-compiler framework like Yocto.
The user-visible frontend change is the introduction of a new option
called "-r" or "--sysroot". It expects a directory that contains the
complete Linux system that has all the files (kernel drivers, firmware,
executables, libraries and others) necessary to construct the initramfs.
E.g: dracut --sysroot /path/to/sysroot initramfs.img kernelversion
To support this, a new global variable was introduced inside dracut.
This variable is called "dracutsysrootdir" and all the files installed
into the initramfs image is searched relative to the sysroot directory.
This variable can also be set externally to dracut without using option
-r/--sysroot.
There are other details that are necessary to tweak to be able to
run on cross-compiled (a.k.a. foreign) binaries.
dracut uses these crucial utilities during its operation:
ldd
===
It lists dynamic library dependencies for executables or libraries
ldconfig
========
It creates /etc/ld.so.cache, i.e. the cached information about libraries
known to the system.
These utilities the way they exist on the host system only work on
the host system.
To support cross-compiled binaries, a different ldd variant is needed that
works on those binaries. One such ldd script is found at
https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f
ldconfig in GLIBC as is does support a sysroot with its -r option.
Extra environment variables needed to run dracut on the sysroot are
documented in the dracut(8) man page.
For the Plymouth boot splash to be added to the initramfs image,
this gitlab PR is needed for Plymouth:
https://gitlab.freedesktop.org/plymouth/plymouth/merge_requests/72
Extensions to be used with Yocto
================================
examples/yocto/classes/dracut.bbclass:
Bitbake class for running dracut during the "do_rootfs" stage of
creating a distribution image and from the postinstall script of
a package. A kernel recipe needs this line to activate it:
inherit dracut
examples/yocto/postinst-intercepts/execute_dracut
The "intercept" script used during "do_rootfs" mentioned above.
examples/yocto/recipes/cross-compiler-ldd_git.bb
Package recipe for the cross-compiler-ldd script from the above link.
All the above three need to be added to a Yocto layer to their
proper locations.
They were tested on Yocto 2.7 with MACHINE="intel-core2-32" and
MACHINE="genericx86-64".

View File

@@ -3,17 +3,14 @@ dracut
dracut is an event driven initramfs infrastructure.
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](.github/CODE_OF_CONDUCT.md)
[![Fedora-32](https://github.com/dracutdevs/dracut/workflows/Fedora-32/badge.svg?branch=master)](https://github.com/dracutdevs/dracut/actions?query=workflow%3AFedora-32)
[![Fedora-33](https://github.com/dracutdevs/dracut/workflows/Fedora-33/badge.svg?branch=master)](https://github.com/dracutdevs/dracut/actions?query=workflow%3AFedora-33)
[![Fedora-latest](https://github.com/dracutdevs/dracut/workflows/Fedora-latest/badge.svg?branch=master)](https://github.com/dracutdevs/dracut/actions?query=workflow%3AFedora-latest)
[![Build Status](https://travis-ci.org/dracutdevs/dracut.svg?branch=master)](https://travis-ci.org/dracutdevs/dracut)
dracut (the tool) is used to create an initramfs image by copying tools
and files from an installed system and combining it with the
dracut framework, usually found in /usr/lib/dracut/modules.d.
Unlike other implementations, dracut hard-codes as little
as possible into the initramfs. The initramfs has
Unlike existing initramfs's, this is an attempt at having as little as
possible hard-coded into the initramfs as possible. The initramfs has
(basically) one purpose in life -- getting the rootfs mounted so that
we can transition to the real rootfs. This is all driven off of
device availability. Therefore, instead of scripts hard-coded to do
@@ -21,7 +18,10 @@ various things, we depend on udev to create device nodes for us and
then when we have the rootfs's device node, we mount and carry on.
This helps to keep the time required in the initramfs as little as
possible so that things like a 5 second boot aren't made impossible as
a result of the very existence of an initramfs.
a result of the very existence of an initramfs. It's likely that
we'll grow some hooks for running arbitrary commands in the flow of
the script, but it's worth trying to resist the urge as much as we can
as hooks are guaranteed to be the path to slow-down.
Most of the initramfs generation functionality in dracut is provided by a bunch
of generator modules that are sourced by the main dracut script to install
@@ -29,6 +29,32 @@ specific functionality into the initramfs. They live in the modules.d
subdirectory, and use functionality provided by dracut-functions to do their
work.
Some general rules for writing modules:
* Use one of the inst family of functions to actually install files
on to the initramfs. They handle mangling the pathnames and (for binaries,
scripts, and kernel modules) installing dependencies as appropriate so
you do not have to.
* Scripts that end up on the initramfs should be POSIX compliant. dracut
will try to use /bin/dash as /bin/sh for the initramfs if it is available,
so you should install it on your system -- dash aims for strict POSIX
compliance to the extent possible.
* Hooks MUST be POSIX compliant -- they are sourced by the init script,
and having a bashism break your user's ability to boot really sucks.
* Generator modules should have a two digit numeric prefix -- they run in
ascending sort order. Anything in the 90-99 range is stuff that dracut
relies on, so try not to break those hooks.
* Hooks must have a .sh extension.
* Generator modules are described in more detail in README.modules.
* We have some breakpoints for debugging your hooks. If you pass 'rdbreak'
as a kernel parameter, the initramfs will drop to a shell just before
switching to a new root. You can pass 'rdbreak=hookpoint', and the initramfs
will break just before hooks in that hookpoint run.
Also, there is an attempt to keep things as distribution-agnostic as
possible. Every distribution has their own tool here and it's not
something which is really interesting to have separate across them.
So contributions to help decrease the distro-dependencies are welcome.
Currently dracut lives on github.com and kernel.org.
The tarballs can be found here:
@@ -36,7 +62,15 @@ The tarballs can be found here:
ftp://ftp.kernel.org/pub/linux/utils/boot/dracut/
Git:
https://github.com/dracutdevs/dracut.git
git://git.kernel.org/pub/scm/boot/dracut/dracut.git
http://git.kernel.org/pub/scm/boot/dracut/dracut.git
https://git.kernel.org/pub/scm/boot/dracut/dracut.git
git@github.com:dracutdevs/dracut.git
Git Web:
https://github.com/dracutdevs/dracut.git
http://git.kernel.org/?p=boot/dracut/dracut.git
Project Documentation:
@@ -45,8 +79,8 @@ Project Documentation:
Project Wiki:
http://dracut.wiki.kernel.org
See the github issue tracker for things which still need to be done and HACKING.md
for some instructions on how to get started. There is also a mailing list
See the TODO file for things which still need to be done and HACKING for
some instructions on how to get started. There is also a mailing list
that is being used for the discussion -- initramfs@vger.kernel.org.
It is a typical vger list, send mail to majordomo@vger.kernel.org with body
of 'subscribe initramfs email@host.com'

112
README.modules Normal file
View File

@@ -0,0 +1,112 @@
Most of the functionality that dracut implements are actually implemented
by dracut modules. dracut modules live in modules.d, and have the following
structure:
dracut_install_dir/modules.d/
00modname/
module-setup.sh
check
<other files as needed by the hook>
00modname: The name of the module prefixed by a two-digit numeric sort code.
The numeric code must be present and in the range of 00 - 99.
Modules with lower numbers are installed first. This is important
because the dracut install functions (which install files onto
the initrd) refuse to overwrite already installed files. This makes
it easy for an earlier module to override the functionality of a
later module, so that you can have a distro or system specific
module override or modify the functionality of a generic module
without having to patch the more generic module.
module-setup.sh:
dracut sources this script to install the functionality that a
module implements onto the initrd. For the most part, this amounts
to copying files from the host system onto the initrd in a controlled
manner.
install():
This function of module-setup.sh is called to install all
non-kernel files. dracut supplies several install functions that are
specialized for different file types. Browse through dracut-functions
fore more details. dracut also provides a $moddir variable if you
need to install a file from the module directory, such as an initrd
hook, a udev rule, or a specialized executable.
installkernel():
This function of module-setup.sh is called to install all
kernel related files.
check():
dracut calls this function to check and see if a module can be installed
on the initrd.
When called without options, check should check to make sure that
any files it needs to install into the initrd from the host system
are present. It should exit with a 0 if they are, and a 1 if they are
not.
When called with $hostonly set, it should perform the same check
that it would without it set, and it should also check to see if the
functionality the module implements is being used on the host system.
For example, if this module handles installing support for LUKS
encrypted volumes, it should return 0 if all the tools to handle
encrpted volumes are available and the host system has the root
partition on an encrypted volume, 1 otherwise.
depends():
This function should output a list of dracut modules
that it relies upon. An example would be the nfs and iscsi modules,
which rely on the network module to detect and configure network
interfaces.
Any other files in the module will not be touched by dracut directly.
You are encouraged to provide a README that describes what the module is for.
HOOKS
=====
init has the following hook points to inject scripts:
/lib/dracut/hooks/cmdline/*.sh
scripts for command line parsing
/lib/dracut/hooks/pre-udev/*.sh
scripts to run before udev is started
/lib/dracut/hooks/pre-trigger/*.sh
scripts to run before the main udev trigger is pulled
/lib/dracut/hooks/initqueue/*.sh
runs in parallel to the udev trigger
Udev events can add scripts here with /sbin/initqueue.
If /sbin/initqueue is called with the "--onetime" option, the script
will be removed after it was run.
If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then
this loop can process the jobs in parallel to the udevtrigger.
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
Scripts can remove themselves from the initqueue by "rm $job".
/lib/dracut/hooks/pre-mount/*.sh
scripts to run before the root filesystem is mounted
Network filesystems like NFS that do not use device files are an
exception. Root can be mounted already at this point.
/lib/dracut/hooks/mount/*.sh
scripts to mount the root filesystem
If the udev queue is empty and no root device is found or no root
filesystem was mounted, the user will be dropped to a shell after
a timeout.
/lib/dracut/hooks/pre-pivot/*.sh
scripts to run before latter initramfs cleanups
/lib/dracut/hooks/cleanup/*.sh
scripts to run before the real init is executed and the initramfs
disappears
All processes started before should be killed here.

45
README.testsuite Normal file
View File

@@ -0,0 +1,45 @@
For the testsuite to work, you will have to install at least the following software packages:
dash \
asciidoc \
mdadm \
lvm2 \
dmraid \
cryptsetup \
nfs-utils \
nbd \
dhcp-server \
scsi-target-utils \
iscsi-initiator-utils \
strace \
syslinux \
python-imgcreate \
genisoimage \
btrfs-progs \
kmod-devel \
gcc \
bzip2 \
xz \
tar \
wget \
rpm-build \
${NULL}
TEST-04-FULL-SYSTEMD: systemd >= 187
How to run the testsuite:
$ sudo make clean check
in verbose mode:
$ sudo make V=1 clean check
only specific test:
$ sudo make TESTS="01 20 40" clean check
only runs the 01, 20 and 40 tests.
debug a specific test case:
$ cd TEST-01-BASIC
$ sudo make clean setup run
... change some kernel parameters ...
$ sudo make run
to run the test without doing the setup

51
TODO Normal file
View File

@@ -0,0 +1,51 @@
Current TODO list, broken into things which are relevant for the
initramfs itself (/init et al) vs the generator.
A lot of things are/should be marked with "FIXME" in the code.
Items are ordered in priority.
INITRAMFS TODO
- search domain string
- allow dual stack configuration (IPv4, IPv6) for the same interface
- "bind-mount" kernel drivers in real root for the rescue image,
if the real root does not have any kernel modules for this kernel
https://bugzilla.redhat.com/show_bug.cgi?id=1046510
- use info and warn prefix
- generate systemd unit dracut-initramfs-restore in /run/systemd dynamically
- put "root=" parsing hooks in separate hook dir
- call "root=" parsing hooks after getting new rootpath from dhcp
- put mount hook in main initqueue loop / careful about resume!
- the hard-coded list of udev rules that we care about is kind of lame.
- panic fallback
- progress indication for fsck https://bugzilla.redhat.com/show_bug.cgi?id=827118
- domain, searchdomain https://bugzilla.redhat.com/show_bug.cgi?id=840778
- probably fix "--include" https://bugzilla.redhat.com/show_bug.cgi?id=849338
GENERATOR TODO
- report errors on missing files in check()
- remove wait for swap devs, if no "resume=" is given on the kernel command line
- remove wait for swap devs, if the "resume" dracut module is not included (omitted)
- add presets (predefined set of modules)
- add interpreter/plugin-scripts to be sourced at the beginning or end (can use dracut-functions)
- add mechanism for module specific command line options
- pkg-config integration, to make it easy for other packages to use us.
- default module specification could use some work
- udev rule copying, as mentioned above, is a bit too hard-coded
- dracut-install parse LD_SHOW_AUXV="" AT_PLATFORM for lib install
CODE TODO
- document more functions
- make function vars local, and prefix with "_"
Future Enhancement Requests
- run ssh server to enter crypto password or perform debugging (supported by debian)
- https://bugzilla.redhat.com/show_bug.cgi?id=524727 - dracut + encrypted root + networking
- lsinitrd --print-cmdline
- dracut --print-cmdline error if additional arguments
- library for cmdline

50
configure vendored
View File

@@ -7,7 +7,6 @@ prefix=/usr
enable_documentation=yes
CC="${CC:-cc}"
PKG_CONFIG="${PKG_CONFIG:-pkg-config}"
# Little helper function for reading args from the commandline.
@@ -19,9 +18,9 @@ read_arg() {
# $3 = arg parameter
local rematch='^[^=]*=(.*)$'
if [[ $2 =~ $rematch ]]; then
read -r "$1" <<< "${BASH_REMATCH[1]}"
read "$1" <<< "${BASH_REMATCH[1]}"
else
read -r "$1" <<< "$3"
read "$1" <<< "$3"
# There is no way to shift our callers args, so
# return 1 to indicate they should do it instead.
return 1
@@ -58,50 +57,6 @@ if ! ${PKG_CONFIG} --exists --print-errors " libkmod >= 23 "; then
exit 1
fi
cat <<EOF >conftest.c
#include <fts.h>
int main() {
return 0;
}
EOF
# shellcheck disable=SC2086
${CC} $CFLAGS $LDFLAGS conftest.c >/dev/null 2>&1
ret=$?
rm -f conftest.c a.out
# musl doesn't have fts.h included
if test $ret -ne 0; then
echo "dracut needs fts development files." >&2
exit 1
fi
cat <<EOF >conftest.c
#include <fts.h>
int main(void) {
fts_open(0, 0, 0);
return 0;
}
EOF
found=no
for lib in "-lc" "-lfts"; do
# shellcheck disable=SC2086
${CC} $CFLAGS $LDFLAGS conftest.c -Wl,$lib >/dev/null 2>&1
ret=$?
if test $ret -eq 0; then
FTS_LIBS="$lib"
found=yes
break;
fi
done
rm -f conftest.c a.out
if test $found = no; then
echo "dracut couldn't find usable fts library" >&2
exit 1
fi
cat > Makefile.inc.$$ <<EOF
prefix ?= ${prefix}
libdir ?= ${libdir:-${prefix}/lib}
@@ -113,7 +68,6 @@ enable_documentation ?= ${enable_documentation:-yes}
bindir ?= ${bindir:-${prefix}/bin}
KMOD_CFLAGS ?= $(${PKG_CONFIG} --cflags " libkmod >= 23 ")
KMOD_LIBS ?= $(${PKG_CONFIG} --libs " libkmod >= 23 ")
FTS_LIBS ?= ${FTS_LIBS}
EOF
{

View File

@@ -1,70 +0,0 @@
# Conducting A Successful Release
This documents contains the necessary steps to conduct a successful release.
1. Add all items to `NEWS.md`
Get a first template with [`clog`](https://github.com/clog-tool/clog-cli)
```console
$ clog -F -r https://github.com/dracutdevs/dracut
```
2. Update the contributors list in NEWS.md
Produce the list with:
```console
$ make CONTRIBUTORS
```
Append the list to the section in `NEWS.md`
3. Update AUTHORS
```console
$ make AUTHORS
```
4. Check in AUTHORS and NEWS.md
```console
$ git ci -m "docs: update NEWS.md and AUTHORS" NEWS.md AUTHORS
```
5. Tag the release and push
```console
$ VERSION=052
$ git tag -s "$VERSION"
$ git push --tags
```
Add the section from `NEWS.md` to the git tag message.
6. Push git to kernel.org
With:
```console
$ git remote add kernelorg ssh://gitolite@ra.kernel.org/pub/scm/boot/dracut/dracut.git
```
Push to kernel.org git:
```console
$ git push --atomic kernelorg master "$VERSION"
```
7. Sign and upload tarballs to kernel.org
```console
$ make upload
```
This requires `kup` and a kernel.org account.
Wait until the tarballs are synced to http://www.kernel.org/pub/linux/utils/boot/dracut/ .
8. Create a new release on github (https://github.com/dracutdevs/dracut/releases/new)
- Add the section from `NEWS.md` to the release.
- Attach the tarballs and signature file from http://www.kernel.org/pub/linux/utils/boot/dracut/ to the github release.
9. Close the github milestone and open a new one (https://github.com/dracutdevs/dracut/milestones)
10. Ensure that announcement was sent and reached the linux-initramfs mailinglist (https://www.spinics.net/lists/linux-initramfs/)

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#
# Copyright 2013 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
@@ -16,13 +16,13 @@
#
__contains_word () {
local word="$1"; shift
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
}
_dracut() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-f -v -q -l -H -h -M -N
--ro-mnt --force --kernel-only --no-kernel --strip --nostrip
@@ -42,7 +42,6 @@ _dracut() {
'
)
# shellcheck disable=SC2086
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--kmoddir|-k|--fwdir|--confdir|--tmpdir)
@@ -57,41 +56,23 @@ _dracut() {
comps=$(dracut --list-modules 2>/dev/null)
;;
--persistent-policy)
comps=$(cd /dev/disk/ || return 0; printf -- "%s " *)
comps=$(cd /dev/disk/; echo *)
;;
--kver)
comps=$(cd /lib/modules || return 0; echo [0-9]*)
comps=$(cd /lib/modules; echo [0-9]*)
;;
*)
return 0
;;
esac
# shellcheck disable=SC2207
# shellcheck disable=SC2016
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ $cur = -* ]]; then
# shellcheck disable=SC2207
# shellcheck disable=SC2016
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
local args
_count_args
if [[ $args -eq 1 ]]; then
_filedir
return 0
elif [[ $args -eq 2 ]]; then
# shellcheck disable=SC2034
comps=$(cd /lib/modules || return 0; echo [0-9]*)
# shellcheck disable=SC2207
# shellcheck disable=SC2016
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
}
complete -F _dracut dracut

View File

@@ -18,7 +18,7 @@
dwarning() {
echo "Warning: $*" >&2
echo "Warning: $@" >&2
}
dinfo() {
@@ -26,7 +26,7 @@ dinfo() {
}
derror() {
echo "Error: $*" >&2
echo "Error: $@" >&2
}
usage() {
@@ -61,7 +61,7 @@ while (($# > 0)); do
--nooverlay) no_overlay=yes;shift;;
--noimagedir) no_imagedir=yes;shift;;
-h|--help) usage; exit 1 ;;
--debug) export debug="yes";;
--debug) debug="yes";;
-v|--verbose) beverbose="yes";;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
*) break ;;
@@ -104,7 +104,7 @@ if [[ ! $no_overlay ]]; then
ofile="$imagedir/90-overlay.img"
dinfo "Creating image $ofile from directory $overlay"
type pigz &>/dev/null && gzip=pigz || gzip=gzip
( cd "$overlay" || return 1 ; find . |cpio --quiet -H newc -o |$gzip -9 > "$ofile"; )
( cd "$overlay"; find . |cpio --quiet -H newc -o |$gzip -9 > "$ofile"; )
fi
if [[ ! $no_imagedir ]]; then
@@ -113,7 +113,7 @@ if [[ ! $no_imagedir ]]; then
done
fi
images+=( "$@" )
images+=($@)
dinfo "Using base image $baseimage"
cat -- "$baseimage" > "$outfile"

View File

@@ -31,7 +31,6 @@ strstr() { [[ $1 = *"$2"* ]]; }
# Generic glob matching function. If glob pattern $2 matches anywhere in $1, OK
strglobin() { [[ $1 = *$2* ]]; }
# Generic glob matching function. If glob pattern $2 matches all of $1, OK
# shellcheck disable=SC2053
strglob() { [[ $1 = $2 ]]; }
# returns OK if $1 contains literal string $2 at the beginning, and isn't empty
str_starts() { [ "${1#"$2"*}" != "$1" ]; }
@@ -41,49 +40,19 @@ str_ends() { [ "${1%*"$2"}" != "$1" ]; }
# find a binary. If we were not passed the full path directly,
# search in the usual places to find the binary.
find_binary() {
local _delim
local _path
local l
local p
[[ -z ${1##/*} ]] || _delim="/"
if [[ "$1" == *.so* ]]; then
# shellcheck disable=SC2154
for l in $libdirs ; do
_path="${l}${_delim}${1}"
if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then
printf "%s\n" "${_path}"
return 0
fi
done
_path="${_delim}${1}"
if { $DRACUT_LDD "${dracutsysrootdir}${_path}" &>/dev/null; }; then
printf "%s\n" "${_path}"
if [[ -z ${1##/*} ]]; then
if [[ -x $1 ]] || { [[ "$1" == *.so* ]] && ldd "$1" &>/dev/null; }; then
printf "%s\n" "$1"
return 0
fi
fi
if [[ "$1" == */* ]]; then
_path="${_delim}${1}"
if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
printf "%s\n" "${_path}"
return 0
fi
fi
for p in $DRACUT_PATH ; do
_path="${p}${_delim}${1}"
if [[ -L ${dracutsysrootdir}${_path} ]] || [[ -x ${dracutsysrootdir}${_path} ]]; then
printf "%s\n" "${_path}"
return 0
fi
done
[[ -n "$dracutsysrootdir" ]] && return 1
type -P "${1##*/}"
}
ldconfig_paths()
{
$DRACUT_LDCONFIG ${dracutsysrootdir:+-r ${dracutsysrootdir} -f /etc/ld.so.conf} -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
ldconfig -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq
}
# Version comparision function. Assumes Linux style version scheme.
@@ -91,12 +60,7 @@ ldconfig_paths()
# $2 = comparision op (gt, ge, eq, le, lt, ne)
# $3 = version b
vercmp() {
local _n1
read -a _n1 <<< "${1//./ }"
local _op=$2
local _n2
read -a _n2 <<< "${3//./ }"
local _i _res
local _n1=(${1//./ }) _op=$2 _n2=(${3//./ }) _i _res
for ((_i=0; ; _i++))
do
@@ -121,7 +85,6 @@ vercmp() {
# Create all subdirectories for given path without creating the last element.
# $1 = path
mksubdirs() {
# shellcheck disable=SC2174
[[ -e ${1%/*} ]] || mkdir -m 0755 -p -- "${1%/*}"
}
@@ -168,8 +131,8 @@ convert_abs_rel() {
# corner case #2 - own dir link
[[ "${1%/*}" == "$2" ]] && { printf ".\n"; return; }
read -d '/' -r -a __current <<< "$1"
read -d '/' -a __absolute <<< "$2"
IFS="/" __current=($1)
IFS="/" __absolute=($2)
__abssize=${#__absolute[@]}
__cursize=${#__current[@]}
@@ -201,7 +164,7 @@ convert_abs_rel() {
__newpath=$__newpath${__absolute[__i]}
done
printf -- "%s\n" "$__newpath"
printf "%s\n" "$__newpath"
}
@@ -343,7 +306,6 @@ shorten_persistent_dev() {
find_block_device() {
local _dev _majmin _find_mpt
_find_mpt="$1"
if [[ $use_fstab != yes ]]; then
[[ -d $_find_mpt/. ]]
findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt" | { \
@@ -479,13 +441,11 @@ find_mp_fsopts() {
# Echo the filesystem options for a given device.
# /proc/self/mountinfo is taken as the primary source of information
# and /etc/fstab is used as a fallback.
# if `use_fstab == yes`, then only `/etc/fstab` is used.
#
# Example:
# $ find_dev_fsopts /dev/sda2
# rw,relatime,discard,data=ordered
find_dev_fsopts() {
local _find_dev
local _find_dev _opts
_find_dev="$1"
if ! [[ "$_find_dev" = /dev* ]]; then
[[ -b "/dev/block/$_find_dev" ]] && _find_dev="/dev/block/$_find_dev"
@@ -537,6 +497,7 @@ check_block_and_slaves() {
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0
fi
[[ -d /sys/dev/block/$2/slaves ]] || return 1
for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x/dev ]] || continue
[[ $_x/subsystem -ef /sys/class/block ]] || continue
@@ -555,6 +516,7 @@ check_block_and_slaves_all() {
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
fi
[[ -d /sys/dev/block/$2/slaves ]] || return 1
for _x in /sys/dev/block/$2/slaves/*; do
[[ -f $_x/dev ]] || continue
[[ $_x/subsystem -ef /sys/class/block ]] || continue
@@ -571,7 +533,7 @@ for_each_host_dev_and_slaves_all()
local _dev
local _ret=1
[[ "${host_devs[*]}" ]] || return 2
[[ "${host_devs[@]}" ]] || return 2
for _dev in "${host_devs[@]}"; do
[[ -b "$_dev" ]] || continue
@@ -587,7 +549,7 @@ for_each_host_dev_and_slaves()
local _func="$1"
local _dev
[[ "${host_devs[*]}" ]] || return 2
[[ "${host_devs[@]}" ]] || return 2
for _dev in "${host_devs[@]}"; do
[[ -b "$_dev" ]] || continue
@@ -630,12 +592,6 @@ check_vol_slaves_all() {
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
# when filter/global_filter is set, lvm may be failed
lvm lvs --noheadings -o vg_name $_vg 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
return 1
fi
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves_all $1 $(get_maj_min $_pv)
@@ -671,23 +627,18 @@ check_kernel_config()
{
local _config_opt="$1"
local _config_file
[[ -f $dracutsysrootdir/boot/config-$kernel ]] \
[[ -f /boot/config-$kernel ]] \
&& _config_file="/boot/config-$kernel"
[[ -f $dracutsysrootdir/lib/modules/$kernel/config ]] \
[[ -f /lib/modules/$kernel/config ]] \
&& _config_file="/lib/modules/$kernel/config"
# no kernel config file, so return true
[[ $_config_file ]] || return 0
grep -q -F "${_config_opt}=" "$dracutsysrootdir$_config_file" && return 0
grep -q -F "${_config_opt}=" "$_config_file" && return 0
return 1
}
# 0 if the kernel module is either built-in or available
# 1 if the kernel module is not enabled
check_kernel_module() {
modprobe -S $kernel --dry-run $1 &>/dev/null || return 1
}
# get_cpu_vendor
# Only two values are returned: AMD or Intel
@@ -742,166 +693,3 @@ btrfs_devs() {
printf -- "%s\n" "$_dev"
done
}
iface_for_remote_addr() {
set -- $(ip -o route get to "$1")
echo $3
}
local_addr_for_remote_addr() {
set -- $(ip -o route get to "$1")
echo $5
}
peer_for_addr() {
local addr=$1
local qtd
# quote periods in IPv4 address
qtd=${addr//./\\.}
ip -o addr show | \
sed -n 's%^.* '"$qtd"' peer \([0-9a-f.:]\{1,\}\(/[0-9]*\)\?\).*$%\1%p'
}
netmask_for_addr() {
local addr=$1
local qtd
# quote periods in IPv4 address
qtd=${addr//./\\.}
ip -o addr show | sed -n 's,^.* '"$qtd"'/\([0-9]*\) .*$,\1,p'
}
gateway_for_iface() {
local ifname=$1 addr=$2
case $addr in
*.*) proto=4;;
*:*) proto=6;;
*) return;;
esac
ip -o -$proto route show | \
sed -n "s/^default via \([0-9a-z.:]\{1,\}\) dev $ifname .*\$/\1/p"
}
# This works only for ifcfg-style network configuration!
bootproto_for_iface() {
local ifname=$1
local dir
# follow ifcfg settings for boot protocol
for dir in network-scripts network; do
[ -f "/etc/sysconfig/$dir/ifcfg-$ifname" ] && {
sed -n "s/BOOTPROTO=[\"']\?\([[:alnum:]]\{1,\}\)[\"']\?.*\$/\1/p" \
"/etc/sysconfig/$dir/ifcfg-$ifname"
return
}
done
}
is_unbracketed_ipv6_address() {
strglob "$1" '*:*' && ! strglob "$1" '\[*:*\]'
}
# Create an ip= string to set up networking such that the given
# remote address can be reached
ip_params_for_remote_addr() {
local remote_addr=$1
local ifname local_addr peer netmask= gateway ifmac
[[ $remote_addr ]] || return 1
ifname=$(iface_for_remote_addr "$remote_addr")
[[ $ifname ]] || {
berror "failed to determine interface to connect to $remote_addr"
return 1
}
# ifname clause to bind the interface name to a MAC address
if [ -d "/sys/class/net/$ifname/bonding" ]; then
dinfo "Found bonded interface '${ifname}'. Make sure to provide an appropriate 'bond=' cmdline."
elif [ -e "/sys/class/net/$ifname/address" ] ; then
ifmac=$(cat "/sys/class/net/$ifname/address")
[[ $ifmac ]] && printf 'ifname=%s:%s ' "${ifname}" "${ifmac}"
fi
bootproto=$(bootproto_for_iface "$ifname")
case $bootproto in
dhcp|dhcp6|auto6) ;;
dhcp4)
bootproto=dhcp;;
static*|"")
bootproto=;;
*)
derror "bootproto \"$bootproto\" is unsupported by dracut, trying static configuration"
bootproto=;;
esac
if [[ $bootproto ]]; then
printf 'ip=%s:%s ' "${ifname}" "${bootproto}"
else
local_addr=$(local_addr_for_remote_addr "$remote_addr")
[[ $local_addr ]] || {
berror "failed to determine local address to connect to $remote_addr"
return 1
}
peer=$(peer_for_addr "$local_addr")
# Set peer or netmask, but not both
[[ $peer ]] || netmask=$(netmask_for_addr "$local_addr")
gateway=$(gateway_for_iface "$ifname" "$local_addr")
# Quote IPv6 addresses with brackets
is_unbracketed_ipv6_address "$local_addr" && local_addr="[$local_addr]"
is_unbracketed_ipv6_address "$peer" && peer="[$peer]"
is_unbracketed_ipv6_address "$gateway" && gateway="[$gateway]"
printf 'ip=%s:%s:%s:%s::%s:none ' \
"${local_addr}" "${peer}" "${gateway}" "${netmask}" "${ifname}"
fi
}
# block_is_nbd <maj:min>
# Check whether $1 is an nbd device
block_is_nbd() {
[[ -b /dev/block/$1 && $1 == 43:* ]]
}
# block_is_iscsi <maj:min>
# Check whether $1 is an nbd device
block_is_iscsi() {
local _dir
local _dev=$1
[[ -L "/sys/dev/block/$_dev" ]] || return
_dir="$(readlink -f "/sys/dev/block/$_dev")" || return
until [[ -d "$_dir/sys" || -d "$_dir/iscsi_session" ]]; do
_dir="$_dir/.."
done
[[ -d "$_dir/iscsi_session" ]]
}
# block_is_fcoe <maj:min>
# Check whether $1 is an FCoE device
# Will not work for HBAs that hide the ethernet aspect
# completely and present a pure FC device
block_is_fcoe() {
local _dir
local _dev=$1
[[ -L "/sys/dev/block/$_dev" ]] || return
_dir="$(readlink -f "/sys/dev/block/$_dev")"
until [[ -d "$_dir/sys" ]]; do
_dir="$_dir/.."
if [[ -d "$_dir/subsystem" ]]; then
subsystem=$(basename $(readlink $_dir/subsystem))
[[ $subsystem == "fcoe" ]] && return 0
fi
done
return 1
}
# block_is_netdevice <maj:min>
# Check whether $1 is a net device
block_is_netdevice() {
block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1"
}
# get the corresponding kernel modules of a /sys/class/*/* or/dev/* device
get_dev_module() {
udevadm info -a "$1" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p'
}

View File

@@ -19,7 +19,7 @@
#
export LC_MESSAGES=C
if [[ "$EUID" = "0" ]] && ! [[ $DRACUT_NO_XATTR ]]; then
if [[ "$EUID" = "0" ]]; then
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
else
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"
@@ -39,12 +39,10 @@ if ! [[ $dracutbasedir ]]; then
fi
if ! is_func dinfo >/dev/null 2>&1; then
# shellcheck source=./dracut-logger.sh
. "$dracutbasedir/dracut-logger.sh"
dlog_init
fi
# shellcheck disable=SC2154
if ! [[ $initdir ]]; then
dfatal "initdir not set"
exit 1
@@ -59,10 +57,8 @@ if ! [[ $kernel ]]; then
export kernel
fi
# shellcheck disable=SC2154
srcmods="$dracutsysrootdir/lib/modules/$kernel/"
srcmods="/lib/modules/$kernel/"
# shellcheck disable=SC2154
[[ $drivers_dir ]] && {
if ! command -v kmod &>/dev/null && vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
@@ -83,22 +79,17 @@ export srcmods
export hookdirs
}
DRACUT_LDD=${DRACUT_LDD:-ldd}
DRACUT_TESTBIN=${DRACUT_TESTBIN:-/bin/sh}
DRACUT_LDCONFIG=${DRACUT_LDCONFIG:-ldconfig}
# shellcheck source=./dracut-functions.sh
. "$dracutbasedir"/dracut-functions.sh
. $dracutbasedir/dracut-functions.sh
# Detect lib paths
if ! [[ $libdirs ]] ; then
if [[ $("$DRACUT_LDD" "$dracutsysrootdir$DRACUT_TESTBIN") == */lib64/* ]] &>/dev/null \
&& [[ -d $dracutsysrootdir/lib64 ]]; then
if [[ "$(ldd /bin/sh)" == */lib64/* ]] &>/dev/null \
&& [[ -d /lib64 ]]; then
libdirs+=" /lib64"
[[ -d $dracutsysrootdir/usr/lib64 ]] && libdirs+=" /usr/lib64"
[[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64"
else
libdirs+=" /lib"
[[ -d $dracutsysrootdir/usr/lib ]] && libdirs+=" /usr/lib"
[[ -d /usr/lib ]] && libdirs+=" /usr/lib"
fi
libdirs+=" $(ldconfig_paths)"
@@ -110,7 +101,6 @@ fi
# to check for required installed binaries
# issues a standardized warning message
require_binaries() {
# shellcheck disable=SC2154
local _module_name="${moddir##*/}"
local _ret=0
@@ -125,7 +115,7 @@ require_binaries() {
((_ret++))
fi
done
return "$_ret"
return $_ret
}
require_any_binary() {
@@ -144,8 +134,8 @@ require_any_binary() {
fi
done
if (( _ret != 0 )); then
dinfo "$_module_name: Could not find any command of '$*'!"
if (( $_ret != 0 )); then
dinfo "$_module_name: Could not find any command of '$@'!"
return 1
fi
@@ -153,27 +143,19 @@ require_any_binary() {
}
dracut_need_initqueue() {
: >"$initdir/lib/dracut/need-initqueue"
>"$initdir/lib/dracut/need-initqueue"
}
dracut_module_included() {
# shellcheck disable=SC2154
[[ " $mods_to_load $modules_loaded " == *\ $*\ * ]]
}
dracut_no_switch_root() {
: >"$initdir/lib/dracut/no-switch-root"
>"$initdir/lib/dracut/no-switch-root"
}
dracut_module_path() {
local _dir
# shellcheck disable=SC2231
for _dir in "${dracutbasedir}"/modules.d/??${1}; do
echo "$_dir"
return 0
done
return 1
echo ${dracutbasedir}/modules.d/??${1} | { read a b; echo "$a"; }
}
if ! [[ $DRACUT_INSTALL ]]; then
@@ -186,18 +168,7 @@ elif ! [[ $DRACUT_INSTALL ]] && [[ -x $dracutbasedir/install/dracut-install ]];
DRACUT_INSTALL=$dracutbasedir/install/dracut-install
fi
# Test if dracut-install is a standalone executable with no options.
# E.g. DRACUT_INSTALL may be set externally as:
# DRACUT_INSTALL="valgrind dracut-install"
# or
# DRACUT_INSTALL="dracut-install --debug"
# in which case the string cannot be tested for being executable.
DRINSTALLPARTS=0
for i in $DRACUT_INSTALL ; do
DRINSTALLPARTS=$((DRINSTALLPARTS+1))
done
if [[ $DRINSTALLPARTS = 1 ]] && ! command -v "$DRACUT_INSTALL" > /dev/null 2>&1 ; then
if ! [[ -x $DRACUT_INSTALL ]]; then
dfatal "dracut-install not found!"
exit 10
fi
@@ -205,16 +176,15 @@ fi
if [[ $hostonly == "-h" ]]; then
if ! [[ $DRACUT_KERNEL_MODALIASES ]] || ! [[ -f "$DRACUT_KERNEL_MODALIASES" ]]; then
export DRACUT_KERNEL_MODALIASES="${DRACUT_TMPDIR}/modaliases"
"$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES"
$DRACUT_INSTALL ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES"
fi
fi
[[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1
inst_dir() {
[[ -e ${initdir}/"$1" ]] && return 0 # already there
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@"
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} -d "$@" || :
}
inst() {
@@ -224,10 +194,8 @@ inst() {
shift
fi
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
# shellcheck disable=SC2154
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
}
inst_simple() {
@@ -238,9 +206,8 @@ inst_simple() {
fi
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[[ -e $1 ]] || return 1 # no source
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@" || :
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@"
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@" || :
}
inst_symlink() {
@@ -251,20 +218,16 @@ inst_symlink() {
fi
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[[ -L $1 ]] || return 1
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
}
inst_multiple() {
local _ret
if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
return 0
else
_ret=$?
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
return $_ret
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"
_ret=$?
(($_ret != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
return $_ret
}
dracut_install() {
@@ -274,20 +237,14 @@ dracut_install() {
dracut_instmods() {
local _silent=0;
local i;
# shellcheck disable=SC2154
[[ $no_kernel = yes ]] && return
for i in "$@"; do
[[ $i == "--silent" ]] && _silent=1
done
# shellcheck disable=SC2154
if ! "$DRACUT_INSTALL" \
${dracutsysrootdir:+-r "$dracutsysrootdir"} \
${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@"; then
if ((_silent == 0)); then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" || :
fi
fi
$DRACUT_INSTALL \
${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@"
(($? != 0)) && (($_silent == 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@" || :
}
inst_library() {
@@ -298,28 +255,24 @@ inst_library() {
fi
[[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there
[[ -e $1 ]] || return 1 # no source
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
}
inst_binary() {
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
}
inst_script() {
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then
derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"
(($? != 0)) && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@" || :
}
inst_fsck_help() {
local _helper="/run/dracut/fsck/fsck_help_$1.txt"
if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper"; then
derror "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper" || :
fi
$DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper
(($? != 0)) && derror $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" $_helper || :
}
# Use with form hostonly="$(optional_hostonly)" inst_xxxx <args>
@@ -327,9 +280,8 @@ inst_fsck_help() {
# be applied, else will ignore hostonly mode and try to install all
# given modules.
optional_hostonly() {
# shellcheck disable=SC2154
if [[ $hostonly_mode = "strict" ]]; then
printf -- "%s" "$hostonly"
printf -- "$hostonly"
else
printf ""
fi
@@ -352,36 +304,28 @@ mark_hostonly() {
# output: libfoo.so.8 libfoo.so
# (Only if libfoo.so.8 and libfoo.so exists on host system.)
rev_lib_symlinks() {
local _fn
local _orig
local _links
[[ ! $1 ]] && return 0
_fn="$1"
_orig="$(readlink -f "$1")"
_links=()
local fn="$1" orig="$(readlink -f "$1")" links=''
[[ ${_fn} == *.so.* ]] || return 1
[[ ${fn} == *.so.* ]] || return 1
until [[ ${_fn##*.} == so ]]; do
_fn="${_fn%.*}"
[[ -L ${_fn} ]] && [[ $(readlink -f "${_fn}") == "${_orig}" ]] && _links+=( "${_fn}" )
until [[ ${fn##*.} == so ]]; do
fn="${fn%.*}"
[[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}"
done
echo "${_links[*]}}"
echo "${links}"
}
# attempt to install any programs specified in a udev rule
inst_rule_programs() {
local _prog _bin
# shellcheck disable=SC2013
for _prog in $(sed -nr 's/.*PROGRAM==?"([^ "]+).*/\1/p' "$1"); do
_bin=""
# shellcheck disable=SC2154
if [[ -x ${udevdir}/$_prog ]]; then
_bin="${udevdir}"/$_prog
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
@@ -391,11 +335,9 @@ inst_rule_programs() {
[[ $_bin ]] && inst_binary "$_bin"
done
# shellcheck disable=SC2013
for _prog in $(sed -nr 's/.*RUN[+=]=?"([^ "]+).*/\1/p' "$1"); do
_bin=""
if [[ -x ${udevdir}/$_prog ]]; then
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then
_bin=$(find_binary "$_prog") || {
@@ -406,11 +348,9 @@ inst_rule_programs() {
[[ $_bin ]] && inst_binary "$_bin"
done
# shellcheck disable=SC2013
for _prog in $(sed -nr 's/.*IMPORT\{program\}==?"([^ "]+).*/\1/p' "$1"); do
_bin=""
if [[ -x ${udevdir}/$_prog ]]; then
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || {
@@ -427,17 +367,14 @@ inst_rule_programs() {
inst_rule_group_owner() {
local i
# shellcheck disable=SC2013
for i in $(sed -nr 's/.*OWNER=?"([^ "]+).*/\1/p' "$1"); do
if ! grep -Eq "^$i:" "$initdir/etc/passwd" 2>/dev/null; then
grep -E "^$i:" "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep -E "^$i:" /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
fi
done
# shellcheck disable=SC2013
for i in $(sed -nr 's/.*GROUP=?"([^ "]+).*/\1/p' "$1"); do
if ! grep -Eq "^$i:" "$initdir/etc/group" 2>/dev/null; then
grep -E "^$i:" "$dracutsysrootdir"/etc/group 2>/dev/null >> "$initdir/etc/group"
grep -E "^$i:" /etc/group 2>/dev/null >> "$initdir/etc/group"
fi
done
}
@@ -457,7 +394,7 @@ inst_rules() {
inst_dir "$_target"
for _rule in "$@"; do
if [ "${_rule#/}" = "$_rule" ]; then
for r in "$dracutsysrootdir${udevdir}/rules.d" ${hostonly:+"$dracutsysrootdir"/etc/udev/rules.d}; do
for r in ${udevdir}/rules.d ${hostonly:+/etc/udev/rules.d}; do
[[ -e $r/$_rule ]] || continue
_found="$r/$_rule"
inst_rule_programs "$_found"
@@ -466,7 +403,7 @@ inst_rules() {
inst_simple "$_found"
done
fi
for r in '' "$dracutsysrootdir$dracutbasedir/rules.d/"; do
for r in '' $dracutbasedir/rules.d/; do
# skip rules without an absolute path
[[ "${r}$_rule" != /* ]] && continue
[[ -f ${r}$_rule ]] || continue
@@ -507,35 +444,22 @@ inst_rules_wildcard() {
}
prepare_udev_rules() {
if [ -z "$UDEVVERSION" ]; then
UDEVVERSION=$(udevadm --version)
export UDEVVERSION
fi
if [ -z "$UDEVVERSION" ]; then
derror "Failed to detect udev version!"
return 1
fi
if [ -z "${UDEVVERSION##*[!0-9]*}" ]; then
derror "udevadm --version did not report an integer, udev version cannot be determined!"
return 1
fi
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
for f in "$@"; do
f="${initdir}/etc/udev/rules.d/$f"
[ -e "$f" ] || continue
while read -r line || [ -n "$line" ]; do
while read line || [ -n "$line" ]; do
if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
if (( UDEVVERSION >= 174 )); then
if [ $UDEVVERSION -ge 174 ]; then
printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
else
printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
fi
elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
if (( UDEVVERSION >= 176 )); then
if [ $UDEVVERSION -ge 176 ]; then
printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
else
# shellcheck disable=SC2016
printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
fi
else
@@ -593,28 +517,28 @@ inst_any() {
# Install a <file> located on a lib directory to the initramfs image
# -n <pattern> install matching files
inst_libdir_file() {
local -a _files
local _files
if [[ "$1" == "-n" ]]; then
local _pattern=$2
shift 2
for _dir in $libdirs; do
for _i in "$@"; do
for _f in "$dracutsysrootdir$_dir"/$_i; do
[[ "${_f#$dracutsysrootdir}" =~ $_pattern ]] || continue
[[ -e "$_f" ]] && _files+=("${_f#$dracutsysrootdir}")
for _f in "$_dir"/$_i; do
[[ "$_f" =~ $_pattern ]] || continue
[[ -e "$_f" ]] && _files+="$_f "
done
done
done
else
for _dir in $libdirs; do
for _i in "$@"; do
for _f in "$dracutsysrootdir$_dir"/$_i; do
[[ -e "$_f" ]] && _files+=("${_f#$dracutsysrootdir}")
for _f in "$_dir"/$_i; do
[[ -e "$_f" ]] && _files+="$_f "
done
done
done
fi
[[ ${#_files[@]} -gt 0 ]] && inst_multiple "${_files[@]}"
[[ $_files ]] && inst_multiple $_files
}
# get a command to decompress the given file
@@ -634,10 +558,11 @@ get_decompress_cmd() {
inst_decompress() {
local _src _cmd
for _src in "$@"; do
_cmd=$(get_decompress_cmd "${_src}")
for _src in $@
do
_cmd=$(get_decompress_cmd ${_src})
[[ -z "${_cmd}" ]] && return 1
inst_simple "${_src}"
inst_simple ${_src}
# Decompress with chosen tool. We assume that tool changes name e.g.
# from 'name.gz' to 'name'.
${_cmd} "${initdir}${_src}"
@@ -650,7 +575,7 @@ inst_decompress() {
inst_opt_decompress() {
local _src
for _src in "$@"; do
for _src in $@; do
inst_decompress "${_src}" || inst "${_src}"
done
}
@@ -670,20 +595,16 @@ module_check() {
if [[ ! -f $_moddir/module-setup.sh ]]; then
# if we do not have a check script, we are unconditionally included
[[ -x $_moddir/check ]] || return 0
[[ $_forced != 0 ]] && unset hostonly
# don't quote $hostonly to leave argument empty
# shellcheck disable=SC2086
"$_moddir"/check $hostonly
[ $_forced -ne 0 ] && unset hostonly
$_moddir/check $hostonly
_ret=$?
else
unset check depends cmdline install installkernel
check() { true; }
. "$_moddir"/module-setup.sh
. $_moddir/module-setup.sh
is_func check || return 0
[[ $_forced != 0 ]] && unset hostonly
# don't quote $hostonly to leave argument empty
# shellcheck disable=SC2086
moddir="$_moddir" check $hostonly
[ $_forced -ne 0 ] && unset hostonly
moddir=$_moddir check $hostonly
_ret=$?
unset check depends cmdline install installkernel
fi
@@ -698,24 +619,24 @@ module_check() {
module_check_mount() {
local _moddir=$2
local _ret
export mount_needs=1
mount_needs=1
[[ -z $_moddir ]] && _moddir=$(dracut_module_path "$1")
[[ -d $_moddir ]] || return 1
if [[ ! -f $_moddir/module-setup.sh ]]; then
# if we do not have a check script, we are unconditionally included
[[ -x $_moddir/check ]] || return 0
mount_needs=1 "$_moddir"/check 0
mount_needs=1 $_moddir/check 0
_ret=$?
else
unset check depends cmdline install installkernel
check() { false; }
. "$_moddir"/module-setup.sh
. $_moddir/module-setup.sh
moddir=$_moddir check 0
_ret=$?
unset check depends cmdline install installkernel
fi
unset mount_needs
return "$_ret"
return $_ret
}
# module_depends <dracut module> [<module path>]
@@ -729,12 +650,12 @@ module_depends() {
if [[ ! -f $_moddir/module-setup.sh ]]; then
# if we do not have a check script, we have no deps
[[ -x $_moddir/check ]] || return 0
"$_moddir"/check -d
$_moddir/check -d
return $?
else
unset check depends cmdline install installkernel
depends() { true; }
. "$_moddir"/module-setup.sh
. $_moddir/module-setup.sh
moddir=$_moddir depends
_ret=$?
unset check depends cmdline install installkernel
@@ -756,8 +677,8 @@ module_cmdline() {
else
unset check depends cmdline install installkernel
cmdline() { true; }
. "$_moddir"/module-setup.sh
moddir="$_moddir" cmdline
. $_moddir/module-setup.sh
moddir=$_moddir cmdline
_ret=$?
unset check depends cmdline install installkernel
return $_ret
@@ -778,8 +699,8 @@ module_install() {
else
unset check depends cmdline install installkernel
install() { true; }
. "$_moddir"/module-setup.sh
moddir="$_moddir" install
. $_moddir/module-setup.sh
moddir=$_moddir install
_ret=$?
unset check depends cmdline install installkernel
return $_ret
@@ -800,8 +721,8 @@ module_installkernel() {
else
unset check depends cmdline install installkernel
installkernel() { true; }
. "$_moddir"/module-setup.sh
moddir="$_moddir" installkernel
. $_moddir/module-setup.sh
moddir=$_moddir installkernel
_ret=$?
unset check depends cmdline install installkernel
return $_ret
@@ -818,7 +739,6 @@ check_mount() {
local _moddep
[[ -z $_moddir ]] && _moddir=$(dracut_module_path "$1")
# shellcheck disable=SC2154
[ "${#host_fs_types[@]}" -le 0 ] && return 1
# If we are already scheduled to be loaded, no need to check again.
@@ -830,13 +750,12 @@ check_mount() {
[[ $2 ]] || mods_checked_as_dep+=" $_mod "
# shellcheck disable=SC2154
if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then
return 1
fi
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
module_check_mount "$_mod" "$_moddir"; ret=$?
module_check_mount $_mod $_moddir; ret=$?
# explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1
@@ -844,14 +763,14 @@ check_mount() {
# module not in our list
if [[ $dracutmodules = all ]]; then
# check, if we can and should install this module
module_check_mount "$_mod" "$_moddir" || return 1
module_check_mount $_mod $_moddir || return 1
else
# skip this module
return 1
fi
fi
for _moddep in $(module_depends "$_mod" "$_moddir"); do
for _moddep in $(module_depends $_mod $_moddir); do
# handle deps as if they were manually added
[[ " $dracutmodules " == *\ $_mod\ * ]] \
&& [[ " $dracutmodules " != *\ $_moddep\ * ]] \
@@ -863,7 +782,7 @@ check_mount() {
&& [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \
&& force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also
if ! check_module "$_moddep"; then
if ! check_module $_moddep; then
derror "dracut module '$_mod' depends on '$_moddep', which can't be installed"
return 1
fi
@@ -896,15 +815,15 @@ check_module() {
[[ $2 ]] || mods_checked_as_dep+=" $_mod "
if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then
ddebug "dracut module '$_mod' will not be installed, because it's in the list to be omitted!"
dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!"
return 1
fi
if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
if [[ " $dracutmodules $force_add_dracutmodules " == *\ $_mod\ * ]]; then
module_check "$_mod" 1 "$_moddir"; ret=$?
module_check $_mod 1 $_moddir; ret=$?
else
module_check "$_mod" 0 "$_moddir"; ret=$?
module_check $_mod 0 $_moddir; ret=$?
fi
# explicit module, so also accept ret=255
[[ $ret = 0 || $ret = 255 ]] || return 1
@@ -912,7 +831,7 @@ check_module() {
# module not in our list
if [[ $dracutmodules = all ]]; then
# check, if we can and should install this module
module_check "$_mod" 0 "$_moddir"; ret=$?
module_check $_mod 0 $_moddir; ret=$?
if [[ $ret != 0 ]]; then
[[ $2 ]] && return 1
[[ $ret != 255 ]] && return 1
@@ -923,7 +842,7 @@ check_module() {
fi
fi
for _moddep in $(module_depends "$_mod" "$_moddir"); do
for _moddep in $(module_depends $_mod $_moddir); do
# handle deps as if they were manually added
[[ " $dracutmodules " == *\ $_mod\ * ]] \
&& [[ " $dracutmodules " != *\ $_moddep\ * ]] \
@@ -935,7 +854,7 @@ check_module() {
&& [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \
&& force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also
if ! check_module "$_moddep"; then
if ! check_module $_moddep; then
derror "dracut module '$_mod' depends on '$_moddep', which can't be installed"
return 1
fi
@@ -960,7 +879,7 @@ for_each_module_dir() {
[[ -e $_moddir/install || -e $_moddir/installkernel || \
-e $_moddir/module-setup.sh ]] || continue
_mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]}
$_func "$_mod" 1 "$_moddir"
$_func $_mod 1 $_moddir
done
# Report any missing dracut modules, the user has specified
@@ -988,7 +907,7 @@ dracut_kernel_post() {
# generate module dependencies for the initrd
if [[ -d $initdir/lib/modules/$kernel ]] && \
! depmod -a -b "$initdir" "$kernel"; then
! depmod -a -b "$initdir" $kernel; then
dfatal "\"depmod -a $kernel\" failed."
exit 1
fi
@@ -1026,9 +945,8 @@ instmods() {
return 0
fi
"$DRACUT_INSTALL" \
$DRACUT_INSTALL \
${initdir:+-D "$initdir"} \
${dracutsysrootdir:+-r "$dracutsysrootdir"} \
${loginstall:+-L "$loginstall"} \
${hostonly:+-H} \
${omit_drivers:+-N "$omit_drivers"} \
@@ -1038,11 +956,10 @@ instmods() {
-m "$@"
_ret=$?
if ((_ret != 0)) && [[ -z "$_silent" ]]; then
if (($_ret != 0)) && [[ -z "$_silent" ]]; then
derror "FAILED: " \
"$DRACUT_INSTALL" \
$DRACUT_INSTALL \
${initdir:+-D "$initdir"} \
${dracutsysrootdir:+-r "$dracutsysrootdir"} \
${loginstall:+-L "$loginstall"} \
${hostonly:+-H} \
${omit_drivers:+-N "$omit_drivers"} \
@@ -1074,9 +991,8 @@ is_qemu_virtualized() {
# 1 if a virt environment could not be detected
# 255 if any error was encountered
if type -P systemd-detect-virt >/dev/null 2>&1; then
if ! vm=$(systemd-detect-virt --vm >/dev/null 2>&1); then
return 255
fi
vm=$(systemd-detect-virt --vm >/dev/null 2>&1)
(($? != 0)) && return 255
[[ $vm = "qemu" ]] && return 0
[[ $vm = "kvm" ]] && return 0
[[ $vm = "bochs" ]] && return 0
@@ -1084,7 +1000,7 @@ is_qemu_virtualized() {
for i in /sys/class/dmi/id/*_vendor; do
[[ -f $i ]] || continue
read -r vendor < "$i"
read vendor < $i
[[ "$vendor" == "QEMU" ]] && return 0
[[ "$vendor" == "Red Hat" ]] && return 0
[[ "$vendor" == "Bochs" ]] && return 0

View File

@@ -16,17 +16,10 @@ SKIP="$dracutbasedir/skipcpio"
mount -o ro /boot &>/dev/null || true
if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
&& [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]] ; then
IMG="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
else
IMG="/boot/initramfs-${KERNEL_VERSION}.img"
fi
[[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img"
cd /run/initramfs

View File

@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
export __DRACUT_LOGGER__=1
__DRACUT_LOGGER__=1
## @brief Logging facility module for dracut both at build- and boot-time.
@@ -114,13 +114,13 @@ dlog_init() {
if [ -z "$fileloglvl" ]; then
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
elif (( fileloglvl > 0 )); then
elif (( $fileloglvl > 0 )); then
if [[ $logfile ]]; then
__oldumask=$(umask)
umask 0377
! [ -e "$logfile" ] && : >"$logfile"
umask "$__oldumask"
if [[ -w $logfile ]] && [[ -f $logfile ]]; then
! [ -e "$logfile" ] && >"$logfile"
umask $__oldumask
if [ -w "$logfile" -a -f "$logfile" ]; then
# Mark new run in the log file
echo >>"$logfile"
if command -v date >/dev/null; then
@@ -138,12 +138,12 @@ dlog_init() {
fi
fi
if (( UID != 0 )); then
if (( $UID != 0 )); then
kmsgloglvl=0
sysloglvl=0
fi
if (( sysloglvl > 0 )); then
if (( $sysloglvl > 0 )); then
if [[ -d /run/systemd/journal ]] \
&& type -P systemd-cat &>/dev/null \
&& systemctl --quiet is-active systemd-journald.socket &>/dev/null \
@@ -153,7 +153,7 @@ dlog_init() {
readonly _dlogfd=15
systemd-cat -t 'dracut' --level-prefix=true <"$_systemdcatfile" &
exec 15>"$_systemdcatfile"
elif ! [[ -S /dev/log ]] && [[ -w /dev/log ]] || ! command -v logger >/dev/null; then
elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then
# We cannot log to syslog, so turn this facility off.
kmsgloglvl=$sysloglvl
sysloglvl=0
@@ -162,7 +162,7 @@ dlog_init() {
fi
fi
if (( sysloglvl > 0 )) || (( kmsgloglvl > 0 )); then
if (($sysloglvl > 0)) || (($kmsgloglvl > 0 )); then
if [ -n "$dracutbasedir" ]; then
readonly syslogfacility=user
else
@@ -173,40 +173,40 @@ dlog_init() {
local lvl; local maxloglvl_l=0
for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
(( lvl > maxloglvl_l )) && maxloglvl_l=$lvl
(( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl
done
readonly maxloglvl=$maxloglvl_l
export maxloglvl
if (( stdloglvl < 6 )) && ((kmsgloglvl < 6)) && ((fileloglvl < 6)) && ((sysloglvl < 6)); then
if (($stdloglvl < 6)) && (($kmsgloglvl < 6)) && (($fileloglvl < 6)) && (($sysloglvl < 6)); then
unset dtrace
dtrace() { :; };
fi
if ((stdloglvl < 5)) && ((kmsgloglvl < 5)) && ((fileloglvl < 5)) && ((sysloglvl < 5)); then
if (($stdloglvl < 5)) && (($kmsgloglvl < 5)) && (($fileloglvl < 5)) && (($sysloglvl < 5)); then
unset ddebug
ddebug() { :; };
fi
if ((stdloglvl < 4)) && ((kmsgloglvl < 4)) && ((fileloglvl < 4)) && ((sysloglvl < 4)); then
if (($stdloglvl < 4)) && (($kmsgloglvl < 4)) && (($fileloglvl < 4)) && (($sysloglvl < 4)); then
unset dinfo
dinfo() { :; };
fi
if ((stdloglvl < 3)) && ((kmsgloglvl < 3)) && ((fileloglvl < 3)) && ((sysloglvl < 3)); then
if (($stdloglvl < 3)) && (($kmsgloglvl < 3)) && (($fileloglvl < 3)) && (($sysloglvl < 3)); then
unset dwarn
dwarn() { :; };
unset dwarning
dwarning() { :; };
fi
if ((stdloglvl < 2)) && ((kmsgloglvl < 2)) && ((fileloglvl < 2)) && ((sysloglvl < 2)); then
if (($stdloglvl < 2)) && (($kmsgloglvl < 2)) && (($fileloglvl < 2)) && (($sysloglvl < 2)); then
unset derror
derror() { :; };
fi
if ((stdloglvl < 1)) && ((kmsgloglvl < 1)) && ((fileloglvl < 1)) && ((sysloglvl < 1)); then
if (($stdloglvl < 1)) && (($kmsgloglvl < 1)) && (($fileloglvl < 1)) && (($sysloglvl < 1)); then
unset dfatal
dfatal() { :; };
fi
@@ -241,7 +241,7 @@ _lvl2char() {
# @retval 0 if @a lvl is correct.
# @result Echoes logger priority.
_lvl2syspri() {
printf "%s" -- "$syslogfacility."
printf $syslogfacility.
case "$1" in
1) echo crit;;
2) echo error;;
@@ -288,7 +288,7 @@ _dlvl2syslvl() {
*) return 1;;
esac
[ "$syslogfacility" = user ] && echo $(( 8 + lvl )) || echo $(( 24 + lvl ))
[ "$syslogfacility" = user ] && echo $((8+$lvl)) || echo $((24+$lvl))
}
## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg
@@ -323,22 +323,22 @@ _do_dlog() {
local msg="$*"
local lmsg="$lvlc: $*"
(( lvl <= stdloglvl )) && printf -- 'dracut: %s\n' "$msg" >&2
(( $lvl <= $stdloglvl )) && printf -- 'dracut: %s\n' "$msg" >&2
if (( lvl <= sysloglvl )); then
if (( $lvl <= $sysloglvl )); then
if [[ "$_dlogfd" ]]; then
printf -- "<%s>%s\n" "$(($(_dlvl2syslvl "$lvl") & 7))" "$msg" >&$_dlogfd
printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd
else
logger -t "dracut[$$]" -p "$(_lvl2syspri "$lvl")" -- "$msg"
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) -- "$msg"
fi
fi
if (( lvl <= fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
echo "$lmsg" >>"$logfile"
fi
(( lvl <= kmsgloglvl )) && \
echo "<$(_dlvl2syslvl "$lvl")>dracut[$$] $msg" >/dev/kmsg
(( $lvl <= $kmsgloglvl )) && \
echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
}
## @brief Internal helper function for _do_dlog()
@@ -359,12 +359,12 @@ _do_dlog() {
# echo "This is a warning" | dwarn
dlog() {
[ -z "$maxloglvl" ] && return 0
(( $1 <= maxloglvl )) || return 0
(( $1 <= $maxloglvl )) || return 0
if (( $# > 1 )); then
_do_dlog "$@"
else
while read -r line || [ -n "$line" ]; do
while read line || [ -n "$line" ]; do
_do_dlog "$1" "$line"
done
fi

View File

@@ -3,7 +3,6 @@ DRACUT(8)
:doctype: manpage
:man source: dracut
:man manual: dracut
:man version: {version}
NAME
----
@@ -265,9 +264,6 @@ example:
**-v, --verbose**::
increase verbosity level (default is info(4))
**--version**::
display version and exit
**-q, --quiet**:: decrease verbosity level (default is info(4))
**-c, --conf** _<dracut configuration file>_::
@@ -288,15 +284,6 @@ Default:
Default:
_/var/tmp_
**-r, --sysroot** _<sysroot directory>_::
specify the sysroot directory to collect files from.
This is useful to create the initramfs image from
a cross-compiled sysroot directory. For the extra helper
variables, see *ENVIRONMENT* below.
+
Default:
_empty_
**--sshkey** _<sshkey file>_:: ssh key file used with ssh-client module.
**--logfile** _<logfile>_:: logfile to use; overrides any setting from
@@ -510,9 +497,6 @@ will not be able to boot.
The <BUILD_ID> is taken from BUILD_ID in _/usr/lib/os-release_ or if it exists
_/etc/os-release_ and is left out, if BUILD_ID is non-existant or empty.
**--no-uefi**::
Disables UEFI mode.
**--no-machineid**::
affects the default output filename of **--uefi** and will discard the <MACHINE_ID>
part.
@@ -523,10 +507,6 @@ will not be able to boot.
_$prefix/lib/systemd/boot/efi/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_
or _$prefix/lib/gummiboot/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_
**--uefi-splash-image _<FILE>_**::
Specifies the UEFI stub loader's splash image. Requires bitmap (**.bmp**) image
format.
**--kernel-image _<FILE>_**::
Specifies the kernel image, which to include in the UEFI executable. The default is
_/lib/modules/<KERNEL-VERSION>/vmlinuz_ or _/boot/vmlinuz-<KERNEL-VERSION>_
@@ -537,97 +517,6 @@ ENVIRONMENT
_INITRD_COMPRESS_::
sets the default compression program. See **--compress**.
_DRACUT_LDCONFIG_::
sets the _ldconfig_ program path and options. Optional.
Used for **--sysroot**.
+
Default:
_ldconfig_
_DRACUT_LDD_::
sets the _ldd_ program path and options. Optional.
Used for **--sysroot**.
+
Default:
_ldd_
_DRACUT_TESTBIN_::
sets the initially tested binary for detecting library paths.
Optional. Used for **--sysroot**. In the cross-compiled sysroot,
the default value (_/bin/sh_) is unusable, as it is an absolute
symlink and points outside the sysroot directory.
+
Default:
_/bin/sh_
_DRACUT_INSTALL_::
overrides path and options for executing _dracut-install_ internally.
Optional. Can be used to debug _dracut-install_ while running the
main dracut script.
+
Default:
_dracut-install_
+
Example:
DRACUT_INSTALL="valgrind dracut-install"
_DRACUT_COMPRESS_BZIP2_::
_DRACUT_COMPRESS_BZIP2_::
_DRACUT_COMPRESS_LBZIP2_::
_DRACUT_COMPRESS_LZMA_::
_DRACUT_COMPRESS_XZ_::
_DRACUT_COMPRESS_GZIP_::
_DRACUT_COMPRESS_PIGZ_::
_DRACUT_COMPRESS_LZOP_::
_DRACUT_COMPRESS_ZSTD_::
_DRACUT_COMPRESS_LZ4_::
_DRACUT_COMPRESS_CAT_::
overrides for compression utilities to support using them from
non-standard paths.
+
Default values are the default compression utility names to be found in **PATH**.
_DRACUT_ARCH_::
overrides the value of **uname -m**. Used for **--sysroot**.
+
Default:
_empty_ (the value of **uname -m** on the host system)
_SYSTEMD_VERSION_::
overrides systemd version. Used for **--sysroot**.
_SYSTEMCTL_::
overrides the systemctl binary. Used for **--sysroot**.
_NM_VERSION_::
overrides the NetworkManager version. Used for **--sysroot**.
_DRACUT_INSTALL_PATH_::
overrides **PATH** environment for **dracut-install** to look for
binaries relative to **--sysroot**. In a cross-compiled environment
(e.g. Yocto), PATH points to natively built binaries that are not
in the host's /bin, /usr/bin, etc. **dracut-install** still needs plain
/bin and /usr/bin that are relative to the cross-compiled sysroot.
+
Default:
_PATH_
_DRACUT_INSTALL_LOG_TARGET_::
overrides **DRACUT_LOG_TARGET** for **dracut-install**. It allows
running **dracut-install* to run with different log target that
**dracut** runs with.
+
Default:
_DRACUT_LOG_TARGET_
_DRACUT_INSTALL_LOG_LEVEL_::
overrides **DRACUT_LOG_LEVEL** for **dracut-install**. It allows
running **dracut-install* to run with different log level that
**dracut** runs with.
+
Default:
_DRACUT_LOG_LEVEL_
FILES
-----
_/var/log/dracut.log_::
@@ -671,18 +560,18 @@ Harald Hoyer
Victor Lowther
Amadeusz Żołnowski
Hannes Reinecke
Daniel Molkentin
Will Woods
Philippe Seewer
Warren Togami
Amadeusz Żołnowski
Jeremy Katz
David Dillow
Will Woods
SEE ALSO
--------
*dracut.cmdline*(7) *dracut.conf*(5) *lsinitrd*(1)

View File

@@ -1,8 +1,8 @@
dracut {mainversion}
====================
:author: Harald Hoyer
:email: harald@redhat.com
:revnumber: {version}
dracut
======
Harald Hoyer <harald@redhat.com>
v3.0, October 2013
:language: bash
= Introduction

View File

@@ -3,7 +3,6 @@ DRACUT.BOOTUP(7)
:doctype: manpage
:man source: dracut
:man manual: dracut
:man version: {version}
NAME
----

View File

@@ -3,7 +3,6 @@ DRACUT.CMDLINE(7)
:doctype: manpage
:man source: dracut
:man manual: dracut
:man version: {version}
NAME
----
@@ -113,9 +112,6 @@ resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
iso-scan/filename
~~~~~~~~~~~~~~~~~
Mount all mountable devices and search for ISO pointed by the argument. When
the ISO is found set it up as a loop device. Device containing this ISO
image will stay mounted at /run/initramfs/isoscandev.
Using iso-scan/filename with a Fedora/Red Hat/CentOS Live iso should just work
by copying the original kernel cmdline parameters.
@@ -167,12 +163,6 @@ Misc
specify the controlling terminal for the console.
This is useful, if you have multiple "console=" arguments.
**rd.shutdown.timeout.umount=**__<seconds>__::
specify how long dracut should wait for an individual umount to finish
during shutdown. This avoids the system from blocking when unmounting a file
system cannot complete and waits indefinitely. Value '0' means to wait
'forever'. The default is 90 seconds.
[[dracutkerneldebug]]
Debug
~~~~~
@@ -197,8 +187,8 @@ It should be attached to any report about dracut problems.
_/run/initramfs/init.log_.
If "quiet" is set, it also logs to the console.
**rd.memdebug=[0-5]**::
Print memory usage info at various points, set the verbose level from 0 to 5.
**rd.memdebug=[0-4]**::
Print memory usage info at various points, set the verbose level from 0 to 4.
+
Higher level means more debugging output:
+
@@ -207,14 +197,10 @@ It should be attached to any report about dracut problems.
1 - partial /proc/meminfo
2 - /proc/meminfo
3 - /proc/meminfo + /proc/slabinfo
4 - /proc/meminfo + /proc/slabinfo + memstrack summary
NOTE: memstrack is a memory tracing tool that tracks the total memory
consumption, and peak memory consumption of each kernel modules
and userspace progress during the whole initramfs runtime, report
is genereted and the end of initramsfs run.
5 - /proc/meminfo + /proc/slabinfo + memstrack (with top memory stacktrace)
NOTE: memstrack (with top memory stacktrace) will print top memory
allocation stack traces during the whole initramfs runtime.
4 - /proc/meminfo + /proc/slabinfo + tracekomem
NOTE: tracekomem is a shell script utilizing kernel trace to track
the rough total memory consumption of kernel modules during
loading. It may override other trace configurations.
----
**rd.break**::
@@ -290,12 +276,12 @@ LVM
disable LVM detection
**rd.lvm.vg=**__<volume group name>__::
only activate all logical volumes in the the volume groups with the given name.
rd.lvm.vg can be specified multiple times on the kernel command line.
only activate the volume groups with the given name. rd.lvm.vg can be
specified multiple times on the kernel command line.
**rd.lvm.lv=**__<volume group name>/<logical volume name>__::
only activate the logical volumes with the given name.
rd.lvm.lv can be specified multiple times on the kernel command line.
**rd.lvm.lv=**__<logical volume name>__::
only activate the logical volumes with the given name. rd.lvm.lv can be
specified multiple times on the kernel command line.
**rd.lvm.conf=0**::
remove any _/etc/lvm/lvm.conf_, which may exist in the initramfs
@@ -311,8 +297,6 @@ crypto LUKS
The comparisons also matches, if _<luks uuid>_ is only the beginning of the
LUKS UUID, so you don't have to specify the full UUID.
This parameter can be specified multiple times.
_<luks uuid>_ may be prefixed by the keyword `keysource:`, see
_rd.luks.key_ below.
**rd.luks.allow-discards=**__<luks uuid>__::
Allow using of discards (TRIM) requests for LUKS partitions with the given
@@ -334,37 +318,22 @@ crypto LUKS
crypto LUKS - key on removable device support
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NB: If systemd is included in the dracut initrd, dracut's built in
removable device keying support won't work. systemd will prompt for
a password from the console even if you've supplied **rd.luks.key**.
You may be able to use standard systemd *fstab*(5) syntax to
get the same effect. If you do need **rd.luks.key** to work,
you will have to exclude the "systemd" dracut module and any modules
that depend on it. See *dracut.conf*(5) and
https://bugzilla.redhat.com/show_bug.cgi?id=905683 for more
information.
**rd.luks.key=**_<keypath>[:<keydev>[:<luksdev>]]_::
_<keypath>_ is the pathname of a key file, relative to the root
of the filesystem on some device. It's REQUIRED. When
_<keypath>_ ends with '.gpg' it's considered to be key encrypted
symmetrically with GPG. You will be prompted for the GPG password on
boot. GPG support comes with the 'crypt-gpg' module, which needs to be
added explicitly.
**rd.luks.key=**__<keypath>__:__<keydev>__:__<luksdev>__::
_keypath_ is a path to key file to look for. It's REQUIRED. When _keypath_
ends with '.gpg' it's considered to be key encrypted symmetrically with GPG.
You will be prompted for password on boot. GPG support comes with
'crypt-gpg' module which needs to be added explicitly.
+
_<keydev>_ identifies the device on which the key file resides. It may
be the kernel name of the device (should start with "/dev/"), a UUID
(prefixed with "UUID=") or a label (prefix with "LABEL="). You don't
have to specify a full UUID. Just its beginning will suffice, even if
its ambiguous. All matching devices will be probed. This parameter is
recommended, but not required. If it's not present, all block devices will
be probed, which may significantly increase boot time.
_keydev_ is a device on which key file resides. It might be kernel name of
devices (should start with "/dev/"), UUID (prefixed with "UUID=") or label
(prefix with "LABEL="). You don't have to specify full UUID. Just its beginning
will suffice, even if its ambiguous. All matching devices will be probed.
This parameter is recommended, but not required. If not present, all block
devices will be probed, which may significantly increase boot time.
+
If _<luksdev>_ is given, the specified key will only be used for
the specified LUKS device. Possible values are the same as for
_<keydev>_. Unless you have several LUKS devices, you don't have to
specify this parameter. The simplest usage is:
If _luksdev_ is given, the specified key will only be applied for that LUKS
device. Possible values are the same as for _keydev_. Unless you have several
LUKS devices, you don't have to specify this parameter. The simplest usage is:
+
[listing]
.Example
@@ -373,84 +342,28 @@ rd.luks.key=/foo/bar.key
--
+
As you see, you can skip colons in such a case.
+
[NOTE]
===============================
Your LUKS partition must match your key file.
dracut pipes key to cryptsetup with _-d -_ argument, therefore you need to pipe
to cryptsetup luksFormat with _-d -_, too!
dracut provides keys to cryptsetup with _-d_ (an older alias for
_--key-file_). This uses the entire binary
content of the key file as part of the secret. If
you pipe a password into cryptsetup *without* _-d_ or _--key-file_,
it will be treated as text user input, and only characters before
the first newline will be used. Therefore, when you're creating
an encrypted partition for dracut to mount, and you pipe a key into
_cryptsetup luksFormat_,you must use _-d -_.
Here is an example for a key encrypted with GPG (warning:
_--batch-mode_ will overwrite the device without asking for
confirmation):
Here follows example for key encrypted with GPG:
[listing]
--
gpg --quiet --decrypt rootkey.gpg | \
cryptsetup --batch-mode --key-file - \
luksFormat /dev/sda47
cryptsetup -d - -v --cipher serpent-cbc-essiv:sha256 \
--key-size 256 luksFormat /dev/sda3
--
If you use unencrypted key files, just use the key file pathname
instead of the standard input. For a random key with 256 bits of
entropy, you might use:
If you use plain keys, just add path to _-d_ option:
[listing]
--
head -32c /dev/urandom > rootkey.key
cryptsetup --batch-mode --key-file rootkey.key \
luksFormat /dev/sda47
cryptsetup -d rootkey.key -v --cipher serpent-cbc-essiv:sha256 \
--key-size 256 luksFormat /dev/sda3
--
You can also use regular key files on an encrypted _keydev_.
Compared to using GPG encrypted keyfiles on an unencrypted
device this provides the following advantages:
- you can unlock your disk(s) using multiple passphrases
- better security by not loosing the key stretching mechanism
To use an encrypted _keydev_ you *must* ensure that it becomes
available by using the keyword `keysource`, e.g.
`rd.luks.uuid=keysource:aaaa`
_aaaa_ being the uuid of the encrypted _keydev_.
Example:
Lets assume you have three disks _A_, _B_ and _C_ with the uuids
_aaaa_, _bbbb_ and _cccc_. +
You want to unlock _A_ and _B_ using keyfile _keyfile_. +
The unlocked volumes be _A'_, _B'_ and _C'_ with the uuids
_AAAA_, _BBBB_ and _CCCC_. +
_keyfile_ is saved on _C'_ as _/keyfile_.
One luks keyslot of each _A_, _B_ and _C_ is setup with a
passphrase. +
Another luks keyslot of each _A_ and _B_ is setup with _keyfile_.
To boot this configuration you could use:
[listing]
--
rd.luks.uuid=aaaa
rd.luks.uuid=bbbb
rd.luks.uuid=keysource:cccc
rd.luks.key=/keyfile:UUID=CCCC
--
Dracut asks for the passphrase for _C_ and uses the
keyfile to unlock _A_ and _B_. +
If getting the passphrase for _C_ fails it falls back to
asking for the passphrases for _A_ and _B_.
If you want _C'_ to stay unlocked, specify a luks name for
it, e.g. `rd.luks.name=cccc=mykeys`, otherwise it gets closed
when not needed anymore.
===============================
MD RAID
@@ -489,9 +402,6 @@ MULTIPATH
**rd.multipath=0**::
disable multipath detection
**rd.multipath=default**::
use default multipath settings
FIPS
~~~~
**rd.fips**::
@@ -575,17 +485,11 @@ USB Android phone::
* enp0s29u1u2
=====================
**ip=**__{dhcp|on|any|dhcp6|auto6|either6|single-dhcp}__::
**ip=**__{dhcp|on|any|dhcp6|auto6|either6}__::
dhcp|on|any::: get ip from dhcp server from all interfaces. If root=dhcp,
loop sequentially through all interfaces (eth0, eth1, ...) and use the first
with a valid DHCP root-path.
single-dhcp::: Send DHCP on all available interfaces in parallel, as
opposed to one after another. After the first DHCP response is received,
stop DHCP on all other interfaces. This gives the fastest boot time by
using the IP on interface for which DHCP succeeded first during early boot.
Caveat: Does not apply to Network Manager and to SUSE using wicked.
auto6::: IPv6 autoconfiguration
dhcp6::: IPv6 DHCP
@@ -667,7 +571,7 @@ interface name. Better name it "bootnet" or "bluesocket".
boolean, bring up network even without netroot set
**vlan=**__<vlanname>__:__<phydevice>__::
Setup vlan device named <vlanname> on <phydevice>.
Setup vlan device named <vlanname> on <phydeivce>.
We support the four styles of vlan names: VLAN_PLUS_VID (vlan0005),
VLAN_PLUS_VID_NO_PAD (vlan5), DEV_PLUS_VID (eth0.0005),
DEV_PLUS_VID_NO_PAD (eth0.5)
@@ -682,13 +586,9 @@ interface name. Better name it "bootnet" or "bluesocket".
Bond without parameters assumes
bond=bond0:eth0,eth1:mode=balance-rr
**team=**__<teammaster>__:__<teamslaves>__[:__<teamrunner>__]::
**team=**__<teammaster>__:__<teamslaves>__::
Setup team device <teammaster> on top of <teamslaves>.
<teamslaves> is a comma-separated list of physical (ethernet) interfaces.
<teamrunner> is the runner type to be used (see *teamd.conf*(5)); defaults to
activebackup.
Team without parameters assumes
team=team0:eth0,eth1:activebackup
**bridge=**__<bridgename>__:__<ethnames>__::
Setup bridge <bridgename> with <ethnames>. <ethnames> is a comma-separated
@@ -745,7 +645,7 @@ NFS
Wait <seconds> until IPv6 automatic addresses are assigned. Default is 40 seconds.
**rd.net.timeout.carrier=**__<seconds>__::
Wait <seconds> until carrier is recognized. Default is 10 seconds.
Wait <seconds> until carrier is recognized. Default is 5 seconds.
CIFS
~~~
@@ -857,9 +757,6 @@ iscsistart -b --param node.session.timeo.replacement_timeout=30
**rd.iscsi.ibft** **rd.iscsi.ibft=1**:
Turn on iBFT autoconfiguration for the interfaces
**rd.iscsi.mp** **rd.iscsi.mp=1**:
Configure all iBFT interfaces, not only used for booting (multipath)
**rd.iscsi.waitnet=0**:
Turn off waiting for all interfaces to be up before trying to login to the iSCSI targets.
@@ -868,7 +765,7 @@ iscsistart -b --param node.session.timeo.replacement_timeout=30
FCoE
~~~~
**rd.fcoe=0**::
**rd.nofcoe=0**::
disable FCoE and lldpad
**fcoe=**__<edd|interface|MAC>__:__{dcb|nodcb}__:__{fabric|vn2vn}__::
@@ -880,23 +777,6 @@ FCoE
+
NOTE: letters in the MAC-address must be lowercase!
NVMf
~~~~
**rd.nvmf.hostnqn=**__<hostNQN>__::
NVMe host NQN to use
**rd.nvmf.hostid=**__<hostID>__::
NVMe host id to use
**rd.nvmf.discover=**__{rdma|fc|tcp}__,__<traddr>__,[__<host_traddr>__],[__<trsvcid>__]::
Discover and connect to a NVMe-over-Fabric controller specified by
_<traddr>_ and the optionally _<host_traddr>_ or _<trsvcid>_.
The first argument specifies the transport to use; currently only
'rdma', 'fc', or 'tcp' are supported.
The _<traddr>_ parameter can be set to 'auto' to select
autodiscovery; in that case all other parameters are ignored.
This parameter can be specified multiple times.
NBD
~~~
**root=**??? **netroot=**nbd:__<server>__:__<port/exportname>__[:__<fstype>__[:__<mountopts>__[:__<nbdopts>__]]]::
@@ -948,11 +828,6 @@ ZNET
RHEL/Fedora with ccw_init, which is called from udev for certain
devices on z-series.
rd.znet can be specified multiple times on the kernel command line.
**rd.znet_ifname=**__<ifname>__:__<subchannels>__::
Assign network device name <interface> (i.e. "bootnet") to the NIC
corresponds to the subchannels. This is useful when dracut's default
"ifname=" doesn't work due to device having a changing MAC address.
+
[listing]
.Example
@@ -1109,7 +984,7 @@ used to persist the changes made to the device specified by the
**root=live:__<url>__** option.
+
The default _pathspec_, when _auto_ or no _:<pathspec>_ is given, is
`/<rd.live.dir>/overlay-<label>-<uuid>`, where _<label>_ is the
`/<+++<b>rd.live.dir</b>+++>/overlay-<label>-<uuid>`, where _<label>_ is the
device LABEL, and _<uuid>_ is the device UUID.
* _none_ (the word itself) specifies that no overlay will be used, such as when
an uncompressed, writable live root filesystem is available.

View File

@@ -3,7 +3,6 @@ DRACUT.CONF(5)
:doctype: manpage
:man source: dracut
:man manual: dracut
:man version: {version}
NAME
----
@@ -80,13 +79,12 @@ Configuration files must have the extension .conf; other extensions are ignored.
Specify additional files to include in the initramfs, separated by spaces,
if they exist.
*compress=*"__{cat|bzip2|lzma|xz|gzip|lzo|lz4|zstd|<compressor [args ...]>}__"::
*compress=*"__{bzip2|lzma|xz|gzip|lzo|lz4|zstd|<compressor [args ...]>}__"::
Compress the generated initramfs using the passed compression program. If
you pass it just the name of a compression program, it will call that
program with known-working arguments. If you pass arguments, it will be called
with exactly those arguments. Depending on what you pass, this may result in
an initramfs that the kernel cannot decompress.
To disable compression, use "cat".
*do_strip=*"__{yes|no}__"::
Strip binaries in the initramfs (default=yes)
@@ -206,9 +204,6 @@ provide a valid _/etc/fstab_.
_/lib/systemd/boot/efi/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_
or _/usr/lib/gummiboot/linux<EFI-MACHINE-TYPE-NAME>.efi.stub_
*uefi_splash_image=*"_<FILE>_"::
Specifies the UEFI stub loader's splash image. Requires bitmap (**.bmp**) image format.
*uefi_secureboot_cert=*"_<FILE>_", *uefi_secureboot_key=*"_<FILE>_"::
Specifies a certificate and corresponding key, which are used to sign the created UEFI executable.
Requires both certificate and key need to be specified and _sbsign_ to be installed.

View File

@@ -10,35 +10,9 @@ stdloglvl=3
sysloglvl=5
install_optional_items+=" vi /etc/virc ps grep cat rm "
prefix="/"
environment=/usr/lib/environment.d
environmentconfdir=/etc/environment.d
dbus=/usr/share/dbus-1
dbusinterfaces=/usr/share/dbus-1/interfaces
dbusservices=/usr/share/dbus-1/services
dbussession=/usr/share/dbus-1/session.d
dbussystem=/usr/share/dbus-1/system.d
dbussystemservices=/usr/share/dbus-1/system-services
dbusconfdir=/etc/dbus-1
dbusinterfacesconfdir=/etc/dbus-1/interfaces
dbusservicesconfdir=/etc/dbus-1/services
dbussessionconfdir=/etc/dbus-1/session.d
dbussystem=confdir/etc/dbus-1/system.d
dbussystemservicesconfdir=/etc/dbus-1/system-services
sysctld=/usr/lib/sysctl.d
sysctldconfdir=/etc/sysctl.d
systemdutildir=/usr/lib/systemd
systemdutilconfdir=/etc/systemd
systemdcatalog=/usr/lib/systemd/catalog
systemdntpunits=/usr/lib/systemd/ntp-units.d
systemdntpunitsconfdir=/etc/systemd/ntp-units.d
systemdportable=/usr/lib/systemd/portable
systemdportableconfdir=/etc/systemd/portable
systemdsystemunitdir=/usr/lib/systemd/system
systemdsystemconfdir=/etc/systemd/system
systemduser=/usr/lib/systemd/user
systemduserconfdir=/etc/systemd/user
sysusers=/usr/lib/sysusers.d
sysusersconfdir=/etc/sysusers.d
udevdir=/usr/lib/udev
hostonly="yes"
hostonly_cmdline="no"

6
dracut.logrotate Normal file
View File

@@ -0,0 +1,6 @@
/var/log/dracut.log {
missingok
notifempty
size 30k
create 0600 root root
}

View File

@@ -3,7 +3,6 @@ DRACUT.MODULES(7)
:doctype: manpage
:man source: dracut
:man manual: dracut
:man version: {version}
NAME
----
@@ -93,18 +92,13 @@ udev state.
==== Initqueue settled
This hook (initqueue/settled) gets executed every time udev has settled.
This hooks (initqueue/settled) gets executed every time udev has settled.
==== Initqueue timeout
This hook (initqueue/timeout) gets executed, when the main loop counter becomes
This hooks (initqueue/timeout) gets executed, when the main loop counter becomes
half of the rd.retry counter.
==== Initqueue online
This hook (initqueue/online) gets executed whenever a network interface comes online
(that is, once it is up and configured by the configured network module).
==== Initqueue finished
This hook (initqueue/finished) is called after udev has settled and
@@ -151,8 +145,8 @@ FIXME
== Writing a Module
A simple example module is _90kernel-modules_, which modprobes a kernel module
after udev has settled and the basic device drivers have been loaded.
A simple example module is _96insmodpost_, which modprobes a kernel module after
udev has settled and the basic device drivers have been loaded.
All module installation information is in the file module-setup.sh.
@@ -164,7 +158,7 @@ check():
return 0
----
Then we create the install() function, which installs a cmdline hook with
The we create the install() function, which installs a cmdline hook with
priority number 20 called _parse-insmodpost.sh_. It also installs the
_insmodpost.sh_ script in _/sbin_.

924
dracut.sh

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,7 @@ Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar
Source1: https://www.gnu.org/licenses/lgpl-2.1.txt
BuildRequires: bash
BuildRequires: git-core
BuildRequires: git
BuildRequires: pkgconfig(libkmod) >= 23
BuildRequires: gcc
@@ -77,7 +77,6 @@ Requires: xz
Requires: gzip
%if 0%{?fedora} || 0%{?rhel}
Recommends: memstrack
Recommends: hardlink
Recommends: pigz
Recommends: kpartx
@@ -99,7 +98,7 @@ Requires: libkcapi-hmaccalc
%description
dracut contains tools to create bootable initramfses for the Linux
kernel. Unlike other implementations, dracut hard-codes as little
kernel. Unlike previous implementations, dracut hard-codes as little
as possible into the initramfs. dracut contains various modules which
are driven by the event-based udev. Having root on MD, DM, LVM2, LUKS
is supported as well as NFS, iSCSI, NBD, FCoE with the dracut-network
@@ -118,8 +117,7 @@ Requires: %{name} = %{version}-%{release}
%endif
Requires: iputils
Requires: iproute
Requires: (NetworkManager >= 1.20 or dhclient)
Suggests: NetworkManager
Requires: dhclient
Obsoletes: dracut-generic < 008
Provides: dracut-generic = %{version}-%{release}
@@ -203,10 +201,11 @@ cp %{SOURCE1} .
%endif
${NULL}
%make_build
make %{?_smp_mflags}
%install
%make_install %{?_smp_mflags} \
make %{?_smp_mflags} install \
DESTDIR=$RPM_BUILD_ROOT \
libdir=%{_prefix}/lib
echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dracut-version.sh
@@ -215,12 +214,14 @@ echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dr
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
%endif
%if %{defined _unitdir}
# for systemd, better use systemd-bootchart
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
# we do not support mksh in the initramfs
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00mksh
# remove gentoo specific modules
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash
@@ -273,9 +274,15 @@ rm -f -- $RPM_BUILD_ROOT%{_mandir}/man1/lsinitrd.1*
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
%if 0%{?fedora} || 0%{?rhel}
# FIXME: remove after F30
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
%endif
%files
%if %{with doc}
%doc README.md HACKING.md AUTHORS NEWS.md dracut.html dracut.png dracut.svg
%doc README.md HACKING TODO AUTHORS NEWS dracut.html dracut.png dracut.svg
%endif
%{!?_licensedir:%global license %%doc}
%license COPYING lgpl-2.1.txt
@@ -323,6 +330,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%endif
%if %{undefined _unitdir}
%{dracutlibdir}/modules.d/00bootchart
%endif
%{dracutlibdir}/modules.d/00bash
%{dracutlibdir}/modules.d/00systemd
@@ -332,22 +340,12 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
%{dracutlibdir}/modules.d/01fips
%endif
%{dracutlibdir}/modules.d/01systemd-ask-password
%{dracutlibdir}/modules.d/01systemd-coredump
%{dracutlibdir}/modules.d/01systemd-initrd
%{dracutlibdir}/modules.d/01systemd-modules-load
%{dracutlibdir}/modules.d/01systemd-repart
%{dracutlibdir}/modules.d/01systemd-sysctl
%{dracutlibdir}/modules.d/01systemd-sysusers
%{dracutlibdir}/modules.d/03modsign
%{dracutlibdir}/modules.d/03rescue
%{dracutlibdir}/modules.d/04watchdog
%{dracutlibdir}/modules.d/04watchdog-modules
%{dracutlibdir}/modules.d/05busybox
%{dracutlibdir}/modules.d/06dbus-broker
%{dracutlibdir}/modules.d/06dbus-daemon
%{dracutlibdir}/modules.d/06rngd
%{dracutlibdir}/modules.d/09dbus
%{dracutlibdir}/modules.d/10i18n
%{dracutlibdir}/modules.d/30convertfs
%{dracutlibdir}/modules.d/45url-lib
@@ -363,15 +361,13 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/modules.d/90lvm
%{dracutlibdir}/modules.d/90mdraid
%{dracutlibdir}/modules.d/90multipath
%{dracutlibdir}/modules.d/90nvdimm
%{dracutlibdir}/modules.d/90ppcmac
%{dracutlibdir}/modules.d/90stratis
%{dracutlibdir}/modules.d/90qemu
%{dracutlibdir}/modules.d/91crypt-gpg
%{dracutlibdir}/modules.d/91crypt-loop
%{dracutlibdir}/modules.d/95debug
%{dracutlibdir}/modules.d/95fstab-sys
%{dracutlibdir}/modules.d/95lunmask
%{dracutlibdir}/modules.d/95nvmf
%{dracutlibdir}/modules.d/95resume
%{dracutlibdir}/modules.d/95rootfs-block
%{dracutlibdir}/modules.d/95terminfo
@@ -402,7 +398,6 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/modules.d/98syslog
%{dracutlibdir}/modules.d/98usrmount
%{dracutlibdir}/modules.d/99base
%{dracutlibdir}/modules.d/99memstrack
%{dracutlibdir}/modules.d/99fs-lib
%{dracutlibdir}/modules.d/99shutdown
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
@@ -431,7 +426,6 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/modules.d/02systemd-networkd
%{dracutlibdir}/modules.d/35network-manager
%{dracutlibdir}/modules.d/35network-legacy
%{dracutlibdir}/modules.d/35network-wicked
%{dracutlibdir}/modules.d/40network
%{dracutlibdir}/modules.d/45ifcfg
%{dracutlibdir}/modules.d/90kernel-network-modules
@@ -476,5 +470,9 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%files config-rescue
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%if 0%{?fedora} || 0%{?rhel}
# FIXME: remove after F30
%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%changelog

View File

@@ -62,7 +62,7 @@ _/etc/dracut.conf_ or _/etc/dracut.conf.d/myconf.conf_. See *dracut.conf*(5).
You can also add dracut modules on the command line
by using the -a or --add option:
----
# dracut --add module initramfs-module.img
# dracut --add bootchart initramfs-bootchart.img
----
To see a list of available dracut modules, use the --list-modules option:

View File

@@ -1,116 +0,0 @@
DRACUT_PN ??= "${PN}"
def dracut_compression_type(d):
rdtype = d.getVar("INITRAMFS_FSTYPES", True).split('.')
if len(rdtype) != 2:
return ['','','']
if rdtype[0] != 'cpio':
return ['','','']
cmptypes = [['gz','--gzip','gzip'],['bz2', '--bzip2','bzip2'],['lzma','--lzma','xz'],['xz','--xz','xz'],['lzo','--lzo','lzo'],['lz4','--lz4','lz4'],['zstd','--zstd','zstd']]
for cmp in cmptypes:
if rdtype[1] == cmp[0]:
return cmp
return ['','','']
def dracut_compression_opt(d):
cmp = dracut_compression_type(d)
return cmp[1]
def dracut_compression_pkg(d):
cmp = dracut_compression_type(d)
return cmp[2]
def dracut_compression_pkg_native(d):
cmp = dracut_compression_type(d)
if cmp[2] == '':
return ''
return cmp[2] + '-native'
DRACUT_COMPRESS_OPT ??= "${@dracut_compression_opt(d)}"
DRACUT_COMPRESS_PKG ??= "${@dracut_compression_pkg(d)}"
DRACUT_COMPRESS_PKG_NATIVE ??= "${@dracut_compression_pkg_native(d)}"
DRACUT_OPTS ??= "--early-microcode ${DRACUT_COMPRESS_OPT}"
python __anonymous () {
pkg = d.getVar("DRACUT_PN", True)
if pkg != 'dracut':
d.appendVar("RDEPENDS_%s" % pkg, " dracut %s " % d.getVar("DRACUT_COMPRESS_PKG", True))
if not pkg.startswith('kernel'):
d.appendVarFlag("do_configure", "depends", "virtual/kernel:do_shared_workdir")
d.appendVarFlag("do_compile", "depends", "virtual/kernel:do_compile_kernelmodules")
}
export BUILD_TIME_KERNEL_VERSION = "${@oe.utils.read_file('${STAGING_KERNEL_BUILDDIR}/kernel-abiversion')}"
dracut_postinst () {
MY_KERNEL_VERSION=$(readlink $D/boot/bzimage | sed 's,^.*bzImage-,,')
if [[ -z "$MY_KERNEL_VERSION" ]]; then
MY_KERNEL_VERSION="${KERNEL_VERSION}"
fi
if [[ -z "$MY_KERNEL_VERSION" ]]; then
MY_KERNEL_VERSION="${BUILD_TIME_KERNEL_VERSION}"
fi
if [[ -z "$MY_KERNEL_VERSION" ]]; then
exit 1
fi
if [ -n "$D" ]; then
#DEBUGOPTS="--debug --keep"
DEBUGOPTS="--keep"
$INTERCEPT_DIR/postinst_intercept execute_dracut ${PKG} mlprefix=${MLPREFIX} \
prefix= \
MY_KERNEL_VERSION=$MY_KERNEL_VERSION \
DEBUGOPTS="\"$DEBUGOPTS\"" \
DRACUT_OPTS="\"${DRACUT_OPTS}\"" \
systemdutildir=${systemd_unitdir} \
systemdsystemunitdir=${systemd_system_unitdir} \
systemdsystemconfdir=${sysconfdir}/systemd/system \
udevdir=${libdir}/udev \
DRACUT_TMPDIR=${WORKDIR}/dracut-tmpdir \
DRACUT_ARCH="${TUNE_ARCH}" \
DRACUT_COMPRESS_GZIP=$NATIVE_ROOT${bindir}/gzip \
DRACUT_COMPRESS_BZIP2=$NATIVE_ROOT${bindir}/bzip2 \
DRACUT_COMPRESS_LZMA=$NATIVE_ROOT${bindir}/lzma \
DRACUT_LDD="\"PATH='$PATH' ${STAGING_BINDIR_CROSS}/ldd --root $D\"" \
DRACUT_LDCONFIG=$NATIVE_ROOT${bindir}/ldconfig \
DRACUT_INSTALL="\"$NATIVE_ROOT${libdir}/dracut/dracut-install\"" \
PLYMOUTH_LDD="\"${STAGING_BINDIR_CROSS}/ldd --root $D\"" \
PLYMOUTH_LDD_PATH="'$PATH'" \
PLYMOUTH_PLUGIN_PATH=${libdir}/plymouth \
PLYMOUTH_THEME_NAME=${PLYMOUTH_THEME_NAME:-spinner} \
PLYMOUTH_THEME=${PLYMOUTH_THEME_NAME:-spinner}
else
depmod -a $MY_KERNEL_VERSION
echo RUNNING: dracut -f ${DRACUT_OPTS} /boot/initramfs.img $MY_KERNEL_VERSION
echo "dracut: $(dracut --help | grep 'Version:')"
dracut -f ${DRACUT_OPTS} /boot/initramfs.img $MY_KERNEL_VERSION
fi
}
dracut_populate_packages[vardeps] += "dracut_postinst"
python dracut_populate_packages() {
localdata = d.createCopy()
pkg = d.getVar('DRACUT_PN', True)
postinst = d.getVar('pkg_postinst_%s' % pkg, True)
if not postinst:
postinst = '#!/bin/sh\n'
postinst += localdata.getVar('dracut_postinst', True)
d.setVar('pkg_postinst_%s' % pkg, postinst)
}
PACKAGESPLITFUNCS_prepend = "dracut_populate_packages "
DRACUT_DEPENDS = " \
binutils-cross-${TUNE_ARCH} gcc-cross-${TUNE_ARCH} \
ldconfig-native coreutils-native findutils-native \
cpio-native util-linux-native kmod-native ${DRACUT_COMPRESS_PKG_NATIVE} \
dracut-native pkgconfig-native cross-compiler-ldd \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \
"
DEPENDS_append_class-target = " ${DRACUT_DEPENDS}"
PACKAGE_WRITE_DEPS_append = " ${DRACUT_DEPENDS}"

View File

@@ -1,44 +0,0 @@
#!/bin/sh
set -e
if [[ -z "$DRACUT_TMPDIR" ]]; then
echo "DRACUT_TMPDIR is unset, exiting"
exit 0
fi
# We have to unset "prefix" as dracut uses it to move files around.
# Yocto has it set as part of the build environment.
export prefix=
# DRACUT settings
export UDEVVERSION=241
export SYSTEMD_VERSION=241
export DRACUT_TESTBIN=/bin/bash.bash
export DRACUT_INSTALL_PATH="/usr/sbin:/usr/bin:/sbin:/bin"
# PLYMOUTH settings
export PLYMOUTH_SYSROOT=$D
export \
systemdutildir systemdsystemunitdir systemdsystemconfdir udevdir \
DRACUT_ARCH DRACUT_TESTBIN DRACUT_LDD DRACUT_LDCONFIG DRACUT_INSTALL \
DRACUT_COMPRESS_GZIP DRACUT_COMPRESS_BZIP2 DRACUT_COMPRESS_LZMA \
PLYMOUTH_LDD PLYMOUTH_LDD_PATH PLYMOUTH_PLUGIN_PATH \
PLYMOUTH_THEME_NAME PLYMOUTH_THEME
# List environment for debugging
echo ROOTFS-POSTINST-ENVIRONMENT
echo -----------
env
echo -----------
[[ -d $DRACUT_TMPDIR ]] || mkdir -p $DRACUT_TMPDIR
# Execute depmod and dracut
echo "$(date) - RUNNING: depmod -b $D -a $MY_KERNEL_VERSION"
depmod -b $D -a $MY_KERNEL_VERSION
echo "dracut: $(dracut --sysroot $D --help | grep 'Version:')"
echo "$(date) - RUNNING: dracut -f --sysroot $D --tmpdir $DRACUT_TMPDIR $DRACUT_OPTS $DEBUGOPTS -k $D/lib/modules/$MY_KERNEL_VERSION $D/boot/initramfs.img $MY_KERNEL_VERSION"
dracut -f --sysroot $D --tmpdir $DRACUT_TMPDIR $DRACUT_OPTS $DEBUGOPTS -k $D/lib/modules/$MY_KERNEL_VERSION $D/boot/initramfs.img $MY_KERNEL_VERSION
echo "$(date) - DONE: dracut"

View File

@@ -1,19 +0,0 @@
diff --git a/cross-compile-ldd b/cross-compile-ldd
index ef2ca20..332d57f 100644
--- a/cross-compile-ldd
+++ b/cross-compile-ldd
@@ -337,13 +337,13 @@ do_scan_etc_ldsoconf() {
# Build up the full list of search directories
declare -a needed_search_path
do_trace "Adding basic lib dirs\n"
-ld_library_path="${ld_library_path}:"
while [ -n "${ld_library_path}" ]; do
d="${ld_library_path%%:*}"
if [ -n "${d}" ]; then
do_trace "-> adding search dir '%s'\n" "${d}"
needed_search_path+=( "${d}" )
fi
+ [[ "$ld_library_path" == "${ld_library_path#*:}" ]] && break
ld_library_path="${ld_library_path#*:}"
done
do_trace "Done adding basic lib dirs\n"

View File

@@ -1,33 +0,0 @@
SUMMARY = "Cross-compiler LDD"
HOMEPAGE = "https://gist.github.com/c403786c1394f53f44a3b61214489e6f"
BUGTRACKER = ""
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://cross-compile-ldd;beginline=53;endline=57;md5=2b29d19d18a430b931dda3750e865c84"
SRCBRANCH = "master"
SRCREV = "eb44581caf7dd60b149a6691abef46264c46e866"
SRC_URI = " \
git://gist.github.com/c403786c1394f53f44a3b61214489e6f.git;protocol=https;branch=${SRCBRANCH} \
file://cross-compile-ldd-fix-infinite-loop.patch \
"
S = "${WORKDIR}/git"
inherit siteinfo
SYSROOT_PREPROCESS_FUNCS += " cross_ldd_populate_sysroot "
cross_ldd_populate_sysroot() {
mkdir -p ${SYSROOT_DESTDIR}${bindir_crossscripts}
cat ${S}/cross-compile-ldd | \
sed \
-e "s,^prefix=.*$,prefix=${TARGET_SYS}," \
-e "s,^bits=.*$,bits=${SITEINFO_BITS}," \
-e "s,^ld_library_path=.*$,ld_library_path=${LD_LIBRARY_PATH:-/lib:/usr/lib}," \
>${SYSROOT_DESTDIR}${bindir_crossscripts}/ldd
chmod +x ${SYSROOT_DESTDIR}${bindir_crossscripts}/ldd
}
DEPENDS = "coreutils-native sed-native binutils-cross-${TARGET_ARCH} gcc-cross-${TARGET_ARCH}"
PACKAGE_WRITE_DEPS = "coreutils-native sed-native binutils-cross-${TARGET_ARCH} gcc-cross-${TARGET_ARCH}"

View File

@@ -1,45 +0,0 @@
#!/bin/bash
set -ex
[[ -d ${0%/*} ]] && cd "${0%/*}"
RUN_ID="$1"
TESTS=$2
./configure
NCPU=$(getconf _NPROCESSORS_ONLN)
if ! [[ $TESTS ]]; then
# GitHub workflows fetch a clone of the dracut repository which doesn't
# contain git tags, thus "breaking" the RPM build in certain situations
# i.e.:
# DRACUT_MAIN_VERSION in Makefile is defined as an output of `git describe`,
# which in full git clone returns a tag with a numeric version. However,
# without tags it returns SHA of the last commit, which later propagates into
# `Provides:` attribute of the built RPM and can break dependency tree when
# installed
[[ -d .git ]] && git fetch --tags && git describe --tags
make -j "$NCPU" all syncheck rpm logtee
else
if [[ $TESTS == "99" ]]; then
[[ -d .git ]] && git fetch --tags && git describe --tags
make_docs=yes
else
make_docs=no
fi
make -j "$NCPU" enable_documentation=$make_docs all logtee
cd test
time LOGTEE_TIMEOUT_MS=590000 make \
enable_documentation=$make_docs \
KVERSION="$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1)" \
DRACUT_NO_XATTR=1 \
TEST_RUN_ID="$RUN_ID" \
${TESTS:+TESTS="$TESTS"} \
-k V=1 \
check
fi

View File

@@ -7,6 +7,41 @@ set -ex
RUN_ID="$1"
TESTS=$2
dnf -y update --best --allowerasing &>/dev/null
dnf -y install --best --allowerasing \
dash \
asciidoc \
mdadm \
lvm2 \
dmraid \
cryptsetup \
nfs-utils \
nbd \
dhcp-server \
scsi-target-utils \
iscsi-initiator-utils \
strace \
btrfs-progs \
kmod-devel \
gcc \
bzip2 \
xz \
tar \
wget \
rpm-build \
make \
git \
bash-completion \
sudo \
kernel \
dhcp-client \
/usr/bin/qemu-kvm \
/usr/bin/qemu-system-$(uname -i) \
e2fsprogs \
tcpdump \
$NULL &>/dev/null
./configure
NCPU=$(getconf _NPROCESSORS_ONLN)
@@ -14,15 +49,12 @@ NCPU=$(getconf _NPROCESSORS_ONLN)
if ! [[ $TESTS ]]; then
make -j$NCPU all syncheck rpm logtee
else
[[ $TESTS == "99" ]] && make_docs=yes || make_docs=no
make -j$NCPU enable_documentation=$make_docs all logtee
make -j$NCPU all logtee
cd test
time sudo LOGTEE_TIMEOUT_MS=300000 make \
enable_documentation=$make_docs \
time sudo make \
KVERSION=$(rpm -qa kernel --qf '%{VERSION}-%{RELEASE}.%{ARCH}\n' | sort -rn | head -1) \
DRACUT_NO_XATTR=1 \
TEST_RUN_ID=$RUN_ID \
${TESTS:+TESTS="$TESTS"} \
-k V=2 \

View File

@@ -10,7 +10,7 @@ sub create_patches {
mkdir $pdir, 0755;
open( GIT, 'git log -p --pretty=email --stat -m --first-parent --reverse --binary '.$tag.'..HEAD |');
open( GIT, 'git log -p --pretty=email --stat -m --first-parent --reverse '.$tag.'..HEAD |');
while (<GIT>) {
if (/^From [a-z0-9]{40} .*$/) {

View File

@@ -27,7 +27,6 @@
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <glob.h>
#include <libgen.h>
#include <limits.h>
#include <stdbool.h>
@@ -60,15 +59,11 @@ static bool arg_modalias = false;
static bool arg_resolvelazy = false;
static bool arg_resolvedeps = false;
static bool arg_hostonly = false;
static bool no_xattr = false;
static char *destrootdir = NULL;
static char *sysrootdir = NULL;
static size_t sysrootdirlen = 0;
static char *kerneldir = NULL;
static size_t kerneldirlen = 0;
static char **firmwaredirs = NULL;
static char **pathdirs;
static char *ldd = NULL;
static char *logdir = NULL;
static char *logfile = NULL;
FILE *logfile_f = NULL;
@@ -124,7 +119,6 @@ static inline void fts_closep(FTS **p) {
}
#define _cleanup_fts_close_ _cleanup_(fts_closep)
#define _cleanup_globfree_ _cleanup_(globfree)
static size_t dir_len(char const *file)
@@ -313,7 +307,7 @@ static int cp(const char *src, const char *dst)
normal_copy:
pid = fork();
if (pid == 0) {
if (geteuid() == 0 && no_xattr == false)
if (geteuid() == 0)
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL", src, dst,
NULL);
else
@@ -325,7 +319,7 @@ static int cp(const char *src, const char *dst)
while (waitpid(pid, &ret, 0) < 0) {
if (errno != EINTR) {
ret = -1;
if (geteuid() == 0 && no_xattr == false)
if (geteuid() == 0)
log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s", src,
dst);
else
@@ -404,75 +398,6 @@ static int library_install(const char *src, const char *lib)
return ret;
}
static char *get_real_file(const char *src, bool fullyresolve)
{
char linktarget[PATH_MAX + 1];
ssize_t linksz;
_cleanup_free_ char *fullsrcpath;
char *abspath = NULL;
struct stat sb;
if (sysrootdirlen) {
if (strncmp(src, sysrootdir, sysrootdirlen) == 0)
fullsrcpath = strdup(src);
else if (asprintf(&fullsrcpath, "%s/%s", (sysrootdirlen ? sysrootdir : ""), (src[0] == '/' ? src+1 : src)) < 0)
_exit(EXIT_FAILURE);
} else
fullsrcpath = strdup(src);
log_debug("get_real_file('%s')", fullsrcpath);
if (lstat(fullsrcpath, &sb) < 0)
return NULL;
switch (sb.st_mode & S_IFMT) {
case S_IFDIR:
case S_IFREG:
return strdup(fullsrcpath);
case S_IFLNK:
break;
default:
return NULL;
}
linksz = readlink(fullsrcpath, linktarget, sizeof(linktarget));
if (linksz < 0)
return NULL;
linktarget[linksz] = '\0';
log_debug("get_real_file: readlink('%s') returns '%s'", fullsrcpath, linktarget);
if (linktarget[0] == '/') {
if (asprintf(&abspath, "%s%s", (sysrootdirlen ? sysrootdir : ""), linktarget) < 0)
return NULL;
} else {
_cleanup_free_ char *fullsrcdir = strdup(fullsrcpath);
if (!fullsrcdir) {
log_error("Out of memory!");
return NULL;
}
fullsrcdir[dir_len(fullsrcdir)] = '\0';
if (asprintf(&abspath, "%s/%s", fullsrcdir, linktarget) < 0)
return NULL;
}
if (fullyresolve) {
struct stat st;
if (lstat(abspath, &st) < 0) {
if (errno != ENOENT)
return NULL;
}
if (S_ISLNK(st.st_mode))
return get_real_file(abspath, fullyresolve);
}
log_debug("get_real_file('%s') => '%s'", src, abspath);
return abspath;
}
static int resolve_deps(const char *src)
{
int ret = 0;
@@ -481,12 +406,6 @@ static int resolve_deps(const char *src)
size_t linesize = LINE_MAX;
_cleanup_pclose_ FILE *fptr = NULL;
_cleanup_free_ char *cmd = NULL;
_cleanup_free_ char *fullsrcpath = NULL;
fullsrcpath = get_real_file(src, true);
log_debug("resolve_deps('%s') -> get_real_file('%s', true) = '%s'", src, src, fullsrcpath);
if (!fullsrcpath)
return 0;
buf = malloc(LINE_MAX);
if (buf == NULL)
@@ -494,7 +413,7 @@ static int resolve_deps(const char *src)
if (strstr(src, ".so") == 0) {
_cleanup_close_ int fd = -1;
fd = open(fullsrcpath, O_RDONLY | O_CLOEXEC);
fd = open(src, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -errno;
@@ -518,14 +437,12 @@ static int resolve_deps(const char *src)
}
/* run ldd */
ret = asprintf(&cmd, "%s %s 2>&1", ldd, fullsrcpath);
ret = asprintf(&cmd, "ldd %s 2>&1", src);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
log_debug("%s", cmd);
ret = 0;
fptr = popen(cmd, "r");
@@ -544,13 +461,6 @@ static int resolve_deps(const char *src)
break;
}
/* errors from cross-compiler-ldd */
if (strstr(buf, "unable to find sysroot") || strstr(buf, "command not found")) {
log_error("%s", buf);
ret += 1;
break;
}
/* musl ldd */
if (strstr(buf, "Not a valid dynamic program"))
break;
@@ -571,9 +481,6 @@ static int resolve_deps(const char *src)
if (strstr(buf, "cannot read header"))
break;
if (strstr(buf, "cannot be preloaded"))
break;
if (strstr(buf, destrootdir))
break;
@@ -690,80 +597,16 @@ static bool check_hashmap(Hashmap *hm, const char *item)
return false;
}
static int dracut_mkdir(const char *src) {
_cleanup_free_ char *parent = NULL;
char *path;
struct stat sb;
parent = strdup(src);
if (!parent)
return 1;
path = parent[0] == '/' ? parent+1 : parent;
while (path) {
path = strstr(path, "/");
if (path)
*path = '\0';
if (stat(parent, &sb) == 0) {
if (!S_ISDIR(sb.st_mode)) {
log_error("%s exists but is not a directory!", parent);
return 1;
}
} else if (errno != ENOENT) {
log_error("ERROR: stat '%s': %s", parent, strerror(errno));
return 1;
} else {
if (mkdir(parent, 0755) < 0) {
log_error("ERROR: mkdir '%s': %s", parent, strerror(errno));
return 1;
}
}
if (path) {
*path = '/';
path++;
}
}
return 0;
}
static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir, bool resolvedeps, bool hashdst)
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst)
{
struct stat sb, db;
_cleanup_free_ char *fullsrcpath = NULL;
_cleanup_free_ char *fulldstpath = NULL;
_cleanup_free_ char *fulldstdir = NULL;
int ret;
bool src_islink = false;
bool src_isdir = false;
mode_t src_mode = 0;
bool dst_exists = true;
bool src_exists = true;
char *i = NULL;
_cleanup_free_ char *src;
_cleanup_free_ char *dst;
if (sysrootdirlen) {
if (strncmp(orig_src, sysrootdir, sysrootdirlen) == 0) {
src = strdup(orig_src + sysrootdirlen);
fullsrcpath = strdup(orig_src);
} else {
src = strdup(orig_src);
if (asprintf(&fullsrcpath, "%s%s", sysrootdir, src) < 0)
_exit(EXIT_FAILURE);
}
if (strncmp(orig_dst, sysrootdir, sysrootdirlen) == 0)
dst = strdup(orig_dst + sysrootdirlen);
else
dst = strdup(orig_dst);
} else {
src = strdup(orig_src);
fullsrcpath = strdup(src);
dst = strdup(orig_dst);
}
log_debug("dracut_install('%s', '%s', %d, %d, %d)", src, dst, isdir, resolvedeps, hashdst);
log_debug("dracut_install('%s', '%s')", src, dst);
if (check_hashmap(items_failed, src)) {
log_debug("hash hit items_failed for '%s'", src);
@@ -775,19 +618,22 @@ static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir
return 0;
}
if (lstat(fullsrcpath, &sb) < 0) {
if (lstat(src, &sb) < 0) {
src_exists = false;
if (!isdir) {
i = strdup(src);
hashmap_put(items_failed, i, i);
/* src does not exist */
return 1;
}
} else {
src_islink = S_ISLNK(sb.st_mode);
src_isdir = S_ISDIR(sb.st_mode);
src_mode = sb.st_mode;
}
i = strdup(dst);
if (!i)
return -ENOMEM;
hashmap_put(items, i, i);
ret = asprintf(&fulldstpath, "%s/%s", destrootdir, (dst[0]=='/' ? (dst+1) : dst));
if (ret < 0) {
log_error("Out of memory!");
@@ -796,152 +642,121 @@ static int dracut_install(const char *orig_src, const char *orig_dst, bool isdir
ret = stat(fulldstpath, &sb);
if (ret != 0) {
dst_exists = false;
if (errno != ENOENT) {
log_error("ERROR: stat '%s': %m", fulldstpath);
return 1;
}
if (ret != 0 && (errno != ENOENT)) {
log_error("ERROR: stat '%s': %m", fulldstpath);
return 1;
}
if (ret == 0) {
if (resolvedeps && S_ISREG(sb.st_mode) && (sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) {
log_debug("'%s' already exists, but checking for any deps", fulldstpath);
ret = resolve_deps(fullsrcpath + sysrootdirlen);
ret = resolve_deps(src);
} else
log_debug("'%s' already exists", fulldstpath);
/* dst does already exist */
} else {
return ret;
}
/* check destination directory */
fulldstdir = strdup(fulldstpath);
if (!fulldstdir) {
log_error("Out of memory!");
/* check destination directory */
fulldstdir = strdup(fulldstpath);
fulldstdir[dir_len(fulldstdir)] = '\0';
ret = stat(fulldstdir, &db);
if (ret < 0) {
_cleanup_free_ char *dname = NULL;
if (errno != ENOENT) {
log_error("ERROR: stat '%s': %m", fulldstdir);
return 1;
}
fulldstdir[dir_len(fulldstdir)] = '\0';
/* create destination directory */
log_debug("dest dir '%s' does not exist", fulldstdir);
dname = strdup(dst);
if (!dname)
return 1;
ret = stat(fulldstdir, &db);
dname[dir_len(dname)] = '\0';
ret = dracut_install(dname, dname, true, false, true);
if (ret < 0) {
_cleanup_free_ char *dname = NULL;
if (errno != ENOENT) {
log_error("ERROR: stat '%s': %m", fulldstdir);
return 1;
}
/* create destination directory */
log_debug("dest dir '%s' does not exist", fulldstdir);
dname = strdup(dst);
if (!dname)
return 1;
dname[dir_len(dname)] = '\0';
ret = dracut_install(dname, dname, true, false, true);
if (ret != 0) {
log_error("ERROR: failed to create directory '%s'", fulldstdir);
return 1;
}
}
if (src_isdir) {
if (dst_exists) {
if (S_ISDIR(sb.st_mode)) {
log_debug("dest dir '%s' already exists", fulldstpath);
return 0;
}
log_error("dest dir '%s' already exists but is not a directory", fulldstpath);
return 1;
}
log_info("mkdir '%s'", fulldstpath);
ret = dracut_mkdir(fulldstpath);
if (ret == 0) {
i = strdup(dst);
if (!i)
return -ENOMEM;
hashmap_put(items, i, i);
}
return ret;
}
/* ready to install src */
if (src_islink) {
_cleanup_free_ char *abspath = NULL;
abspath = get_real_file(src, false);
if (abspath == NULL)
return 1;
if (dracut_install(abspath, abspath, false, resolvedeps, hashdst)) {
log_debug("'%s' install error", abspath);
return 1;
}
if (lstat(abspath, &sb) != 0) {
log_debug("lstat '%s': %m", abspath);
return 1;
}
if (lstat(fulldstpath, &sb) != 0) {
_cleanup_free_ char *absdestpath = NULL;
ret = asprintf(&absdestpath, "%s/%s", destrootdir, (abspath[0]=='/' ? (abspath+1) : abspath) + sysrootdirlen);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ln_r(absdestpath, fulldstpath);
}
if (arg_hmac) {
/* copy .hmac files also */
hmac_install(src, dst, NULL);
}
return 0;
}
if (src_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
if (resolvedeps)
ret += resolve_deps(fullsrcpath + sysrootdirlen);
if (arg_hmac) {
/* copy .hmac files also */
hmac_install(src, dst, NULL);
}
}
log_debug("dracut_install ret = %d", ret);
if (arg_hostonly && !arg_module)
mark_hostonly(dst);
if (isdir) {
log_info("mkdir '%s'", fulldstpath);
ret += dracut_mkdir(fulldstpath);
} else {
log_info("cp '%s' '%s'", fullsrcpath, fulldstpath);
ret += cp(fullsrcpath, fulldstpath);
if (ret != 0) {
log_error("ERROR: failed to create directory '%s'", fulldstdir);
return 1;
}
}
if (ret == 0) {
i = strdup(dst);
if (!i)
return -ENOMEM;
hashmap_put(items, i, i);
if (logfile_f)
dracut_log_cp(src);
if (isdir && !src_exists) {
log_info("mkdir '%s'", fulldstpath);
ret = mkdir(fulldstpath, 0755);
return ret;
}
/* ready to install src */
if (S_ISDIR(sb.st_mode)) {
log_info("mkdir '%s'", fulldstpath);
ret = mkdir(fulldstpath, sb.st_mode | S_IWUSR);
return ret;
}
if (S_ISLNK(sb.st_mode)) {
_cleanup_free_ char *abspath = NULL;
abspath = realpath(src, NULL);
if (abspath == NULL)
return 1;
if (dracut_install(abspath, abspath, false, resolvedeps, hashdst)) {
log_debug("'%s' install error", abspath);
return 1;
}
if (lstat(abspath, &sb) != 0) {
log_debug("lstat '%s': %m", abspath);
return 1;
}
if (lstat(fulldstpath, &sb) != 0) {
_cleanup_free_ char *absdestpath = NULL;
ret = asprintf(&absdestpath, "%s/%s", destrootdir, (abspath[0]=='/' ? (abspath+1) : abspath));
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ln_r(absdestpath, fulldstpath);
}
if (arg_hmac) {
/* copy .hmac files also */
hmac_install(src, dst, NULL);
}
return 0;
}
if (sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
if (resolvedeps)
ret += resolve_deps(src);
if (arg_hmac) {
/* copy .hmac files also */
hmac_install(src, dst, NULL);
}
}
log_debug("dracut_install ret = %d", ret);
log_info("cp '%s' '%s'", src, fulldstpath);
if (arg_hostonly && !arg_module)
mark_hostonly(dst);
ret += cp(src, fulldstpath);
if (ret == 0 && logfile_f)
dracut_log_cp(src);
log_debug("dracut_install ret = %d", ret);
return ret;
@@ -956,11 +771,11 @@ static void item_free(char *i)
static void usage(int status)
{
/* */
printf("Usage: %s -D DESTROOTDIR [-r SYSROOTDIR] [OPTION]... -a SOURCE...\n"
"or: %s -D DESTROOTDIR [-r SYSROOTDIR] [OPTION]... SOURCE DEST\n"
"or: %s -D DESTROOTDIR [-r SYSROOTDIR] [OPTION]... -m KERNELMODULE [KERNELMODULE …]\n"
printf("Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE...\n"
"or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST\n"
"or: %s -D DESTROOTDIR [OPTION]... -m KERNELMODULE [KERNELMODULE …]\n"
"\n"
"Install SOURCE (from rootfs or SYSROOTDIR) to DEST in DESTROOTDIR with all needed dependencies.\n"
"Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n"
"\n"
" KERNELMODULE can have the format:\n"
" <absolute path> with a leading /\n"
@@ -968,7 +783,6 @@ static void usage(int status)
" <module name>\n"
"\n"
" -D --destrootdir Install all files to DESTROOTDIR as the root\n"
" -r --sysrootdir Install all files from SYSROOTDIR\n"
" -a --all Install all SOURCE arguments to DESTROOTDIR\n"
" -o --optional If SOURCE does not exist, do not fail\n"
" -d --dir SOURCE is a directory\n"
@@ -1028,7 +842,6 @@ static int parse_argv(int argc, char *argv[])
{"module", no_argument, NULL, 'm'},
{"fips", no_argument, NULL, 'f'},
{"destrootdir", required_argument, NULL, 'D'},
{"sysrootdir", required_argument, NULL, 'r'},
{"logdir", required_argument, NULL, 'L'},
{"mod-filter-path", required_argument, NULL, 'p'},
{"mod-filter-nopath", required_argument, NULL, 'P'},
@@ -1042,7 +855,7 @@ static int parse_argv(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
while ((c = getopt_long(argc, argv, "madfhlL:oD:Hr:Rp:P:s:S:N:v", options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "madfhlL:oD:HRp:P:s:S:N:", options, NULL)) != -1) {
switch (c) {
case ARG_VERSION:
puts(PROGRAM_VERSION_STRING);
@@ -1081,10 +894,6 @@ static int parse_argv(int argc, char *argv[])
case 'D':
destrootdir = strdup(optarg);
break;
case 'r':
sysrootdir = strdup(optarg);
sysrootdirlen = strlen(sysrootdir);
break;
case 'p':
if (regcomp(&mod_filter_path, optarg, REG_NOSUB|REG_EXTENDED) != 0) {
log_error("Module path filter %s is not a regular expression", optarg);
@@ -1213,7 +1022,6 @@ static char **find_binary(const char *src)
{
char **ret = NULL;
char **q;
char *fullsrcpath;
char *newsrc = NULL;
STRV_FOREACH(q, pathdirs) {
@@ -1226,28 +1034,15 @@ static char **find_binary(const char *src)
exit(EXIT_FAILURE);
}
fullsrcpath = get_real_file(newsrc, false);
if (!fullsrcpath) {
log_debug("get_real_file(%s) not found", newsrc);
if (stat(newsrc, &sb) != 0) {
log_debug("stat(%s) != 0", newsrc);
free(newsrc);
newsrc = NULL;
continue;
}
if (lstat(fullsrcpath, &sb) != 0) {
log_debug("stat(%s) != 0", fullsrcpath);
free(newsrc);
newsrc = NULL;
free(fullsrcpath);
fullsrcpath = NULL;
continue;
}
strv_push(&ret, newsrc);
free(fullsrcpath);
fullsrcpath = NULL;
};
if (ret) {
@@ -1318,30 +1113,8 @@ static int install_all(int argc, char **argv)
}
} else {
if (strchr(argv[i], '*') == NULL) {
_cleanup_free_ char *dest = strdup(argv[i]);
ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true);
} else {
_cleanup_free_ char *realsrc = NULL;
_cleanup_globfree_ glob_t globbuf;
ret = asprintf(&realsrc, "%s%s", sysrootdir ? sysrootdir : "", argv[i]);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ret = glob(realsrc, 0, NULL, &globbuf);
if (ret == 0) {
int j;
for (j = 0; j < globbuf.gl_pathc; j++) {
char *dest = strdup(globbuf.gl_pathv[j] + sysrootdirlen);
ret |= dracut_install(globbuf.gl_pathv[j] + sysrootdirlen, dest, arg_createdir, arg_resolvedeps, true);
free(dest);
}
}
}
_cleanup_free_ char *dest = strdup(argv[i]);
ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true);
}
if ((ret != 0) && (!arg_optional)) {
@@ -1352,33 +1125,8 @@ static int install_all(int argc, char **argv)
return r;
}
static int install_firmware_fullpath(const char *fwpath)
static int install_firmware(struct kmod_module *mod)
{
const char *fw;
_cleanup_free_ char *fwpath_xz = NULL;
fw = fwpath;
struct stat sb;
int ret, r;
if (stat(fwpath, &sb) != 0) {
r = asprintf(&fwpath_xz, "%s.xz", fwpath);
if (r < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
if (stat(fwpath_xz, &sb) != 0) {
log_debug("stat(%s) != 0", fwpath);
return 1;
}
fw = fwpath_xz;
}
ret = dracut_install(fw, fw, false, false, true);
if (ret == 0) {
log_debug("dracut_install '%s' OK", fwpath);
}
return ret;
}
static int install_firmware(struct kmod_module *mod) {
struct kmod_list *l;
_cleanup_kmod_module_info_free_list_ struct kmod_list *list = NULL;
int ret;
@@ -1403,6 +1151,8 @@ static int install_firmware(struct kmod_module *mod) {
ret = -1;
STRV_FOREACH(q, firmwaredirs) {
_cleanup_free_ char *fwpath = NULL;
_cleanup_free_ char *fwpath_xz = NULL;
const char *fw;
struct stat sb;
int r;
@@ -1412,22 +1162,27 @@ static int install_firmware(struct kmod_module *mod) {
exit(EXIT_FAILURE);
}
if ((strstr(value, "*") != 0 || strstr(value, "?") != 0 || strstr(value, "[") != 0) && stat(fwpath, &sb) != 0) {
int i;
_cleanup_globfree_ glob_t globbuf;
glob(fwpath, 0, NULL, &globbuf);
for (i = 0; i < globbuf.gl_pathc; i++) {
install_firmware_fullpath(globbuf.gl_pathv[i]);
if (ret != 0) {
log_info("Possible missing firmware %s for kernel module %s", value, kmod_module_get_name(mod));
}
fw = fwpath;
if (stat(fwpath, &sb) != 0) {
r = asprintf(&fwpath_xz, "%s.xz", fwpath);
if (r < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
} else {
install_firmware_fullpath(fwpath);
if (ret != 0) {
log_info("Possible missing firmware %s for kernel module %s", value, kmod_module_get_name(mod));
if (stat(fwpath_xz, &sb) != 0) {
log_debug("stat(%s) != 0", fwpath);
continue;
}
fw = fwpath_xz;
}
ret = dracut_install(fw, fw, false, false, true);
if (ret == 0)
log_debug("dracut_install '%s' OK", fwpath);
}
if (ret != 0) {
log_info("Possible missing firmware %s for kernel module %s", value, kmod_module_get_name(mod));
}
}
return 0;
@@ -1527,13 +1282,9 @@ static int install_dependent_modules(struct kmod_list *modlist)
ret = install_dependent_modules(modlist);
if (ret == 0) {
ret = kmod_module_get_softdeps(mod, &modpre, &modpost);
if (ret == 0) {
int r;
ret = install_dependent_modules(modpre);
r = install_dependent_modules(modpost);
ret = ret ? : r;
}
}
if (ret == 0)
ret = install_dependent_modules(modpre);
}
} else {
log_error("dracut_install '%s' '%s' ERROR", path, &path[kerneldirlen]);
}
@@ -1594,12 +1345,8 @@ static int install_module(struct kmod_module *mod)
if (ret == 0) {
ret = kmod_module_get_softdeps(mod, &modpre, &modpost);
if (ret == 0) {
int r;
if (ret == 0)
ret = install_dependent_modules(modpre);
r = install_dependent_modules(modpost);
ret = ret ? : r;
}
}
return ret;
@@ -1964,7 +1711,6 @@ int main(int argc, char **argv)
int r;
char *i;
char *path = NULL;
char *env_no_xattr = NULL;
r = parse_argv(argc, argv);
if (r <= 0)
@@ -1992,13 +1738,7 @@ int main(int argc, char **argv)
exit(0);
}
log_debug("Program arguments:");
for (r = 0; r < argc; r++)
log_debug("%s", argv[r]);
path = getenv("DRACUT_INSTALL_PATH");
if (path == NULL)
path = getenv("PATH");
path = getenv("PATH");
if (path == NULL) {
log_error("PATH is not set");
@@ -2007,15 +1747,6 @@ int main(int argc, char **argv)
log_debug("PATH=%s", path);
ldd = getenv("DRACUT_LDD");
if (ldd == NULL)
ldd = "ldd";
log_debug("LDD=%s", ldd);
env_no_xattr = getenv("DRACUT_NO_XATTR");
if (env_no_xattr != NULL)
no_xattr = true;
pathdirs = strv_split(path, ":");
umask(0022);

View File

@@ -41,10 +41,86 @@ struct Hashmap {
struct hashmap_entry *iterate_list_head, *iterate_list_tail;
unsigned n_entries;
bool from_pool;
};
#define BY_HASH(h) ((struct hashmap_entry**) ((uint8_t*) (h) + ALIGN(sizeof(Hashmap))))
struct pool {
struct pool *next;
unsigned n_tiles;
unsigned n_used;
};
static struct pool *first_hashmap_pool = NULL;
static void *first_hashmap_tile = NULL;
static struct pool *first_entry_pool = NULL;
static void *first_entry_tile = NULL;
static void* allocate_tile(struct pool **first_pool, void **first_tile, size_t tile_size) {
unsigned i;
if (*first_tile) {
void *r;
r = *first_tile;
*first_tile = * (void**) (*first_tile);
return r;
}
if (_unlikely_(!*first_pool) || _unlikely_((*first_pool)->n_used >= (*first_pool)->n_tiles)) {
unsigned n;
size_t size;
struct pool *p;
n = *first_pool ? (*first_pool)->n_tiles : 0;
n = MAX(512U, n * 2);
size = PAGE_ALIGN(ALIGN(sizeof(struct pool)) + n*tile_size);
n = (size - ALIGN(sizeof(struct pool))) / tile_size;
p = malloc(size);
if (!p)
return NULL;
p->next = *first_pool;
p->n_tiles = n;
p->n_used = 0;
*first_pool = p;
}
i = (*first_pool)->n_used++;
return ((uint8_t*) (*first_pool)) + ALIGN(sizeof(struct pool)) + i*tile_size;
}
static void deallocate_tile(void **first_tile, void *p) {
* (void**) p = *first_tile;
*first_tile = p;
}
#ifndef __OPTIMIZE__
static void drop_pool(struct pool *p) {
while (p) {
struct pool *n;
n = p->next;
free(p);
p = n;
}
}
__attribute__((destructor)) static void cleanup_pool(void) {
/* Be nice to valgrind */
drop_pool(first_hashmap_pool);
drop_pool(first_entry_pool);
}
#endif
unsigned string_hash_func(const void *p) {
unsigned hash = 5381;
const signed char *c;
@@ -70,15 +146,26 @@ int trivial_compare_func(const void *a, const void *b) {
}
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
bool b;
Hashmap *h;
size_t size;
b = is_main_thread();
size = ALIGN(sizeof(Hashmap)) + NBUCKETS * sizeof(struct hashmap_entry*);
h = malloc0(size);
if (b) {
h = allocate_tile(&first_hashmap_pool, &first_hashmap_tile, size);
if (!h)
return NULL;
if (!h)
return NULL;
memset(h, 0, size);
} else {
h = malloc0(size);
if (!h)
return NULL;
}
h->hash_func = hash_func ? hash_func : trivial_hash_func;
h->compare_func = compare_func ? compare_func : trivial_compare_func;
@@ -86,6 +173,8 @@ Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
h->n_entries = 0;
h->iterate_list_head = h->iterate_list_tail = NULL;
h->from_pool = b;
return h;
}
@@ -156,8 +245,7 @@ static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash) {
h->n_entries--;
}
static void remove_entry(Hashmap *h, struct hashmap_entry **ep) {
struct hashmap_entry *e = *ep;
static void remove_entry(Hashmap *h, struct hashmap_entry *e) {
unsigned hash;
assert(h);
@@ -167,8 +255,10 @@ static void remove_entry(Hashmap *h, struct hashmap_entry **ep) {
unlink_entry(h, e, hash);
free(e);
*ep = NULL;
if (h->from_pool)
deallocate_tile(&first_entry_tile, e);
else
free(e);
}
void hashmap_free(Hashmap*h) {
@@ -178,7 +268,10 @@ void hashmap_free(Hashmap*h) {
hashmap_clear(h);
free(h);
if (h->from_pool)
deallocate_tile(&first_hashmap_tile, h);
else
free(h);
}
void hashmap_free_free(Hashmap *h) {
@@ -194,10 +287,8 @@ void hashmap_clear(Hashmap *h) {
if (!h)
return;
while (h->iterate_list_head) {
struct hashmap_entry *e = h->iterate_list_head;
remove_entry(h, &e);
}
while (h->iterate_list_head)
remove_entry(h, h->iterate_list_head);
}
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key) {
@@ -228,7 +319,10 @@ int hashmap_put(Hashmap *h, const void *key, void *value) {
return -EEXIST;
}
e = new(struct hashmap_entry, 1);
if (h->from_pool)
e = allocate_tile(&first_entry_pool, &first_entry_tile, sizeof(struct hashmap_entry));
else
e = new(struct hashmap_entry, 1);
if (!e)
return -ENOMEM;
@@ -287,7 +381,7 @@ void* hashmap_remove(Hashmap *h, const void *key) {
return NULL;
data = e->value;
remove_entry(h, &e);
remove_entry(h, e);
return data;
}
@@ -332,7 +426,7 @@ int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_
if ((k = hash_scan(h, new_hash, new_key)))
if (e != k)
remove_entry(h, &k);
remove_entry(h, k);
unlink_entry(h, e, old_hash);
@@ -359,7 +453,7 @@ void* hashmap_remove_value(Hashmap *h, const void *key, void *value) {
if (e->value != value)
return NULL;
remove_entry(h, &e);
remove_entry(h, e);
return value;
}
@@ -485,7 +579,6 @@ void* hashmap_last(Hashmap *h) {
}
void* hashmap_steal_first(Hashmap *h) {
struct hashmap_entry *e;
void *data;
if (!h)
@@ -494,15 +587,13 @@ void* hashmap_steal_first(Hashmap *h) {
if (!h->iterate_list_head)
return NULL;
e = h->iterate_list_head;
data = e->value;
remove_entry(h, &e);
data = h->iterate_list_head->value;
remove_entry(h, h->iterate_list_head);
return data;
}
void* hashmap_steal_first_key(Hashmap *h) {
struct hashmap_entry *e;
void *key;
if (!h)
@@ -511,9 +602,8 @@ void* hashmap_steal_first_key(Hashmap *h) {
if (!h->iterate_list_head)
return NULL;
e = h->iterate_list_head;
key = (void*) e->key;
remove_entry(h, &e);
key = (void*) h->iterate_list_head->key;
remove_entry(h, h->iterate_list_head);
return key;
}
@@ -604,6 +694,22 @@ int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) {
return 0;
}
Hashmap *hashmap_copy(Hashmap *h) {
Hashmap *copy;
assert(h);
if (!(copy = hashmap_new(h->hash_func, h->compare_func)))
return NULL;
if (hashmap_merge(copy, h) < 0) {
hashmap_free(copy);
return NULL;
}
return copy;
}
char **hashmap_get_strv(Hashmap *h) {
char **sv;
Iterator it;

View File

@@ -46,6 +46,7 @@ int trivial_compare_func(const void *a, const void *b);
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
void hashmap_free(Hashmap *h);
void hashmap_free_free(Hashmap *h);
Hashmap *hashmap_copy(Hashmap *h);
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func);
int hashmap_put(Hashmap *h, const void *key, void *value);

View File

@@ -264,21 +264,14 @@ int log_set_max_level_from_string(const char *e) {
void log_parse_environment(void) {
const char *e;
if ((e = getenv("DRACUT_INSTALL_LOG_TARGET"))) {
if ((e = getenv("DRACUT_LOG_TARGET")))
if (log_set_target_from_string(e) < 0)
log_warning("Failed to parse log target %s. Ignoring.", e);
} else if ((e = getenv("DRACUT_LOG_TARGET"))) {
if (log_set_target_from_string(e) < 0)
log_warning("Failed to parse log target %s. Ignoring.", e);
}
if ((e = getenv("DRACUT_INSTALL_LOG_LEVEL"))) {
if ((e = getenv("DRACUT_LOG_LEVEL")))
if (log_set_max_level_from_string(e) < 0)
log_warning("Failed to parse log level %s. Ignoring.", e);
} else if ((e = getenv("DRACUT_LOG_LEVEL"))) {
if (log_set_max_level_from_string(e) < 0)
log_warning("Failed to parse log level %s. Ignoring.", e);
}
}
LogTarget log_get_target(void) {

View File

@@ -1,6 +1,5 @@
#define _GNU_SOURCE
#include <fcntl.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -14,26 +13,13 @@ main(int argc, char *argv[])
{
int fd;
int len, slen;
int ret;
int timeout;
char *timeout_env;
struct pollfd fds[] = {{
.fd = STDIN_FILENO,
.events = POLLIN | POLLERR,
}};
timeout_env = getenv("LOGTEE_TIMEOUT_MS");
if (timeout_env)
timeout = atoi(timeout_env);
else
timeout = -1;
if (argc != 2) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
exit(EXIT_FAILURE);
}
fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, 0644);
fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd == -1) {
perror("open");
exit(EXIT_FAILURE);
@@ -44,13 +30,8 @@ main(int argc, char *argv[])
slen = 0;
do {
ret = poll (fds, sizeof(fds) / sizeof(fds[0]), timeout);
if (ret == 0) {
fprintf (stderr, "Timed out after %d milliseconds of no output.\n", timeout);
exit(EXIT_FAILURE);
}
len = splice(STDIN_FILENO, NULL, fd, NULL,
BUFLEN, SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
BUFLEN, SPLICE_F_MOVE);
if (len < 0) {
if (errno == EAGAIN)

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#
# Copyright 2013 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
@@ -16,20 +16,19 @@
#
__contains_word () {
local word="$1"; shift
for w in "$@"; do [[ $w = "$word" ]] && return 0; done
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
}
_lsinitrd() {
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-s --size -h --help'
[ARG]='-f --file -k --kver'
)
# shellcheck disable=SC2086
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--file|-f)
@@ -37,30 +36,23 @@ _lsinitrd() {
compopt -o filenames
;;
--kver|-k)
comps=$(cd /lib/modules || return 1; echo [0-9]*)
comps=$(cd /lib/modules; echo [0-9]*)
;;
*)
return 0
;;
esac
# shellcheck disable=SC2207
# shellcheck disable=SC2016
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ $cur = -* ]]; then
# shellcheck disable=SC2207
# shellcheck disable=SC2016
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
# shellcheck disable=SC2034
comps=$(compgen -f -- "$cur")
compopt -o filenames
# shellcheck disable=SC2207
# shellcheck disable=SC2016
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
}

View File

@@ -3,7 +3,6 @@ LSINITRD(1)
:doctype: manpage
:man source: dracut
:man manual: dracut
:man version: {version}
NAME
----

View File

@@ -97,11 +97,7 @@ if [[ $1 ]]; then
else
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
if [[ -d /efi/loader/entries || -L /efi/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
&& [[ -d /efi/${MACHINE_ID} || -L /efi/${MACHINE_ID} ]] ; then
image="/efi/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
elif [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
if [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
image="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
@@ -210,7 +206,7 @@ if [ "$bin" = "MZ" ]; then
fi
if (( ${#filenames[@]} <= 0 )) && [[ -z "$unpack" ]] && [[ -z "$unpackearly" ]]; then
if [ -n "$uefi" ]; then
if [ -n $uefi ]; then
echo -n "initrd in UEFI: $uefi: "
du -h $image | while read a b || [ -n "$a" ]; do echo $a;done
if [ -f "$TMPDIR/osrel.txt" ]; then
@@ -240,8 +236,6 @@ case $bin in
$'\x71\xc7'*|070701)
CAT="cat --"
is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2>/dev/null)
# Debian mkinitramfs does not create the file 'early_cpio', so let's check if firmware files exist
[[ "$is_early" ]] || is_early=$(cpio --list --verbose --quiet --to-stdout -- 'kernel/*/microcode/*.bin' < "$image" 2>/dev/null)
if [[ "$is_early" ]]; then
if [[ -n "$unpack" ]]; then
# should use --unpackearly for early CPIO

View File

@@ -36,7 +36,7 @@ read_arg() {
else
for ((i=3; $i <= $#; i++)); do
# Only read next arg if it not an arg itself.
if [[ ${*:$i:1} = -* ]];then
if [[ ${@:$i:1} = -* ]];then
break
fi
result="$result ${@:$i:1}"
@@ -53,14 +53,14 @@ default_kernel_images() {
local regex kernel_image kernel_version version_version initrd_image
local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
case "${DRACUT_ARCH:-$(uname -m)}" in
case "$(uname -m)" in
s390|s390x)
regex='image'
;;
ppc*)
ppc|ppc64)
regex='vmlinux'
;;
i?86|x86_64)
i386|x86_64)
regex='vmlinuz'
;;
arm*)
@@ -153,6 +153,7 @@ while (($# > 0)); do
--loopopts*) ;;
--looppath*) ;;
--dsdt*) ;;
--bootchart) ;;
-s) ;;
--quiet|-q) quiet=1;;
-b) read_arg boot_dir "$@" || shift $?

View File

@@ -87,7 +87,7 @@ read_arg() {
else
for ((i=3; $i <= $#; i++)); do
# Only read next arg if it not an arg itself.
if [[ ${*:$i:1} = -* ]];then
if [[ ${@:$i:1} = -* ]];then
break
fi
result="$result ${@:$i:1}"
@@ -164,14 +164,14 @@ default_kernel_images() {
local regex kernel_image kernel_version version_version initrd_image
local qf='%{NAME}-%{VERSION}-%{RELEASE}\n'
case "${DRACUT_ARCH:-$(uname -m)}" in
case "$(uname -m)" in
s390|s390x)
regex='image'
;;
ppc|ppc64)
regex='vmlinux'
;;
i?86|x86_64)
i386|x86_64)
regex='vmlinuz'
;;
arm*)

View File

@@ -3,7 +3,6 @@ MKINITRD(8)
:doctype: manpage
:man source: dracut
:man manual: dracut
:man version: {version}
NAME
----

View File

@@ -0,0 +1,30 @@
#!/bin/bash
# called by dracut
check() {
[[ "$mount_needs" ]] && return 1
require_binaries /sbin/bootchartd || return 1
return 255
}
# called by dracut
depends() {
return 0
}
# called by dracut
install() {
inst_symlink /init /sbin/init
inst_dir /lib/bootchart/tmpfs
inst_multiple bootchartd bash \
/lib/bootchart/bootchart-collector /etc/bootchartd.conf \
accton \
echo \
grep \
usleep
inst /usr/bin/pkill /bin/pkill
inst /usr/bin/[ /bin/[
}

View File

@@ -1,21 +0,0 @@
#!/bin/bash
# called by dracut
check() {
require_binaries /bin/mksh
}
# called by dracut
depends() {
return 0
}
# called by dracut
install() {
# If another shell is already installed, do not use mksh
[[ -x $initdir/bin/sh ]] && return
# Prefer mksh as /bin/sh if it is available.
inst /bin/mksh && ln -sf mksh "${initdir}/bin/sh"
}

View File

@@ -1,22 +1,22 @@
#!/bin/bash
getSystemdVersion() {
[ -z "$SYSTEMD_VERSION" ] && SYSTEMD_VERSION=$("$systemdutildir"/systemd --version | { read -r _ b _; echo "$b"; })
SYSTEMD_VERSION=$($systemdutildir/systemd --version | { read a b a; echo $b; })
# Check if the systemd version is a valid number
if ! [[ $SYSTEMD_VERSION =~ ^[0-9]+$ ]]; then
dfatal "systemd version is not a number ($SYSTEMD_VERSION)"
exit 1
fi
echo "$SYSTEMD_VERSION"
echo $SYSTEMD_VERSION
}
# called by dracut
check() {
[[ $mount_needs ]] && return 1
if require_binaries "$systemdutildir"/systemd; then
if require_binaries $systemdutildir/systemd; then
SYSTEMD_VERSION=$(getSystemdVersion)
(( SYSTEMD_VERSION >= 198 )) && return 0
(( $SYSTEMD_VERSION >= 198 )) && return 0
return 255
fi
@@ -42,113 +42,111 @@ install() {
exit 1
fi
if [[ $(getSystemdVersion) -ge 240 ]]; then
if [ $(getSystemdVersion) -ge 240 ]; then
inst_multiple -o \
"$systemdutildir"/system-generators/systemd-debug-generator \
"$systemdsystemunitdir"/debug-shell.service
$systemdutildir/system-generators/systemd-debug-generator \
$systemdsystemunitdir/debug-shell.service
fi
inst_multiple -o \
"$systemdutildir"/systemd \
"$systemdutildir"/systemd-coredump \
"$systemdutildir"/systemd-cgroups-agent \
"$systemdutildir"/systemd-shutdown \
"$systemdutildir"/systemd-reply-password \
"$systemdutildir"/systemd-fsck \
"$systemdutildir"/systemd-udevd \
"$systemdutildir"/systemd-journald \
"$systemdutildir"/systemd-sysctl \
"$systemdutildir"/systemd-modules-load \
"$systemdutildir"/systemd-vconsole-setup \
"$systemdutildir"/systemd-volatile-root \
"$systemdutildir"/system-generators/systemd-fstab-generator \
"$systemdutildir"/system-generators/systemd-gpt-auto-generator \
$systemdutildir/systemd \
$systemdutildir/systemd-coredump \
$systemdutildir/systemd-cgroups-agent \
$systemdutildir/systemd-shutdown \
$systemdutildir/systemd-reply-password \
$systemdutildir/systemd-fsck \
$systemdutildir/systemd-udevd \
$systemdutildir/systemd-journald \
$systemdutildir/systemd-sysctl \
$systemdutildir/systemd-modules-load \
$systemdutildir/systemd-vconsole-setup \
$systemdutildir/systemd-volatile-root \
$systemdutildir/system-generators/systemd-fstab-generator \
$systemdutildir/system-generators/systemd-gpt-auto-generator \
\
"$systemdsystemunitdir"/cryptsetup.target \
"$systemdsystemunitdir"/cryptsetup-pre.target \
"$systemdsystemunitdir"/remote-cryptsetup.target \
"$systemdsystemunitdir"/emergency.target \
"$systemdsystemunitdir"/sysinit.target \
"$systemdsystemunitdir"/basic.target \
"$systemdsystemunitdir"/halt.target \
"$systemdsystemunitdir"/kexec.target \
"$systemdsystemunitdir"/local-fs.target \
"$systemdsystemunitdir"/local-fs-pre.target \
"$systemdsystemunitdir"/remote-fs.target \
"$systemdsystemunitdir"/remote-fs-pre.target \
"$systemdsystemunitdir"/multi-user.target \
"$systemdsystemunitdir"/network.target \
"$systemdsystemunitdir"/network-pre.target \
"$systemdsystemunitdir"/network-online.target \
"$systemdsystemunitdir"/nss-lookup.target \
"$systemdsystemunitdir"/nss-user-lookup.target \
"$systemdsystemunitdir"/poweroff.target \
"$systemdsystemunitdir"/reboot.target \
"$systemdsystemunitdir"/rescue.target \
"$systemdsystemunitdir"/rpcbind.target \
"$systemdsystemunitdir"/shutdown.target \
"$systemdsystemunitdir"/final.target \
"$systemdsystemunitdir"/sigpwr.target \
"$systemdsystemunitdir"/sockets.target \
"$systemdsystemunitdir"/swap.target \
"$systemdsystemunitdir"/timers.target \
"$systemdsystemunitdir"/paths.target \
"$systemdsystemunitdir"/umount.target \
$systemdsystemunitdir/cryptsetup.target \
$systemdsystemunitdir/emergency.target \
$systemdsystemunitdir/sysinit.target \
$systemdsystemunitdir/basic.target \
$systemdsystemunitdir/halt.target \
$systemdsystemunitdir/kexec.target \
$systemdsystemunitdir/local-fs.target \
$systemdsystemunitdir/local-fs-pre.target \
$systemdsystemunitdir/remote-fs.target \
$systemdsystemunitdir/remote-fs-pre.target \
$systemdsystemunitdir/multi-user.target \
$systemdsystemunitdir/network.target \
$systemdsystemunitdir/network-pre.target \
$systemdsystemunitdir/network-online.target \
$systemdsystemunitdir/nss-lookup.target \
$systemdsystemunitdir/nss-user-lookup.target \
$systemdsystemunitdir/poweroff.target \
$systemdsystemunitdir/reboot.target \
$systemdsystemunitdir/rescue.target \
$systemdsystemunitdir/rpcbind.target \
$systemdsystemunitdir/shutdown.target \
$systemdsystemunitdir/final.target \
$systemdsystemunitdir/sigpwr.target \
$systemdsystemunitdir/sockets.target \
$systemdsystemunitdir/swap.target \
$systemdsystemunitdir/timers.target \
$systemdsystemunitdir/paths.target \
$systemdsystemunitdir/umount.target \
\
"$systemdsystemunitdir"/sys-kernel-config.mount \
$systemdsystemunitdir/sys-kernel-config.mount \
\
"$systemdsystemunitdir"/kmod-static-nodes.service \
"$systemdsystemunitdir"/systemd-tmpfiles-setup.service \
"$systemdsystemunitdir"/systemd-tmpfiles-setup-dev.service \
"$systemdsystemunitdir"/systemd-ask-password-console.path \
"$systemdsystemunitdir"/systemd-udevd-control.socket \
"$systemdsystemunitdir"/systemd-udevd-kernel.socket \
"$systemdsystemunitdir"/systemd-ask-password-plymouth.path \
"$systemdsystemunitdir"/systemd-journald.socket \
"$systemdsystemunitdir"/systemd-journald-audit.socket \
"$systemdsystemunitdir"/systemd-ask-password-console.service \
"$systemdsystemunitdir"/systemd-modules-load.service \
"$systemdsystemunitdir"/systemd-halt.service \
"$systemdsystemunitdir"/systemd-poweroff.service \
"$systemdsystemunitdir"/systemd-reboot.service \
"$systemdsystemunitdir"/systemd-kexec.service \
"$systemdsystemunitdir"/systemd-fsck@.service \
"$systemdsystemunitdir"/systemd-udevd.service \
"$systemdsystemunitdir"/systemd-udev-trigger.service \
"$systemdsystemunitdir"/systemd-udev-settle.service \
"$systemdsystemunitdir"/systemd-ask-password-plymouth.service \
"$systemdsystemunitdir"/systemd-journald.service \
"$systemdsystemunitdir"/systemd-vconsole-setup.service \
"$systemdsystemunitdir"/systemd-volatile-root.service \
"$systemdsystemunitdir"/systemd-random-seed-load.service \
"$systemdsystemunitdir"/systemd-random-seed.service \
"$systemdsystemunitdir"/systemd-sysctl.service \
$systemdsystemunitdir/kmod-static-nodes.service \
$systemdsystemunitdir/systemd-tmpfiles-setup.service \
$systemdsystemunitdir/systemd-tmpfiles-setup-dev.service \
$systemdsystemunitdir/systemd-ask-password-console.path \
$systemdsystemunitdir/systemd-udevd-control.socket \
$systemdsystemunitdir/systemd-udevd-kernel.socket \
$systemdsystemunitdir/systemd-ask-password-plymouth.path \
$systemdsystemunitdir/systemd-journald.socket \
$systemdsystemunitdir/systemd-journald-audit.socket \
$systemdsystemunitdir/systemd-ask-password-console.service \
$systemdsystemunitdir/systemd-modules-load.service \
$systemdsystemunitdir/systemd-halt.service \
$systemdsystemunitdir/systemd-poweroff.service \
$systemdsystemunitdir/systemd-reboot.service \
$systemdsystemunitdir/systemd-kexec.service \
$systemdsystemunitdir/systemd-fsck@.service \
$systemdsystemunitdir/systemd-udevd.service \
$systemdsystemunitdir/systemd-udev-trigger.service \
$systemdsystemunitdir/systemd-udev-settle.service \
$systemdsystemunitdir/systemd-ask-password-plymouth.service \
$systemdsystemunitdir/systemd-journald.service \
$systemdsystemunitdir/systemd-vconsole-setup.service \
$systemdsystemunitdir/systemd-volatile-root.service \
$systemdsystemunitdir/systemd-random-seed-load.service \
$systemdsystemunitdir/systemd-random-seed.service \
$systemdsystemunitdir/systemd-sysctl.service \
\
"$systemdsystemunitdir"/sysinit.target.wants/systemd-modules-load.service \
"$systemdsystemunitdir"/sysinit.target.wants/systemd-ask-password-console.path \
"$systemdsystemunitdir"/sysinit.target.wants/systemd-journald.service \
"$systemdsystemunitdir"/sockets.target.wants/systemd-udevd-control.socket \
"$systemdsystemunitdir"/sockets.target.wants/systemd-udevd-kernel.socket \
"$systemdsystemunitdir"/sockets.target.wants/systemd-journald.socket \
"$systemdsystemunitdir"/sockets.target.wants/systemd-journald-audit.socket \
"$systemdsystemunitdir"/sockets.target.wants/systemd-journald-dev-log.socket \
"$systemdsystemunitdir"/sysinit.target.wants/systemd-udevd.service \
"$systemdsystemunitdir"/sysinit.target.wants/systemd-udev-trigger.service \
"$systemdsystemunitdir"/sysinit.target.wants/kmod-static-nodes.service \
"$systemdsystemunitdir"/sysinit.target.wants/systemd-tmpfiles-setup.service \
"$systemdsystemunitdir"/sysinit.target.wants/systemd-tmpfiles-setup-dev.service \
"$systemdsystemunitdir"/sysinit.target.wants/systemd-sysctl.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-modules-load.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-ask-password-console.path \
$systemdsystemunitdir/sysinit.target.wants/systemd-journald.service \
$systemdsystemunitdir/sockets.target.wants/systemd-udevd-control.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-udevd-kernel.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-journald.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-journald-audit.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-journald-dev-log.socket \
$systemdsystemunitdir/sysinit.target.wants/systemd-udevd.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-udev-trigger.service \
$systemdsystemunitdir/sysinit.target.wants/kmod-static-nodes.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-tmpfiles-setup.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-tmpfiles-setup-dev.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-sysctl.service \
\
"$systemdsystemunitdir"/ctrl-alt-del.target \
"$systemdsystemunitdir"/reboot.target \
"$systemdsystemunitdir"/systemd-reboot.service \
"$systemdsystemunitdir"/syslog.socket \
$systemdsystemunitdir/ctrl-alt-del.target \
$systemdsystemunitdir/reboot.target \
$systemdsystemunitdir/systemd-reboot.service \
$systemdsystemunitdir/syslog.socket \
\
"$systemdsystemunitdir"/slices.target \
"$systemdsystemunitdir"/system.slice \
"$systemdsystemunitdir"/-.slice \
$systemdsystemunitdir/slices.target \
$systemdsystemunitdir/system.slice \
$systemdsystemunitdir/-.slice \
\
"$tmpfilesdir"/systemd.conf \
$tmpfilesdir/systemd.conf \
\
journalctl systemctl \
echo swapoff \
@@ -156,7 +154,6 @@ install() {
mount umount reboot poweroff \
systemd-run systemd-escape \
systemd-cgls systemd-tmpfiles \
systemd-ask-password systemd-tty-ask-password-agent \
/etc/udev/udev.hwdb \
${NULL}
@@ -166,23 +163,23 @@ install() {
modules_load_get() {
local _line i
for i in "$dracutsysrootdir$1"/*.conf; do
for i in "$1"/*.conf; do
[[ -f $i ]] || continue
while read -r _line || [ -n "$_line" ]; do
while read _line || [ -n "$_line" ]; do
case $_line in
\#*)
;;
\;*)
;;
*)
echo "$_line"
echo $_line
esac
done < "$i"
done
}
mapfile -t _mods <<< $(modules_load_get /usr/lib/modules-load.d)
[[ ${#_mods[@]} -gt 0 ]] && hostonly='' instmods "${_mods[@]}"
_mods=$(modules_load_get /usr/lib/modules-load.d)
[[ $_mods ]] && hostonly='' instmods $_mods
if [[ $hostonly ]]; then
inst_multiple -H -o \
@@ -201,34 +198,34 @@ install() {
/etc/udev/udev.conf \
${NULL}
mapfile -t _mods <<< $(modules_load_get /etc/modules-load.d)
[[ ${#_mods[@]} -gt 0 ]] && hostonly='' instmods "${_mods[@]}"
_mods=$(modules_load_get /etc/modules-load.d)
[[ $_mods ]] && hostonly='' instmods $_mods
fi
if ! [[ -e "$initdir/etc/machine-id" ]]; then
: > "$initdir/etc/machine-id"
> "$initdir/etc/machine-id"
fi
# install adm user/group for journald
inst_multiple nologin
grep '^systemd-journal:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^adm:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-journal:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^wheel:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^adm:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^utmp:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^root:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^systemd-journal:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^adm:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-journal:' /etc/group >> "$initdir/etc/group"
grep '^wheel:' /etc/group >> "$initdir/etc/group"
grep '^adm:' /etc/group >> "$initdir/etc/group"
grep '^utmp:' /etc/group >> "$initdir/etc/group"
grep '^root:' /etc/group >> "$initdir/etc/group"
# we don't use systemd-networkd, but the user is in systemd.conf tmpfiles snippet
grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^systemd-network:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' /etc/group >> "$initdir/etc/group"
ln_r "$systemdutildir"/systemd "/init"
ln_r "$systemdutildir"/systemd "/sbin/init"
ln_r $systemdutildir/systemd "/init"
ln_r $systemdutildir/systemd "/sbin/init"
inst_binary true
ln_r "$(find_binary true)" "/usr/bin/loginctl"
ln_r "$(find_binary true)" "/bin/loginctl"
ln_r $(type -P true) "/usr/bin/loginctl"
ln_r $(type -P true) "/bin/loginctl"
inst_rules \
70-uaccess.rules \
71-seat.rules \
@@ -243,8 +240,9 @@ install() {
systemd-ask-password-console.service \
systemd-ask-password-plymouth.service \
; do
[[ -f "$systemdsystemunitdir"/$i ]] || continue
$SYSTEMCTL -q --root "$initdir" add-wants "$i" systemd-vconsole-setup.service
mkdir -p "${initdir}${systemdsystemunitdir}/${i}.wants"
ln_r "${systemdsystemunitdir}/systemd-vconsole-setup.service" \
"${systemdsystemunitdir}/${i}.wants/systemd-vconsole-setup.service"
done
mkdir -p "$initdir/etc/systemd"
@@ -256,5 +254,6 @@ install() {
echo "RateLimitBurst=0"
} >> "$initdir/etc/systemd/journald.conf"
$SYSTEMCTL -q --root "$initdir" set-default multi-user.target
ln_r "${systemdsystemunitdir}/multi-user.target" "${systemdsystemunitdir}/default.target"
}

View File

@@ -5,7 +5,7 @@
# called by dracut
check() {
# hwclock does not exist on S390(x), bail out silently then
local _arch=${DRACUT_ARCH:-$(uname -m)}
local _arch=$(uname -m)
[ "$_arch" = "s390" -o "$_arch" = "s390x" ] && return 1
[ -e /etc/localtime -a -e /etc/adjtime ] || return 1

View File

@@ -1,9 +1,7 @@
#!/bin/sh
if ! fipsmode=$(getarg fips) || [ "$fipsmode" = "0" ]; then
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif [ -z "$fipsmode" ]; then
die "FIPS mode have to be enabled by 'fips=1' not just 'fips'"
elif getarg boot= >/dev/null; then
. /sbin/fips.sh
if mount_boot; then

View File

@@ -1,9 +1,7 @@
#!/bin/sh
if ! fipsmode=$(getarg fips) || [ "$fipsmode" = "0" ]; then
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif [ -z "$fipsmode" ]; then
die "FIPS mode have to be enabled by 'fips=1' not just 'fips'"
elif ! [ -f /tmp/fipsdone ]; then
. /sbin/fips.sh
mount_boot

View File

@@ -1,17 +1,5 @@
#!/bin/sh
# systemd lets stdout go to journal only, but the system
# has to halt when the integrity check fails to satisfy FIPS.
if [ -z "$DRACUT_SYSTEMD" ]; then
fips_info() {
info "$*"
}
else
fips_info() {
echo "$*" >&2
}
fi
mount_boot()
{
boot=$(getarg boot=)
@@ -57,7 +45,7 @@ mount_boot()
[ -e "$boot" ] || return 1
mkdir /boot
fips_info "Mounting $boot as /boot"
info "Mounting $boot as /boot"
mount -oro "$boot" /boot || return 1
elif [ -d "$NEWROOT/boot" ]; then
rm -fr -- /boot
@@ -77,27 +65,19 @@ do_rhevh_check()
warn "HMAC sum mismatch"
return 1
fi
fips_info "rhevh_check OK"
info "rhevh_check OK"
return 0
}
nonfatal_modprobe()
{
modprobe $1 2>&1 > /dev/stdout |
while read -r line || [ -n "$line" ]; do
echo "${line#modprobe: FATAL: }" >&2
done
}
fips_load_crypto()
{
FIPSMODULES=$(cat /etc/fipsmodules)
fips_info "Loading and integrity checking all crypto modules"
info "Loading and integrity checking all crypto modules"
mv /etc/modprobe.d/fips.conf /etc/modprobe.d/fips.conf.bak
for _module in $FIPSMODULES; do
if [ "$_module" != "tcrypt" ]; then
if ! nonfatal_modprobe "${_module}" 2>/tmp/fips.modprobe_err; then
if ! modprobe "${_module}" 2>/tmp/fips.modprobe_err; then
# check if kernel provides generic algo
_found=0
while read _k _s _v || [ -n "$_k" ]; do
@@ -112,7 +92,7 @@ fips_load_crypto()
done
mv /etc/modprobe.d/fips.conf.bak /etc/modprobe.d/fips.conf
fips_info "Self testing crypto algorithms"
info "Self testing crypto algorithms"
modprobe tcrypt || return 1
rmmod tcrypt
}
@@ -126,26 +106,19 @@ do_fips()
KERNEL=$(uname -r)
fips_info "Checking integrity of kernel"
info "Checking integrity of kernel"
if [ -e "/run/initramfs/live/vmlinuz0" ]; then
do_rhevh_check /run/initramfs/live/vmlinuz0 || return 1
elif [ -e "/run/initramfs/live/isolinux/vmlinuz0" ]; then
do_rhevh_check /run/initramfs/live/isolinux/vmlinuz0 || return 1
elif [ -e "/run/install/repo/images/pxeboot/vmlinuz" ]; then
# This is a boot.iso with the .hmac inside the install.img
do_rhevh_check /run/install/repo/images/pxeboot/vmlinuz || return 1
else
BOOT_IMAGE="$(getarg BOOT_IMAGE)"
# Trim off any leading GRUB boot device (e.g. ($root) )
BOOT_IMAGE="$(echo "${BOOT_IMAGE}" | sed 's/^(.*)//')"
BOOT_IMAGE_NAME="${BOOT_IMAGE##*/}"
BOOT_IMAGE_PATH="${BOOT_IMAGE%${BOOT_IMAGE_NAME}}"
if [ -z "$BOOT_IMAGE_NAME" ]; then
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
elif ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE_NAME}" ]; then
elif ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE}" ]; then
#if /boot is not a separate partition BOOT_IMAGE might start with /boot
BOOT_IMAGE_PATH=${BOOT_IMAGE_PATH#"/boot"}
#on some achitectures BOOT_IMAGE does not contain path to kernel
@@ -156,16 +129,16 @@ do_fips()
fi
fi
BOOT_IMAGE_HMAC="/boot/${BOOT_IMAGE_PATH}/.${BOOT_IMAGE_NAME}.hmac"
BOOT_IMAGE_HMAC="/boot/${BOOT_IMAGE_PATH}.${BOOT_IMAGE_NAME}.hmac"
if ! [ -e "${BOOT_IMAGE_HMAC}" ]; then
warn "${BOOT_IMAGE_HMAC} does not exist"
return 1
fi
(cd "${BOOT_IMAGE_HMAC%/*}" && sha512hmac -c "${BOOT_IMAGE_HMAC}") || return 1
sha512hmac -c "${BOOT_IMAGE_HMAC}" || return 1
fi
fips_info "All initrd crypto checks done"
info "All initrd crypto checks done"
> /tmp/fipsdone

View File

@@ -27,7 +27,7 @@ installkernel() {
_fipsmodules+="cipher_null des3_ede aes cfb "
# Modes/templates:
_fipsmodules+="ecb cbc ctr xts gcm ccm authenc hmac cmac ofb cts "
_fipsmodules+="ecb cbc ctr xts gcm ccm authenc hmac cmac "
# Compression algs:
_fipsmodules+="deflate lzo zlib "

View File

@@ -1,59 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries systemd-ask-password || return 1
require_binaries systemd-tty-ask-password-agent || return 1
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on the systemd module.
echo systemd
# Return 0 to include the dependent systemd module in the initramfs.
return 0
}
# Install the required file(s) for the module in the initramfs.
install() {
inst_multiple -o \
$systemdsystemunitdir/systemd-ask-password-console.path \
$systemdsystemunitdir/systemd-ask-password-console.service \
$systemdsystemunitdir/multi-user.target.wants/systemd-ask-password-wall.path \
$systemdsystemunitdir/sysinit.target.wants/systemd-ask-password-console.path \
systemd-ask-password systemd-tty-ask-password-agent
# Enable the systemd type service unit for systemd-ask-password.
$SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-console.service
# Install systemd-ask-password plymouth units if plymouth is enabled.
if dracut_module_included "plymouth"; then
inst_multiple -o \
$systemdsystemunitdir/systemd-ask-password-plymouth.path \
$systemdsystemunitdir/systemd-ask-password-plymouth.service
$SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-plymouth.service
fi
# Uncomment this section if the usecase for wall module in the initramfs arises.
# Install systemd-ask-password wall units if <wall module> is enabled.
#if dracut_module_included "<wall module>"; then
# inst_multiple -o \
# $systemdsystemunitdir/systemd-ask-password-wall.path \
# $systemdsystemunitdir/systemd-ask-password-wall.service \
# $systemdsystemunitdir/multi-user.target.wants/systemd-ask-password-wall.path
#
# $SYSTEMCTL -q --root "$initdir" enable systemd-ask-password-wall.service
#fi
}

View File

@@ -1,52 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries coredumpctl || return 1
require_binaries $systemdutildir/systemd-coredump || return 1
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on the systemd module.
echo systemd systemd-journald systemd-sysctl
# Return 0 to include the dependent systemd module in the initramfs.
return 0
}
# Install the required file(s) and directories for the module in the initramfs.
install() {
inst_dir /var/lib/systemd/coredump
inst_multiple -o \
$sysctld/50-coredump.conf \
$systemdutildir/coredump.conf \
$systemdsystemunitdir/systemd-coredump \
$systemdsystemunitdir/systemd-coredump.socket \
$systemdsystemunitdir/systemd-coredump@.service\
$systemdsystemunitdir/sockets.target.wants/systemd-coredump.socket \
coredumpctl
# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
$systemdutilconfdir/coredump.conf \
$systemdsystemconfdir/coredump.conf.d/*.conf \
$systemdsystemconfdir/systemd-coredump.socket \
$systemdsystemconfdir/systemd-coredump.socket.d/*.conf \
$systemdsystemconfdir/systemd-coredump@.service \
$systemdsystemconfdir/systemd-coredump@.service.d/*.conf \
$systemdsystemconfdir/sockets.target.wants/systemd-coredump.socket \
${NULL}
fi
}

View File

@@ -4,6 +4,11 @@
check() {
[[ $mount_needs ]] && return 1
if ! dracut_module_included "systemd"; then
derror "systemd-initrd needs systemd in the initramfs"
return 1
fi
return 0
}
@@ -31,5 +36,6 @@ install() {
$systemdsystemunitdir/initrd-udevadm-cleanup-db.service \
$systemdsystemunitdir/initrd-parse-etc.service
$SYSTEMCTL -q --root "$initdir" set-default initrd.target
ln_r "${systemdsystemunitdir}/initrd.target" "${systemdsystemunitdir}/default.target"
}

View File

@@ -1,49 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries $systemdutildir/systemd-modules-load || return 1
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on the systemd module.
echo systemd
# Return 0 to include the dependent systemd module in the initramfs.
return 0
}
# Install the required file(s) for the module in the initramfs.
install() {
# Create systemd-modules-load related directories.
inst_dir $modulesload
inst_dir $modulesloadconfdir
# Install related files for systemd-modules-load
inst_multiple -o \
$systemdsystemunitdir/systemd-modules-load.service \
$systemdutildir/systemd-modules-load
# Install local user configurations if host only is enabled..
if [[ $hostonly ]]; then
inst_multiple -H -o \
$systemdsystemconfdir/systemd-modules-load.service \
$systemdsystemconfdir/systemd-systemd-modules-load.d/*.conf \
${NULL}
fi
# Enable the systemd type service unit for systemd-modules-load.
$SYSTEMCTL -q --root "$initdir" enable systemd-modules-load.service
}

View File

@@ -1,43 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries systemd-repart || return 1
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on the systemd module.
echo systemd
# Return 0 to include the dependent systemd module in the initramfs.
return 0
}
# Install the required file(s) for the module in the initramfs.
install() {
inst_multiple -o \
$libdir/repart.d/*.conf \
$systemdsystemunitdir/systemd-repart.service \
$systemdsystemunitdir/initrd-root-fs.target.wants/systemd-repart.service \
systemd-repart
# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
/etc/repart.d/*.conf \
$systemdsystemconfdir/systemd-repart.service \
$systemdsystemconfdir/systemd-repart.service.d/*.conf \
${NULL}
fi
}

View File

@@ -1,48 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries $systemdutildir/systemd-sysctl || return 1
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on other module(s).
echo systemd systemd-modules-load
# Return 0 to include the dependent module(s) in the initramfs.
return 0
}
# Install the required file(s) for the module in the initramfs.
install() {
inst_multiple -o \
$sysctld/*.conf \
$systemdsystemunitdir/systemd-sysctl.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-sysctl.service \
$systemdutildir/systemd-sysctl
# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
/etc/sysctl.conf \
$sysctldconfdir/*.conf \
$systemdsystemconfdir/systemd-sysctl.service \
$systemdsystemconfdir/systemd-sysctl.service.d/*.conf \
${NULL}
fi
# Enable the systemd type service unit for sysctl.
$SYSTEMCTL -q --root "$initdir" enable systemd-sysctl.service
}

View File

@@ -1,53 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled
# return 1 to not include the binary.
require_binaries systemd-sysusers || return 1
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on the systemd module.
echo systemd
# Return 0 to include the dependent systemd module in the initramfs.
return 0
}
# Install the required file(s) for the module in the initramfs.
install() {
# Install the system users and groups configuration file.
# Install the systemd users and groups configuration file.
# Install the systemd type service unit for sysusers.
# Install the binary executable(s) for sysusers.
inst_multiple -o \
$sysusers/basic.conf \
$sysusers/systemd.conf \
$systemdsystemunitdir/systemd-sysusers.service \
systemd-sysusers
# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
$sysusersconfdir/basic.conf \
$sysusersconfdir/systemd.conf \
$systemdsystemconfdir/systemd-sysusers.service \
$systemdsystemconfdir/systemd-sysusers.service.d/*.conf \
${NULL}
fi
# Enable the systemd type service unit for sysusers.
$SYSTEMCTL -q --root "$initdir" enable systemd-sysusers.service
}

View File

@@ -4,29 +4,28 @@ capsmode=$(getarg rd.caps)
if [ "$capsmode" = "1" ]; then
CAPS_INIT_DROP=$(getarg rd.caps.initdrop=)
# shellcheck disable=SC2016
CAPS_USERMODEHELPER_BSET=$(capsh --drop="$CAPS_INIT_DROP" -- -c 'while read a b || [ -n "$a" ]; do [ "$a" = "CapBnd:" ] && echo $((0x${b:$((${#b}-8)):8})) $((0x${b:$((${#b}-16)):8})) && break; done < /proc/self/status')
CAPS_MODULES_DISABLED=$(getarg rd.caps.disablemodules=)
CAPS_KEXEC_DISABLED=$(getarg rd.caps.disablekexec=)
info "Loading CAPS_MODULES $CAPS_MODULES"
for i in $CAPS_MODULES;do modprobe "$i" 2>&1 >/dev/null | vinfo; done
for i in $CAPS_MODULES;do modprobe $i 2>&1 >/dev/null | vinfo; done
if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then
info "Disabling module loading."
echo "$CAPS_MODULES_DISABLED" > /proc/sys/kernel/modules_disabled
echo $CAPS_MODULES_DISABLED > /proc/sys/kernel/modules_disabled
fi
if [ "$CAPS_KEXEC_DISABLED" = "1" -a -e /proc/sys/kernel/kexec_disabled ]; then
info "Disabling kexec."
echo "$CAPS_KEXEC_DISABLED" > /proc/sys/kernel/kexec_disabled
echo $CAPS_KEXEC_DISABLED > /proc/sys/kernel/kexec_disabled
fi
info "CAPS_USERMODEHELPER_BSET=$CAPS_USERMODEHELPER_BSET"
if [ -e /proc/sys/kernel/usermodehelper/bset ]; then
info "Setting usermode helper bounding set."
echo "$CAPS_USERMODEHELPER_BSET" > /proc/sys/kernel/usermodehelper/bset
echo "$CAPS_USERMODEHELPER_BSET" > /proc/sys/kernel/usermodehelper/inheritable
echo $CAPS_USERMODEHELPER_BSET > /proc/sys/kernel/usermodehelper/bset
echo $CAPS_USERMODEHELPER_BSET > /proc/sys/kernel/usermodehelper/inheritable
fi
echo "CAPS_INIT_DROP=\"$CAPS_INIT_DROP\"" > /etc/capsdrop

View File

@@ -15,7 +15,7 @@ depends() {
install() {
if ! dracut_module_included "systemd"; then
inst_hook pre-pivot 00 "$moddir/caps.sh"
inst $(find_binary capsh 2>/dev/null) /usr/sbin/capsh
inst $(type -P capsh 2>/dev/null) /usr/sbin/capsh
# capsh wants bash and we need bash also
inst /bin/bash
else

View File

@@ -4,6 +4,11 @@
check() {
[[ $mount_needs ]] && return 1
if ! dracut_module_included "systemd"; then
derror "systemd-networkd needs systemd in the initramfs"
return 1
fi
return 255
}
@@ -43,12 +48,12 @@ install() {
# inst_dir /var/lib/systemd/clock
grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
# grep '^systemd-timesync:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
grep '^systemd-network:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
grep '^systemd-network:' /etc/group >> "$initdir/etc/group"
# grep '^systemd-timesync:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
# grep '^systemd-timesync:' /etc/group >> "$initdir/etc/group"
_arch=${DRACUT_ARCH:-$(uname -m)}
_arch=$(uname -m)
inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
@@ -56,11 +61,11 @@ install() {
for i in \
systemd-networkd-wait-online.service \
systemd-networkd.service \
systemd-networkd.socket
# systemd-timesyncd.service
systemd-networkd.service \
systemd-networkd.socket
# systemd-timesyncd.service
do
$SYSTEMCTL -q --root "$initdir" enable "$i"
systemctl --root "$initdir" enable "$i"
done
}

View File

@@ -12,8 +12,8 @@ check() {
# do not include module in hostonly mode,
# if no keys are present
if [[ $hostonly ]]; then
x=$(echo "$dracutsysrootdir"/lib/modules/keys/*)
[[ "${x}" = "$dracutsysrootdir/lib/modules/keys/*" ]] && return 255
x=$(echo /lib/modules/keys/*)
[[ "${x}" = "/lib/modules/keys/*" ]] && return 255
fi
return 0
@@ -31,8 +31,8 @@ install() {
inst_hook pre-trigger 01 "$moddir/load-modsign-keys.sh"
for x in "$dracutsysrootdir"/lib/modules/keys/* ; do
[[ "${x}" = "$dracutsysrootdir/lib/modules/keys/*" ]] && break
inst_simple "${x#$dracutsysrootdir}"
for x in /lib/modules/keys/* ; do
[[ "${x}" = "/lib/modules/keys/*" ]] && break
inst_simple "${x}"
done
}

View File

@@ -1,38 +0,0 @@
#!/bin/bash
# called by dracut
check() {
return 255
}
# called by dracut
depends() {
return 0
}
# called by dracut
install() {
return 0
}
installkernel() {
local -A _drivers
local _alldrivers _wdtdrv _wdtppath _dir
for _wd in /sys/class/watchdog/*; do
! [ -e $_wd ] && continue
_wdtdrv=$(get_dev_module $_wd)
if [[ $_wdtdrv ]]; then
instmods $_wdtdrv
for i in $_wdtdrv; do
_drivers[$i]=1
done
fi
done
# ensure that watchdog module is loaded as early as possible
_alldrivers="${!_drivers[*]}"
[[ $_alldrivers ]] && echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf
return 0
}

View File

@@ -7,7 +7,6 @@ check() {
# called by dracut
depends() {
echo watchdog-modules
return 0
}
@@ -28,7 +27,53 @@ install() {
inst_hook cleanup 00 "$moddir/watchdog.sh"
inst_hook cleanup 99 "$moddir/watchdog.sh"
fi
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
inst_multiple -o wdctl
}
installkernel() {
local -A _drivers
local _alldrivers _active _wdtdrv _wdtppath _dir
[[ -d /sys/class/watchdog/ ]] || return
for _dir in /sys/class/watchdog/*; do
[[ -d "$_dir" ]] || continue
[[ -f "$_dir/state" ]] || continue
_active=$(< "$_dir/state")
! [[ $hostonly ]] || [[ "$_active" = "active" ]] || continue
# device/modalias will return driver of this device
_wdtdrv=$(< "$_dir/device/modalias")
# There can be more than one module represented by same
# modalias. Currently load all of them.
# TODO: Need to find a way to avoid any unwanted module
# represented by modalias
_wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
if [[ $_wdtdrv ]]; then
instmods $_wdtdrv
for i in $_wdtdrv; do
_drivers[$i]=1
done
fi
# however in some cases, we also need to check that if there is
# a specific driver for the parent bus/device. In such cases
# we also need to enable driver for parent bus/device.
_wdtppath=$(readlink -f "$_dir/device")
while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do
_wdtppath=$(readlink -f "$_wdtppath/..")
[[ -f "$_wdtppath/modalias" ]] || continue
_wdtdrv=$(< "$_wdtppath/modalias")
_wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
if [[ $_wdtdrv ]]; then
instmods $_wdtdrv
for i in $_wdtdrv; do
_drivers[$i]=1
done
fi
done
done
# ensure that watchdog module is loaded as early as possible
_alldrivers="${!_drivers[*]}"
[[ $_alldrivers ]] && echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf
return 0
}

View File

@@ -14,16 +14,15 @@ depends() {
# called by dracut
install() {
local _i _path _busybox
local _progs=()
_busybox=$(find_binary busybox)
local _i _progs _path _busybox
_busybox=$(type -P busybox)
inst $_busybox /usr/bin/busybox
for _i in $($_busybox --list); do
[[ ${_i} == busybox ]] && continue
_progs+=("${_i}")
for _i in $($_busybox | sed -ne '1,/Currently/!{s/,//g; s/busybox//g; p}')
do
_progs="$_progs $_i"
done
for _i in "${_progs[@]}"; do
for _i in $_progs; do
_path=$(find_binary "$_i")
[ -z "$_path" ] && continue
ln_r /usr/bin/busybox $_path

View File

@@ -1,89 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries busctl || return 1
require_binaries dbus-broker || return 1
require_binaries dbus-broker-launch || return 1
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on the systemd module.
echo systemd systemd-sysusers
# Return 0 to include the dependent systemd module in the initramfs.
return 0
}
# Install the required file(s) and directories for the module in the initramfs.
install() {
# Create dbus related directories.
inst_dir $dbus
inst_dir $dbusinterfaces
inst_dir $dbusservices
inst_dir $dbussession
inst_dir $dbussystem
inst_dir $dbussystemservices
inst_dir $dbusconfdir
inst_dir $dbusinterfacesconfdir
inst_dir $dbusservicesconfdir
inst_dir $dbussessionconfdir
inst_dir $dbussystemconfdir
inst_dir $dbussystemservicesconfdir
inst_multiple -o \
$dbus/session.conf \
$dbus/system.conf \
$dbussystem/org.freedesktop.systemd1.conf \
$dbusservicesconfdir/org.freedesktop.systemd1.service \
$dbussystemservices/org.freedesktop.systemd1.service \
$sysusers/dbus.conf \
$systemdcatalog/dbus-broker.catalog \
$systemdcatalog/dbus-broker-launch.catalog \
$systemdsystemunitdir/dbus-broker.service \
$systemduser/dbus-broker.service \
$systemdsystemunitdir/dbus.socket \
$systemduser/dbus.socket \
$systemdsystemunitdir/dbus.target.wants \
busctl dbus-broker dbus-broker-launch
# Adjusting dependencies for initramfs in the dbus socket unit.
sed -i -e \
'/^\[Unit\]/aDefaultDependencies=no\
Conflicts=shutdown.target\
Before=shutdown.target
/^\[Socket\]/aRemoveOnStop=yes' \
"$initdir$systemdsystemunitdir/dbus.socket"
# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
$dbusconfdir/session.conf \
$dbusconfdir/system.conf \
$sysusersconfdir/dbus.conf \
$systemdsystemconfdir/dbus.socket \
$systemdsystemconfdir/dbus.socket.d/*.conf \
$systemdsystemconfdir/dbus-broker.service \
$systemdsystemconfdir/dbus-broker.service.d/*.conf \
${NULL}
fi
# We need to make sure that systemd-tmpfiles-setup.service->dbus.socket
# will not wait for local-fs.target to start if swap is encrypted,
# this would make dbus wait the timeout for the swap before loading.
# This could delay sysinit services that are dependent on dbus.service.
sed -i -Ee \
'/^After/s/(After[[:space:]]*=.*)(local-fs.target[[:space:]]*)(.*)/\1-\.mount \3/' \
"$initdir$systemdsystemunitdir/systemd-tmpfiles-setup.service"
}

View File

@@ -1,96 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# If the binary(s) requirements are not fulfilled the module can't be installed
require_binaries busctl || return 1
require_binaries dbus-daemon || return 1
require_binaries dbus-send || return 1
# dbus conflicts with dbus-broker.
if dracut_module_included "dbus-broker"; then
derror "dbus conflicts with dbus-broker in the initramfs."
exit 1
fi
# Return 255 to only include the module, if another module requires it.
return 255
}
# Module dependency requirements.
depends() {
# This module has external dependency on the systemd module.
echo systemd
# Return 0 to include the dependent systemd module in the initramfs.
return 0
}
# Install the required file(s) and directories for the module in the initramfs.
install() {
# Create dbus related directories.
inst_dir $dbus
inst_dir $dbusinterfaces
inst_dir $dbusservices
inst_dir $dbussession
inst_dir $dbussystem
inst_dir $dbussystemservices
inst_dir $dbusconfdir
inst_dir $dbusinterfacesconfdir
inst_dir $dbusservicesconfdir
inst_dir $dbussessionconfdir
inst_dir $dbussystemconfdir
inst_dir $dbussystemservicesconfdir
inst_multiple -o \
$dbus/system.conf \
$dbussystem/org.freedesktop.systemd1.conf \
$dbusservicesconfdir/org.freedesktop.systemd1.service \
$dbussystemservices/org.freedesktop.systemd1.service \
$systemdsystemunitdir/dbus.service \
$systemdsystemunitdir/dbus.socket \
$systemdsystemunitdir/dbus.target.wants \
busctl dbus-send dbus-daemon
# Adjusting dependencies for initramfs in the dbus service unit.
sed -i -e \
'/^\[Unit\]/aDefaultDependencies=no\
Conflicts=shutdown.target\
Before=shutdown.target' \
"$initdir$systemdsystemunitdir/dbus.service"
# Adjusting dependencies for initramfs in the dbus socket unit.
sed -i -e \
'/^\[Unit\]/aDefaultDependencies=no\
Conflicts=shutdown.target\
Before=shutdown.target
/^\[Socket\]/aRemoveOnStop=yes' \
"$initdir$systemdsystemunitdir/dbus.socket"
# Adding the user and group for dbus
grep '^\(d\|message\)bus:' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd"
grep '^\(d\|message\)bus:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
# Install the hosts local user configurations if enabled.
if [[ $hostonly ]]; then
inst_multiple -H -o \
$dbusconfdir/system.conf \
$systemdsystemconfdir/dbus.socket \
$systemdsystemconfdir/dbus.socket.d/*.conf \
$systemdsystemconfdir/dbus.service \
$systemdsystemconfdir/dbus.service.d/*.conf \
${NULL}
fi
# We need to make sure that systemd-tmpfiles-setup.service->dbus.socket
# will not wait for local-fs.target to start if swap is encrypted,
# this would make dbus wait the timeout for the swap before loading.
# This could delay sysinit services that are dependent on dbus.service.
sed -i -Ee \
'/^After/s/(After[[:space:]]*=.*)(local-fs.target[[:space:]]*)(.*)/\1-\.mount \3/' \
"$initdir$systemdsystemunitdir/systemd-tmpfiles-setup.service"
}

View File

@@ -18,6 +18,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
depends() {
echo systemd
return 0
}
check() {
# if there's no rngd binary, no go.
require_binaries rngd || return 1
@@ -25,16 +30,10 @@ check() {
return 0
}
depends() {
echo systemd
return 0
}
install() {
inst rngd
inst_simple "${moddir}/rngd.service" "${systemdsystemunitdir}/rngd.service"
# make sure dependant libs are installed too
inst_libdir_file opensc-pkcs11.so
$SYSTEMCTL -q --root "$initdir" add-wants sysinit.target rngd.service
mkdir -p "${initdir}${systemdsystemunitdir}/sysinit.target.wants"
ln -rfs "${initdir}${systemdsystemunitdir}/rngd.service" \
"${initdir}${systemdsystemunitdir}/sysinit.target.wants/rngd.service"
}

View File

@@ -2,7 +2,6 @@
Description=Hardware RNG Entropy Gatherer Daemon
DefaultDependencies=no
Before=systemd-udevd.service
ConditionVirtualization=!container
[Service]
ExecStart=/usr/sbin/rngd -f

View File

@@ -1,31 +0,0 @@
#!/bin/sh
# This file is part of dracut.
# SPDX-License-Identifier: GPL-2.0-or-later
# Prerequisite check(s) for module.
check() {
# We only want to return 255 since this is a meta module.
return 255
}
# Module dependency requirements.
depends() {
local _module
# Add a dbus meta dependency based on the module in use.
for _module in dbus-daemon dbus-broker; do
if dracut_module_included "$_module" ; then
echo "$_module"
return 0
fi
done;
if find_binary dbus-broker &> /dev/null ; then
echo "dbus-broker"
return 0
else
echo "dbus-daemon"
return 0
fi
return 1
}

View File

@@ -19,10 +19,10 @@ install() {
if dracut_module_included "systemd"; then
unset FONT
unset KEYMAP
[[ -f "$dracutsysrootdir"/etc/vconsole.conf ]] && . "$dracutsysrootdir"/etc/vconsole.conf
[[ -f /etc/vconsole.conf ]] && . /etc/vconsole.conf
fi
KBDSUBDIRS=(consolefonts consoletrans keymaps unimaps)
KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps
DEFAULT_FONT="${i18n_default_font:-eurlatgr}"
I18N_CONF="/etc/locale.conf"
VCONFIG_CONF="/etc/vconsole.conf"
@@ -32,20 +32,19 @@ install() {
local MAPS=$1
local MAPNAME=${1%.map*}
local map
[[ ! -f $dracutsysrootdir$MAPS ]] && \
MAPS=$(find $dracutsysrootdir${kbddir}/keymaps -type f -name ${MAPNAME} -o -name ${MAPNAME}.map -o -name ${MAPNAME}.map.\*)
[[ ! -f $MAPS ]] && \
MAPS=$(find ${kbddir}/keymaps -type f -name ${MAPNAME} -o -name ${MAPNAME}.map -o -name ${MAPNAME}.map.\*)
for map in $MAPS; do
KEYMAPS="$KEYMAPS $map "
case $map in
*.gz) cmd="zgrep";;
*.bz2) cmd="bzgrep";;
*) cmd="grep";;
*.gz) cmd=zgrep;;
*.bz2) cmd=bzgrep;;
*) cmd=grep ;;
esac
for INCL in $($cmd "^include " $map | while read _ a _ || [ -n "$a" ]; do echo ${a//\"/}; done); do
for FN in $(find $dracutsysrootdir${kbddir}/keymaps -type f -name $INCL\*); do
[[ -f $FN ]] || continue
for INCL in $($cmd "^include " $map | while read a a b || [ -n "$a" ]; do echo ${a//\"/}; done); do
for FN in $(find ${kbddir}/keymaps -type f -name $INCL\*); do
strstr "$KEYMAPS" " $FN " || findkeymap $FN
done
done
@@ -82,16 +81,14 @@ install() {
gather_vars() {
local item map value
# FIXME: double check
# shellcheck disable=SC2068
for item in $@
do
item=(${item/:/ })
for map in ${item[1]//,/ }
do
map=(${map//-/ })
if [[ -f "$dracutsysrootdir${item[0]}" ]]; then
value=$(grep "^${map[0]}=" "$dracutsysrootdir${item[0]}")
if [[ -f "${item[0]}" ]]; then
value=$(grep "^${map[0]}=" "${item[0]}")
value=${value#*=}
echo "${map[1]:-${map[0]}}=${value}"
fi
@@ -110,7 +107,7 @@ install() {
if [[ ${kbddir} != "/usr/share" ]]; then
inst_dir /usr/share
for _src in "${KBDSUBDIRS[@]}"; do
for _src in $(eval echo {${KBDSUBDIRS}}); do
[ ! -e "${initdir}/usr/share/${_src}" ] && ln -s "${kbddir}/${_src}" "${initdir}/usr/share/${_src}"
done
fi
@@ -119,9 +116,9 @@ install() {
install_all_kbd() {
local rel f
for _src in "${KBDSUBDIRS[@]}"; do
inst_dir "${kbddir}/$_src"
$DRACUT_CP -L -t "${initdir}/${kbddir}/$_src" "${dracutsysrootdir}${kbddir}/$_src"/*
for _src in $(eval echo ${kbddir}/{${KBDSUBDIRS}}); do
inst_dir "$_src"
$DRACUT_CP -L -t "${initdir}/${_src}" "$_src"/*
done
# remove unnecessary files
@@ -142,8 +139,8 @@ install() {
local map
eval $(gather_vars ${i18n_vars})
[ -f $dracutsysrootdir$I18N_CONF ] && . $dracutsysrootdir$I18N_CONF
[ -f $dracutsysrootdir$VCONFIG_CONF ] && . $dracutsysrootdir$VCONFIG_CONF
[ -f $I18N_CONF ] && . $I18N_CONF
[ -f $VCONFIG_CONF ] && . $VCONFIG_CONF
shopt -q -s nocasematch
if [[ ${UNICODE} ]]
@@ -225,14 +222,16 @@ install() {
inst_simple ${kbddir}/unimaps/${FONT_UNIMAP}.uni
fi
if dracut_module_included "systemd" && [[ -f $dracutsysrootdir${I18N_CONF} ]]; then
if dracut_module_included "systemd" && [[ -f ${I18N_CONF} ]]; then
inst_simple ${I18N_CONF}
else
mksubdirs ${initdir}${I18N_CONF}
print_vars LC_ALL LANG >> ${initdir}${I18N_CONF}
fi
if ! dracut_module_included "systemd"; then
if dracut_module_included "systemd" && [[ -f ${VCONFIG_CONF} ]]; then
inst_simple ${VCONFIG_CONF}
else
mksubdirs ${initdir}${VCONFIG_CONF}
print_vars KEYMAP EXT_KEYMAPS UNICODE FONT FONT_MAP FONT_UNIMAP >> ${initdir}${VCONFIG_CONF}
fi
@@ -241,17 +240,18 @@ install() {
}
checks() {
for kbddir in ${kbddir} /usr/lib/kbd /lib/kbd /usr/share /usr/share/kbd; do
if [[ -d "$dracutsysrootdir${kbddir}" ]]; then
for dir in "${KBDSUBDIRS[@]}"; do
[[ -d "$dracutsysrootdir${kbddir}/${dir}" ]] && continue
false
done && break
fi
for kbddir in ${kbddir} /usr/lib/kbd /lib/kbd /usr/share /usr/share/kbd
do
[[ -d "${kbddir}" ]] && \
for dir in ${KBDSUBDIRS//,/ }
do
[[ -d "${kbddir}/${dir}" ]] && continue
false
done && break
kbddir=''
done
[[ -f $dracutsysrootdir$I18N_CONF && -f $dracutsysrootdir$VCONFIG_CONF ]] || \
[[ -f $I18N_CONF && -f $VCONFIG_CONF ]] || \
[[ ! ${hostonly} || ${i18n_vars} ]] || {
derror 'i18n_vars not set! Please set up i18n_vars in ' \
'configuration file.'
@@ -262,11 +262,6 @@ install() {
if checks; then
install_base
# https://github.com/dracutdevs/dracut/issues/796
if dracut_module_included "systemd" && [[ -f $dracutsysrootdir${VCONFIG_CONF} ]]; then
inst_simple ${VCONFIG_CONF}
fi
if [[ ${hostonly} ]] && ! [[ ${i18n_install_all} == "yes" ]]; then
install_local_i18n || install_all_kbd
else

View File

@@ -7,10 +7,10 @@ inst_key_val() {
_file="$1"; shift
_key="$1"; shift
_default="$1"; shift
_value="$(getarg "$@")"
_value="$(getarg $@)"
[ -z "${_value}" ] && _value=$_default
if [ -n "${_value}" ]; then
printf -- '%s="%s"\n' "${_key}" "${_value}" >> "$_file"
printf '%s="%s"\n' ${_key} ${_value} >> $_file
fi
unset _file
unset _value

View File

@@ -75,8 +75,8 @@ setup_interface() {
setup_interface6() {
domain=$new_domain_name
search=$(printf -- "$new_dhcp6_domain_search")
namesrv=$new_dhcp6_name_servers
search=$(printf -- "$new_domain_search")
namesrv=$new_domain_name_servers
hostname=$new_host_name
[ -n "$new_dhcp_lease_time" ] && lease_time=$new_dhcp_lease_time
[ -n "$new_max_life" ] && lease_time=$new_max_life
@@ -146,7 +146,7 @@ parse_option_121() {
temp_result="$destination via $gateway dev $interface"
fi
echo "/sbin/ip route replace $temp_result"
echo "/sbin/ip route add $temp_result"
done
}
@@ -164,7 +164,7 @@ case $reason in
;;
BOUND)
echo "dhcp: BOUND setting up $netif"
echo "dhcp: BOND setting $netif"
unset layer2
if [ -f /sys/class/net/$netif/device/layer2 ]; then
read layer2 < /sys/class/net/$netif/device/layer2
@@ -223,7 +223,7 @@ case $reason in
;;
BOUND6)
echo "dhcp: BOUND6 setting up $netif"
echo "dhcp: BOND6 setting $netif"
setup_interface6
set | while read line || [ -n "$line" ]; do

Some files were not shown because too many files have changed in this diff Show More