-
Notifications
You must be signed in to change notification settings - Fork 5
/
fedora.sh
423 lines (382 loc) · 19.2 KB
/
fedora.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# SPDX-License-Identifier: GPL-3.0-or-later
packages_buildroot=()
options[loadpin]=
DEFAULT_RELEASE=41
function create_buildroot() {
local -r cver=1.4
local -r image="https://dl.fedoraproject.org/pub/fedora/linux/releases/${options[release]:=$DEFAULT_RELEASE}/Container/$DEFAULT_ARCH/images/Fedora-Container-Base-Generic-Minimal-${options[release]}-$cver.$DEFAULT_ARCH.oci.tar.xz"
opt bootable && packages_buildroot+=(kernel-core zstd)
opt bootable && [[ ${options[arch]:-$DEFAULT_ARCH} == *[3-6x]86* ]] && packages_buildroot+=(amd-ucode-firmware microcode_ctl)
opt bootable && opt squash && packages_buildroot+=(kernel-modules)
opt gpt && packages_buildroot+=(util-linux)
opt gpt && opt uefi && packages_buildroot+=(dosfstools mtools)
opt read_only || packages_buildroot+=(findutils)
opt read_only && ! opt squash && packages_buildroot+=(erofs-utils)
opt secureboot && packages_buildroot+=(nss-tools pesign)
opt selinux && packages_buildroot+=(busybox kernel-core policycoreutils qemu-system-x86-core zstd)
opt squash && packages_buildroot+=(squashfs-tools)
opt uefi && packages_buildroot+=(binutils fedora-logos ImageMagick systemd-boot-unsigned)
opt uefi_vars && packages_buildroot+=(qemu-system-x86-core)
opt verity && packages_buildroot+=(veritysetup)
opt verity_sig && opt bootable && packages_buildroot+=(kernel-devel keyutils)
packages_buildroot+=(crypto-policies-scripts e2fsprogs openssl systemd)
$curl -L "${image%-Base*}-${options[release]}-$cver-$DEFAULT_ARCH-CHECKSUM" > "$output/checksum"
$curl -L "$image" > "$output/image.txz"
verify_distro "$output/checksum" "$output/image.txz"
$mkdir -p "$output/oci"
$tar -C "$output/oci" -xJf "$output/image.txz"
local -r manifest=$($sed -n 's/.*"sha256:\([^"]*\).*/\1/p' "$output/oci/index.json")
local -r layer=$($sed -n 's/.*layers[^]]*"sha256:\([^"]*\).*/\1/p' "$output/oci/blobs/sha256/$manifest")
$tar -C "$buildroot" -xzf "$output/oci/blobs/sha256/$layer"
$rm -fr "$output/checksum" "$output/image.txz" "$output/oci"
# Disable bad packaging options.
$sed -i -e '/^[[]main]/ainstall_weak_deps=False' "$buildroot/etc/dnf/dnf.conf"
$sed -i -e 's/^enabled=1.*/enabled=0/' "$buildroot"/etc/yum.repos.d/*{cisco,modular}*.repo
# Let the configuration decide if the system should have documentation.
$sed -i -e '/^tsflags=/d' "$buildroot/etc/dnf/dnf.conf"
configure_initrd_generation
initialize_buildroot "$@"
script "${packages_buildroot[@]}" << 'EOF'
dnf --assumeyes --setopt={keepcache=1,tsflags=nodocs} upgrade
exec dnf --assumeyes --setopt={keepcache=1,tsflags=nodocs} install "$@"
EOF
}
function install_packages() {
opt bootable && packages+=(systemd)
opt networkd && packages+=(systemd-networkd systemd-resolved)
opt selinux && packages+=("selinux-policy-${options[selinux]}")
mount -o bind,X-mount.mkdir {,root}/var/cache/libdnf5
trap -- 'umount root/var/cache/libdnf5 ; trap - RETURN' RETURN
dnf --assumeyes --installroot="$PWD/root" --use-host-config \
${options[arch]:+--forcearch="${options[arch]}"} \
--releasever="${options[release]}" \
install "${packages[@]:-filesystem}" "$@"
# Fix PAM and friends immediately before any configuration is written.
if [[ -x root/usr/bin/authselect ]]
then
chroot root /usr/bin/authselect select local --force --nobackup
chroot root /usr/bin/authselect opt-out
fi
rpm -qa | sort > packages-buildroot.txt
rpm --root="$PWD/root" -qa | sort > packages.txt
}
function distro_tweaks() {
exclude_paths+=('usr/lib/.build-id')
rm -fr root/etc/inittab root/etc/rc.d
[[ -d root/etc/crypto-policies ]] &&
base_dir=$PWD/root/etc/crypto-policies \
profile_dir=$PWD/root/usr/share/crypto-policies \
update-crypto-policies --no-reload --set FUTURE
[[ -s root/etc/dnf/dnf.conf ]] &&
sed -i -e '/^[[]main]/ainstall_weak_deps=False' root/etc/dnf/dnf.conf
compgen -G 'root/etc/yum.repos.d/*cisco*.repo' && [[ ! -d root/usr/share/licenses/openh264 ]] &&
sed -i -e 's/^enabled=1.*/enabled=0/' root/etc/yum.repos.d/*cisco*.repo
compgen -G 'root/etc/yum.repos.d/*modular*.repo' &&
sed -i -e 's/^enabled=1.*/enabled=0/' root/etc/yum.repos.d/*modular*.repo
[[ -s root/etc/profile.d/bash-color-prompt.sh ]] &&
sed -i -e "s/PS1='"'/&$? /' root/etc/profile.d/bash-color-prompt.sh
sed -i -e 's/^[^#]*PS1="./&\\$? /;s/mask 002$/mask 022/' root/etc/bashrc
}
function save_boot_files() if opt bootable
then
opt uefi && [[ ! -s logo.bmp ]] &&
magick -background none /usr/share/fedora-logos/fedora_logo.svg -trim logo.bmp
[[ -s initrd.img ]] || build_systemd_ramdisk "$(cd /lib/modules ; compgen -G '[0-9]*')"
[[ -s vmlinuz ]] || cp -pt . /lib/modules/*/vmlinuz
if opt verity_sig
then
local -r v=$(echo /lib/modules/[0-9]*)
"$v/build/scripts/extract-vmlinux" "$v/vmlinuz" > vmlinux
"$v/build/scripts/insert-sys-cert" -b vmlinux -c "$keydir/verity.der" -s "$v/System.map"
fi
fi
function configure_initrd_generation() if opt bootable
then
# Don't expect that the build system is the target system.
$mkdir -p "$buildroot/etc/dracut.conf.d"
$cat << EOF > "$buildroot/etc/dracut.conf.d/99-settings.conf"
add_drivers+=" ${options[ramdisk]:+loop} "
compress="zstd --threads=0 --ultra -22"
hostonly="no"
i18n_install_all="no"
reproducible="yes"
EOF
# Load disk support before verity so dm-init can find the partition.
if opt rootmod
then
$mkdir -p "$buildroot/usr/lib/modprobe.d"
echo > "$buildroot/usr/lib/modprobe.d/verity-root.conf" \
"softdep dm-verity pre: ${options[rootmod]}"
fi
# Since systemd can't skip canonicalization, wait for a udev hack.
if opt verity
then
local dropin=/usr/lib/systemd/system/sysroot.mount.d
$mkdir -p "$buildroot$dropin"
echo > "$buildroot$dropin/verity-root.conf" '[Unit]
After=dev-mapper-root.device
Requires=dev-mapper-root.device'
echo >> "$buildroot/etc/dracut.conf.d/99-settings.conf" \
"install_optional_items+=\" $dropin/verity-root.conf \""
fi
# Create a generator to handle verity ramdisks since dm-init can't.
opt verity && if opt ramdisk || opt verity_sig
then
local -r gendir=/usr/lib/systemd/system-generators
$mkdir -p "$buildroot$gendir"
echo > "$buildroot$gendir/dmsetup-verity-root" '#!/bin/bash -eu
read -rs cmdline < /proc/cmdline
[[ $cmdline == *DVR=\"*\"* ]] || exit 0
concise=${cmdline##*DVR=\"} concise=${concise%%\"*}
device=${concise#* * * * } device=${device%% *}
if [[ $device =~ ^[A-Z]+= ]]
then
tag=${device%%=*} tag=${tag,,}
device=${device#*=}
[[ $tag == partuuid ]] && device=${device,,}
device="/dev/disk/by-$tag/$device"
fi
device=$(systemd-escape --path "$device").device
rundir=/run/systemd/system
echo > "$rundir/dmsetup-verity-root.service" "[Unit]
DefaultDependencies=no
After=$device
Requires=$device
[Service]
ExecStart=/bin/sh -c \"test -s /wd/verity.sig &&\
keyctl padd user verity:root @s < /wd/verity.sig ;\
exec dmsetup create --concise '\'\$concise\''\"
RemainAfterExit=yes
Type=oneshot"
mkdir -p "$rundir/dev-dm\x2d0.device.requires"
ln -fst "$rundir/dev-dm\x2d0.device.requires" ../dmsetup-verity-root.service'
$chmod 0755 "$buildroot$gendir/dmsetup-verity-root"
echo >> "$buildroot/etc/dracut.conf.d/99-settings.conf" \
'install_optional_items+="' \
"$gendir/dmsetup-verity-root" \
/wd/verity.sig '"'
else
local dropin=/usr/lib/systemd/system/dev-dm\\x2d0.device.requires
$mkdir -p "$buildroot$dropin"
$ln -fst "$buildroot$dropin" ../udev-workaround.service
echo > "$buildroot${dropin%/*}/udev-workaround.service" '[Unit]
DefaultDependencies=no
After=systemd-udev-trigger.service
[Service]
ExecStart=/usr/bin/udevadm trigger
RemainAfterExit=yes
Type=oneshot'
echo >> "$buildroot/etc/dracut.conf.d/99-settings.conf" \
'install_optional_items+="' \
"$dropin/udev-workaround.service" \
"${dropin%/*}/udev-workaround.service" \
'"'
fi
# Load overlayfs in the initrd in case modules aren't installed.
if opt read_only
then
$mkdir -p "$buildroot/usr/lib/modules-load.d"
echo overlay > "$buildroot/usr/lib/modules-load.d/overlay.conf"
fi
fi
function verify_distro() {
local -rx GNUPGHOME="$output/gnupg"
trap -- '$rm -fr "$GNUPGHOME" ; trap - RETURN' RETURN
$mkdir -pm 0700 "$GNUPGHOME"
$gpg --import
$gp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ewaafEYhsitUtKagx6z3F7UObnvQpOz5U5iFcJCvRDtC4FXq+VkMdhT09zMZY4Ey
ia29bV1B1R7pe7yXh6l3WyVj9AAXUSEBR/OsakaYEMzScLnROBEU1YbWR9iHsc7M
rEsqju8tVUh1XAqIqJgLW3VrKs0g0nDVR0rBc8aDhrtVfylwWVl61gHsPFJfAkjj
OPgvQgThrhlCWo23EZSk/Hj8YRrnhUbEDnk+Z3Xv5Uyl1kxGRk5dGBnv+7u3CKvV
G6sU3tPtna/8rFblfKSMZIPhzTADdsUZ88Fn9pZkfqgPi8LZ4sS8vHtaykZmbfj6
t9a2mBYJQ+/pxiH8olzyhKMdNyesLPeQmESgwM/qlJ+b2Hbogwuuzp8o2JMezxIe
CAwLoPh+hxMPGnBRklh6Vj5R5z29wIZd6pKCavVRfJ+ON94wuOSEofhBfQNZIIFV
jagEbk60iksysxsObfVEHFhtGnZCEgCRC87BfX6tzIIDv23Zs4Bv9gcaaRXTAml2
kZXktduHkV9q3hhcoha5FgGSe244C4GsMUkWCsZtuN6tevUPo+n2ZZAA7ikQ768r
Iz9rPOI8/Ra7qnwSlNIVnkTb9bc=
=e2ew
-----END PGP PUBLIC KEY BLOCK-----
EOF
# OPTIONAL (BUILDROOT)
function enable_repo_rpmfusion_free() {
local key="RPM-GPG-KEY-rpmfusion-free-fedora-${options[release]}"
local url="https://download1.rpmfusion.org/free/fedora/releases/${options[release]}/Everything/$DEFAULT_ARCH/os/Packages/r/rpmfusion-free-release-${options[release]}-1.noarch.rpm"
$sed -i -e '/^[[]fedora-cisco-openh264]$/,/^$/s/^enabled=.*/enabled=1/' "$buildroot/etc/yum.repos.d/fedora-cisco-openh264.repo"
[[ -s $buildroot/etc/pki/rpm-gpg/$key ]] || script "$url"
} << 'EOF'
cat << 'EOG' > /tmp/key ; rpmkeys --import /tmp/key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF2tu8EBEADnI6bmlE7ebLuYSBKJavk7gwX8L2S0lDwtmAFmNcxQ/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2K3NkXqzkvQSM68JZiYR2+wMkoO9f72B7LTBrfkwy
RcFPA7kj65pysB+l2wez03Dh/MyA3LTusd9M6FGiSOUVpQZ+NUFipIisS3vh/Bgp
zMsj1NSsMLjUDcX8stR8GfVgTxSgWwHTNl75XwTZpJOKMoj97kh9zzLwBhZ1W+xo
8s2W7YqVnOUl8rPm7ZbOefGkamNg8bhqcyNIEbHqR5QZVzDBT2AxVcB6jsxSHf5b
sb+KEJff4g6E4fWPA/IYdtJ7DItbVXnkAjqD7ADUh7Xq7pOgfC/4Cledf27x73m+
sdBvKsEBrroAsX/v4z46mQApszkfjTUAXwj2lUT+ujoktJHXqR71jbY0+8JX6Fyw
6ZW0emxR++bt9ksLcsNmjOQP9TmQpi2CW4Z+Ol2tlwtlnKAo6ecx4aacHKg+FYuQ
HTJRq6E6GpCPn1avf1v797RM+3zzw9TYkadfVLIQQ4HYbYzienOgGGporclrtrQ=
=oOVZ
-----END PGP PUBLIC KEY BLOCK-----
EOG
curl -L "$1" > rpmfusion-free.rpm
curl -L "${1/-release-/-release-tainted-}" > rpmfusion-free-tainted.rpm
rpm --checksig --define=_pkgverify_{'flags 0x0','level all'} rpmfusion-free{,-tainted}.rpm
rpm --install rpmfusion-free{,-tainted}.rpm
exec rm -f rpmfusion-free{,-tainted}.rpm
EOF
function enable_repo_rpmfusion_nonfree() {
local key="RPM-GPG-KEY-rpmfusion-nonfree-fedora-${options[release]}"
local url="https://download1.rpmfusion.org/nonfree/fedora/releases/${options[release]}/Everything/$DEFAULT_ARCH/os/Packages/r/rpmfusion-nonfree-release-${options[release]}-1.noarch.rpm"
enable_repo_rpmfusion_free
[[ -s $buildroot/etc/pki/rpm-gpg/$key ]] || script "$url"
} << 'EOF'
cat << 'EOG' > /tmp/key ; rpmkeys --import /tmp/key
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF2tvGQBEAC5Q2ePLZZafOkFhYHpGZdRRBCcCd+aiLATofFV8+FjPuPLL/3R
7fx9RRukL+XKs6K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qx6+LJ6Ng0YfCQ
fO7IMfwtgUt34AfrHWnq0S9BW0hmtPvcYjTtveQKCeGfdMcpRRJsOrvaDDKo1Wmr
IcvGO2VwiF9i19ppghXOSy7q51wTlEqtj3PWYhmJYcRq8Jr1SqjGx73QhUPtsF67
g3vjNEm8PE7pj7vg52BJlzkx6yU+hH5ZNBRM5ll4ZjiX+X7EzKa9so83uszuwoQA
mScTwyyQDNeflnUwiSgZc7PEv1i0BYIHVK7VjmamhOWZRHaaYFCc//gcmu10TJLn
ZCGF2ZDkAdUT6EoWBsT/QCgYSFggrjH9lgKqC5ON8+F5DO1RQe84irgz9jjE9+62
kgQgWZ6F2RZm5/R28DHdAetji50XbnmXgAk/u9u2Hw2bVVJfJ0WpEVcPvA1L86SE
8i8p1fmzljwRazZAksk5Zh2QfaM0jlMYHWbKpbXQcX19Uerm7D9IkciZvDAmgBYV
S6Y=
=rOqq
-----END PGP PUBLIC KEY BLOCK-----
EOG
curl -L "$1" > rpmfusion-nonfree.rpm
curl -L "${1/-release-/-release-tainted-}" > rpmfusion-nonfree-tainted.rpm
rpm --checksig --define=_pkgverify_{'flags 0x0','level all'} rpmfusion-nonfree{,-tainted}.rpm
rpm --install rpmfusion-nonfree{,-tainted}.rpm
exec rm -f rpmfusion-nonfree{,-tainted}.rpm
EOF
# OPTIONAL (IMAGE)
function check_for_updates() if [[ -x root/usr/bin/dnf ]]
then
# Define a service to categorize which updates are available, if any.
cat << 'EOF' > root/usr/lib/systemd/system/image-update-check.service
[Unit]
Description=Write the MOTD with the system update status
After=network.target network-online.target
#Before=display-manager.service sshd.service # Don't delay booting.
[Service]
ExecStart=/bin/bash -eo pipefail -c 'declare -A total=() ;\
for retry in 1 2 3 4 5 ; do while read -rs count type extra ;\
do [[ $$count =~ [0-9]+ ]] && total[$$type]=$$count ||\
{ [[ $$count == Error: ]] && break ; } ;\
done < <(exec /usr/bin/dnf --quiet updateinfo summary --available 2>&1) ;\
[[ -n $$count ]] && /usr/bin/sleep 10 || break ; done ;\
[[ -n $$count ]] && exit 1 ; unset "total["{New,Moderate,Low}"]" ;\
/usr/bin/mkdir -pZ /run/motd.d ; exec > /run/motd.d/image-update-check ;\
[[ $${#total[@]} -gt 0 ]] || exit 0 ;\
{ (( total[Critical] + total[Important] )) && echo -n UPDATES REQUIRED ; } ||\
{ (( total[Security] )) && echo -n Security updates are available ; } ||\
{ (( total[Bugfix] )) && echo -n Bug fixes are available ; } ||\
echo -n Updates are available ; sec= ;\
(( total[Critical] )) && sec+=" ($${total[Critical]} critical)" ;\
(( total[Important] )) && { sec="$${sec/%?/, }" ;\
sec="${sec:- (}$${total[Important]} important)" ; } ;\
echo -n $${total[Security]:+, $${total[Security]} security$$sec} ;\
echo -n $${total[Bugfix]:+, $${total[Bugfix]} bugfix} ;\
echo -n $${total[Enhancement]:+, $${total[Enhancement]} enhancement} ;\
echo -n $${total[other]:+, $${total[other]} other}'
ExecStartPost=-/bin/bash -euo pipefail -c '[[ -x /usr/bin/dconf ]] || exit 0 ;\
[[ -s /etc/dconf/db/gdm.d/01-banner && -s /run/motd.d/image-update-check ]] &&\
echo -e > /etc/dconf/db/gdm.d/02-banner "[org/gnome/login-screen]\n\
banner-message-text=\'$(</run/motd.d/image-update-check)\'" ||\
/usr/bin/rm -f /etc/dconf/db/gdm.d/02-banner ;\
exec /usr/bin/dconf update'
TimeoutStartSec=5m
Type=oneshot
[Install]
WantedBy=multi-user.target
EOF
ln -fst root/usr/lib/systemd/system/multi-user.target.wants \
../image-update-check.service
# Define a timer to check for updates twice per day.
cat << 'EOF' > root/usr/lib/systemd/system/image-update-check.timer
[Unit]
Description=Check for system update notifications twice daily
[Timer]
AccuracySec=1h
OnUnitInactiveSec=12h
[Install]
WantedBy=timers.target
EOF
ln -fst root/usr/lib/systemd/system/timers.target.wants \
../image-update-check.timer
# Show the status message on GDM if it exists.
if [[ -x root/usr/sbin/gdm ]]
then
mkdir -p root/etc/dconf/db/gdm.d root/etc/dconf/profile
cat << 'EOF' > root/etc/dconf/db/gdm.d/01-banner
[org/gnome/login-screen]
banner-message-enable=true
EOF
cat << 'EOF' > root/etc/dconf/profile/gdm
user-db:user
system-db:gdm
file-db:/usr/share/gdm/greeter-dconf-defaults
EOF
fi
fi
function drop_package() while read -rs
do exclude_paths+=("${REPLY#/}")
done < <(rpm --root="$PWD/root" -qal "$@")
# WORKAROUNDS
# Older Fedora releases are still available, but most of them are EOL.
[[ ${options[release]:-$DEFAULT_RELEASE} -ge DEFAULT_RELEASE ]] ||
[[ ${options[distro]:-fedora} != fedora ]] || # Expect CentOS reusing this.
. "legacy/fedora$(( --DEFAULT_RELEASE )).sh"