2 # This file is part of Ian Kelling's automated-distro-installer
3 # Copyright (C) 2024 Ian Kelling
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
22 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
28 # note: update kernel_ver when we are ready to jump to a new stable kernel.
29 # Stable kernels are listed here: https://www.kernel.org/category/releases.html
39 for p
in wget curl
; do
40 if ! type -p $p &>/dev
/null
; then
44 if (( ${#prereqs[@]} >= 1 )); then
45 apt-get
-y install ${prereqs[@]}
49 tmpdir
=$
($ROOTCMD mktemp
-d) ||
exit
50 # shellcheck disable=SC2154 # defined by fai
51 outertmp
=$target/$tmpdir
52 trap 'cd; rm -rf "$outertmp"' EXIT
55 # We get 10 versions cuz maybe the latest directory (or few) get created but not populated.
56 tmps
=$
(curl
-s https
://kernel.ubuntu.com
/mainline
/ | \
57 sed -rn 's,.*alt="\[DIR\]".*href="([^/]+).*,\1,p' | \
58 grep -v -- -rc |
sed 's/^v//' |
grep "^$kernel_ver" |
sort -Vr |
head -n10)
59 mapfile
-t latest_versions
<<<"$tmps"
61 for va
in "${latest_versions[@]}"; do
63 # note the wiki page about these says to install linux-headers.*generic.*amd64, but
64 # as of 2024, they have a requirement of a very new glibc, and people report
65 # that installing it is not needed.
66 tmpstr
=$
(curl
-s https
://kernel.ubuntu.com
/mainline
/v
$va/amd64
/CHECKSUMS |
awk '$2 ~ /^linux-/ { print $2 }' |
sort -u |
sed '/linux-headers.*generic.*amd64/d' )
67 if [[ $tmpstr ]]; then
68 mapfile
-t pkgs
<<<"$tmpstr"
73 if (( ${#pkgs[@]} != 3 )); then
74 echo "$0: error. expected to find 3 kernel packages, got: ${pkgs[*]}" >&2
79 for p
in ${pkgs[@]}; do
80 if ! $ROOTCMD dpkg
-s -- "${p%%_*}" 2>&1 |
grep -Fx "Status: install ok installed" &>/dev
/null
; then
81 urls
+=(https
://kernel.ubuntu.com
/mainline
/v
$va/amd64
/$p)
84 if (( ${#urls[@]} >= 1 )); then
86 $ROOTCMD dpkg
-i ${pkgs[@]/#/$tmpdir/}