1
1
mirror of https://pagure.io/fedora-kickstarts.git synced 2024-09-27 16:57:21 +00:00
fedora-kickstarts/fedora-container-toolbox.ks
Debarshi Ray f2c6224ade container-toolbox: Install all languages (part 2)
This is a continuation from commit 9456429624, which tried to
ensure that all languages are present in the fedora-toolbox OCI image by
removing --inst-langs=en from fedora-container-toolbox.ks.  Sadly, this
wasn't enough.

The image was still missing various localization bits like translations
for programs and manuals.  All translations for all programs, such as
LC_MESSAGES and LC_TIME, were missing, except for those coming from
glibc-all-langpacks.  eg., see:
  $ LANG=cs_CZ.UTF-8 cp foo bar
  cp: cannot stat 'foo': Adresář nebo soubor neexistuje

Only the part coming from glibc is translated.  The part coming from
coreutils isn't.  There are lots and lots of such packages.  eg., bash,
coreutils, dnf, grep, rpm, sed, tar, etc..

Any package with translated manuals marked with %lang() in their %files
section were missing them.  eg., man-db, passwd, psmisc, etc..

Finally, even though the %pre section in fedora-container-toolbox.ks
removes %_install_langs from /etc/rpm/macros.image-language-conf, it was
still set to en_US in the final image.

This was happening because fedora-container-toolbox.ks includes
fedora-container-common.ks, and some unintended bits from the latter
were leaking into the fedora-toolbox OCI image's build.

The image was still being built with '%packages --inst-langs=en',
possibly since fedora-container-common.ks has '%package --instLangs=en'.
That option wasn't just being applied to the packages being installed by
fedora-container-common.ks, but also to those being installed by
fedora-container-toolbox.ks [1].

Secondly, fedora-container-common.ks sets %_install_langs to en_US in
its %post section.  This will strip out all non-English languages from
future RPM transactions in containers created from the image.

To address this, fedora-container-toolbox.ks has now been decoupled from
fedora-container-common.ks, by copying over the relevant bits.

[1] https://koji.fedoraproject.org/koji/buildinfo?buildID=2311452
    https://kojipkgs.fedoraproject.org//packages/Fedora-Container-Toolbox/Rawhide/20231025.n.0/images/fedora-container-toolbox.ks
    https://kojipkgs.fedoraproject.org//packages/Fedora-Container-Toolbox/Rawhide/20231025.n.0/images/koji-f40-build-108073454-base.ks
    https://kojipkgs.fedoraproject.org//packages/Fedora-Container-Toolbox/Rawhide/20231025.n.0/data/logs/image/oz-aarch64.log

https://bugzilla.redhat.com/show_bug.cgi?id=2244503
https://pagure.io/fedora-kickstarts/pull-request/1004
2023-10-25 20:19:51 +02:00

204 lines
4.0 KiB
Plaintext

# Kickstart file for Fedora Toolbox
# See fedora-container-common.ks for details on how to hack on container image kickstarts
text # don't use cmdline -- https://github.com/rhinstaller/anaconda/issues/931
bootloader --disabled
timezone --isUtc Etc/UTC
timesource --ntp-disable
rootpw --lock --iscrypted locked
keyboard us
network --bootproto=dhcp --device=link --activate --onboot=on
reboot
# boot partitions are irrelevant as the final docker image is a tarball
zerombr
clearpart --all
autopart --noboot --nohome --noswap --nolvm
# Install packages
%packages --nocore
acl
bash
bash-completion
bc
bzip2
coreutils
coreutils-common
curl
diffutils
dnf
dnf-yum # https://fedorahosted.org/fesco/ticket/1312#comment:29
dnf-plugins-core
-dosfstools
-e2fsprogs
fedora-release-container
findutils
flatpak-spawn
fpaste
-fuse-libs
gawk
git
-glibc-minimal-langpack
glibc-all-langpacks
gnupg2
gnupg2-smime
grep
-grubby
gvfs-client
gzip
hostname
iproute
iputils
-kernel
keyutils
krb5-libs
less
libcap
-libss
lsof
man-db
man-pages
mesa-dri-drivers
mesa-vulkan-drivers
mtr
nano-default-editor
nss-mdns
openssh-clients
openssl
p11-kit
pam
passwd
pigz
-pinentry
procps-ng
python3
rootfiles
rpm
rsync
sed
shadow-utils
-shared-mime-info
-sssd-client
sudo
systemd
tar # https://bugzilla.redhat.com/show_bug.cgi?id=1409920
tcpdump
time
traceroute
tree
-trousers
unzip
util-linux
util-linux-core
vim-enhanced
vte-profile
vulkan-loader
wget
which
whois
words
-xkeyboard-config
xorg-x11-xauth
xz
zip
%end
# Pre-installation commands
%pre
# Copy README.md
cp /README.md /mnt/sysimage/README.md
# Remove macros.image-language-conf file
rm -f /mnt/sysimage/etc/rpm/macros.image-language-conf
# Remove 'tsflags=nodocs' line from dnf.conf
sed -i '/tsflags=nodocs/d' /mnt/sysimage/etc/dnf/dnf.conf
%end
%post --erroronfail --log=/root/anaconda-post.log
set -eux
# https://bugzilla.redhat.com/show_bug.cgi?id=1727489
echo 'LANG="C.UTF-8"' > /etc/locale.conf
# https://bugzilla.redhat.com/show_bug.cgi?id=1400682
echo "Import RPM GPG key"
releasever=$(rpm --eval '%{?fedora}')
# When building ELN containers, we don't have the %{fedora} macro
if [ -z $releasever ]; then
releasever=eln
fi
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-primary
echo "# fstab intentionally empty for containers" > /etc/fstab
# Remove machine-id on pre generated images
rm -f /etc/machine-id
touch /etc/machine-id
echo "# resolv placeholder" > /etc/resolv.conf
chmod 644 /etc/resolv.conf
# https://bugzilla.redhat.com/show_bug.cgi?id=1343138
# Fix /run/lock breakage since it's not tmpfs in docker
# This unmounts /run (tmpfs) and then recreates the files
# in the /run directory on the root filesystem of the container
#
# We ignore the return code of the systemd-tmpfiles command because
# at this point we have already removed the /etc/machine-id and all
# tmpfiles lines with %m in them will fail and cause a bad return
# code. Example failure:
# [/usr/lib/tmpfiles.d/systemd.conf:26] Failed to replace specifiers: /run/log/journal/%m
#
umount /run
rm -f /run/nologin # https://pagure.io/atomic-wg/issue/316
# Final pruning
rm -rfv /var/cache/* /var/log/* /tmp/*
%end
# Perform any necessary post-installation configurations specific to Fedora Toolbox (nochroot environment)
# Post-installation commands
%post --nochroot --erroronfail --log=/mnt/sysimage/root/anaconda-post-nochroot.log
set -eux
# Check if specified files exist
#declare -a files=(
# "/usr/share/man/man1/bash.1*"
# "/usr/share/man/man1/cd.1*"
# "/usr/share/man/man1/export.1*"
# "/usr/share/man/man1/cat.1*"
# "/usr/share/man/man1/cp.1*"
# "/usr/share/man/man1/ls.1*"
# "/usr/share/man/man1/gpg2.1*"
# "/usr/share/man/man7/gnupg2.7*"
# "/usr/share/man/fr/man8/rpm.8*"
# "/usr/share/man/ja/man8/rpm.8*"
# "/usr/share/man/man8/rpm.8*"
# "/usr/share/man/man1/kill.1*"
# "/usr/share/man/man8/mount.8*"
#)
#ret_val=0
#for file in "${files[@]}"; do
# if ! compgen -G "$file" >/dev/null; then
# echo "$file: No such file or directory" >&2
# ret_val=1
# break
# fi
#done
#if [ "$ret_val" -ne 0 ]; then
# false
#fi
# Clean up dnf cache
dnf clean all
%end