c0247969695e2bdb0d2ab9f13516432824eff05f
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 stable_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
31 va
=$
(curl
-s https
://kernel.ubuntu.com
/mainline
/ | \
32 sed -rn 's,.*alt="\[DIR\]".*href="([^/]+).*,\1,p' | \
33 grep -v -- -rc |
sed 's/^v//' |
grep "^$stable_ver" |
sort -V |
tail -n1)
35 # note the wiki page about these says to install linux-headers.*generic.*amd64, but
36 # as of 2024, they have a requirement of a very new glibc, and people report
37 # that installing it is not needed.
38 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' )
39 mapfile
-t pkgs
<<<"$tmpstr"
41 if (( ${#pkgs[@]} != 3 )); then
42 echo "$0: error. expected to find 3 kernel packages, got: ${pkgs[*]}" >&2
47 for p
in ${pkgs[@]}; do
48 if ! dpkg
-s -- "${p%%_*}" 2>&1 |
grep -Fx "Status: install ok installed" &>/dev
/null
; then
49 urls
+=(https
://kernel.ubuntu.com
/mainline
/v
$va/amd64
/$p)
52 if (( ${#urls[@]} >= 1 )); then