83774909e2d6e99a932a4f50693a89441c1b0812
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]}" "$@"
24 tmpdir
=$
(mktemp
-d) ||
exit
25 trap 'cd; rm -rf "$tmpdir"' EXIT
28 # update ver= when we are ready to jump to a new stable kernel.
29 # note: this is duplicated in 11-iank.
30 # Stable kernels are listed here: https://www.kernel.org/category/releases.html
32 va
=$
(curl
-s https
://kernel.ubuntu.com
/mainline
/ | \
33 sed -rn 's,.*alt="\[DIR\]".*href="([^/]+).*,\1,p' | \
34 grep -v -- -rc |
sed 's/^v//' |
grep "^$ver" |
sort -V |
tail -n1)
36 # note the wiki page about these says to install linux-headers.*generic.*amd64, but
37 # as of 2024, they have a requirement of a very new glibc, and people report
38 # that installing it is not needed.
39 tmpstr
=$
(curl
-s https
://kernel.ubuntu.com
/mainline
/v
$va/amd64
/CHECKSUMS |
awk '$2 ~ /^linux-/ { print $2 }' |
sort -u |
grep -iv 'linux-headers.*generic.*amd64' )
40 mapfile
-t pkgs
<<<"$tmpstr"
42 if (( ${#pkgs[@]} != 3 )); then
43 echo "$0: error. expected to find 3 kernel packages, got: ${pkgs[*]}" >&2
48 for p
in ${pkgs[@]}; do
49 if ! dpkg
-s -- "${p%%_*}" 2>&1 |
grep -Fx "Status: install ok installed" &>/dev
/null
; then
50 urls
+=(https
://kernel.ubuntu.com
/mainline
/v
$va/amd64
/$p)
53 if (( ${#urls[@]} >= 1 )); then