# Generated by pykickstart v3.47
#version=DEVEL
# Use text mode install
text
# Firewall configuration
firewall --enabled --service=mdns
# Run the Setup Agent on first boot
firstboot --reconfig
# Keyboard layouts
keyboard 'us'
# System language
lang en_US.UTF-8
# Network information
network  --bootproto=dhcp --device=link --activate
# Shutdown after installation
shutdown
repo --name="koji-override-0" --baseurl=http://fedora.riscv.rocks/compose/rawhide/Fedora-Rawhide-20230903.n.0/compose/Everything/riscv64/os
repo --name="koji-override-1" --baseurl=http://fedora.riscv.rocks/compose/rawhide/Fedora-Rawhide-20230903.n.0/compose/Server/riscv64/os
# Root password
rootpw --iscrypted --lock locked
# SELinux configuration
selinux --enforcing
# System services
services --enabled="sshd,NetworkManager,chronyd,initial-setup"
# System timezone
timezone Etc/UTC --utc
# Use network installation
url --url="http://fedora.riscv.rocks/compose/rawhide/Fedora-Rawhide-20230903.n.0/compose/Everything/riscv64/os"
# System bootloader configuration
bootloader --append="console=tty1 console=ttyS0,115200n8" --location=mbr --timeout=1
reqpart --add-boot
# Partition clearing information
clearpart --all --initlabel --disklabel=gpt
# Disk partitioning information
part pv.007 --grow --size=4000
volgroup sysvg pv.007
logvol / --fstype="xfs" --grow --maxsize=16000 --size=4000 --label="sysroot" --name=root --vgname=sysvg

%post --logfile=/root/anaconda-post-1.log --erroronfail

# Find the architecture we are on
arch=$(uname -m)

# Import RPM GPG key, during installation saved in /etc/pki
echo "Import RPM GPG key"
releasever=$(rpm --eval '%{fedora}')
basearch=$(uname -i)
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch

# See the systemd-random-seed.service man page that says:
#   " It is recommended to remove the random seed from OS images intended
#     for replication on multiple systems"
# The newly installed instance should make it's own
echo "Removing random-seed so it's not the same in every image."
rm -f /var/lib/systemd/random-seed

# When we build the image a networking config file gets left behind.
# Let's clean it up.
echo "Cleanup leftover networking configuration"
rm -f /etc/NetworkManager/system-connections/*.nmconnection

# Truncate the /etc/resolv.conf left over from NetworkManager during the
# kickstart because the DNS server is environment specific.
truncate -s 0 /etc/resolv.conf

echo "Cleaning repodata to save space."
dnf clean all

# linux-firmware is installed by default and is quite large. As of mid 2020:
#   Total download size: 97 M
#   Installed size: 268 M
# Not needed in virtual environment.
echo "Removing linux-firmware package."
rpm -e linux-firmware

# Will ever anybody see this?
echo "Packages within this disk image"
rpm -qa --qf '%{size}\t%{name}-%{version}-%{release}.%{arch}\n' |sort -rn

# Note that running rpm recreates the rpm db files which aren't needed or wanted
rm -f /var/lib/rpm/__db*


# Do we need a serial terminal with a VM?
if [[ $arch == "aarch64" ]] || [[ $arch == "armv7l" ]]; then
 # Anaconda adds console=tty0 to the grub boot line on all images. this is problematic
 # when you are using fedora via serial console as you do not get any output post grub
 # linux does a good job of knowing what consoles need to be enabled.
 # https://bugzilla.redhat.com/show_bug.cgi?id=2022757
 sed -i -e 's|console=tty0||g' /boot/loader/entries/*conf
fi


# Remove machine-id on pre generated images
rm -f /etc/machine-id
touch /etc/machine-id

%end

%post

# When we build the image /var/log gets populated.
# Let's clean it up.
echo "Cleanup leftover in /var/log"
cd /var/log  && find . -name \* -type f -delete 

echo "Zeroing out empty space."
# Create zeros file with nodatacow and no compression
touch /var/tmp/zeros
chattr +C /var/tmp/zeros
# This forces the filesystem to reclaim space from deleted files
dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
echo "(Don't worry -- that out-of-space error was expected.)"
# Force sync to disk
sync /
rm -f /var/tmp/zeros
sync /

# setup systemd to boot to the right runlevel
echo -n "Setting default runlevel to multiuser text mode"
rm -f /etc/systemd/system/default.target
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
echo .

%end

%packages --inst-langs=en
@core
@domain-client
@guest-agents
@headless-management
@networkmanager-submodules
@server-product
@standard
glibc-all-langpacks
initial-setup
kernel-core
-dracut-config-rescue
-generic-release*
-initial-setup-gui
-kernel
-linux-firmware
-plymouth
-smartmontools
-smartmontools-selinux

%end