further bookworm support
[automated-distro-installer] / fai / config / scripts / IANK / 11-iank
index 0b8d6c5576caba9763234f1de2bbca79f9a0e41a..63c85f96e992452999a349210252fd05af96595a 100755 (executable)
@@ -1,4 +1,20 @@
 #!/bin/bash -x
+# This file is part of Ian Kelling's automated-distro-installer
+# Copyright (C) 2024 Ian Kelling
+
+# 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; either version 2
+# of the License, or (at your option) any later version.
+
+# 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
@@ -19,8 +35,11 @@ if [[ -e /a/bin/fai/fai-wrapper ]]; then
   }
 fi
 
-if [[ $FAI_ROOT != / ]]; then
-  bprogs_pre=/srv
+if [[ $FAI_ROOT == / ]]; then
+  source /a/bin/bash_unpublished/source-state
+  bprogs_dir=/a/opt/btrfs-progs-release
+else
+  bprogs_dir=/srv/btrfs-progs-release
   chroot="chroot $FAI_ROOT"
 fi
 
@@ -117,7 +136,7 @@ systemctl enable myncq.service
 /usr/bin/myncq no-upgrub
 EOFOUTER
 
-        ;;
+        ;;&
       # per rubens suggestion to make a d16 more stable
       kd|kw) cmdline+=" pci=realloc=off" ;;
     esac
@@ -205,39 +224,41 @@ EOF
 
 fi
 
-# for btrfs bug reporting, install latest kernel and btrfs progs, as of
-# 2023-07-21
 case $HOSTNAME in
   sy)
-    mkdir -p $FAI_ROOT/tmp/kernel-debs
-    cd $FAI_ROOT/tmp/kernel-debs
-    va=6.4.3
-    vb=$va-060403
-    vc=${vb}.202307110536
-    pre="https://kernel.ubuntu.com/~kernel-ppa/mainline/v$va/amd64/linux-"
-    if ! dpkg -s -- linux-headers-${vb}  2>&1 | grep -Fx "Status: install ok installed" &>/dev/null; then
-      urls=(
-        ${pre}headers-${vb}_${vc}_all.deb
-        ${pre}{headers,image-unsigned,modules}-${vb}-generic_${vc}_amd64.deb
-      )
-      wget "${urls[@]}"
-      $chroot bash <<EOF
-cd /tmp/kernel-debs
-dpkg -i *.deb
-EOF
-    fi
+    $FAI/distro-install-common/install-stable-kernel-debs
     ;;
   *)
     $chroot apt-get -y install linux-libre
     ;;
 esac
 
-cp -ra $bprogs_pre/a/opt/btrfs-progs-release/btrfs-progs-v6.3.2 $FAI_ROOT/tmp/btrfs-progs
-$chroot bash <<EOF
-cd /tmp/btrfs-progs
+pre=https://mirrors.edge.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs
+tarball=$(curl -s $pre/sha256sums.asc \
+            | awk '$2 ~ /^btrfs-progs-v/ { print $2 }' | grep -v -- -rc | grep "^btrfs-progs-v.*gz\$" | sort -V | tail -n1)
+url="$pre/$tarball"
+dir=${tarball%.tar.gz}
+ver=${dir#btrfs-progs-}
+cur_ver=$(btrfs --version 2>/dev/null | awk '{print $2}') ||:
+if [[ $ver != "$cur_ver" ]]; then
+  if [[ $HOST2 == "$HOSTNAME" && $ver != "$($bprogs_dir/btrfs --version 2>/dev/null | awk '{print $2}')" ]]; then
+    rm -rf $bprogs_dir
+    cd /tmp
+    wget $url
+    sudo -u iank tar xzf $tarball
+    mv ${tarball%.tar.gz} $bprogs_dir
+    cd $bprogs_dir
+    apt-get -y build-dep btrfs-progs
+    sudo -u iank ./configure --disable-documentation
+    sudo -u iank make
+    make install
+  else
+    $chroot bash -xe <<EOF
+cd $bprogs_dir
 make install
 EOF
-
+  fi
+fi
 
 if ifclass LINODE; then
   mkdir -p $target/etc/initramfs-tools/conf.d
@@ -277,7 +298,7 @@ fi
 ##### end network setup  #####
 
 
-if ifclass VOL_BULLSEYE_BOOTSTRAP; then
+if ifclass VOL_BULLSEYE_BOOTSTRAP || ifclass VOL_BOOKWORM_BOOTSTRAP; then
   fcopy /etc/systemd/system/faicheck.service
   $chroot bash <<'EOFOUTER'
 systemctl enable faicheck.service
@@ -312,7 +333,6 @@ fi
 # but that made a service that started too soon and didn't pick up our
 # x env vars. instead, copy from the root ssh-agent just the
 # appropriate things into a new service.
-rm -f /home/iank/.config/systemd/user/default.target.wants/ssh-agent.service
 
 rm -f /home/iank/.local/share/systemd/user/sshaiank.service \
   /home/iank/.config/systemd/user/default.target.wants/sshaiank.service