|
| 1 | +#!/usr/bin/bash |
| 2 | + |
| 3 | +set -oeux pipefail |
| 4 | + |
| 5 | +### PREPARE REPOS |
| 6 | +# ARCH="$(rpm -E '%_arch')" |
| 7 | +RELEASE="$(rpm -E '%fedora')" |
| 8 | + |
| 9 | +sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-cisco-openh264.repo |
| 10 | + |
| 11 | +# enable RPMs with alternatives to create them in this image build |
| 12 | +mkdir -p /var/lib/alternatives |
| 13 | + |
| 14 | +if [[ -f $(find /tmp/akmods-rpms/ublue-os/ublue-os-*.rpm 2> /dev/null) ]]; then |
| 15 | + dnf install -y /tmp/akmods-rpms/ublue-os/ublue-os-*.rpm |
| 16 | +fi |
| 17 | + |
| 18 | + |
| 19 | +# install kernel_cache provided kernel |
| 20 | +echo "Installing ${KERNEL_FLAVOR} kernel-cache RPMs..." |
| 21 | +# fedora image has no kernel so this needs nothing fancy, just install |
| 22 | +dnf install -y /tmp/kernel_cache/*.rpm |
| 23 | + |
| 24 | +if [[ "${KERNEL_FLAVOR}" == "surface" ]]; then |
| 25 | + KERNEL_VERSION=$(rpm -q kernel-surface|cut -d '-' -f2-) |
| 26 | +else |
| 27 | + KERNEL_VERSION=$(rpm -q kernel|cut -d '-' -f2-) |
| 28 | +fi |
| 29 | + |
| 30 | +# enable more repos |
| 31 | +RPMFUSION_MIRROR_RPMS="https://mirrors.rpmfusion.org" |
| 32 | +if [ -n "${RPMFUSION_MIRROR}" ]; then |
| 33 | + RPMFUSION_MIRROR_RPMS=${RPMFUSION_MIRROR} |
| 34 | +fi |
| 35 | + |
| 36 | +if [[ "${RELEASE}" -ge 41 ]]; then |
| 37 | + COPR_RELEASE="rawhide" |
| 38 | +else |
| 39 | + COPR_RELEASE="${RELEASE}" |
| 40 | +fi |
| 41 | + |
| 42 | +curl -Lo /etc/yum.repos.d/_copr_ublue-os_staging.repo \ |
| 43 | + "https://copr.fedorainfracloud.org/coprs/ublue-os/staging/repo/fedora-${COPR_RELEASE}/ublue-os-staging-fedora-${COPR_RELEASE}.repo" |
| 44 | + |
| 45 | +curl -Lo /etc/yum.repos.d/_copr_kylegospo_oversteer.repo \ |
| 46 | + "https://copr.fedorainfracloud.org/coprs/kylegospo/oversteer/repo/fedora-${COPR_RELEASE}/kylegospo-oversteer-fedora-${COPR_RELEASE}.repo" |
| 47 | + |
| 48 | +curl -Lo /etc/yum.repos.d/_copr_ublue-os-akmods.repo \ |
| 49 | + "https://copr.fedorainfracloud.org/coprs/ublue-os/akmods/repo/fedora-${COPR_RELEASE}/ublue-os-akmods-fedora-${COPR_RELEASE}.repo" |
| 50 | + |
| 51 | +curl -Lo /etc/yum.repos.d/negativo17-fedora-multimedia.repo \ |
| 52 | + "https://negativo17.org/repos/fedora-multimedia.repo" |
| 53 | + |
| 54 | +if [[ -f $(find /tmp/akmods-rpms/kmods/kmod-vhba-*.rpm) ]]; then |
| 55 | +curl -LsSf -o /etc/yum.repos.d/_copr_rok-cdemu.repo \ |
| 56 | + "https://copr.fedorainfracloud.org/coprs/rok/cdemu/repo/fedora-${COPR_RELEASE}/rok-cdemu-fedora-${COPR_RELEASE}.repo" |
| 57 | +fi |
| 58 | + |
| 59 | +if [[ -f $(find /tmp/akmods-rpms/kmods/kmod-facetimehd-*.rpm) ]]; then |
| 60 | +curl -LsSf -o /etc/yum.repos.d/_copr_mulderje-facetimehd-kmod.repo \ |
| 61 | + "https://copr.fedorainfracloud.org/coprs/mulderje/facetimehd-kmod/repo/fedora-${COPR_RELEASE}/mulderje-facetimehd-kmod-fedora-${COPR_RELEASE}.repo" |
| 62 | +fi |
| 63 | + |
| 64 | +if [[ -f $(find /tmp/akmods-rpms/kmods/kmod-kvmfr-*.rpm) ]]; then |
| 65 | +curl -LsSf -o /etc/yum.repos.d/_copr_hikariknight-looking-glass-kvmfr.repo \ |
| 66 | + "https://copr.fedorainfracloud.org/coprs/hikariknight/looking-glass-kvmfr/repo/fedora-${COPR_RELEASE}/hikariknight-looking-glass-kvmfr-fedora-${COPR_RELEASE}.repo" |
| 67 | +fi |
| 68 | + |
| 69 | +if [[ -f $(find /tmp/akmods-rpms/kmods/kmod-nvidia-*.rpm) ]]; then |
| 70 | + curl -Lo /etc/yum.repos.d/negativo17-fedora-nvidia.repo \ |
| 71 | + "https://negativo17.org/repos/fedora-nvidia.repo" |
| 72 | + curl -Lo /etc/yum.repos.d/nvidia-container-toolkit.repo \ |
| 73 | + "https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo" |
| 74 | + curl -Lo /etc/yum.repos.d/nvidia-container.pp \ |
| 75 | + "https://raw.githubusercontent.com/NVIDIA/dgx-selinux/master/bin/RHEL9/nvidia-container.pp" |
| 76 | + curl -Lo /etc/yum.repos.d/eyecantcu-supergfxctl.repo \ |
| 77 | + "https://copr.fedorainfracloud.org/coprs/eyecantcu/supergfxctl/repo/fedora-${COPR_RELEASE}/eyecantcu-supergfxctl-fedora-${COPR_RELEASE}.repo" |
| 78 | + curl -Lo /tmp/nvidia-install.sh \ |
| 79 | + "https://raw.githubusercontent.com/ublue-os/hwe/main/nvidia-install.sh" |
| 80 | + chmod +x /tmp/nvidia-install.sh |
| 81 | + sed -i "s@gpgcheck=0@gpgcheck=1@" /etc/yum.repos.d/nvidia-container-toolkit.repo |
| 82 | +fi |
| 83 | + |
| 84 | +dnf install -y \ |
| 85 | + "${RPMFUSION_MIRROR_RPMS}"/free/fedora/rpmfusion-free-release-"${RELEASE}".noarch.rpm \ |
| 86 | + "${RPMFUSION_MIRROR_RPMS}"/nonfree/fedora/rpmfusion-nonfree-release-"${RELEASE}".noarch.rpm \ |
| 87 | + fedora-repos-archive \ |
| 88 | + openssl |
| 89 | + |
| 90 | + |
| 91 | +# after F41 launches, bump to 42 |
| 92 | +if [[ "${FEDORA_MAJOR_VERSION}" -ge 41 ]]; then |
| 93 | + # pre-release rpmfusion is in a different location |
| 94 | + sed -i "s%free/fedora/releases%free/fedora/development%" /etc/yum.repos.d/rpmfusion-*.repo |
| 95 | + # pre-release rpmfusion needs to enable testing |
| 96 | + sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/rpmfusion-*-updates-testing.repo |
| 97 | +fi |
| 98 | + |
| 99 | +if [ -n "${RPMFUSION_MIRROR}" ]; then |
| 100 | + # force use of single rpmfusion mirror |
| 101 | + echo "Using single rpmfusion mirror: ${RPMFUSION_MIRROR}" |
| 102 | + sed -i.bak "s%^metalink=%#metalink=%" /etc/yum.repos.d/rpmfusion-*.repo |
| 103 | + sed -i "s%^#baseurl=http://download1.rpmfusion.org%baseurl=${RPMFUSION_MIRROR}%" /etc/yum.repos.d/rpmfusion-*.repo |
| 104 | +fi |
| 105 | + |
| 106 | +if [[ ! -s "/tmp/certs/private_key.priv" ]]; then |
| 107 | + echo "WARNING: Using test signing key. Run './generate-akmods-key' for production builds." |
| 108 | + cp /tmp/certs/public_key.der{.test,} |
| 109 | +fi |
| 110 | + |
| 111 | +openssl x509 -in /tmp/certs/public_key.der -out /tmp/certs/public_key.crt |
| 112 | +cat /tmp/certs/public_key.crt > /tmp/certs/public_key_chain.pem |
| 113 | +rm -f /tmp/certs/private_key.priv |
| 114 | + |
| 115 | +if [[ "${DUAL_SIGN}" == "true" ]]; then |
| 116 | + if [[ ! -s "/tmp/certs/private_key_2.priv" ]]; then |
| 117 | + echo "WARNING: Using test signing key. Run './generate-akmods-key' for production builds." |
| 118 | + cp /tmp/certs/public_key_2.der{.test,} |
| 119 | + fi |
| 120 | + openssl x509 -in /tmp/certs/public_key_2.der -out /tmp/certs/public_key_2.crt |
| 121 | + rm -f /tmp/certs/public_key_chain.pem |
| 122 | + cat /tmp/certs/public_key.crt <(echo) /tmp/certs/public_key_2.crt >> /tmp/certs/public_key_chain.pem |
| 123 | +fi |
| 124 | + |
| 125 | +rm -f /tmp/certs/private_key_2.priv |
| 126 | + |
| 127 | +if [[ -f $(find /tmp/akmods-rpms/kmods/kmod-nvidia-*.rpm 2> /dev/null) ]]; then |
| 128 | + sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/eyecantcu-supergfxctl.repo |
| 129 | + sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/negativo17-fedora-nvidia.repo |
| 130 | + sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/nvidia-container-toolkit.repo |
| 131 | + source /tmp/akmods-rpms/kmods/nvidia-vars |
| 132 | + dnf install -y \ |
| 133 | + libnvidia-fbc \ |
| 134 | + libnvidia-ml.i686 \ |
| 135 | + libva-nvidia-driver \ |
| 136 | + mesa-vulkan-drivers.i686 \ |
| 137 | + nvidia-driver \ |
| 138 | + nvidia-driver-cuda \ |
| 139 | + nvidia-driver-cuda-libs.i686 \ |
| 140 | + nvidia-driver-libs.i686 \ |
| 141 | + nvidia-modprobe \ |
| 142 | + nvidia-persistenced \ |
| 143 | + nvidia-settings \ |
| 144 | + nvidia-container-toolkit \ |
| 145 | + /tmp/akmods-rpms/kmods/kmod-nvidia-"${KERNEL_VERSION}"-"${NVIDIA_AKMOD_VERSION}".fc"${RELEASE}".rpm |
| 146 | +elif [[ -f $(find /tmp/akmods-rpms/kmods/zfs/kmod-*.rpm 2> /dev/null) ]]; then |
| 147 | + dnf install -y \ |
| 148 | + pv \ |
| 149 | + /tmp/akmods-rpms/kmods/zfs/*.rpm |
| 150 | +else |
| 151 | + dnf install -y \ |
| 152 | + /tmp/akmods-rpms/kmods/*.rpm |
| 153 | +fi |
| 154 | + |
| 155 | +printf "KERNEL_NAME=%s" "$KERNEL_NAME" >> /tmp/info.sh |
0 commit comments