Mercurial > emacs
annotate admin/quick-install-emacs @ 70417:95f3ef491663
(setenv): Use add-to-history.
| author | Kim F. Storm <storm@cua.dk> |
|---|---|
| date | Fri, 05 May 2006 23:36:55 +0000 |
| parents | f6384702a1b6 |
| children | 65f7f7adff78 e4694597cbf4 |
| rev | line source |
|---|---|
| 39041 | 1 #!/bin/sh |
| 2 # quick-install-emacs -- do a halfway-decent job of installing emacs quickly | |
| 3 # Written by Miles Bader <miles@gnu.org> | |
| 4 | |
| 5 # This script is mainly intended for emacs maintainer or pretesters who | |
| 6 # install emacs very often. See the --help output for more details. | |
| 7 | |
| 8 PUBLIC_LIBSRC_BINARIES='b2m emacsclient etags ctags ebrowse' | |
| 9 PUBLIC_LIBSRC_SCRIPTS='grep-changelog rcs-checkin' | |
| 10 | |
|
52634
bb955cc088f9
Revision: miles@gnu.org--gnu-2003/emacs--cvs-trunk--0--patch-62
Miles Bader <miles@gnu.org>
parents:
52506
diff
changeset
|
11 AVOID="CVS -DIC README COPYING ChangeLog ~ [.]orig$ [.]rej$ Makefile makefile stamp-subdir [.]cvsignore [.]arch-ids [{]arch[}] [.][cho]$ make-docfile testfile test-distrib" |
| 39041 | 12 |
| 13 # Prune old binaries lying around in the source tree | |
| 14 PRUNE=no | |
| 15 # Re-install files even if they already exist | |
| 16 FORCE=no | |
| 17 # Command verbose flag | |
| 18 VERBOSE='' | |
| 19 | |
| 20 me="`basename $0`" | |
| 21 | |
|
60340
f6384702a1b6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-146
Miles Bader <miles@gnu.org>
parents:
52708
diff
changeset
|
22 # Install commands (if the user specifies the `--verbose' option, it is |
|
f6384702a1b6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-146
Miles Bader <miles@gnu.org>
parents:
52708
diff
changeset
|
23 # passed to these commands, so that feature only works if these commands |
|
f6384702a1b6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-146
Miles Bader <miles@gnu.org>
parents:
52708
diff
changeset
|
24 # implement it too) |
| 39041 | 25 LINK='cp -lf' |
| 26 COPY='cp -f' | |
| 27 REMOVE='rm -r' | |
|
60340
f6384702a1b6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-146
Miles Bader <miles@gnu.org>
parents:
52708
diff
changeset
|
28 MKDIR='mkdir -p' |
| 39041 | 29 |
| 30 # Used to execute commands once once we create them | |
| 31 EXEC='sh' | |
| 32 | |
| 33 NAWK=/usr/bin/nawk | |
| 34 | |
|
49088
a22f8991ae27
Unset LANG etc. to avoid non-standard command output from non-C locales.
Miles Bader <miles@gnu.org>
parents:
45539
diff
changeset
|
35 # avoid non-standard command output from non-C locales |
|
a22f8991ae27
Unset LANG etc. to avoid non-standard command output from non-C locales.
Miles Bader <miles@gnu.org>
parents:
45539
diff
changeset
|
36 unset LANG LC_ALL LC_MESSAGES |
|
a22f8991ae27
Unset LANG etc. to avoid non-standard command output from non-C locales.
Miles Bader <miles@gnu.org>
parents:
45539
diff
changeset
|
37 |
| 39041 | 38 # Some messages |
| 39 USAGE="Usage: $me [OPTION...] BUILD_TREE [PREFIX]" | |
| 40 TRY="Try "\`"$me --help' for more information." | |
| 41 | |
| 42 # Parse command-line options | |
| 43 while :; do | |
| 44 case "$1" in | |
| 45 -n|--dry-run) | |
| 46 EXEC=cat; shift;; | |
| 47 -p|--prune) | |
| 48 PRUNE=yes; shift;; | |
| 49 -P|--no-prune) | |
| 50 PRUNE=no; shift;; | |
| 51 --prune-only) | |
| 52 PRUNE=only; shift;; | |
| 53 -f|--force) | |
| 54 FORCE=yes; shift;; | |
| 55 -v|--verbose) | |
| 56 VERBOSE="-v"; shift;; | |
| 57 --help) | |
| 58 cat <<EOF | |
| 59 $USAGE | |
| 60 Install emacs quickly | |
| 61 | |
| 62 -n, --dry-run print installation commands instead of | |
| 63 executing them | |
| 64 | |
| 65 -f, --force install even files that haven't changed | |
| 66 -v, --verbose print messages describing what is done | |
| 67 | |
| 68 -p, --prune prune old generated files | |
| 69 -P, --no-prune don't prune old generated files (default) | |
| 70 --prune-only prune old generated files, but don't install | |
| 71 | |
| 72 --help display this help and exit | |
| 73 --version output version information and exit | |
| 74 | |
| 75 $me install emacs \`incrementally,' that is, it will | |
| 76 install only those files that have changed since the last time it was | |
| 77 invoked, and remove any obsolete files from the installation | |
| 78 directories. It also uses hard-links into the source and build trees to | |
| 79 do the install, so it uses much less space than the default Makefile | |
| 80 install target; however, this also means that $me can | |
| 81 not install onto a disk partition other than the one on which the source | |
| 82 and build directories reside. | |
| 83 | |
| 84 Optionally, $me can also remove old versions of | |
| 85 automatically generated files that are version-specific (such as the | |
| 86 versioned emacs executables in the \`src' directory, and the DOC-* files | |
| 87 in the \`etc' directory). The latter action is called \`pruning,' and | |
| 88 can be enabled using the \`-p' or \`--prune' options. | |
| 89 EOF | |
| 90 exit 0 | |
| 91 ;; | |
| 92 --version) | |
| 93 cat <<EOF | |
| 49089 | 94 $me 1.6 |
| 39041 | 95 |
| 96 Written by Miles Bader <miles@gnu.org> | |
| 97 EOF | |
| 98 exit 0 | |
| 99 ;; | |
| 100 -[^-]?*) | |
| 101 # split concatenated single-letter options apart | |
| 102 FIRST="$1"; shift | |
| 103 set -- `echo $FIRST | sed 's/-\(.\)\(.*\)/-\1 -\2/'` "$@" | |
| 104 ;; | |
| 105 -*) | |
| 106 echo 1>&2 "$me: unrecognized option "\`"$1'" | |
| 107 echo 1>&2 "$TRY" | |
| 108 exit 1 | |
| 109 ;; | |
| 110 *) | |
| 111 break; | |
| 112 esac | |
| 113 done | |
| 114 | |
| 115 LINK_CMD="$LINK $VERBOSE" | |
| 116 REMOVE_CMD="$REMOVE $VERBOSE" | |
| 117 | |
| 118 case $# in | |
| 119 1) BUILD="$1";; | |
| 120 2) BUILD="$1"; prefix="$2";; | |
| 121 *) | |
| 122 echo 1>&2 "$USAGE" | |
| 123 echo 1>&2 "$TRY" | |
| 124 exit 1 | |
| 125 ;; | |
| 126 esac | |
| 127 | |
| 128 if test ! -d "$BUILD"; then | |
| 129 echo 1>&2 "$me: $BUILD: Build tree not found" | |
| 130 exit 2 | |
| 131 elif test ! -r "$BUILD/config.status"; then | |
| 132 echo 1>&2 "$me: $BUILD: Not a proper build tree, config.status not found" | |
| 133 exit 2 | |
| 134 fi | |
| 135 | |
| 136 CONFIG_STATUS="$BUILD/config.status" | |
|
52708
8f70aecafdb5
Revision: miles@gnu.org--gnu-2003/emacs--cvs-trunk--0--patch-68
Miles Bader <miles@gnu.org>
parents:
52634
diff
changeset
|
137 get_config_var () |
|
8f70aecafdb5
Revision: miles@gnu.org--gnu-2003/emacs--cvs-trunk--0--patch-68
Miles Bader <miles@gnu.org>
parents:
52634
diff
changeset
|
138 { |
|
44112
271a4f9d12fc
(PRUNED): Avoid "head -1" and "tail +2", as POSIX 1003.1-2001
Paul Eggert <eggert@twinsun.com>
parents:
40064
diff
changeset
|
139 if ! sed -n "s/^s\(.\)@$1@\1\(.*\)\1.*$/\2/p" $CONFIG_STATUS | sed q | grep '' |
| 39041 | 140 then |
| 141 echo 1>&2 "$me: $1: Configuration variable not found in $CONFIG_STATUS" | |
| 142 exit 4 | |
| 143 fi | |
| 144 } | |
| 145 | |
|
40064
90451d9e7e0e
Exit if we can't find some variable.
Miles Bader <miles@gnu.org>
parents:
39041
diff
changeset
|
146 test x"$SRC" = x && { SRC="`get_config_var srcdir`" || exit 4 ; } |
|
90451d9e7e0e
Exit if we can't find some variable.
Miles Bader <miles@gnu.org>
parents:
39041
diff
changeset
|
147 test x"$prefix" = x && { prefix="`get_config_var prefix`" || exit 4 ; } |
|
90451d9e7e0e
Exit if we can't find some variable.
Miles Bader <miles@gnu.org>
parents:
39041
diff
changeset
|
148 test x"$ARCH" = x && { ARCH="`get_config_var host`" || exit 4 ; } |
| 39041 | 149 |
|
45539
99b2cc9b795c
(VERSION): Calculate using the same method that configure.in uses.
Miles Bader <miles@gnu.org>
parents:
44112
diff
changeset
|
150 VERSION=`grep 'defconst[ ]*emacs-version' $SRC/lisp/version.el \ |
|
99b2cc9b795c
(VERSION): Calculate using the same method that configure.in uses.
Miles Bader <miles@gnu.org>
parents:
44112
diff
changeset
|
151 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'` |
|
99b2cc9b795c
(VERSION): Calculate using the same method that configure.in uses.
Miles Bader <miles@gnu.org>
parents:
44112
diff
changeset
|
152 |
| 39041 | 153 DST_SHARE="$prefix/share/emacs/$VERSION" |
| 154 DST_BIN="$prefix/bin" | |
| 155 DST_LIBEXEC="$prefix/libexec/emacs/$VERSION/$ARCH" | |
| 156 DST_INFO="$prefix/info" | |
| 157 | |
|
52708
8f70aecafdb5
Revision: miles@gnu.org--gnu-2003/emacs--cvs-trunk--0--patch-68
Miles Bader <miles@gnu.org>
parents:
52634
diff
changeset
|
158 maybe_mkdir () |
|
8f70aecafdb5
Revision: miles@gnu.org--gnu-2003/emacs--cvs-trunk--0--patch-68
Miles Bader <miles@gnu.org>
parents:
52634
diff
changeset
|
159 { |
| 39041 | 160 if ! test -d "$1"; then |
|
60340
f6384702a1b6
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-146
Miles Bader <miles@gnu.org>
parents:
52708
diff
changeset
|
161 $MKDIR $VERBOSE "$1" 2>&1 | sed "s/^mkdir:/$me:/" 1>&2 |
| 39041 | 162 fi |
| 163 } | |
| 164 | |
| 165 maybe_mkdir "$DST_BIN" | |
| 166 maybe_mkdir "$DST_SHARE" | |
| 167 maybe_mkdir "$DST_SHARE/site-lisp" | |
| 168 maybe_mkdir "$DST_LIBEXEC" | |
| 169 maybe_mkdir "$DST_INFO" | |
| 170 | |
| 171 ( # start of command-generating sub-shell | |
| 172 | |
| 173 PRUNED="" | |
| 174 if test x"$PRUNE" != xno; then | |
|
44112
271a4f9d12fc
(PRUNED): Avoid "head -1" and "tail +2", as POSIX 1003.1-2001
Paul Eggert <eggert@twinsun.com>
parents:
40064
diff
changeset
|
175 for D in `ls -1t $BUILD/etc/DOC-* | sed 1d`; do |
| 39041 | 176 echo $REMOVE_CMD $D |
| 177 PRUNED="$PRUNED $D" | |
| 178 done | |
|
44112
271a4f9d12fc
(PRUNED): Avoid "head -1" and "tail +2", as POSIX 1003.1-2001
Paul Eggert <eggert@twinsun.com>
parents:
40064
diff
changeset
|
179 for D in `ls -1t $BUILD/src/emacs-$VERSION.* | sed 1d`; do |
| 39041 | 180 echo $REMOVE_CMD $D |
| 181 PRUNED="$PRUNED $D" | |
| 182 done | |
| 183 fi | |
| 184 | |
| 185 test x"$PRUNE" = xonly && exit 0 | |
| 186 | |
|
52708
8f70aecafdb5
Revision: miles@gnu.org--gnu-2003/emacs--cvs-trunk--0--patch-68
Miles Bader <miles@gnu.org>
parents:
52634
diff
changeset
|
187 maybe_emit_copy () |
|
8f70aecafdb5
Revision: miles@gnu.org--gnu-2003/emacs--cvs-trunk--0--patch-68
Miles Bader <miles@gnu.org>
parents:
52634
diff
changeset
|
188 { |
| 39041 | 189 if test "$FORCE" = yes || ! cmp -s $1 $2; then |
| 190 echo $LINK_CMD $1 $2 | |
| 191 fi | |
| 192 } | |
| 193 | |
| 194 maybe_emit_copy $BUILD/src/emacs $DST_BIN/emacs | |
| 195 maybe_emit_copy $BUILD/src/emacs $DST_BIN/emacs-$VERSION | |
| 196 | |
| 197 for F in $PUBLIC_LIBSRC_BINARIES; do | |
| 198 maybe_emit_copy $BUILD/lib-src/$F $DST_BIN/$F | |
| 199 done | |
| 200 for F in $PUBLIC_LIBSRC_SCRIPTS; do | |
| 201 maybe_emit_copy $SRC/lib-src/$F $DST_BIN/$F | |
| 202 done | |
| 203 | |
| 204 if test x"$SRC" = x"$BUILD"; then | |
| 205 PFXS="$BUILD" | |
| 206 else | |
| 207 PFXS="$SRC $BUILD" | |
| 208 fi | |
| 209 | |
| 210 for SUBDIR in lisp leim etc lib-src info; do | |
| 211 # defaults | |
| 212 SHARED=no | |
| 213 FORCED='' | |
| 214 AVOID_PAT="`echo "($AVOID)" | tr ' ' '|'`" | |
| 215 | |
| 216 # Set subdir-specific values | |
| 217 case $SUBDIR in | |
| 218 lisp|leim) | |
| 219 DST="$DST_SHARE/$SUBDIR" | |
| 220 ;; | |
| 221 etc) | |
| 222 DST="$DST_SHARE/$SUBDIR" | |
| 223 # COPYING is in the avoid list, but there should be a copy of it in | |
| 224 # the install etc dir, so make that here. | |
| 225 FORCED="$DST/COPYING" | |
| 226 ;; | |
| 227 lib-src) | |
| 228 DST="$DST_LIBEXEC" | |
| 229 AVOID_PAT="`echo "($AVOID ($PUBLIC_LIBSRC_BINARIES $PUBLIC_LIBSRC_SCRIPTS)\$)" | tr ' ' '|'`" | |
| 230 ;; | |
| 231 info) | |
| 232 DST="$DST_INFO" | |
| 233 SHARED=yes | |
| 234 ;; | |
| 235 esac | |
| 236 | |
| 237 for PFX in $PFXS; do | |
| 238 if [ -d $PFX/$SUBDIR ]; then | |
| 239 for DIR in `(cd $PFX/$SUBDIR; find . -type d -print | sed 's@^./@@')`; do | |
| 240 if [ -d $DST/$DIR ]; then | |
| 241 echo Directory $DST/$DIR exists | |
| 242 else | |
| 243 echo Directory $DST/$DIR non-existant | |
| 244 if [ "`echo $DIR | egrep -v "$AVOID_PAT"`" ]; then | |
| 245 maybe_mkdir $DST/$DIR | |
| 246 fi | |
| 247 fi | |
| 248 done | |
| 249 diff -sqr $PFX/$SUBDIR $DST | |
| 250 fi | |
| 251 done | $NAWK ' | |
| 252 BEGIN { | |
| 253 src_pat = "^'"$SRC"'/'"$SUBDIR"'/" | |
| 254 build_pat = "^'"$BUILD"'/'"$SUBDIR"'/" | |
| 255 dst_pat = "^'"$DST"'/" | |
| 256 dst_pfx = "'"$DST"'/" | |
| 257 avoid_pat = "'"$AVOID_PAT"'" | |
| 258 force = ("'"$FORCE"'" == "yes") | |
| 259 shared = ("'"$SHARED"'" == "yes") | |
| 260 init_bool_array(pruned, "'"$PRUNED"'") | |
| 261 init_bool_array(forced, "'"$FORCED"'") | |
| 262 } | |
| 263 function init_bool_array(array, string, a,k) | |
| 264 { | |
| 265 split (string, a) | |
| 266 for (k in a) | |
| 267 array[a[k]] = 1 | |
| 268 } | |
| 269 function install(src, dst) | |
| 270 { | |
| 271 if (! (src in pruned)) { | |
| 272 cp[src] = dst; | |
| 273 from[dst] = src; | |
| 274 delete rm[dst]; | |
| 275 } | |
| 276 } | |
| 277 function update(src, dst, copy) | |
| 278 { | |
| 279 if (src in pruned) { | |
| 280 rm[dst] = 1; | |
| 281 delete from[dst] | |
| 282 } else { | |
| 283 if (copy) | |
| 284 cp[src] = dst; | |
| 285 from[dst] = src; | |
| 286 delete rm[dst]; | |
| 287 } | |
| 288 } | |
| 289 function uninstall(dst) | |
| 290 { | |
| 291 if (!(dst in from)) | |
| 292 rm[dst] = 1; | |
| 293 } | |
| 294 /^Directory / { | |
| 295 if ($2 ~ avoid_pat) { | |
| 296 if ($NF == "exists") | |
| 297 uninstall($2) | |
| 298 } else | |
| 299 update(0, $2, 0) | |
| 300 next | |
| 301 } | |
| 302 /^Files / { | |
| 303 if ($4 ~ avoid_pat && !($4 in forced)) | |
| 304 uninstall($4) | |
| 305 else if ($NF == "identical") | |
| 306 update($2, $4, force) | |
| 307 else | |
| 308 update($2, $4, 1) | |
| 309 next | |
| 310 } | |
| 311 /^Only / { | |
| 312 pfx = $3 | |
| 313 sub (/:$/, "/", pfx) | |
| 314 | |
| 315 if (pfx ~ dst_pat) { | |
| 316 if (! shared) | |
| 317 uninstall(pfx $4) | |
| 318 } else { | |
| 319 subdir = pfx | |
| 320 if (subdir ~ src_pat) | |
| 321 sub (src_pat, "", subdir) | |
| 322 else | |
| 323 sub (build_pat, "", subdir) | |
| 324 | |
| 325 dst = dst_pfx subdir $4 | |
| 326 if (! (dst ~ avoid_pat)) | |
| 327 install(pfx $4, dst) | |
| 328 } | |
| 329 next | |
| 330 } | |
| 331 END { | |
| 332 for (f in rm) | |
| 333 print "'"$REMOVE_CMD"' " f | |
| 334 for (f in cp) | |
| 335 print "'"$LINK_CMD"' " f " " cp[f] | |
| 336 } | |
| 337 ' | |
| 338 done | |
| 339 | |
| 340 ) | eval $EXEC | |
| 52401 | 341 |
| 342 # arch-tag: 9322b572-9755-4cf7-a67a-21e6505f1477 |
