fix emacs
[buildscripts] / emacs
diff --git a/emacs b/emacs
index f4444f8e1d8acc81f0e286c249c0dc81300f6b58..142a9800871b62693914b9bd7fdaeaef8215c66f 100755 (executable)
--- a/emacs
+++ b/emacs
@@ -1,5 +1,12 @@
 #!/bin/bash
 #!/bin/bash
-# Copyright (C) 2016 Ian Kelling
+# 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 switch
+# its license to GPL.
+
+# Copyright 2024 Ian Kelling
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -13,6 +20,7 @@
 # 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.
 
+
 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
 
 #set -x
 if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
 
 #set -x
@@ -49,12 +57,10 @@ pupdate
 ver=$(apt-cache showsrc emacs | sed -rn 's/^Version: 1:([0-9]+).*/\1/p' | sort -n | tail -n1) ||:
 for x in {35..25} ""; do
   if [[ $ver ]] && (( ver >= x )); then
 ver=$(apt-cache showsrc emacs | sed -rn 's/^Version: 1:([0-9]+).*/\1/p' | sort -n | tail -n1) ||:
 for x in {35..25} ""; do
   if [[ $ver ]] && (( ver >= x )); then
-    echo latest_emacs=emacs
     latest_emacs=emacs
     break
   fi
   if apt-cache showsrc emacs$x 2>/dev/null |grep . &>/dev/null; then
     latest_emacs=emacs
     break
   fi
   if apt-cache showsrc emacs$x 2>/dev/null |grep . &>/dev/null; then
-    echo latest_emacs=$x
     latest_emacs=emacs$x
     break
   fi
     latest_emacs=emacs$x
     break
   fi
@@ -73,7 +79,7 @@ if $show_pkgs; then
     if ! type -p apt-rdepends &>/dev/null; then
       sudo apt-get -y install --purge --auto-remove apt-rdepends
     fi
     if ! type -p apt-rdepends &>/dev/null; then
       sudo apt-get -y install --purge --auto-remove apt-rdepends
     fi
-    apt-rdepends -p --build-depends --follow=DEPENDS $x/$(debian-codename)|sed -rn 's/^\s*Build-Depends: (\S+).*/\1/p'
+    apt-rdepends -p --build-depends --follow=DEPENDS $x/$(debian-codename) 2>/dev/null |sed -rn 's/^\s*Build-Depends: (\S+).*/\1/p'
   done
   exit 0
 fi
   done
   exit 0
 fi
@@ -104,8 +110,15 @@ if [[ -e $dir ]]; then
   rev=$(cat $last_build 2>/dev/null) ||:
   head=$(git rev-parse HEAD)
   if ! $recompile && ! $bootstrap && [[ $rev == "$head" ]]; then
   rev=$(cat $last_build 2>/dev/null) ||:
   head=$(git rev-parse HEAD)
   if ! $recompile && ! $bootstrap && [[ $rev == "$head" ]]; then
-    echo "already compiled, exiting"
-    exit 0
+    echo "already compiled"
+    installed_info=$(file -b $(readlink -f $(type -P emacs)))
+    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
   if [[ $rev != "$head" ]]; then
     bootstrap=true
   fi
   if [[ $rev != "$head" ]]; then
     bootstrap=true