From 0a7fd125adf01ecdbb0425786b63d00be30678be Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 10 Mar 2025 23:45:38 -0400 Subject: [PATCH] minor fixes, refactor, network config --- .../distro-install-common/new-btrfs-progs | 138 ++++++++++++++++++ fai/config/scripts/DEBIAN/11-iank | 2 +- fai/config/scripts/IANK/11-iank | 126 +--------------- wrt-setup-local | 8 +- 4 files changed, 146 insertions(+), 128 deletions(-) create mode 100644 fai/config/distro-install-common/new-btrfs-progs diff --git a/fai/config/distro-install-common/new-btrfs-progs b/fai/config/distro-install-common/new-btrfs-progs new file mode 100644 index 0000000..f492a66 --- /dev/null +++ b/fai/config/distro-install-common/new-btrfs-progs @@ -0,0 +1,138 @@ +#!/bin/bash + +# we want these files from the package: +# /usr/share/initramfs-tools/hooks/btrfs +# /usr/share/initramfs-tools/scripts/local-premount/btrfs +# everything else, seems better to take from upstream package. + +[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + +if [[ ! -d $FAI_ROOT ]]; then + export FAI_ROOT=/ +fi + +### dependencies +{ + for f in $(dpkg-query -L btrfs-progs | grep '/man/|^/s?bin/|^/usr/lib/udev') ; do + if [[ ! -f $f ]]; then + continue + fi + # use --no-rename so that I don't need to track whether this was the first + # btrfs-progs install. + $ROOTCMD dpkg-divert --no-rename --local --add $f + done + + # from packages listed in .github/workflows/devel.yml + # The dumb makefile makes us build docs even if they were already built. + if ! type -p sphinx-build &>/dev/null; then + $ROOTCMD apt-get -y install python3-sphinx-rtd-theme + fi + + if ! type -p curl &>/dev/null; then + $ROOTCMD apt-get -y install curl + fi + if ! type -p wget &>/dev/null; then + $ROOTCMD apt-get -y install wget + fi +} + + +## If we need to use a dev version temporarily, this to true +## and copy it over in fai-redep. See comment there. +static_ver=false +if $static_ver; then + # The version with the bug fix is really some git version, but this is + # what it outputs for --version. + ver=6.10 + bp_dirname=btrfs-progs +else + + bp_dirname=btrfs-progs-release + # latest released version. + 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-} +fi +cur_ver=$($ROOTCMD btrfs --version 2>/dev/null | head -n1 | awk '{print $2}') ||: + +if [[ $FAI_ROOT == / ]]; then + bp_dir=/a/opt/$bp_dirname + if [[ ! -d $bp_dir ]]; then + bp_dir=/root/$bp_dirname + fi +else + bp_dir=$FAI/distro-install-common/$bp_dirname +fi + +last_built_ver=$([[ ! -e $bp_dir/btrfs ]] || $bp_dir/btrfs --version 2>/dev/null | head -n1 | awk '{print $2}') + +# todo: this doesn't account for multiple distros versions that require +# their own builds. +if [[ $ver != "$cur_ver" ]]; then + # Assumes we've pre-built the static_ver version if we are using that. + if $static_ver || [[ $ver == "$last_built_ver" ]]; then + if ! $ROOTCMD dpkg -s -- build-essential 2>&1 | grep -Fx "Status: install ok installed" &>/dev/null; then + $ROOTCMD apt-get -y install build-essential + fi + + if [[ $FAI_ROOT == / ]]; then + cd $bp_dir + make install + mv /usr/bin/{fsck,mkfs}.btrfs /usr/sbin/ + else + mkdir -p $target/tmp/bprogs + mount -o bind $bp_dir $target/tmp/bprogs + # pre-build. in t11: + # ./autogen.sh && ./configure --disable-documentation --prefix=/usr && make + # in t12, we have the docs prerequisites, so enabled documentation. + # We won't have the latest docs in t11, i could install them from the t12 + # build dir, but meh. + $ROOTCMD bash -xe </dev/null; then +if [[ -e networkd-dispatcher.service ]]; then systemctl disable networkd-dispatcher systemctl mask networkd-dispatcher fi diff --git a/fai/config/scripts/IANK/11-iank b/fai/config/scripts/IANK/11-iank index b2dda7a..b3e1b69 100755 --- a/fai/config/scripts/IANK/11-iank +++ b/fai/config/scripts/IANK/11-iank @@ -54,7 +54,6 @@ if [[ ! -e $dst && -e $src ]]; then mount -o bind $src $dst fi -chmod 700 $target/mnt/root $FAI/distro-install-common/end @@ -280,6 +279,7 @@ EOFOUTER exit 0 # avoid unnecessary stuff in bootstrap vol fi +chmod 700 $target/mnt/root ## misc settings $ROOTCMD bash <<'EOFOUTER' @@ -374,127 +374,7 @@ esac #### begin btrfs-progs -# we want these files from the package: -# /usr/share/initramfs-tools/hooks/btrfs -# /usr/share/initramfs-tools/scripts/local-premount/btrfs -# everything else, seems better to take from upstream package. -for f in $(dpkg-query -L btrfs-progs | grep '/man/|^/s?bin/|^/usr/lib/udev') ; do - if [[ ! -f $f ]]; then - continue - fi - # use --no-rename so that I don't need to track whether this was the first - # btrfs-progs install. - $ROOTCMD dpkg-divert --no-rename --local --add $f -done - -# from packages listed in .github/workflows/devel.yml -# The dumb makefile makes us build docs even if they were already built. -if ! type -p sphinx-build &>/dev/null; then - $ROOTCMD apt-get -y install python3-sphinx-rtd-theme -fi - -if ! type -p curl &>/dev/null; then - $ROOTCMD apt-get -y install curl -fi -if ! type -p wget &>/dev/null; then - $ROOTCMD apt-get -y install wget -fi - - -## If we need to use a dev version temporarily, this to true -## and copy it over in fai-redep. See comment there. -static_ver=false -if $static_ver; then - # The version with the bug fix is really some git version, but this is - # what it outputs for --version. - ver=6.10 - bp_dirname=btrfs-progs -else - - bp_dirname=btrfs-progs-release - # latest released version. - 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-} -fi -cur_ver=$($ROOTCMD btrfs --version 2>/dev/null | head -n1 | awk '{print $2}') ||: - -if [[ $FAI_ROOT == / ]]; then - bp_dir=/a/opt/$bp_dirname -else - bp_dir=$FAI/distro-install-common/$bp_dirname -fi - -last_built_ver=$($bp_dir/btrfs --version 2>/dev/null | head -n1 | awk '{print $2}') - -# todo: this doesn't account for multiple distros versions that require -# their own builds. -if [[ $ver != "$cur_ver" ]]; then - # Assumes we've pre-built the static_ver version if we are using that. - if $static_ver || [[ $ver == "$last_built_ver" ]]; then - if ! $ROOTCMD dpkg -s -- build-essential 2>&1 | grep -Fx "Status: install ok installed" &>/dev/null; then - $ROOTCMD apt-get -y install build-essential - fi - - if [[ $FAI_ROOT == / ]]; then - cd $bp_dir - make install - mv /usr/bin/{fsck,mkfs}.btrfs /usr/sbin/ - else - mkdir -p $target/tmp/bprogs - mount -o bind $bp_dir $target/tmp/bprogs - # pre-build. in t11: - # ./autogen.sh && ./configure --disable-documentation --prefix=/usr && make - # in t12, we have the docs prerequisites, so enabled documentation. - # We won't have the latest docs in t11, i could install them from the t12 - # build dir, but meh. - $ROOTCMD bash -xe <