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]}" "$@"
27 for p
in wget curl
; do
28 if ! type -p $p &>/dev
/null
; then
32 if (( ${#prereqs[@]} >= 1 )); then
33 apt-get
-y install ${prereqs[@]}
37 tmpdir
=$
($ROOTCMD mktemp
-d) ||
exit
38 outertmp
=$target/$tmpdir
39 trap 'cd; rm -rf "$outertmp"' EXIT
42 # update stable_ver when we are ready to jump to a new stable kernel.
43 # Stable kernels are listed here: https://www.kernel.org/category/releases.html
45 # Actually, I dont want stable right now. comment this out to get stable
48 va
=$
(curl
-s https
://kernel.ubuntu.com
/mainline
/ | \
49 sed -rn 's,.*alt="\[DIR\]".*href="([^/]+).*,\1,p' | \
50 grep -v -- -rc |
sed 's/^v//' |
grep "^$stable_ver" |
sort -V |
tail -n1)
52 # note the wiki page about these says to install linux-headers.*generic.*amd64, but
53 # as of 2024, they have a requirement of a very new glibc, and people report
54 # that installing it is not needed.
55 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' )
56 mapfile
-t pkgs
<<<"$tmpstr"
58 if (( ${#pkgs[@]} != 3 )); then
59 echo "$0: error. expected to find 3 kernel packages, got: ${pkgs[*]}" >&2
64 for p
in ${pkgs[@]}; do
65 if ! $ROOTCMD dpkg
-s -- "${p%%_*}" 2>&1 |
grep -Fx "Status: install ok installed" &>/dev
/null
; then
66 urls
+=(https
://kernel.ubuntu.com
/mainline
/v
$va/amd64
/$p)
69 if (( ${#urls[@]} >= 1 )); then
71 $ROOTCMD dpkg
-i ${pkgs[@]/#/$tmpdir/}