From: Ian Kelling Date: Tue, 19 Nov 2024 08:54:47 +0000 (-0500) Subject: fixes, shellcheck, separate unused files X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=e9523e7b390fef4a7972fd7a553433fd4d7348d7;p=buildscripts fixes, shellcheck, separate unused files --- diff --git a/emacs b/emacs index 88ecb63..b4c7511 100755 --- a/emacs +++ b/emacs @@ -22,7 +22,10 @@ # 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 354b92e..3cbb616 100755 --- 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 562af77..acf5f33 100755 --- a/mu4e +++ b/mu4e @@ -21,7 +21,10 @@ # 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 diff --git a/navidrome b/navidrome index 2956200..c2f9758 100755 --- 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##*/} diff --git a/bbb b/old-unused/bbb similarity index 100% rename from bbb rename to old-unused/bbb diff --git a/debbugs b/old-unused/debbugs similarity index 100% rename from debbugs rename to old-unused/debbugs diff --git a/elisp b/old-unused/elisp similarity index 100% rename from elisp rename to old-unused/elisp diff --git a/emacstrisquel7 b/old-unused/emacstrisquel7 similarity index 100% rename from emacstrisquel7 rename to old-unused/emacstrisquel7 diff --git a/esniper b/old-unused/esniper similarity index 100% rename from esniper rename to old-unused/esniper diff --git a/exim b/old-unused/exim similarity index 100% rename from exim rename to old-unused/exim diff --git a/librecaptcha b/old-unused/librecaptcha similarity index 100% rename from librecaptcha rename to old-unused/librecaptcha diff --git a/mumble b/old-unused/mumble similarity index 100% rename from mumble rename to old-unused/mumble diff --git a/nodejs b/old-unused/nodejs similarity index 100% rename from nodejs rename to old-unused/nodejs diff --git a/org-mode b/old-unused/org-mode similarity index 100% rename from org-mode rename to old-unused/org-mode diff --git a/pithosfly b/old-unused/pithosfly similarity index 100% rename from pithosfly rename to old-unused/pithosfly diff --git a/misc b/old-unused/textern similarity index 100% rename from misc rename to old-unused/textern diff --git a/tor-browser b/tor-browser index 923c4e3..ec213e9 100755 --- a/tor-browser +++ b/tor-browser @@ -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