Add admin/emacs-shell-lib for shared bash code
* admin/emacs-shell-lib: New file for shared bash code. * admin/automerge: * admin/diff-tar-files: * admin/emacs-shell-lib: * admin/make-manuals: * admin/update_autogen: * admin/upload-manuals: Simplify and improve using above new library.
This commit is contained in:
parent
5247a72aec
commit
a9111d8670
6 changed files with 98 additions and 63 deletions
|
@ -35,18 +35,7 @@
|
|||
## it with the -d option in the repository directory, in case a pull
|
||||
## updates this script while it is working.
|
||||
|
||||
set -o nounset
|
||||
|
||||
die () # write error to stderr and exit
|
||||
{
|
||||
[ $# -gt 0 ] && echo "$PN: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
PN=${0##*/} # basename of script
|
||||
PD=${0%/*}
|
||||
|
||||
[ "$PD" = "$0" ] && PD=. # if PATH includes PWD
|
||||
source "${0%/*}/emacs-shell-lib"
|
||||
|
||||
usage ()
|
||||
{
|
||||
|
@ -129,13 +118,7 @@ OPTIND=1
|
|||
[ "$test" ] && build=1
|
||||
|
||||
|
||||
if [ -x "$(command -v mktemp)" ]; then
|
||||
tempfile=$(mktemp "/tmp/$PN.XXXXXXXXXX")
|
||||
else
|
||||
tempfile=/tmp/$PN.$$
|
||||
fi
|
||||
|
||||
trap 'rm -f $tempfile 2> /dev/null' EXIT
|
||||
tempfile="$(emacs_mktemp)"
|
||||
|
||||
|
||||
[ -e Makefile ] && [ "$build" ] && {
|
||||
|
@ -263,5 +246,3 @@ git push || die "push error"
|
|||
|
||||
|
||||
exit 0
|
||||
|
||||
### automerge ends here
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#! /bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2001-2022 Free Software Foundation, Inc.
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
source "${0%/*}/emacs-shell-lib"
|
||||
|
||||
if [ $# != 2 ]; then
|
||||
cat <<EOF
|
||||
|
@ -31,9 +32,8 @@ fi
|
|||
old_tar=$1
|
||||
new_tar=$2
|
||||
|
||||
old_tmp=/tmp/old.$$
|
||||
new_tmp=/tmp/new.$$
|
||||
trap "rm -f $old_tmp $new_tmp; exit 1" 1 2 15
|
||||
old_tmp="$(emacs_mktemp ${PN}-old)"
|
||||
new_tmp="$(emacs_mktemp ${PN}-new)"
|
||||
|
||||
tar tf "$old_tar" | sed -e 's,^[^/]*,,' | sort > $old_tmp
|
||||
tar tf "$new_tar" | sed -e 's,^[^/]*,,' | sort > $new_tmp
|
||||
|
|
87
admin/emacs-shell-lib
Normal file
87
admin/emacs-shell-lib
Normal file
|
@ -0,0 +1,87 @@
|
|||
#!/bin/bash
|
||||
### emacs-shell-lib - shared code for Emacs shell scripts
|
||||
|
||||
## Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
|
||||
## Author: Stefan Kangas <stefankangas@gmail.com>
|
||||
|
||||
## This file is part of GNU Emacs.
|
||||
|
||||
## GNU Emacs is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
|
||||
## GNU Emacs is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
### Code:
|
||||
|
||||
# Set an explicit umask.
|
||||
umask 077
|
||||
|
||||
# Treat unset variables as an error.
|
||||
set -o nounset
|
||||
|
||||
# Exit immediately on error.
|
||||
set -o errexit
|
||||
|
||||
# Avoid non-standard command output from non-C locales.
|
||||
unset LANG LC_ALL LC_MESSAGES
|
||||
|
||||
PN=${0##*/} # basename of script
|
||||
PD=${0%/*} # script directory
|
||||
|
||||
[ "$PD" = "$0" ] && PD=. # if PATH includes PWD
|
||||
|
||||
die () # write error to stderr and exit
|
||||
{
|
||||
[ $# -gt 0 ] && echo "$PN: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
emacs_tempfiles=()
|
||||
|
||||
emacs_tempfiles_cleanup ()
|
||||
{
|
||||
for file in ${emacs_tempfiles[@]}; do
|
||||
rm -f "${file}" 2> /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
trap '
|
||||
ret=$?
|
||||
emacs_tempfiles_cleanup
|
||||
exit $ret
|
||||
' EXIT
|
||||
|
||||
emacs_mktemp ()
|
||||
{
|
||||
local readonly file="${1-}"
|
||||
local tempfile
|
||||
local prefix
|
||||
|
||||
if [ -z "$file" ]; then
|
||||
prefix="$PN"
|
||||
else
|
||||
prefix="$1"
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v mktemp)" ]; then
|
||||
tempfile=$(mktemp "${TMPDIR-/tmp}/${prefix}.XXXXXXXXXX")
|
||||
else
|
||||
tempfile="${TMPDIR-/tmp}/${prefix}.$RANDOM$$"
|
||||
(umask 077 && touch "$tempfile")
|
||||
fi
|
||||
|
||||
[ -z "${tempfile}" ] && die "Creating temporary file failed"
|
||||
|
||||
emacs_tempfiles+=("${tempfile}")
|
||||
|
||||
echo "$tempfile"
|
||||
}
|
|
@ -33,15 +33,7 @@
|
|||
|
||||
### Code:
|
||||
|
||||
set -o nounset
|
||||
|
||||
die () # write error to stderr and exit
|
||||
{
|
||||
[ $# -gt 0 ] && echo "$PN: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
PN=${0##*/} # basename of script
|
||||
source "${0%/*}/emacs-shell-lib"
|
||||
|
||||
usage ()
|
||||
{
|
||||
|
@ -96,8 +88,7 @@ OPTIND=1
|
|||
[ -e admin/admin.el ] || die "admin/admin.el not found"
|
||||
|
||||
|
||||
tempfile=/tmp/$PN.$$
|
||||
trap "rm -f $tempfile 2> /dev/null" EXIT
|
||||
tempfile="$(emacs_mktemp)"
|
||||
|
||||
|
||||
[ "$continue" ] || rm -rf $outdir
|
||||
|
|
|
@ -32,18 +32,7 @@
|
|||
|
||||
### Code:
|
||||
|
||||
set -o nounset
|
||||
|
||||
die () # write error to stderr and exit
|
||||
{
|
||||
[ $# -gt 0 ] && echo "$PN: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
PN=${0##*/} # basename of script
|
||||
PD=${0%/*}
|
||||
|
||||
[ "$PD" = "$0" ] && PD=. # if PATH includes PWD
|
||||
source "${0%/*}/emacs-shell-lib"
|
||||
|
||||
## This should be the admin directory.
|
||||
cd $PD || exit
|
||||
|
@ -102,10 +91,7 @@ done
|
|||
|
||||
[ "$basegen" ] || die "internal error"
|
||||
|
||||
tempfile=/tmp/$PN.$$
|
||||
|
||||
trap 'rm -f $tempfile 2> /dev/null' EXIT
|
||||
|
||||
tempfile="$(emacs_mktemp)"
|
||||
|
||||
while getopts ":hcfqA:CL" option ; do
|
||||
case $option in
|
||||
|
@ -312,5 +298,3 @@ commit "loaddefs" $modified || die "commit error"
|
|||
|
||||
|
||||
exit 0
|
||||
|
||||
### update_autogen ends here
|
||||
|
|
|
@ -36,15 +36,7 @@
|
|||
|
||||
### Code:
|
||||
|
||||
set -o nounset
|
||||
|
||||
die () # write error to stderr and exit
|
||||
{
|
||||
[ $# -gt 0 ] && echo "$PN: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
PN=${0##*/} # basename of script
|
||||
source "${0%/*}/emacs-shell-lib"
|
||||
|
||||
usage ()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue