Remove final uses of 'cl' in lisp/net
[emacs.git] / admin / automerge
blobd96974ca5623d96aa0cf721ef22c7c4c38e8df8d
1 #!/bin/bash
2 ### automerge - merge the Emacs release branch to master
4 ## Copyright (C) 2018 Free Software Foundation, Inc.
6 ## Author: Glenn Morris <rgm@gnu.org>
8 ## This file is part of GNU Emacs.
10 ## GNU Emacs is free software: you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
15 ## GNU Emacs is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
23 ### Commentary:
25 ## Automatically merge the Emacs release branch to master.
26 ## No warranty, etc.
28 die () # write error to stderr and exit
30 [ $# -gt 0 ] && echo "$PN: $@" >&2
31 exit 1
34 PN=${0##*/} # basename of script
35 PD=${0%/*}
37 [ "$PD" = "$0" ] && PD=. # if PATH includes PWD
39 ## This should be the admin directory.
40 cd $PD
41 cd ../
42 [ -d admin ] || die "Could not locate admin directory"
44 [ -e .git ] || die "No .git"
46 usage ()
48 cat 1>&2 <<EOF
49 Usage: ${PN} [-b] [-e emacs] [-n nmin] [-p] [-t] [-- make-flags]
50 Merge the Emacs release branch to master.
51 Passes any non-option args to make (eg -- -j2).
52 Options:
53 -e: Emacs executable to use for the initial merge (default $emacs)
54 -n: Minimum number of commits to try merging (default $nmin)
55 -b: try to build after merging
56 -t: try to check after building
57 -p: if merge, build, check all succeed, push when finished (caution!)
58 EOF
59 exit 1
63 ## Defaults.
65 emacs=emacs
66 nmin=10
67 build=
68 test=
69 push=
70 quiet=
72 while getopts ":hbe:n:pqt" option ; do
73 case $option in
74 (h) usage ;;
76 (b) build=1 ;;
78 (e) emacs=$OPTARG ;;
80 (n) nmin=$OPTARG ;;
82 (p) push=1 ;;
84 (q) quiet=1 ;;
86 (t) test=1 ;;
88 (\?) die "Bad option -$OPTARG" ;;
90 (:) die "Option -$OPTARG requires an argument" ;;
92 (*) die "getopts error" ;;
93 esac
94 done
95 shift $(( --OPTIND ))
96 OPTIND=1
99 ## Does not work 100% because a lot of Emacs batch output comes on
100 ## stderr (?).
101 [ "$quiet" ] && exec 1> /dev/null
104 [ "$push" ] && test=1
105 [ "$test" ] && build=1
108 tempfile=/tmp/$PN.$$
110 trap "rm -f $tempfile 2> /dev/null" EXIT
113 [ -e Makefile ] && [ "$build" ] && {
114 echo "Cleaning..."
115 make maintainer-clean >& /dev/null
119 echo "Merging..."
121 if $emacs --batch -Q -l ./admin/gitmerge.el \
122 --eval "(setq gitmerge-minimum-missing $nmin)" -f gitmerge \
123 >| $tempfile 2>&1; then
124 echo "merged ok"
126 else
127 grep -qE "Nothing to merge|Number of missing commits" $tempfile && {
128 echo "Fewer than $nmin commits to merge"
129 exit 0
132 cat "$tempfile" 1>&2
134 die "merge error"
138 [ "$build" ] || exit 0
141 echo "Running autoreconf..."
143 autoreconf -i -I m4 2>| $tempfile
145 retval=$?
147 ## Annoyingly, autoreconf puts the "installing `./foo' messages on stderr.
148 if [ "$quiet" ]; then
149 grep -v 'installing `\.' $tempfile 1>&2
150 else
151 cat "$tempfile" 1>&2
154 [ $retval -ne 0 ] && die "autoreconf error"
157 echo "Running ./configure..."
159 ## Minimize required packages.
160 ./configure --without-x || die "configure error"
163 echo "Building..."
165 make "$@" || die "make error"
167 echo "Build finished ok"
170 [ "$test" ] || exit 0
173 echo "Testing..."
175 make "$@" check || die "check error"
177 echo "Tests finished ok"
180 [ "$push" ] || exit 0
183 ## In case someone else pushed while we were working.
184 echo "Checking for remote changes..."
185 git fetch || die "fetch error"
186 ## git >= 1.8.5 has "pull --rebase=preserve"
187 git rebase --preserve-merges || die "rebase error"
190 echo "Pushing..."
191 git push || die "push error"
194 exit 0
196 ### automerge ends here