fixes, shellcheck, separate unused files master
authorIan Kelling <iank@fsf.org>
Tue, 19 Nov 2024 08:54:47 +0000 (03:54 -0500)
committerIan Kelling <iank@fsf.org>
Tue, 19 Nov 2024 08:54:47 +0000 (03:54 -0500)
17 files changed:
emacs
go
mu4e
navidrome
old-unused/bbb [moved from bbb with 100% similarity]
old-unused/debbugs [moved from debbugs with 100% similarity]
old-unused/elisp [moved from elisp with 100% similarity]
old-unused/emacstrisquel7 [moved from emacstrisquel7 with 100% similarity]
old-unused/esniper [moved from esniper with 100% similarity]
old-unused/exim [moved from exim with 100% similarity]
old-unused/librecaptcha [moved from librecaptcha with 100% similarity]
old-unused/mumble [moved from mumble with 100% similarity]
old-unused/nodejs [moved from nodejs with 100% similarity]
old-unused/org-mode [moved from org-mode with 100% similarity]
old-unused/pithosfly [moved from pithosfly with 100% similarity]
old-unused/textern [moved from misc with 100% similarity]
tor-browser

diff --git a/emacs b/emacs
index 88ecb631f7bd9050e985c9b84635baf130ac0ea8..b4c751150ece31be23d03da0eb1690965a2739c1 100755 (executable)
--- a/emacs
+++ b/emacs
 
 # note: i store a log of emacs versions i've used in /a/opt/emacs/iank-readme
 
-if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
+source /b/distro-functions/src/identify-distros
+source /b/distro-functions/src/package-manager-abstractions
+source /b/log-quiet/logq-function
+m() { printf "%s\n" "$*";  "$@"; }
 
 #set -x
 # arg = git commit to check out
@@ -66,7 +69,7 @@ if $show_pkgs; then
       sudo apt-get -y install --purge --auto-remove apt-rdepends
     fi
     codename=$(debian-codename)
-    if [[ $x == emacs && codename == aramo ]]; then
+    if [[ $x == emacs && $codename == aramo ]]; then
       codename=bookworm
     fi
     if ! apt-cache show emacs/$codename &>/dev/null; then
@@ -101,11 +104,13 @@ m cd /a/opt/emacs
 if [[ -e $dir ]]; then
   m cd $dir
   rev=$(cat $last_build 2>/dev/null) ||:
-  head=$(git rev-parse HEAD)
+  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 -b $(readlink -f $emacs_path))
+      installed_info=$(file -bL $emacs_path)
       build_info=$(file -b $dir/src/emacs)
       if [[ $installed_info == "$build_info" ]]; then
         echo "already installed exiting"
@@ -132,8 +137,8 @@ fi
 
 if $bootstrap; then
   m rsync --exclude /.git --delete-excluded -ra /a/opt/emacs/ $dir
-  mkdir $dir.git
-  m rsync -ra /a/opt/emacs/.git/{HEAD,refs} $dir/.git
+  mkdir $dir/.git
+  printf "%s\n" "$head" >$dir/.git/iank-head
   recompile=true
 fi
 
@@ -144,7 +149,7 @@ case $(distro-name) in
     ;;&
   debian|ubuntu|trisquel)
     # todo: unknown for other distros, this will fail
-    logq p -y build-dep maildir-utils/$(debian-archive)
+    logq p -y build-dep maildir-utils/"$(debian-archive)"
     if [[ $(debian-codename) == aramo ]]; then
       # we need newer build deps
       logq p -y build-dep emacs/bookworm
@@ -216,8 +221,9 @@ if $recompile; then
     else
       logq ./configure
     fi
-    logq make -j `nproc` bootstrap
-    logq make -j `nproc`
+    nproc=$(nproc)
+    logq make -j $nproc bootstrap
+    logq make -j $nproc
     if ! $nox; then
       logq sudo make install
       # make emacs always work for root
diff --git a/go b/go
index 354b92e3ae3ecc8c0edb7554236362926cf837ee..3cbb616bd32c2b4ed028cb863500fafea1298aa7 100755 (executable)
--- a/go
+++ b/go
@@ -33,6 +33,7 @@ case $1 in
   -f) force=true ;;
 esac
 
+pre=buildscripts/go
 m() { printf "$pre %s\n"  "$*"; "$@"; }
 e() { printf "$pre %s\n"  "$*"; }
 err() { echo "[$(date +'%Y-%m-%d %H:%M:%S%z')]: $0: $*" >&2; }
@@ -86,8 +87,10 @@ if $up; then
   mkdir -p ~/.local
   touch ~/.local/gofetch
 
-  vers=($(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head))
+  tmpf=$(git tag | sort -Vr | grep -E '^go[0-9.]+$' | head)
+  maptfile -t vers <<<"$tmpf"
 
+  # shellcheck disable=SC2154 # false positive
   ver=${vers[0]}
   dl() {
     arch=$(dpkg --print-architecture)
@@ -107,7 +110,7 @@ if $up; then
   fi
 
   new_timestamp=$(stat -c %Y $f)
-  if [[ $timestamp != $new_timestamp ]]; then
+  if [[ $timestamp != "$new_timestamp" ]]; then
     install=true
   fi
 fi
@@ -118,6 +121,6 @@ if $install || [[  ! -e /usr/local/go/bin/go ]]; then
 fi
 
 for x in go*.tar.gz; do
-  if [[ $x == $f ]]; then continue; fi
+  if [[ $x == "$f" ]]; then continue; fi
   rm -fv $x
 done
diff --git a/mu4e b/mu4e
index 562af776fe12937d8d0c32242bd71b7225286cde..acf5f330b75474f9df182ff0a885cada52468618 100755 (executable)
--- a/mu4e
+++ b/mu4e
 # limitations under the License.
 
 
-if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
+source /b/distro-functions/src/identify-distros
+source /b/distro-functions/src/package-manager-abstractions
+source /b/log-quiet/logq-function
+m() { printf "%s\n" "$*";  "$@"; }
 
 
 cd /a/opt/mu
@@ -49,11 +52,13 @@ last_build=$dir/iank-mu-build
 if [[ -e $dir ]]; then
   m cd $dir
   rev=$(cat $last_build 2>/dev/null) ||:
-  head=$(git rev-parse HEAD)
+  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 -b $(readlink -f $mu_path))
+      installed_info=$(file -bL "$mu_path")
       build_info=$(file -b $dir/build/mu/mu)
       if [[ $installed_info == "$build_info" ]]; then
         echo "already installed exiting"
@@ -78,7 +83,9 @@ if $dryrun; then
 fi
 
 if $bootstrap; then
-  m rsync --delete -ra /a/opt/mu/ $dir
+  m rsync --exclude /.git --delete-excluded -ra /a/opt/mu/ $dir
+  mkdir $dir/.git
+  printf "%s\n" "$head" >$dir/.git/iank-head
   recompile=true
   cd $dir
 fi
@@ -95,7 +102,8 @@ else
 fi
 if $recompile; then
   m git clean -xfffd
-  m ./autogen.sh && make -j`nproc`
+  nproc=$(nproc)
+  m ./autogen.sh && make -j$nproc
   # note uninstall is implemented
   m sudo make install
 else
index 29562002b27b631d860af115783926ba4ee2f159..c2f9758ee8a24f77419efb1cf76083da48934662 100755 (executable)
--- a/navidrome
+++ b/navidrome
@@ -25,7 +25,7 @@
 up=$(wget -q -O- https://api.github.com/repos/navidrome/navidrome/releases/latest | jq -r .assets[].browser_download_url | grep Linux_x86_64)
 
 re='[[:space:]]'
-if [[ ! $up || $up == $re ]]; then
+if [[ ! $up || $up == "$re" ]]; then
   echo "failed to get good update url. got: $up"
 fi
 uptar=${up##*/}
similarity index 100%
rename from bbb
rename to old-unused/bbb
similarity index 100%
rename from debbugs
rename to old-unused/debbugs
similarity index 100%
rename from elisp
rename to old-unused/elisp
similarity index 100%
rename from emacstrisquel7
rename to old-unused/emacstrisquel7
similarity index 100%
rename from esniper
rename to old-unused/esniper
similarity index 100%
rename from exim
rename to old-unused/exim
similarity index 100%
rename from librecaptcha
rename to old-unused/librecaptcha
similarity index 100%
rename from mumble
rename to old-unused/mumble
similarity index 100%
rename from nodejs
rename to old-unused/nodejs
similarity index 100%
rename from org-mode
rename to old-unused/org-mode
similarity index 100%
rename from pithosfly
rename to old-unused/pithosfly
similarity index 100%
rename from misc
rename to old-unused/textern
index 923c4e3c4145502707fdfdda2f90d12f68895ee2..ec213e98fa97e909667e6ec691c44fe0519b64a3 100755 (executable)
@@ -21,7 +21,7 @@
 # limitations under the License.
 
 
-if [[ -s ~/.bashrc ]]; then . ~/.bashrc; fi
+set -e; . /usr/local/lib/bash-bear; set +e
 
 
 # stable version is shown on:
@@ -41,7 +41,8 @@ if [[ ! $c ]]; then
   echo "$0: error: failed to curl tor directory listing" >&2
   exit 1
 fi
-vers=($(printf "%s\n" "$c" | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p' | sort -Vr))
+tmpf=$(printf "%s\n" "$c" | sed -rn 's#.*href="([0-9]+\.[0-9]+[.0-9]*)/.*#\1#p' | sort -Vr)
+mapfile -t vers <<<"$tmpf"
 
 # by default it has perms for just 1 non-root user, which is ok for now.
 
@@ -70,7 +71,7 @@ for ((i=0; i<${#vers[@]}; i++)); do
 done
 
 new_timestamp=$(stat -c %Y $f)
-if [[ $timestamp != $new_timestamp || ! -e /a/opt/tor-browser/Browser/start-tor-browser ]]; then
+if [[ $timestamp != "$new_timestamp" || ! -e /a/opt/tor-browser/Browser/start-tor-browser ]]; then
   # not already installed
   rm -rf tor-browser
   tar Jxf $f
@@ -98,6 +99,6 @@ fi
 for x in tor-*.tar.xz; do
   # cleanup old tarballs
   [[ -e $x ]] || break
-  [[ $x != $f ]] || continue
+  [[ $x != "$f" ]] || continue
   command rm -f $x
 done