URL:
https://svn.lrde.epita.fr/svn/lrde-tools/trunk
ChangeLog:
2007-11-26 Akim Demaille <demaille(a)gostai.com>
Minor fixes.
* src/install-pysyck (stderr): New.
Use it.
Fix uses of $debug_p.
Suggest using --sudo-command.
Use portable sed scripts.
Prefer case (a builtin) to grep.
---
install-pysyck | 75 ++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 45 insertions(+), 30 deletions(-)
Index: trunk/src/install-pysyck
===================================================================
--- trunk/src/install-pysyck (revision 473)
+++ trunk/src/install-pysyck (revision 474)
@@ -1,7 +1,12 @@
#! /bin/bash
# The path of the script.
-me="$0"
+me=$(basename "$0")
+
+stderr ()
+{
+ echo >&2 "$me: $@"
+}
# The (general) install prefix.
prefix="/usr/local"
@@ -72,7 +77,10 @@
# success, 1 otherwise.
match_option()
{
- echo "$1" | grep -q "^$2" 2>/dev/null
+ case $1 in
+ "$2"*) return 0;;
+ * ) return 1;;
+ esac
}
# ARGUMENT OPTION
@@ -80,8 +88,8 @@
# Get the argument of OPTION
argument()
{
- # I don't remember whether sed -r is portable...
- echo "$1" | sed "s/[^=]\+=\(.*\)/\1/"
+ # sed -r is not portable, and neither is +.
+ echo "$1" | sed 's/^[^=]*=//'
}
# CLEANUP
@@ -123,11 +131,11 @@
break
;;
n|no*)
- echo "Installation aborted."
+ stderr "Installation aborted."
exit 1
;;
*)
- echo "Please answer \`y' or \`n'."
+ stderr "Please answer \`y' or \`n'."
;;
esac
done
@@ -141,23 +149,23 @@
# 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
+$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"
+stderr "Work directory is $work_dir"
+stderr "Syck prefix is $syck_prefix"
+stderr "PySyck prefix is $pysyck_prefix"
+test -n "$sudo_command" && stderr "Sudo command is
$sudo_command"
+$debug_p && stderr "Debug mode on"
# Turn on debug mode if requested so.
-debug_p && set -x
+$debug_p && set -x
# Download.
-echo "Downloading Syck from $syck_url..."
+stderr "Downloading Syck from $syck_url..."
wget -O "$syck_archive" "$syck_url"
-echo "Downloading PySyck from $pysyck_url..."
+stderr "Downloading PySyck from $pysyck_url..."
wget -O "$pysyck_archive" "$pysyck_url"
## ------ ##
@@ -168,17 +176,24 @@
| perl -n \
-e "print \"\$1\n\"" \
-e " if (s,^.* ([^ /]*syck[^ /]+)/\$,\1,)")
-echo "Unpacking Syck into $syck_srcdir..."
+stderr "Unpacking Syck into $syck_srcdir..."
tar xzf "$syck_archive"
cd "$syck_srcdir"
-echo "Building Syck..."
+stderr "Building Syck..."
./configure --prefix="$syck_prefix"
make
make check
-echo "Installing Syck..."
-eval "$sudo_command make install"
-echo "Cleaning Syck build tree..."
+stderr "Installing Syck..."
+stderr "$sudo_command make install"
+if !eval "$sudo_command make install"; then
+ stderr "make install failed."
+ if test x"$sudo_command" = x; then
+ stderr "You might need to use --sudo-command=sudo"
+ fi
+ exit 1
+fi
+stderr "Cleaning Syck build tree..."
make clean
# Absolute prefix.
@@ -196,11 +211,11 @@
| perl -n \
-e "print \"\$1\n\"" \
-e " if (s,^.* ([^ /]*PySyck[^ /]+)/\$,\1,)")
-echo "Unpacking PySyck into $pysyck_srcdir..."
+stderr "Unpacking PySyck into $pysyck_srcdir..."
tar xzf "$pysyck_archive"
cd "$pysyck_srcdir"
-echo "Patching setup.cfg..."
+stderr "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
@@ -217,9 +232,9 @@
EOF
-echo "Installing PySyck..."
+stderr "Installing PySyck..."
eval "$sudo_command python setup.py install
--prefix=\"$pysyck_prefix\""
-echo "Cleaning PySyck build tree..."
+stderr "Cleaning PySyck build tree..."
python setup.py clean
# Absolute prefix.
@@ -228,9 +243,9 @@
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 "======================================================================"
+stderr
+stderr
"======================================================================"
+stderr "Syck and PySyck installed successfully! Don't forget to update"
+stderr "your PYTHONPATH to use the freshly installed PySyck"
+stderr "(e.g., pre/append $abs_pysyck_prefix/lib/python2.5/site-packages)."
+stderr
"======================================================================"