This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xm-install
executable file
·101 lines (82 loc) · 3.7 KB
/
xm-install
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
#!/bin/bash
# -----------------------------------------------------------------------
# Install kernel.
# Author: Mario Roy - http://github.com/marioroy
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 or later of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------
# shellcheck disable=SC2012,SC2086
# Capture the active kernel release, for safety to not replace self.
kversion="$(uname -r)" # e.g 6.1.54-100.xmbore
kvariant="${kversion}"
kvariant="${kvariant##*.}" # xmbore
kversion="${kversion%.*}" # 6.1.54-100
function xm_install {
local variant="$1"; local release="$2"; local base_name="linux-${1}"
echo "Installing linux-${variant}"
if [[ -n "$release" ]]; then
# Install given xm_variant release (e.g. 100).
file1=$(ls -1t "${base_name}"-license-*-"${release}".x86_64.rpm | head -1)
file2=$(ls -1t "${base_name}"-[0-9]*-"${release}".x86_64.rpm | head -1)
file3=$(ls -1t "${base_name}"-extra-*-"${release}".x86_64.rpm | head -1)
file4=$(ls -1t "${base_name}"-dev-*-"${release}".x86_64.rpm | head -1)
else
# Install newest xm_variant (time stamp).
file1=$(ls -1t "${base_name}"-license-*.x86_64.rpm | head -1)
file2=$(ls -1t "${base_name}"-[0-9]*.x86_64.rpm | head -1)
file3=$(ls -1t "${base_name}"-extra-*.x86_64.rpm | head -1)
file4=$(ls -1t "${base_name}"-dev-*.x86_64.rpm | head -1)
fi
if [[ -z "$file1" || -z "$file2" || -z "$file3" || -z "$file4" ]]; then
echo "Aborting installation! One or more files are missing."
exit 2
fi
if [[ "$file2" == "linux-${kvariant}-${kversion}.x86_64.rpm" ]]; then
echo "Cannot replace the live kernel ${file2//.x86_64.rpm/}"
exit 0
fi
sudo rm -f "/usr/lib/default-${variant}"
sudo mkdir -p /usr/lib/modules
if ! sudo rpm -ivh --nodeps --force "$file1" "$file2" "$file3" "$file4"; then
# Cleanup before exiting if the 'rpm' command failed.
# Create default symbolic link if another release exists on the system.
cd "/usr/lib/kernel" || exit 1
other_kernel=$(ls -1t "org.clearlinux.${variant}".* 2>/dev/null | head -1)
[[ -n "$other_kernel" ]] && sudo ln -sf "$other_kernel" "default-${variant}"
exit 2
fi
sudo clr-boot-manager update
if [[ -d "/var/lib/dkms/nvidia" ]]; then
echo "Building kernel drivers for NVIDIA graphics"
xm_variant=${base_name#*-} # i.e. xmbore
if [[ "$variant" == *"-rt"* ]]; then
kernel=$(echo "${file2//.x86_64.rpm/}" | cut -d- -f4-).$xm_variant
else
kernel=$(echo "${file2//.x86_64.rpm/}" | cut -d- -f3-).$xm_variant
fi
sudo rm -fr /var/lib/dkms/*/kernel-${kernel}-x86_64
sudo rm -fr /var/lib/dkms/*/*/${kernel}
sudo CFLAGS="" CXXFLAGS="" IGNORE_PREEMPT_RT_PRESENCE=1 \
nice -n 12 dkms autoinstall -k "$kernel" --force >/dev/null
sudo depmod -A "$kernel"
fi
echo "done."
}
case "$1" in
bore | bore-rt )
cd "rpmbuild/RPMS/x86_64" || exit 1
xm_install "xm${1}" "$2"
;;
* ) echo "synopsis"
echo " $0 bore | bore-rt [<rel>]"
esac