https://svn.lrde.epita.fr/svn/lrde-tools/trunk
This should ease the transition to PySyck 0.61 (which supports
multiple YAML document in a single file/stream) for Mac OS X users.
TC's generators should run fine with the programs installed by this script.
BTW, If you know how to create Portfiles for the MacPorts, don't
hesitate to propose one for PySyck and one (update) for Syck to the
MacPorts maintainers.
(I think I know understand why this project is called Syck...)
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add a script making installations of PySyck easier.
* src/install-pysyck: New installer.
* README: Mention install-pysyck.
README | 4
src/install-pysyck | 236 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 240 insertions(+)
Index: src/install-pysyck
--- src/install-pysyck (revision 0)
+++ src/install-pysyck (revision 0)
@@ -0,0 +1,236 @@
+#! /bin/bash
+
+# The path of the script.
+me="$0"
+
+# The (general) install prefix.
+prefix="/usr/local"
+# The install prefix for Syck.
+syck_prefix="$prefix"
+# The install prefix for PySyck.
+pysyck_prefix="$prefix"
+
+# Syck URL.
+syck_url="http://pyyaml.org/download/pysyck/syck-0.61+svn231+patches.tar.gz"
+# PySyck URL
+pysyck_url="http://pyyaml.org/download/pysyck/PySyck-0.61.2.tar.gz"
+
+# The name of the dowloaded Syck archive.
+syck_archive="syck.tar.gz"
+# The name of the dowloaded PySyck archive.
+pysyck_archive="pysyck.tar.gz"
+
+# The sudo command used when installing files (empty by default).
+sudo_command=
+# Turn on debug mode?
+debug_p=false
+
+
+usage()
+{
+ # Using single quotes around EOF allows us to display backslashes (\)
+ # as expected in the output.
+ cat <<EOF
+\`install-pysyck' downloads, builds and installs Syck and PySyck from
+http://www.pyyaml.org. See
http://www.pyyaml.org/wiki/PySyck for more
+information. This script is especially useful on Mac OS X, since the
+MacPorts do not provide (yet) a recent version of PySyck.
+
+Usage: $me [OPTION]...
+
+Defaults for the options are specified in brackets.
+
+General
+ -h, --help display this help and exit
+
+Installation directories
+ --prefix=PREFIX install files in PREFIX [/usr/local]
+ --syck-prefix=SYCK_PREFIX install Syck files in PREFIX [PREFIX]
+ --pysyck-prefix=PYSYCK_PREFIX install PySyck files in PREFIX [PREFIX]
+
+Installation
+ --sudo-command=SUDO_CMD prepend SUDO_CMD to installation statements []
+
+Debug
+ --debug turn on debug mode (display every command)
+
+Examples:
+ $me --sudo=sudo
+ $me --prefix=/mnt/shared-tools --sudo="sudo -u admin"
+ $me --prefix=/usr/local/stow/pysyck
+ $me \\
+ --syck-prefix=\$HOME/local/stow/syck-0.61+svn231+patches \\
+ --pysyck-prefix=\$HOME/local/stow/PySyck-0.61.2
+
+EOF
+ exit
+}
+
+# MATCH_OPTION OPTION PREFIX
+# --------------------------
+# Try to match OPTION at the beginning of PREFIX. Return 0 in case of
+# success, 1 otherwise.
+match_option()
+{
+ echo "$1" | grep -q "^$2" 2>/dev/null
+}
+
+# ARGUMENT OPTION
+# ---------------
+# Get the argument of OPTION
+argument()
+{
+ # I don't remember whether sed -r is portable...
+ echo "$1" | sed "s/[^=]\\+=\\(.*\\)/\\1/"
+}
+
+# CLEANUP
+# -------
+# Remove the work directory.
+cleanup()
+{
+ rm -rf "$work_dir"
+}
+
+
+# Handle options.
+for i; do
+ # Help.
+ match_option "$i" "-h" && usage
+ match_option "$i" "--help" && usage
+ # Prefix.
+ match_option "$i" "--prefix" && \
+ prefix=$(argument "$i") && \
+ syck_prefix="$prefix" && \
+ pysyck_prefix="$prefix" \
+ # Syck prefix.
+ match_option "$i" "--syck-prefix" &&
syck_prefix=$(argument "$i")
+ # PySyck prefix.
+ match_option "$i" "--pysyck-prefix" &&
pysyck_prefix=$(argument "$i")
+ # Sudo command.
+ match_option "$i" "--sudo-command" &&
sudo_command=$(argument "$i")
+ # Debug.
+ match_option "$i" "--debug" && debug_p=true
+done
+
+# Ask for confirmation.
+echo "Do you want to install Syck into $syck_prefix"
+echo " and PySyck into $pysyck_prefix? (y/n)"
+while true; do
+ read answer
+ case "$answer" in
+ y|yes*)
+ break
+ ;;
+ n|no*)
+ echo "Installation aborted."
+ exit 1
+ ;;
+ *)
+ echo "Please answer \`y' or \`n'."
+ ;;
+ esac
+done
+
+# Any failure is fatal.
+set -e
+
+# Create a work directory
+work_dir=$(mktemp -d /tmp/install-pysyck.XXXXXX)
+# Clean up the working directory on SIGHUP, SIGINT, SIGQUIT, SIGTERM or
+# an unexpected failure (ERR).
+# This feature is disabled in debug mode, so that the user can look at
+# the work directory after the script terminates.
+debug_p || trap cleanup SIGHUP SIGINT SIGQUIT SIGTERM ERR
+cd "$work_dir"
+
+# Information
+echo "Work directory is $work_dir"
+echo "Syck prefix is $syck_prefix"
+echo "PySyck prefix is $pysyck_prefix"
+test -n "$sudo_command" && echo "Sudo command is
$sudo_command"
+debug_p && echo "Debug mode on"
+
+# Turn on debug mode if requested so.
+debug_p && set -x
+
+# Download.
+echo "Downloading Syck from $syck_url..."
+wget -O "$syck_archive" "$syck_url"
+echo "Downloading PySyck from $pysyck_url..."
+wget -O "$pysyck_archive" "$pysyck_url"
+
+## ------ ##
+## Syck. ##
+## ------ ##
+
+syck_srcdir=$(tar tzvf "$syck_archive" \
+ | perl -n \
+ -e "print \"\$1\\n\"" \
+ -e " if (s,^.* ([^ /]*syck[^ /]+)/\$,\\1,)")
+echo "Unpacking Syck into $syck_srcdir..."
+tar xzf "$syck_archive"
+cd "$syck_srcdir"
+
+echo "Building Syck..."
+./configure --prefix="$syck_prefix"
+make
+make check
+echo "Installing Syck..."
+eval "$sudo_command make install"
+echo "Cleaning Syck build tree..."
+make clean
+
+# Absolute prefix.
+abs_syck_prefix=$(cd $syck_prefix && pwd)
+
+cd ..
+
+
+
+## -------- ##
+## PySyck. ##
+## -------- ##
+
+pysyck_srcdir=$(tar tzvf "$pysyck_archive" \
+ | perl -n \
+ -e "print \"\$1\\n\"" \
+ -e " if (s,^.* ([^ /]*PySyck[^ /]+)/\$,\\1,)")
+echo "Unpacking PySyck into $pysyck_srcdir..."
+tar xzf "$pysyck_archive"
+cd "$pysyck_srcdir"
+
+echo "Patching setup.cfg..."
+cat <<EOF | patch
+--- setup.cfg.orig 2007-11-13 23:28:01.000000000 +0100
++++ setup.cfg 2007-11-13 23:30:44.000000000 +0100
+@@ -4,8 +4,8 @@
+ [build_ext]
+
+ # List of directories to search for 'syck.h' (separated by ':').
+-#include_dirs=/usr/local/include:../../include
++include_dirs=${abs_syck_prefix}/include:/usr/local/include:../../include
+
+ # List of directories to search for 'libsyck.a' (separated by ':').
+-#library_dirs=/usr/local/lib:../../lib
++library_dirs=${abs_syck_prefix}/lib:/usr/local/lib:../../lib
+
+
+EOF
+echo "Installing PySyck..."
+eval "$sudo_command python setup.py install
--prefix=\"$pysyck_prefix\""
+echo "Cleaning PySyck build tree..."
+python setup.py clean
+
+# Absolute prefix.
+abs_pysyck_prefix=$(cd $pysyck_prefix && pwd)
+
+cd ..
+
+# The end.
+echo
+echo "======================================================================"
+echo "Syck and PySyck installed successfully! Don't forget to update"
+echo "your PYTHONPATH to use the freshly installed PySyck"
+echo "(e.g., pre/append $abs_pysyck_prefix/lib/python2.5/site-packages)."
+echo "======================================================================"
Property changes on: src/install-pysyck
___________________________________________________________________
Name: svn:executable
+ *
Index: README
--- README (revision 451)
+++ README (working copy)
@@ -104,6 +104,10 @@
** install-on
Remotely install a package on a machine.
+** src/install-pysyck
+Install PySyck from
http://pyyaml.org. Useful under Mac OS X, whose
+MacPorts do not contain PySyck.
+
** rdiff
Recursive diff between two files/tarballs.