fixes mostly for newer fai
authorIan Kelling <iank@fsf.org>
Thu, 5 Feb 2026 22:59:54 +0000 (17:59 -0500)
committerIan Kelling <iank@fsf.org>
Thu, 5 Feb 2026 22:59:54 +0000 (17:59 -0500)
fai-wrapper
fai/config/distro-install-common/end
fai/config/distro-install-common/new-btrfs-progs
fai/config/hooks/partition.DEFAULT

index b6a75d327e339607900aa74ee7364d9b63e034e3..962c48c6d52ff8185513b8506b8d99aaab6335c6 100644 (file)
 # This wrapper can be detected by using this var:
 export FAI_WRAPPER=true
 
-ifclass() {
-  local var=${1/#/CLASS_}
-  [[ $HOSTNAME == "$1" || ${!var} ]]
-}
+# note: fai changed how classes get defined & checked, now its all in the "classes" env var.
+# And we have a binary outside fai, so don't need this.
+# ifclass() {
+#   local var=${1/#/CLASS_}
+#   [[ $HOSTNAME == "$1" || ${!var} ]]
+# }
+#export -f ifclass
 fai-setclass() {
   for class in "$@"; do
     # export class vars with CLASS_ in front to avoid name collisions.
@@ -44,9 +47,9 @@ eval-fai-classfile() {
   fi
   fai-setclass $(bash $file)
 }
-export -f ifclass
 # DEFAULT is used by fcopy
 classes="DEFAULT $(hostname)"
+export classes
 export CLASS_DEFAULT=true
 if [[ ! -d $FAI_ROOT ]]; then
   export FAI_ROOT=/
index a3c4bb41da8f19babaaedc7bbf096ddd5232c730..8a1b72c3941dacccb64670fe4093c55082e5da8c 100755 (executable)
@@ -98,7 +98,7 @@ Defaults:root,iank !log_allowed, !pam_session
 Defaults>root env_file=/etc/rootsudoenv
 
 # a few commands we should be able to run with no password
-iank ALL = (root) NOPASSWD: /usr/local/bin/spend,/usr/local/bin/us,/usr/local/bin/off,/usr/bin/nmtui-connect,/usr/local/bin/bitcoinoff,/usr/local/bin/bitcoinon
+iank ALL = (root) NOPASSWD: /usr/local/bin/spend,/usr/local/bin/us,/usr/local/bin/off,/usr/bin/nmtui-connect,/usr/local/bin/bitcoinoff,/usr/local/bin/bitcoinon,/usr/local/bin/i3-misc1
 
 EOF
 
index 086c25db7f9bceba562e63227cd7c16ae395fd1a..3116383bd0293ddc9edf6178547850a89db80517 100644 (file)
@@ -27,8 +27,20 @@ if ! type -p wget &>/dev/null; then
 fi
 
 
+
 $ROOTCMD apt-get -y install btrfs-progs
-for f in $(dpkg-query -L btrfs-progs | grep -E '/man/|^/s?bin/|^/usr/lib/udev') ; do
+# Running dpkg-divert on the same file twice will cause an error.
+# Those files are identified in the output of dpkg-query -L like so:
+# /usr/share/man/man8/mkfs.btrfs.8.gz
+# locally diverted to: /usr/share/man/man8/mkfs.btrfs.8.gz.distrib
+# So, with sed we look forward to the next line before printing and
+# if the next line says locally diverted, we avoid printing. If the previous
+# line is "locally diverted", also avoid printing it. On the last
+# line, we don't wait to look forward, just print as long as it is
+# not a "locally diverted" line.
+for f in $(dpkg-query -L btrfs-progs | \
+             sed -r '/^locally diverted/{x;d};$p;x;/^locally diverted/d' | \
+             grep -E '/man/|^/s?bin/|^/usr/lib/udev') ; do
   if [[ ! -f $f ]]; then
     continue
   fi
@@ -108,7 +120,7 @@ EOF
     # todo: this isn't considering the chroot, assumes we've built it
     # outside the chroot and won't get into this case.
     if [[ -e /b/distro-functions/src/identify-distros ]]; then
-      . /b/distro-functions/src/identify-distros
+      for f in /b/distro-functions/src/*; do . $f; done
       debian_codename=$(debian-codename)
       p build-dep btrfs-progs/$debian_codename -y
     else
index cc7ff9ee859c7123b67c9447dc515af288ab47b5..4e1b851abeb71746deaf9d15a47590c1b628a30c 100755 (executable)
@@ -30,9 +30,7 @@ usage() {
   cat <<'EOF'
 Example of calling outside of FAI:
 
-Optionally: source /b/fai/fai-wrapper (note: this exports everything, including functions) and
-set any appropriate classes with: fai-setclass OPT1... which sets CLASS_OPT1=true...
-or run eval-fai-classfile FILE.
+
 
 /a/bin/fai/fai/config/hooks/partition.DEFAULT
 
@@ -40,7 +38,7 @@ Example use in a bootstrap distro:
 scp /b/fai/fai-wrapper /a/bin/fai/fai/config/{distro-install-common/devbyid,hooks/partition.DEFAULT} root@HOST:
 sl root@HOST
 . fai-wrapper # ignore error that FAI is not set, it is not needed for SPECIAL_DISK purposes.
-fai-setclass FSF
+fai-setclass FSF  # note, we could also do: eval-fai-classfile FILE.
 ./partition.DEFAULT -s /dev/sde
 cat /tmp/fai/crypttab >>/etc/crypttab
 cat /tmp/fai/fstab >>/etc/fstab
@@ -118,16 +116,29 @@ EOF
   exit $1
 }
 
+# duplicated in fai-wrapper
+fai-setclass() {
+  for class in "$@"; do
+    classes+=" $class"
+    # old fai way.
+    # export CLASS_$class=true
+  done
+  classes="${classes# }"
+  export classes
+}
+if [[ ! $classes ]]; then
+  classes="DEFAULT $(hostname)"
+  export classes
+fi
+
 
-## duplicates fai-wrapper, for convenience of not needing it
 if ! type -t ifclass &>/dev/null; then
-  ifclass() {
-    local var=${1/#/CLASS_}
-    [[ $HOSTNAME == "$1" || ${!var} ]]
-  }
+  echo "$0: error: install ifclass" >&2
+  exit 1
 fi
 
 
+
 ##### begin command line parsing ########
 
 data_part=false
@@ -182,7 +193,7 @@ fi
 
 
 if [[ $special_disk ]]; then
-  export CLASS_REPARTITION=true
+  fai-setclass REPARTITION
 fi
 
 # # fai's setup-storage won't do btrfs on luks,