Created
September 28, 2012 06:16
-
-
Save haxney/3798214 to your computer and use it in GitHub Desktop.
Turn Geiser into an ELPA package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This program 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, or (at | |
# your option) any later version. | |
# This program 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 this program; see the file COPYING. If not, write to | |
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
# Boston, MA 02110-1301, USA. | |
# Transmutatify the geiser released tarball into an ELPA package! | |
# Run from within the root directory of the extracted tarball | |
GEISER_VERSION=0.2.1 | |
GEISER_TMP_INSTALL=/tmp/staging/install-tmp | |
GEISER_PKG_BASE=/tmp/staging/geiser-$GEISER_VERSION | |
read -r -d '' GEISER_PKG_DESC <<EOF | |
(define-package "geiser" "$GEISER_VERSION" | |
"GNU Emacs and Scheme talk to each other") | |
EOF | |
# 0. Clean out any old installation remnants | |
rm -rf $GEISER_TMP_INSTALL $GEISER_PKG_BASE{,.tar} | |
# 1. Build and install the package to a temporary directory | |
./configure --prefix=$GEISER_TMP_INSTALL; make install | |
# 2. Prepare package target | |
mkdir -p $GEISER_PKG_BASE/bin | |
cp README $GEISER_PKG_BASE | |
cd $GEISER_TMP_INSTALL | |
# 3. Copy over the "geiser-racket" executable, making it use a relative path | |
sed -e 's/top=.*/top="$(dirname $0)\/.."/' \ | |
< bin/geiser-racket \ | |
> $GEISER_PKG_BASE/bin/geiser-racket | |
# 4. Delete the install code; paths are set up through ELPA | |
rm share/emacs/site-lisp/geiser-install.el | |
# 5. Copy files to the package directory | |
cp share/emacs/site-lisp/*.el $GEISER_PKG_BASE | |
cp share/info/* $GEISER_PKG_BASE | |
cp -R share/geiser/* $GEISER_PKG_BASE | |
# 6. Correct paths in "geiser.el" and set up autoloads | |
read -r -d '' EDIT_SCRIPT <<'EOF' | |
(progn | |
(defun autoloadize-things (thing) | |
"Add an autoload token before each THING in the buffer." | |
(goto-char (point-min)) | |
(while (search-forward thing nil t) | |
(beginning-of-line) | |
(insert ";;;###autoload\n") | |
(forward-line 1))) | |
(goto-char (point-min)) | |
(flush-lines "^(setq geiser") | |
(flush-lines "^(add-to-list .load-path geiser-elisp-dir)") | |
(search-forward "defvar geiser-elisp-dir") | |
(kill-word 1) | |
(just-one-space 1) | |
(insert "(file-name-directory load-file-name)") | |
(search-forward "defvar geiser-scheme-dir") | |
(kill-word 1) | |
(just-one-space 1) | |
(insert "geiser-elisp-dir") | |
(autoloadize-things "(add-to-list") | |
(autoloadize-things "(mapc") | |
(autoloadize-things "(autoload") | |
(autoloadize-things "(add-hook") | |
(basic-save-buffer)) | |
EOF | |
emacs -Q --batch --file $GEISER_PKG_BASE/geiser.el --eval "$EDIT_SCRIPT" | |
# 7. Create the geiser-pkg.el file | |
echo $GEISER_PKG_DESC > $GEISER_PKG_BASE/geiser-pkg.el | |
# 8. Go to the directory above the geiser package basedir | |
cd $GEISER_PKG_BASE/../ | |
# 9. Tar up the package | |
tar cf geiser-$GEISER_VERSION.tar geiser-$GEISER_VERSION | |
# 10. Install the package into Emacs | |
# M-x package-install-file RET /tmp/geiser-0.2.1.tar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment