diff options
| author | Glenn Morris | 2018-01-18 20:22:53 -0500 |
|---|---|---|
| committer | Glenn Morris | 2018-01-18 20:22:53 -0500 |
| commit | 256bd99a8bfae91a3c91ae20166af45918d1e986 (patch) | |
| tree | ec2a65c217748d0ca36ea5e0d9188d8374fb240b /admin/automerge | |
| parent | 6213ce554410213d5ffd3acb09ea2ebde8402281 (diff) | |
| download | emacs-256bd99a8bfae91a3c91ae20166af45918d1e986.tar.gz emacs-256bd99a8bfae91a3c91ae20166af45918d1e986.zip | |
* admin/automerge: New script.
Diffstat (limited to 'admin/automerge')
| -rwxr-xr-x | admin/automerge | 196 |
1 files changed, 196 insertions, 0 deletions
diff --git a/admin/automerge b/admin/automerge new file mode 100755 index 00000000000..d96974ca562 --- /dev/null +++ b/admin/automerge | |||
| @@ -0,0 +1,196 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | ### automerge - merge the Emacs release branch to master | ||
| 3 | |||
| 4 | ## Copyright (C) 2018 Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | ## Author: Glenn Morris <rgm@gnu.org> | ||
| 7 | |||
| 8 | ## This file is part of GNU Emacs. | ||
| 9 | |||
| 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. | ||
| 14 | |||
| 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. | ||
| 19 | |||
| 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/>. | ||
| 22 | |||
| 23 | ### Commentary: | ||
| 24 | |||
| 25 | ## Automatically merge the Emacs release branch to master. | ||
| 26 | ## No warranty, etc. | ||
| 27 | |||
| 28 | die () # write error to stderr and exit | ||
| 29 | { | ||
| 30 | [ $# -gt 0 ] && echo "$PN: $@" >&2 | ||
| 31 | exit 1 | ||
| 32 | } | ||
| 33 | |||
| 34 | PN=${0##*/} # basename of script | ||
| 35 | PD=${0%/*} | ||
| 36 | |||
| 37 | [ "$PD" = "$0" ] && PD=. # if PATH includes PWD | ||
| 38 | |||
| 39 | ## This should be the admin directory. | ||
| 40 | cd $PD | ||
| 41 | cd ../ | ||
| 42 | [ -d admin ] || die "Could not locate admin directory" | ||
| 43 | |||
| 44 | [ -e .git ] || die "No .git" | ||
| 45 | |||
| 46 | usage () | ||
| 47 | { | ||
| 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 | ||
| 60 | } | ||
| 61 | |||
| 62 | |||
| 63 | ## Defaults. | ||
| 64 | |||
| 65 | emacs=emacs | ||
| 66 | nmin=10 | ||
| 67 | build= | ||
| 68 | test= | ||
| 69 | push= | ||
| 70 | quiet= | ||
| 71 | |||
| 72 | while getopts ":hbe:n:pqt" option ; do | ||
| 73 | case $option in | ||
| 74 | (h) usage ;; | ||
| 75 | |||
| 76 | (b) build=1 ;; | ||
| 77 | |||
| 78 | (e) emacs=$OPTARG ;; | ||
| 79 | |||
| 80 | (n) nmin=$OPTARG ;; | ||
| 81 | |||
| 82 | (p) push=1 ;; | ||
| 83 | |||
| 84 | (q) quiet=1 ;; | ||
| 85 | |||
| 86 | (t) test=1 ;; | ||
| 87 | |||
| 88 | (\?) die "Bad option -$OPTARG" ;; | ||
| 89 | |||
| 90 | (:) die "Option -$OPTARG requires an argument" ;; | ||
| 91 | |||
| 92 | (*) die "getopts error" ;; | ||
| 93 | esac | ||
| 94 | done | ||
| 95 | shift $(( --OPTIND )) | ||
| 96 | OPTIND=1 | ||
| 97 | |||
| 98 | |||
| 99 | ## Does not work 100% because a lot of Emacs batch output comes on | ||
| 100 | ## stderr (?). | ||
| 101 | [ "$quiet" ] && exec 1> /dev/null | ||
| 102 | |||
| 103 | |||
| 104 | [ "$push" ] && test=1 | ||
| 105 | [ "$test" ] && build=1 | ||
| 106 | |||
| 107 | |||
| 108 | tempfile=/tmp/$PN.$$ | ||
| 109 | |||
| 110 | trap "rm -f $tempfile 2> /dev/null" EXIT | ||
| 111 | |||
| 112 | |||
| 113 | [ -e Makefile ] && [ "$build" ] && { | ||
| 114 | echo "Cleaning..." | ||
| 115 | make maintainer-clean >& /dev/null | ||
| 116 | } | ||
| 117 | |||
| 118 | |||
| 119 | echo "Merging..." | ||
| 120 | |||
| 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" | ||
| 125 | |||
| 126 | else | ||
| 127 | grep -qE "Nothing to merge|Number of missing commits" $tempfile && { | ||
| 128 | echo "Fewer than $nmin commits to merge" | ||
| 129 | exit 0 | ||
| 130 | } | ||
| 131 | |||
| 132 | cat "$tempfile" 1>&2 | ||
| 133 | |||
| 134 | die "merge error" | ||
| 135 | fi | ||
| 136 | |||
| 137 | |||
| 138 | [ "$build" ] || exit 0 | ||
| 139 | |||
| 140 | |||
| 141 | echo "Running autoreconf..." | ||
| 142 | |||
| 143 | autoreconf -i -I m4 2>| $tempfile | ||
| 144 | |||
| 145 | retval=$? | ||
| 146 | |||
| 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 | ||
| 152 | fi | ||
| 153 | |||
| 154 | [ $retval -ne 0 ] && die "autoreconf error" | ||
| 155 | |||
| 156 | |||
| 157 | echo "Running ./configure..." | ||
| 158 | |||
| 159 | ## Minimize required packages. | ||
| 160 | ./configure --without-x || die "configure error" | ||
| 161 | |||
| 162 | |||
| 163 | echo "Building..." | ||
| 164 | |||
| 165 | make "$@" || die "make error" | ||
| 166 | |||
| 167 | echo "Build finished ok" | ||
| 168 | |||
| 169 | |||
| 170 | [ "$test" ] || exit 0 | ||
| 171 | |||
| 172 | |||
| 173 | echo "Testing..." | ||
| 174 | |||
| 175 | make "$@" check || die "check error" | ||
| 176 | |||
| 177 | echo "Tests finished ok" | ||
| 178 | |||
| 179 | |||
| 180 | [ "$push" ] || exit 0 | ||
| 181 | |||
| 182 | |||
| 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" | ||
| 188 | |||
| 189 | |||
| 190 | echo "Pushing..." | ||
| 191 | git push || die "push error" | ||
| 192 | |||
| 193 | |||
| 194 | exit 0 | ||
| 195 | |||
| 196 | ### automerge ends here | ||