| 1 |
#! /bin/bash -e |
| 2 |
# /usr/lib/emacsen-common/packages/install/develock-el |
| 3 |
|
| 4 |
# Written by Jim Van Zandt <[email protected]>, borrowing heavily |
| 5 |
# from the install scripts for gettext by Santiago Vila |
| 6 |
# <[email protected]> and octave by Dirk Eddelbuettel <[email protected]>. |
| 7 |
# |
| 8 |
# Patched by Roland Mas <[email protected]> to add support for lists |
| 9 |
# of flavor-dependently included/excluded files |
| 10 |
|
| 11 |
FLAVOR=$1 |
| 12 |
STAMPFILE=develock.elc |
| 13 |
PACKAGE=develock-el |
| 14 |
|
| 15 |
# INCLUDED_emacs20="" |
| 16 |
# INCLUDED_emacs21="" |
| 17 |
# INCLUDED_xemacs21="" |
| 18 |
# INCLUDE_emacs_snapshot="" |
| 19 |
|
| 20 |
# EXCLUDED_emacs20="" |
| 21 |
# EXCLUDED_emacs21="" |
| 22 |
# EXCLUDED_xemacs21="" |
| 23 |
# EXCLUDED_emacs_snapshot="" |
| 24 |
|
| 25 |
eval included_here=\$$(echo INCLUDED_$FLAVOR | tr - _) |
| 26 |
eval excluded_here=\$$(echo EXCLUDED_$FLAVOR | tr - _) |
| 27 |
eval sourceonly_here=\$$(echo SOURCEONLY_$FLAVOR | tr - _) |
| 28 |
|
| 29 |
included_all=$(for i in ${!INCLUDED_*} ; do |
| 30 |
eval echo \$$i |
| 31 |
done | sort -u) |
| 32 |
|
| 33 |
excluded_all=$(for i in ${!EXCLUDED_*} ; do |
| 34 |
eval echo \$$i |
| 35 |
done | sort -u) |
| 36 |
|
| 37 |
sourceonly_all=$(for i in ${!SOURCEONLY_*} ; do |
| 38 |
eval echo \$$i |
| 39 |
done | sort -u) |
| 40 |
|
| 41 |
if [ ${FLAVOR} = emacs ]; then exit 0; fi |
| 42 |
|
| 43 |
# Install-info-altdir does not actually exist. |
| 44 |
# Maybe somebody will write it. |
| 45 |
#if test -x /usr/sbin/install-info-altdir; then |
| 46 |
# echo install/${PACKAGE}: install Info links for ${FLAVOR} |
| 47 |
# install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/info/${PACKAGE}.info.gz |
| 48 |
#fi |
| 49 |
|
| 50 |
LOG=`tempfile -pelc_ -s.log -m644` |
| 51 |
ELDIR=/usr/share/emacs/site-lisp/${PACKAGE} |
| 52 |
ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE} |
| 53 |
if test -e "${ELCDIR}/${STAMPFILE}"; then |
| 54 |
echo "${PACKAGE} files already compiled in ${ELCDIR}." |
| 55 |
rm -f ${LOG} |
| 56 |
exit |
| 57 |
fi |
| 58 |
echo install/${PACKAGE}: Handling ${FLAVOR}, logged in ${LOG} |
| 59 |
|
| 60 |
if [ -z "$FLAGS" ] ; then |
| 61 |
FLAGS="-q -no-site-file --no-site-file -batch -l path.el -f batch-byte-compile" |
| 62 |
fi |
| 63 |
|
| 64 |
install -m 755 -d ${ELCDIR} |
| 65 |
cd ${ELDIR} |
| 66 |
|
| 67 |
# Now to compute the list of files to install... |
| 68 |
|
| 69 |
FILES=$(ls -1 *.el) |
| 70 |
# Here we have all of them |
| 71 |
|
| 72 |
PATTERN="" |
| 73 |
for i in $included_all $excluded_all $sourceonly_all; do |
| 74 |
[ ! -z "$PATTERN" ] && PATTERN="${PATTERN}\|" |
| 75 |
PATTERN="${PATTERN}^$i\$" |
| 76 |
done |
| 77 |
FILES2=$FILES |
| 78 |
if [ ! -z "$PATTERN" ] ; then |
| 79 |
FILES=$(for i in $FILES2 ; do echo $i | grep -v $PATTERN || true ; done) |
| 80 |
fi |
| 81 |
# Here we only have those not explicitly included or excluded by any flavour |
| 82 |
|
| 83 |
FILES="$FILES $included_here" |
| 84 |
# Here we also have those included for the current flavour |
| 85 |
|
| 86 |
for i in $excluded_all ; do |
| 87 |
include_i="yes" |
| 88 |
for j in $excluded_here ; do |
| 89 |
[ $i = $j ] && include_i="no" |
| 90 |
done |
| 91 |
[ $include_i = "yes" ] && FILES="$FILES $i" |
| 92 |
done |
| 93 |
# And now we have those excluded by other flavours but not the current one |
| 94 |
|
| 95 |
FILES=$(for i in $FILES ; do echo $i ; done | sort -u) |
| 96 |
# And now for my last trick... The list is now uniquified! |
| 97 |
|
| 98 |
# Symlinks instead of copying... |
| 99 |
cd ${ELCDIR} |
| 100 |
for i in $FILES $sourceonly_all; do |
| 101 |
ln -fs /usr/share/emacs/site-lisp/${PACKAGE}/$i |
| 102 |
done |
| 103 |
|
| 104 |
cat << EOF > path.el |
| 105 |
(setq load-path (cons "." load-path) byte-compile-warnings nil) |
| 106 |
EOF |
| 107 |
if test "${APPEND_LOAD_PATH}" != "" |
| 108 |
then |
| 109 |
cat << EOF >> path.el |
| 110 |
(setq load-path (append ${APPEND_LOAD_PATH} load-path)) |
| 111 |
EOF |
| 112 |
fi |
| 113 |
|
| 114 |
echo ${FLAVOR} ${FLAGS} ${FILES} >> ${LOG} |
| 115 |
"${FLAVOR}" ${FLAGS} ${FILES} >> ${LOG} 2>&1 |
| 116 |
egrep -s -e "While compiling|\*\*" ${LOG} || /bin/true |
| 117 |
echo install/${PACKAGE}: Deleting ${LOG} |
| 118 |
rm -f path.el ${LOG} |
| 119 |
|
| 120 |
exit 0 |