forked from ublue-os/akmods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-prep.sh
executable file
·142 lines (126 loc) · 5.56 KB
/
build-prep.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
#!/bin/sh
set -oeux pipefail
### PREPARE REPOS
ARCH="$(rpm -E '%_arch')"
RELEASE="$(rpm -E '%fedora')"
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-cisco-openh264.repo
# enable RPMs with alternatives to create them in this image build
mkdir -p /var/lib/alternatives
# enable more repos
RPMFUSION_MIRROR_RPMS="https://mirrors.rpmfusion.org"
if [ -n "${RPMFUSION_MIRROR}" ]; then
RPMFUSION_MIRROR_RPMS=${RPMFUSION_MIRROR}
fi
rpm-ostree install \
${RPMFUSION_MIRROR_RPMS}/free/fedora/rpmfusion-free-release-${RELEASE}.noarch.rpm \
${RPMFUSION_MIRROR_RPMS}/nonfree/fedora/rpmfusion-nonfree-release-${RELEASE}.noarch.rpm \
fedora-repos-archive
# after F41 launches, bump to 42
if [[ "${FEDORA_MAJOR_VERSION}" -ge 41 ]]; then
# pre-release rpmfusion is in a different location
sed -i "s%free/fedora/releases%free/fedora/development%" /etc/yum.repos.d/rpmfusion-*.repo
# pre-release rpmfusion needs to enable testing
sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/rpmfusion-*-updates-testing.repo
fi
if [ -n "${RPMFUSION_MIRROR}" ]; then
# force use of single rpmfusion mirror
echo "Using single rpmfusion mirror: ${RPMFUSION_MIRROR}"
sed -i.bak "s%^metalink=%#metalink=%" /etc/yum.repos.d/rpmfusion-*.repo
sed -i "s%^#baseurl=http://download1.rpmfusion.org%baseurl=${RPMFUSION_MIRROR}%" /etc/yum.repos.d/rpmfusion-*.repo
fi
# required for main and surface when fedora repo has updated kernel beyond what was in the image
curl -LsSf -o /etc/yum.repos.d/fedora-coreos-pool.repo \
https://raw.githubusercontent.com/coreos/fedora-coreos-config/testing-devel/fedora-coreos-pool.repo
### PREPARE CUSTOM KERNEL SUPPORT
if [[ "asus" == "${KERNEL_FLAVOR}" ]]; then
echo "Installing ASUS Kernel:"
curl -LsSf -o /etc/yum.repos.d/_copr_lukenukem-asus-kernel.repo \
https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel/repo/fedora-$(rpm -E %fedora)/lukenukem-asus-kernel-fedora-$(rpm -E %fedora).repo
rpm-ostree cliwrap install-to-root /
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:lukenukem:asus-kernel \
kernel \
kernel-core \
kernel-devel \
kernel-devel-matched \
kernel-modules \
kernel-modules-core \
kernel-modules-extra
elif [[ "fsync-lts" == "${KERNEL_FLAVOR}" ]]; then
echo "Installing fsync-lts kernel:"
curl -LsSf -o /etc/yum.repos.d/_copr_sentry-kernel-ba.repo \
https://copr.fedorainfracloud.org/coprs/sentry/kernel-ba/repo/fedora-$(rpm -E %fedora)/sentry-kernel-ba-fedora-$(rpm -E %fedora).repo
rpm-ostree cliwrap install-to-root /
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:sentry:kernel-ba \
kernel \
kernel-core \
kernel-devel \
kernel-devel-matched \
kernel-modules \
kernel-modules-core \
kernel-modules-extra
elif [[ "fsync" == "${KERNEL_FLAVOR}" ]]; then
echo "Installing fsync kernel:"
curl -LsSf -o /etc/yum.repos.d/_copr_sentry-kernel-fsync.repo \
https://copr.fedorainfracloud.org/coprs/sentry/kernel-fsync/repo/fedora-$(rpm -E %fedora)/sentry-kernel-fsync-fedora-$(rpm -E %fedora).repo
rpm-ostree cliwrap install-to-root /
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:sentry:kernel-fsync \
kernel \
kernel-core \
kernel-devel \
kernel-devel-matched \
kernel-modules \
kernel-modules-core \
kernel-modules-extra
elif [[ "surface" == "${KERNEL_FLAVOR}" ]]; then
echo "Installing Surface Kernel:"
# Add Linux Surface repo
curl -LsSf -o /etc/yum.repos.d/linux-surface.repo \
https://pkg.surfacelinux.com/fedora/linux-surface.repo
curl -LsSf -o /tmp/surface-kernel.rpm \
https://github.com/linux-surface/linux-surface/releases/download/silverblue-20201215-1/kernel-20201215-1.x86_64.rpm
rpm-ostree cliwrap install-to-root /
rpm-ostree override replace /tmp/surface-kernel.rpm \
--remove kernel-core \
--remove kernel-modules \
--remove kernel-modules-extra \
--install kernel-surface \
--install kernel-surface-core \
--install kernel-surface-devel \
--install kernel-surface-devel-matched \
--install kernel-surface-modules \
--install kernel-surface-modules-core \
--install kernel-surface-modules-extra
elif [[ "main" == "${KERNEL_FLAVOR}" ]] && \
[[ "" != "${KERNEL_VERSION}" ]]; then
echo "main kernel version ${KERNEL_VERSION} to avoid upgrading kernel beyond what is in the image."
rpm-ostree cliwrap install-to-root /
rpm-ostree install \
kernel-devel-${KERNEL_VERSION} \
kernel-devel-matched-${KERNEL_VERSION}
else
echo "Default main kernel without a specific version."
rpm-ostree install \
kernel-devel \
kernel-devel-matched
fi
### PREPARE BUILD ENV
rpm-ostree install \
akmods \
mock
if [[ ! -s "/tmp/certs/private_key.priv" ]]; then
echo "WARNING: Using test signing key. Run './generate-akmods-key' for production builds."
cp /tmp/certs/private_key.priv{.test,}
cp /tmp/certs/public_key.der{.test,}
fi
install -Dm644 /tmp/certs/public_key.der /etc/pki/akmods/certs/public_key.der
install -Dm644 /tmp/certs/private_key.priv /etc/pki/akmods/private/private_key.priv
# protect against incorrect permissions in tmp dirs which can break akmods builds
chmod 1777 /tmp /var/tmp
# create directories for later copying resulting artifacts
mkdir -p /var/cache/rpms/{kmods,ublue-os}