distro_rpm: Add fedora profile
This commit is contained in:
parent
7b6b519f96
commit
bc3c8f1949
112
common.d/common.fedora.sh
Normal file
112
common.d/common.fedora.sh
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
source ./common.d/functions.sh
|
||||||
|
source ./common.d/build_functions.sh
|
||||||
|
source ./common.d/common.rpm.sh
|
||||||
|
|
||||||
|
require "wget"
|
||||||
|
require "pixz"
|
||||||
|
require "losetup"
|
||||||
|
require "rsync"
|
||||||
|
require "pv"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2155
|
||||||
|
fetch_base_system()
|
||||||
|
{
|
||||||
|
local rootdir="$1"
|
||||||
|
local release="$2"
|
||||||
|
local releasever="$3"
|
||||||
|
local edition="$4"
|
||||||
|
[ ! -d "$rootdir" ] && {
|
||||||
|
log "Rootdir [$rootdir] does not exists" ierror
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
|
local xz_url="https://fedora.mirrorservice.org/fedora/linux/releases/$release/$edition/aarch64/images/Fedora-$edition-$release-$releasever.aarch64.raw.xz"
|
||||||
|
local xz_path="./cache/Fedora-$edition-$release-$releasever.aarch64.raw.xz"
|
||||||
|
local raw_path="./cache/Fedora-$edition-$release-$releasever.aarch64.raw"
|
||||||
|
|
||||||
|
[ ! -f "$xz_path" ] && {
|
||||||
|
log "Downloading generic rootfs" internal
|
||||||
|
wget -O "$xz_path" "$xz_url" || {
|
||||||
|
log "Failed to download generic rootfs" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ ! -f "${raw_path}" ] && {
|
||||||
|
log "Extracting generic rootfs" internal
|
||||||
|
{ pv "$xz_path" | pixz -d > "$raw_path"; } || {
|
||||||
|
log "Failed to extract generic rootfs" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Mounting generic rootfs" internal
|
||||||
|
local raw_loop
|
||||||
|
raw_loop=$(losetup -Pf --show "raw_path") || {
|
||||||
|
log "Failed to setup loop device" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
local raw_mnt=$(mktemp --temp=./tmp -d)
|
||||||
|
mount "${raw_loop}p3" "$raw_mnt" || {
|
||||||
|
log "Failed to mount loop device" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
log "rSyncing system"
|
||||||
|
rsync -a --info=progress2 --info=name0 "$raw_mnt/root/"* "$rootdir/" || {
|
||||||
|
log "Failed to rsync system" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Unmounting generic rootfs"
|
||||||
|
{
|
||||||
|
umount "$raw_mnt" &&
|
||||||
|
rm -d "$raw_mnt" &&
|
||||||
|
losetup -d "$raw_loop"
|
||||||
|
} || {
|
||||||
|
log "Failed to umount generic rootfs" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_system()
|
||||||
|
{
|
||||||
|
local rootdir="$1"
|
||||||
|
[ ! -d "$rootdir" ] && {
|
||||||
|
log "Rootdir [$rootdir] does not exists" ierror
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Removing generic kernel and firmware" internal
|
||||||
|
rm -rf "$rootdir/usr/lib/kernel/install.d/10-devicetree.instal"
|
||||||
|
chroot "$rootdir" /usr/bin/bash -c "rpm --noscripts -e gnome-initial-setup qcom-firmware atheros-firmware brcmfmac-firmware amd-ucode-firmware kernel-core nvidia-gpu-firmware kernel kernel-modules kernel-modules-core intel-audio-firmware cirrus-audio-firmware nvidia-gpu-firmware linux-firmware linux-firmware-whence intel-gpu-firmware amd-gpu-firmware libertas-firmware mt7xxx-firmware nxpwireless-firmware realtek-firmware tiwilink-firmware" || {
|
||||||
|
log "Failed to remove generic kernel and firmware" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
chroot "$rootdir" rm -rf "/boot/*"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_zram_generator()
|
||||||
|
{
|
||||||
|
local rootdir="$1"
|
||||||
|
[ ! -d "$rootdir" ] && {
|
||||||
|
log "Rootdir [$rootdir] does not exists" ierror
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Configuring zram-generator" internal
|
||||||
|
cp ./drop/zram-generator.conf "$rootdir/etc/systemd/zram-generator.conf" || {
|
||||||
|
log "Failed to confugire zram-generator" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Enabling zram-generator" internal
|
||||||
|
chroot "$rootdir" systemctl enable systemd-zram-setup@zram0.service || {
|
||||||
|
log "Failed to enable zram-generator" ierror
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
Loading…
Reference in a new issue