From: jiho-sf Date: Sat, 3 Nov 2007 23:12:26 +0000 (+0000) Subject: inkscape: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a2aa00dbaf27e2a3955641a0dc01acf896497640;p=inkscape.git inkscape: - added code to use the python modules that ship with the app bundle. With Leopard using a version of Python different from Panther and Tiger we should probably ship everything and add a runtime check here for the architecture and the version of Python, so what we redirect PYTHONPATH toward the right place script: - put X11 starting in a conditional test, true only on Tiger and Panther. This "should" allow Inkscape to start on Leopard. Needs to be tested though --- diff --git a/packaging/macosx/Resources/bin/inkscape b/packaging/macosx/Resources/bin/inkscape index 97f1268c4..53679e6c3 100755 --- a/packaging/macosx/Resources/bin/inkscape +++ b/packaging/macosx/Resources/bin/inkscape @@ -7,27 +7,30 @@ # CWD="`(cd \"\`dirname \\\"$0\\\"\`\"; echo $PWD)`" +# e.g. /Applications/Inkscape.app/Contents/Resources/bin TOP="`dirname \"$CWD\"`" +# e.g. /Applications/Inkscape.app/Contents/Resources -export DYLD_LIBRARY_PATH="$TOP/lib" -# add /usr/local/bin which, though standard, don't seem to be in the PATH -PATH="/usr/local/bin:$PATH" -# add python from MacPython http://homepages.cwi.nl/~jack/macpython/macpython-osx.html -if [ -d /Library/Frameworks/Python.framework/Versions/Current/bin ] -then - export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH" -fi -# add Fink -if [ -d /sw/bin ] -then - export PATH="/sw/bin/:$PATH" -fi -# add MacPorts (former DarwinPorts) -if [ -d /opt/local/bin ] -then - export PATH="/opt/local/bin:$PATH" + +# Brutally add many things to the PATH. If the directories do not exist, they won't be used anyway. +# People should really use ~/.macosx/environment.plist to set environment variables as explained by Apple: +# http://developer.apple.com/qa/qa2001/qa1067.html +# but since no one does, we correct this by making the 'classic' PATH additions here: +# /usr/local/bin which, though standard, doesn't seem to be in the PATH +# newer python as recommended by MacPython http://www.python.org/download/mac/ +# Fink +# MacPorts (former DarwinPorts) +export PATH="/opt/local/bin:/sw/bin/:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:$CWD:$PATH" + +# Test wether we are using the stock python install +# In which case we can use the python modules shipped alongside Inkscape, in the app bundle +if [ `which python` = "/usr/bin/python" ]; then + export PYTHONPATH="$TOP/python/site-packages" + # NB: we are only preprending some stuff to the default python path so if the directory does not exist it should not harm the rest fi -export PATH="$CWD:$PATH" + +export DYLD_LIBRARY_PATH="$TOP/lib" + export PANGO_RC_FILE="$HOME/.inkscape-etc/pangorc" export FONTCONFIG_PATH="$TOP/etc/fonts" export GTK_IM_MODULE_FILE="$HOME/.inkscape-etc/gtk.immodules" @@ -38,16 +41,18 @@ export GNOME_VFS_MODULE_CONFIG_PATH="$TOP/etc/gnome-vfs-2.0/modules" export GNOME_VFS_MODULE_PATH="$TOP/lib/gnome-vfs-2.0/modules" export INKSCAPE_SHAREDIR="$TOP" +# TODO: move the share directory to a its own folder to make things a bit cleaner in the app bundle export INKSCAPE_PLUGINDIR="$TOP/lib/inkscape" export INKSCAPE_LOCALEDIR="$TOP/locale" # Set GTK theme (only if there is no .gtkrc-2.0 in the user's home) if [[ ! -e $HOME/.gtkrc-2.0 ]]; then # prepare the theme depending on OS X appearance settings - HERE=`pwd` - cd "$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/" - ./sync_osx_look.sh - cd "$HERE" + ( + cd "$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/" + ./sync_osx_look.sh + # TODO: make this more robust, probably by integrating this script directly inline here + ) export GTK2_RC_FILES="$INKSCAPE_SHAREDIR/themes/Clearlooks-Quicksilver-OSX/gtk-2.0/gtkrc" fi diff --git a/packaging/macosx/Resources/script b/packaging/macosx/Resources/script index 5608f7423..986cb530b 100755 --- a/packaging/macosx/Resources/script +++ b/packaging/macosx/Resources/script @@ -5,30 +5,36 @@ CWD="`dirname \"$0\"`" +# System version: 3 for Panther, 4 for Tiger, 5 for Leopard +VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'` + +# FIXME apparently this removes the xterm that starts with X from xinitrc but when is it really used? Should we modify the .xinitrc of the user without warning? ps -wx -ocommand | grep -e '[X]11' > /dev/null if [ "$?" != "0" -a ! -f ~/.xinitrc ]; then echo "rm -f ~/.xinitrc" > ~/.xinitrc sed 's/xterm/# xterm/' /usr/X11R6/lib/X11/xinit/xinitrc >> ~/.xinitrc fi -cp -f "$CWD/bin/getdisplay.sh" /tmp/ -rm -f /tmp/display.$UID -open-x11 /tmp/getdisplay.sh || \ -open -a XDarwin /tmp/getdisplay.sh || \ -echo ":0" > /tmp/display.$UID - -while [ "$?" == "0" -a ! -f /tmp/display.$UID ]; do - sleep 1 -done -export DISPLAY="`cat /tmp/display.$UID`" +# For Panther and Tiger, start X11 +if [[ $VERSION -le 4 ]]; then + # Start X11 and get DISPLAY + cp -f "$CWD/bin/getdisplay.sh" /tmp/ + rm -f /tmp/display.$UID + open-x11 /tmp/getdisplay.sh || \ + open -a XDarwin /tmp/getdisplay.sh || \ + echo ":0" > /tmp/display.$UID + + while [ "$?" == "0" -a ! -f /tmp/display.$UID ]; do + sleep 1 + done + export DISPLAY="`cat /tmp/display.$UID`" + + ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11 +fi -ps -wx -ocommand | grep -e '[X]11' > /dev/null || exit 11 +# In Leopard, X11 should start on itself -# Old OS X version specific test: -# -#VERSION=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 -d'.'` -#if [ "$VERSION" -eq "4" ]; then # Warn the user about time-consuming generation of fontconfig caches. test -f ~/.inkscape/.fccache-new || exit 12 @@ -37,3 +43,4 @@ test -f ~/.inkscape/.fccache-new || exit 12 BASE="`echo "$0" | sed -e 's/\/Contents\/Resources\/script/\//'`" cd "$BASE" exec "$CWD/bin/inkscape" "$@" +# TODO examine wether it would be wisest to move the code from inkscape shell script and getdisplay.sh to here and only keep the real binary in bin. This may make things easier on Leopard and may also help using Inkscape on the command line \ No newline at end of file