-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathupdate-bootengine
More file actions
executable file
·75 lines (62 loc) · 1.91 KB
/
update-bootengine
File metadata and controls
executable file
·75 lines (62 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Copyright (c) 2013 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -e
USAGE="Usage: $0 [-k 4.6.0] [-r /build/amd64-usr] [-o bootengine.cpio]
Options:
-k VERSION Kernel version of modules to include
-r SYSROOT Build the initrd using the given directory
-o OUT.cpio Alternate path to write the initrd
This tool uses dracut to update /usr/share/bootengine/bootengine.cpio
"
DRACUT_ARGS=(
--verbose
--force
--no-hostonly
--no-compress
--omit "fido2 lvm multipath network pkcs11 tpm2-tss zfs"
--add "i18n iscsi"
--add-drivers "loop brd drbd nbd rbd mmc_block xen-blkfront zram libarc4 lru_cache zsmalloc"
--kernel-cmdline "SYSTEMD_SULOGIN_FORCE=1"
)
USE_SYSROOT=
CPIO_PATH=
KERNEL=
while getopts "hk:o:r:" OPTION
do
case $OPTION in
k) KERNEL="$OPTARG";;
o) CPIO_PATH="$OPTARG";;
r) USE_SYSROOT="$OPTARG";;
h) echo "$USAGE"; exit;;
*) exit 1;;
esac
done
if [[ -n "$USE_SYSROOT" && ! -d "$USE_SYSROOT" ]]; then
echo "$0: sysroot directory $USE_SYSROOT does not exist!" >&2
exit 1
fi
if [[ $(id -u) -ne 0 ]]; then
echo "$0: this script must be run as root!" >&2
exit 1
fi
if [[ -n $USE_SYSROOT ]]; then
DRACUT_ARGS+=( --sysroot "${USE_SYSROOT}" )
fi
: "${CPIO_PATH:=${USE_SYSROOT}/usr/share/bootengine/bootengine.cpio}"
if [[ -n "$KERNEL" ]]; then
DRACUT_ARGS+=(
--kver "${KERNEL}"
--kmoddir "${USE_SYSROOT}/lib/modules/${KERNEL}"
)
else
DRACUT_ARGS+=( "--no-kernel" )
fi
# Copying / installing files to initrd while preserving xattrs breaks dracut in certain scenarios,
# e.g. when run in a container.
DRACUT_NO_XATTR=1
export DRACUT_NO_XATTR
mkdir -p "${CPIO_PATH%/*}"
LC_ALL=C DRACUT_INSTALL=/usr/lib/dracut/dracut-install dracut "${DRACUT_ARGS[@]}" "$CPIO_PATH"
chmod 644 "${CPIO_PATH}"