random fixes master
authorIan Kelling <iank@fsf.org>
Tue, 19 Aug 2025 22:32:40 +0000 (18:32 -0400)
committerIan Kelling <iank@fsf.org>
Tue, 19 Aug 2025 22:32:40 +0000 (18:32 -0400)
emacs
emacs-lex-warn [new file with mode: 0644]
emacsish-build-lib [new file with mode: 0644]
go
mu4e
textern [moved from old-unused/textern with 85% similarity]

diff --git a/emacs b/emacs
index b4c751150ece31be23d03da0eb1690965a2739c1..bb7a181c7b401233931b954d6043a7aa5531f1aa 100755 (executable)
--- a/emacs
+++ b/emacs
 
 # note: i store a log of emacs versions i've used in /a/opt/emacs/iank-readme
 
 
 # note: i store a log of emacs versions i've used in /a/opt/emacs/iank-readme
 
+set -e; . /usr/local/lib/bash-bear; set +e
+
 source /b/distro-functions/src/identify-distros
 source /b/distro-functions/src/package-manager-abstractions
 source /b/log-quiet/logq-function
 source /b/distro-functions/src/identify-distros
 source /b/distro-functions/src/package-manager-abstractions
 source /b/log-quiet/logq-function
+source /b/buildscripts/emacsish-build-lib
+source /b/ds/fsf-script-lib
 m() { printf "%s\n" "$*";  "$@"; }
 
 #set -x
 # arg = git commit to check out
 
 m() { printf "%s\n" "$*";  "$@"; }
 
 #set -x
 # arg = git commit to check out
 
+usage() {
+  cat <<EOF
+Usage: ${0##*/} [OPTIONS]
+Build emacs if needed or directed to.
+
+If you want this script to build a new version of emacs, you need to do
+2 things. 1: check it out in /a/opt/emacs. 2: Remove
+/a/opt/emacs-DISTRO_CODENAME. We don't test for the git repo to be a
+different version that the codename directory because the repo can be
+used for testing & development, randomly switching around version. Also,
+we might intentionally use a different version for different distro
+codenames.
+
+-h|--help  Print help and exit.
+
+Note: Uses util-linux getopt option parsing: spaces between args and
+options, short options can be combined, options before args.
+EOF
+  exit $1
+}
+
+
 update=false
 bootstrap=false
 recompile=false
 update=false
 bootstrap=false
 recompile=false
@@ -88,47 +114,12 @@ fi
 # autoconf-archive due to come error
 pi ${pkgs[@]}
 
 # autoconf-archive due to come error
 pi ${pkgs[@]}
 
-#git repo
-dir=/a/opt/emacs-$(debian-codename-compat)
-last_build=$dir/iank-emacs-build
-
-# e/e because autofs failing to mount will make it so
-# you cant ls whatever directory it is in, so we
-# need an extra directory. i dunno why this was like this instead of just $dir-nox.
-#dirs=($dir $dir-nox/.iank/e/e)
+done-detect emacs
 
 dirs=($dir $dir-nox)
 
 
 dirs=($dir $dir-nox)
 
-m cd /a/opt/emacs
 
 
-if [[ -e $dir ]]; then
-  m cd $dir
-  rev=$(cat $last_build 2>/dev/null) ||:
-  if [[ -e .git/iank-head ]]; then
-    head=$(cat .git/iank-head)
-  fi
-  if ! $recompile && ! $bootstrap && [[ $rev == "$head" ]]; then
-    echo "already compiled"
-    if emacs_path=$(type -P emacs 2>/dev/null); then
-      installed_info=$(file -bL $emacs_path)
-      build_info=$(file -b $dir/src/emacs)
-      if [[ $installed_info == "$build_info" ]]; then
-        echo "already installed exiting"
-        # this isn't perfect, because install could partially fail or the
-        # command after it could
-        exit 0
-      fi
-    fi
-  fi
-  if [[ $rev != "$head" ]]; then
-    echo "$0: rev:$rev != head:$head, setting bootstrap=true"
-    bootstrap=true
-  fi
-else
-  echo "$0: dir=$dir does not exist, setting bootstrap=true"
-  head=$(git rev-parse HEAD)
-  bootstrap=true
-fi
+m cd /a/opt/emacs
 
 echo recompile=$recompile bootstrap=$bootstrap update=$update
 if $dryrun; then
 
 echo recompile=$recompile bootstrap=$bootstrap update=$update
 if $dryrun; then
@@ -136,9 +127,8 @@ if $dryrun; then
 fi
 
 if $bootstrap; then
 fi
 
 if $bootstrap; then
-  m rsync --exclude /.git --delete-excluded -ra /a/opt/emacs/ $dir
-  mkdir $dir/.git
-  printf "%s\n" "$head" >$dir/.git/iank-head
+  m sudo rsync --exclude /.git --delete-excluded --delete -ra /a/opt/emacs/ $dir
+  { cd /a/opt/emacs; git rev-parse HEAD >$dir/iank-head; }
   recompile=true
 fi
 
   recompile=true
 fi
 
@@ -268,4 +258,4 @@ fi
 
 my-update-info-dir
 
 
 my-update-info-dir
 
-echo $head >$last_build
+cat $dir/iank-head >$last_built_rev_path
diff --git a/emacs-lex-warn b/emacs-lex-warn
new file mode 100644 (file)
index 0000000..a751601
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+# I, Ian Kelling, follow the GNU license recommendations at
+# https://www.gnu.org/licenses/license-recommendations.en.html. They
+# recommend that small programs, < 300 lines, be licensed under the
+# Apache License 2.0. This file contains or is part of one or more small
+# programs. If a small program grows beyond 300 lines, I plan to change
+# to a recommended GPL license.
+
+# Copyright 2025 Ian Kelling
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/emacsish-build-lib b/emacsish-build-lib
new file mode 100644 (file)
index 0000000..0c57feb
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+#### detection of already done things #####
+done-detect() {
+  prog=$1
+  dir=/a/opt/$prog-$(debian-codename-compat)
+  last_built_rev_path=$dir/iank-$prog-build
+  last_built_rev=$(cat $last_built_rev_path 2>/dev/null) ||:
+  if [[ -e $dir/iank-head ]]; then
+    target_rev=$(cat $dir/iank-head)
+  else
+    e "$0: file $dir/iank-head doesn't exist, setting bootstrap=true"
+    bootstrap=true
+  fi
+  built_rev_eq_target_rev=false
+  if [[ $last_built_rev && $target_rev && $last_built_rev == "$target_rev" ]]; then
+    echo "note: it looks already compiled"
+    if prog_path=$(type -P $prog 2>/dev/null); then
+      installed_info=$(file -bL $prog_path)
+      build_info=$(file -b $dir/src/$prog)
+      if [[ $installed_info == "$build_info" ]]; then
+        echo "note: it looks already installed"
+        if ! $recompile && ! $bootstrap; then
+          e "looks like nothing needs to be done, exiting early"
+          # this isn't perfect, because install could partially fail or the
+          # command after it could
+          exit 0
+        fi
+      fi
+    fi
+  fi
+}
diff --git a/go b/go
index 3cbb616bd32c2b4ed028cb863500fafea1298aa7..27b042e741802323895026e4a1f4e3d92d25664d 100755 (executable)
--- a/go
+++ b/go
@@ -88,7 +88,7 @@ if $up; then
   touch ~/.local/gofetch
 
   tmpf=$(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head)
   touch ~/.local/gofetch
 
   tmpf=$(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head)
-  maptfile -t vers <<<"$tmpf"
+  mapfile -t vers <<<"$tmpf"
 
   # shellcheck disable=SC2154 # false positive
   ver=${vers[0]}
 
   # shellcheck disable=SC2154 # false positive
   ver=${vers[0]}
diff --git a/mu4e b/mu4e
index acf5f330b75474f9df182ff0a885cada52468618..f5a2781cd83c346685f16668f15a1dfe73f9b744 100755 (executable)
--- a/mu4e
+++ b/mu4e
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# update log:
+# 2025-05-27
+
+# was on:
+# commit 80a2d4cef491df8941e1c9e6cb174286fb80afe9
+# Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
+# Date:   Sat Apr 15 23:20:37 2023 +0300
+
+#     build: bump version to 1.10.3
+
+set -e; . /usr/local/lib/bash-bear; set +e
 
 source /b/distro-functions/src/identify-distros
 source /b/distro-functions/src/package-manager-abstractions
 source /b/log-quiet/logq-function
 
 source /b/distro-functions/src/identify-distros
 source /b/distro-functions/src/package-manager-abstractions
 source /b/log-quiet/logq-function
+source /b/buildscripts/emacsish-build-lib
+source /b/ds/fsf-script-lib
+
 m() { printf "%s\n" "$*";  "$@"; }
 
 
 m() { printf "%s\n" "$*";  "$@"; }
 
 
@@ -31,9 +45,11 @@ cd /a/opt/mu
 
 recompile=false
 dryrun=false
 
 recompile=false
 dryrun=false
+bootstrap=false
 
 while [[ $1 == -* ]]; do
   case $1 in
 
 while [[ $1 == -* ]]; do
   case $1 in
+    -b) bootstrap=true; recompile=true ;;
     -n) dryrun=true ;;
     -r) recompile=true ;;
     --no-r) recompile=false ;;
     -n) dryrun=true ;;
     -r) recompile=true ;;
     --no-r) recompile=false ;;
@@ -43,49 +59,16 @@ while [[ $1 == -* ]]; do
   shift
 done
 
   shift
 done
 
-bootstrap=false
-
-#git repo
-dir=/a/opt/mu-$(debian-codename-compat)
-last_build=$dir/iank-mu-build
-
-if [[ -e $dir ]]; then
-  m cd $dir
-  rev=$(cat $last_build 2>/dev/null) ||:
-  if [[ -e .git/iank-head ]]; then
-    head=$(cat .git/iank-head)
-  fi
-  if ! $recompile && ! $bootstrap && [[ $rev == "$head" ]]; then
-    echo "already compiled"
-    if mu_path=$(type -P mu 2>/dev/null); then
-      installed_info=$(file -bL "$mu_path")
-      build_info=$(file -b $dir/build/mu/mu)
-      if [[ $installed_info == "$build_info" ]]; then
-        echo "already installed exiting"
-        # this isn't perfect, because install could partially fail or the
-        # command after it could
-        exit 0
-      fi
-    fi
-  fi
-  echo rev=$rev head=$head
-  if [[ $rev != "$head" ]]; then
-    bootstrap=true
-  fi
-else
-  head=$(git rev-parse HEAD)
-  bootstrap=true
-fi
+done-detect mu
 
 
+echo recompile=$recompile bootstrap=$bootstrap
 if $dryrun; then
 if $dryrun; then
-  e recompile=$recompile bootstrap=$bootstrap
   exit 0
 fi
 
 if $bootstrap; then
   m rsync --exclude /.git --delete-excluded -ra /a/opt/mu/ $dir
   exit 0
 fi
 
 if $bootstrap; then
   m rsync --exclude /.git --delete-excluded -ra /a/opt/mu/ $dir
-  mkdir $dir/.git
-  printf "%s\n" "$head" >$dir/.git/iank-head
+  { cd /a/opt/mu; git rev-parse HEAD >$dir/iank-head; }
   recompile=true
   cd $dir
 fi
   recompile=true
   cd $dir
 fi
@@ -101,7 +84,6 @@ else
   m pi libgmime-3.0-dev meson
 fi
 if $recompile; then
   m pi libgmime-3.0-dev meson
 fi
 if $recompile; then
-  m git clean -xfffd
   nproc=$(nproc)
   m ./autogen.sh && make -j$nproc
   # note uninstall is implemented
   nproc=$(nproc)
   m ./autogen.sh && make -j$nproc
   # note uninstall is implemented
@@ -116,4 +98,4 @@ else
   sudo touch -d @$(($(stat -c%Y build/build.ninja) - 100)) /usr/local/bin/emacs
   m sudo make install
 fi
   sudo touch -d @$(($(stat -c%Y build/build.ninja) - 100)) /usr/local/bin/emacs
   m sudo make install
 fi
-echo $head >$last_build
+cat $dir/iank-head >$last_built_rev_path
similarity index 85%
rename from old-unused/textern
rename to textern
index c304d6167c0191f03c7ad26432fb7d1e9d9a1e4b..4db7ce8b96a9c31d87e31472ad4aad375d582cf2 100755 (executable)
+++ b/textern
 # limitations under the License.
 
 
 # limitations under the License.
 
 
-if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
-
-shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
-set -eE -o pipefail
-trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 source /a/bin/bash-bear-trap/bash-bear
 
 # fuck pip. i hate it.
 source /a/bin/bash-bear-trap/bash-bear
 
 # fuck pip. i hate it.