Code

- Prevent the python packages from accidently being left out of the
[inkscape.git] / packaging / macosx / osx-app.sh
index ba6b7570d45e318d6590161e6e7e738edcaae5fa..b8d608a80b7d27a51546f1765a1b00439fb17ba9 100755 (executable)
@@ -1,12 +1,13 @@
 #!/bin/bash
 #
 # USAGE
-# osx-app [-s] [-py /path/to/python/modules] [-l /path/to/libraries] -b /path/to/bin/inkscape -p /path/to/Info.plist
+# osx-app [-s] [-l /path/to/libraries] -py /path/to/python/modules [-l /path/to/libraries] -b /path/to/bin/inkscape -p /path/to/Info.plist
 #
 # This script attempts to build an Inkscape.app package for OS X, resolving
-# dynamic libraries, etc.       
-# It strips the executable and libraries if '-s' is given.
-# It adds python modules if the '-py option' is given
+# dynamic libraries, etc.
+# 
+# If the '-s' option is given, then the libraries and executable are stripped.
+# 
 # The Info.plist file can be found in the base inkscape directory once
 # configure has been run.
 #
@@ -16,8 +17,8 @@
 #               Jean-Olivier Irisson <jo.irisson@gmail.com>
 # 
 # Copyright (C) 2005 Kees Cook
-# Copyright (C) 2005-2007 Michael Wybrow
-# Copyright (C) 2007 Jean-Olivier Irisson
+# Copyright (C) 2005-2009 Michael Wybrow
+# Copyright (C) 2007-2009 Jean-Olivier Irisson
 #
 # Released under GNU GPL, read the file 'COPYING' for more information
 #
@@ -49,7 +50,7 @@ echo -e "
 Create an app bundle for OS X
 
 \033[1mUSAGE\033[0m
-       $0 [-s] [-py /path/to/python/modules] [-l /path/to/libraries] -b /path/to/bin/inkscape -p /path/to/Info.plist
+       $0 [-s] [-l /path/to/libraries] -py /path/to/python/modules -b /path/to/bin/inkscape -p /path/to/Info.plist
 
 \033[1mOPTIONS\033[0m
        \033[1m-h,--help\033[0m 
@@ -109,11 +110,42 @@ done
 echo -e "\n\033[1mCREATE INKSCAPE APP BUNDLE\033[0m\n"
 
 # Safety tests
-if [ ${add_python} = "true" ]; then
-       if [ ! -e "$python_dir" ]; then
-               echo "Cannot find the directory containing python modules: $python_dir" >&2
-               exit 1
-       fi
+
+if [ "x$binary" == "x" ]; then
+       echo "Inkscape binary path not specified." >&2
+       exit 1
+fi
+
+if [ ! -x "$binary" ]; then
+       echo "Inkscape executable not not found at $binary." >&2
+       exit 1
+fi
+
+if [ "x$plist" == "x" ]; then
+       echo "Info.plist file not specified." >&2
+       exit 1
+fi
+
+if [ ! -f "$plist" ]; then
+       echo "Info.plist file not found at $plist." >&2
+       exit 1
+fi
+
+PYTHONPACKURL="http://inkscape.modevia.com/macosx-snap/Python-packages.dmg"
+
+if [ "x$python_dir" == "x" ]; then
+       echo "Python modules directory not specified." >&2
+       echo "Python modules can be downloaded from:" >&2
+       echo "    $PYTHONPACKURL" >&2
+       exit 1
+fi
+
+if [ ! -e "$python_dir/i386" -o ! -e "$python_dir/ppc" ]; then
+       echo "Directory does not appear to contain the i386 and ppc python modules:" >&2
+       echo "    $python_dir" >&2
+       echo "Python modules can be downloaded from:" >&2
+       echo "    $PYTHONPACKURL" >&2
+       exit 1
 fi
 
 if [ ! -e "$LIBPREFIX" ]; then
@@ -121,18 +153,19 @@ if [ ! -e "$LIBPREFIX" ]; then
        exit 1
 fi
 
-if [ ! -f "$binary" ]; then
-       echo "Need Inkscape binary" >&2
+if [ ! -e "$LIBPREFIX/share/themes/Clearlooks-Quicksilver" ]; then
+       echo "Missing Clearlooks -- please install gtk2-clearlooks and try again." >&2
        exit 1
 fi
 
-if [ ! -f "$plist" ]; then
-       echo "Need plist file" >&2
+if [ ! -e "$LIBPREFIX/lib/gnome-vfs-2.0" ]; then
+       echo "Missing gnome-vfs -- please install gnome-vfs and try again." >&2
        exit 1
 fi
 
-if [ ! -x "$binary" ]; then
-       echo "Not executable: $binary" >&2
+if [ ! -e "$LIBPREFIX/lib/aspell-0.60/en.dat" ]; then
+       echo "Missing aspell en dictionary -- please install at least 'aspell-dict-en', but" >&2
+       echo "preferably all dictionaries ('aspell-dict-*') and try again." >&2
        exit 1
 fi
 
@@ -175,6 +208,7 @@ pkgbin="$package/Contents/Resources/bin"
 pkglib="$package/Contents/Resources/lib"
 pkglocale="$package/Contents/Resources/locale"
 pkgpython="$package/Contents/Resources/python/site-packages/"
+pkgresources="$package/Contents/Resources"
 
 mkdir -p "$pkgexec"
 mkdir -p "$pkgbin"
@@ -182,6 +216,15 @@ mkdir -p "$pkglib"
 mkdir -p "$pkglocale"
 mkdir -p "$pkgpython"
 
+mkdir -p "$pkgresources/Dutch.lprj"
+mkdir -p "$pkgresources/English.lprj"
+mkdir -p "$pkgresources/French.lprj"
+mkdir -p "$pkgresources/German.lprj"
+mkdir -p "$pkgresources/Italian.lprj"
+mkdir -p "$pkgresources/Spanish.lprj"
+mkdir -p "$pkgresources/fi.lprj"
+mkdir -p "$pkgresources/no.lprj"
+mkdir -p "$pkgresources/sv.lprj"
 
 # Build and add the launcher
 #----------------------------------------------------------
@@ -209,12 +252,16 @@ cp -v "$binary" "$binpath"
 # TODO Add a "$verbose" variable and command line switch, which sets wether these commands are verbose or not
 
 # Share files
-rsync -av "$binary_dir/../share/$binary_name"/* "$package/Contents/Resources/"
+rsync -av "$binary_dir/../share/$binary_name"/* "$pkgresources/"
 cp "$plist" "$package/Contents/Info.plist"
-rsync -av "$binary_dir/../share/locale"/* "$package/Contents/Resources/locale"
+rsync -av "$binary_dir/../share/locale"/* "$pkgresources/locale"
+
+# Copy GTK shared mime information
+mkdir -p "$pkgresources/share"
+cp -rp "$LIBPREFIX/share/mime" "$pkgresources/share/"
 
 # Icons and the rest of the script framework
-rsync -av --exclude ".svn" "$resdir"/Resources/* "$package"/Contents/Resources/
+rsync -av --exclude ".svn" "$resdir"/Resources/* "$pkgresources/"
 
 # Add python modules if requested
 if [ ${add_python} = "true" ]; then
@@ -258,14 +305,16 @@ mkdir -p $pkglib/pango/$pango_version/modules
 cp $LIBPREFIX/lib/pango/$pango_version/modules/*.so $pkglib/pango/$pango_version/modules/
 
 gtk_version=`pkg-config --variable=gtk_binary_version gtk+-2.0`
-mkdir -p $pkglib/gtk-2.0/$gtk_version/{engines,immodules,loaders}
-cp -r $LIBPREFIX/lib/gtk-2.0/$gtk_version/engines/* $pkglib/gtk-2.0/$gtk_version/engines/
-cp $LIBPREFIX/lib/gtk-2.0/$gtk_version/immodules/*.so $pkglib/gtk-2.0/$gtk_version/immodules/
-cp $LIBPREFIX/lib/gtk-2.0/$gtk_version/loaders/*.so $pkglib/gtk-2.0/$gtk_version/loaders/
+mkdir -p $pkglib/gtk-2.0/$gtk_version/{engines,immodules,loaders,printbackends}
+cp -r $LIBPREFIX/lib/gtk-2.0/$gtk_version/* $pkglib/gtk-2.0/$gtk_version/
 
 mkdir -p $pkglib/gnome-vfs-2.0/modules
 cp $LIBPREFIX/lib/gnome-vfs-2.0/modules/*.so $pkglib/gnome-vfs-2.0/modules/
 
+# Copy aspell dictionary files:
+cp -r "$LIBPREFIX/lib/aspell-0.60" "$pkglib/"
+cp -r "$LIBPREFIX/share/aspell" "$pkgresources/share/"
+
 # Find out libs we need from fink, darwinports, or from a custom install
 # (i.e. $LIBPREFIX), then loop until no changes.
 a=1
@@ -273,7 +322,7 @@ nfiles=0
 endl=true
 while $endl; do
        echo -e "\033[1mLooking for dependencies.\033[0m Round" $a
-       libs="`otool -L $pkglib/gtk-2.0/$gtk_version/loaders/* $pkglib/gtk-2.0/$gtk_version/immodules/* $pkglib/gtk-2.0/$gtk_version/engines/*.so $pkglib/pango/$pango_version/modules/* $pkglib/gnome-vfs-2.0/modules/* $package/Contents/Resources/lib/* $binary 2>/dev/null | fgrep compatibility | cut -d\( -f1 | grep $LIBPREFIX | sort | uniq`"
+       libs="`otool -L $pkglib/gtk-2.0/$gtk_version/{engines,immodules,loaders,printbackends}/*.{dylib,so} $pkglib/pango/$pango_version/modules/* $pkglib/gnome-vfs-2.0/modules/* $package/Contents/Resources/lib/* $binary 2>/dev/null | fgrep compatibility | cut -d\( -f1 | grep $LIBPREFIX | sort | uniq`"
        cp -f $libs $package/Contents/Resources/lib
        let "a+=1"      
        nnfiles=`ls $package/Contents/Resources/lib | wc -l`
@@ -304,42 +353,72 @@ fi
 #                              Instead we leave them with their original install_names and set
 #                              DYLD_LIBRARY_PATH within the app bundle before running Inkscape.
 #
-# fixlib () {
-#              # Fix a given executable or library to be relocatable
-#              if [ ! -d "$1" ]; then
-#                      echo $1
-#                      libs="`otool -L $1 | fgrep compatibility | cut -d\( -f1`"
-#                      for lib in $libs; do
-#                              echo "  $lib"
-#                              base=`echo $lib | awk -F/ '{print $NF}'`
-#                              first=`echo $lib | cut -d/ -f1-3`
-#                              to=@executable_path/../lib/$base
-#                              if [ $first != /usr/lib -a $first != /usr/X11R6 ]; then
-#                                      /usr/bin/install_name_tool -change $lib $to $1
-#                                      if [ "`echo $lib | fgrep libcrypto`" = "" ]; then
-#                                              /usr/bin/install_name_tool -id $to ../lib/$base
-#                                              for ll in $libs; do
-#                                                      base=`echo $ll | awk -F/ '{print $NF}'`
-#                                                      first=`echo $ll | cut -d/ -f1-3`
-#                                                      to=@executable_path/../lib/$base
-#                                                      if [ $first != /usr/lib -a $first != /usr/X11R6 -a "`echo $ll | fgrep libcrypto`" = "" ]; then
-#                                                              /usr/bin/install_name_tool -change $ll $to ../lib/$base
-#                                                      fi
-#                                              done
-#                                      fi
-#                              fi
-#                      done
-#              fi
-# }
+fixlib () {
+       libPath="`echo $2 | sed 's/.*Resources//'`"
+       pkgPath="`echo $2 | sed 's/Resources\/.*/Resources/'`"
+       # Fix a given executable or library to be relocatable
+       if [ ! -d "$1" ]; then
+               libs="`otool -L $1 | fgrep compatibility | cut -d\( -f1`"
+               for lib in $libs; do
+                       echo "  $lib"
+                       base=`echo $lib | awk -F/ '{print $NF}'`
+                       first=`echo $lib | cut -d/ -f1-3`
+                       relative=`echo $lib | cut -d/ -f4-`
+                       to=@executable_path/../$relative
+                       if [ $first != /usr/lib -a $first != /usr/X11 -a $first != /System/Library ]; then
+                               /usr/bin/install_name_tool -change $lib $to $1
+                               if [ "`echo $lib | fgrep libcrypto`" = "" ]; then
+                                       /usr/bin/install_name_tool -id $to $1
+                                       for ll in $libs; do
+                                               base=`echo $ll | awk -F/ '{print $NF}'`
+                                               first=`echo $ll | cut -d/ -f1-3`
+                                               relative=`echo $ll | cut -d/ -f4-`
+                                               to=@executable_path/../$relative
+                                               if [ $first != /usr/lib -a $first != /usr/X11 -a $first != /System/Library -a "`echo $ll | fgrep libcrypto`" = "" ]; then
+                                                       /usr/bin/install_name_tool -change $ll $to $pkgPath/$relative
+                                               fi
+                                       done
+                               fi
+                       fi
+               done
+       fi
+}
 # 
 # Fix package deps
-#(cd "$package/Contents/MacOS/bin"
+# (cd "$package/Contents/Resources/lib/gtk-2.0/2.10.0/loaders"
+# for file in *.so; do
+#      echo "Rewriting dylib paths for $file..."
+#      fixlib "$file" "`pwd`"
+# done
+# )
+# (cd "$package/Contents/Resources/lib/gtk-2.0/2.10.0/engines"
+# for file in *.so; do
+#      echo "Rewriting dylib paths for $file..."
+#      fixlib "$file" "`pwd`"
+# done
+# )
+# (cd "$package/Contents/Resources/lib/gtk-2.0/2.10.0/immodules"
+# for file in *.so; do
+#      echo "Rewriting dylib paths for $file..."
+#      fixlib "$file" "`pwd`"
+# done
+# )
+# (cd "$package/Contents/Resources/lib/gtk-2.0/2.10.0/printbackends"
+# for file in *.so; do
+#      echo "Rewriting dylib paths for $file..."
+#      fixlib "$file" "`pwd`"
+# done
+# )
+# (cd "$package/Contents/Resources/bin"
 # for file in *; do
-#               fixlib "$file"
+#      echo "Rewriting dylib paths for $file..."
+#      fixlib "$file" "`pwd`"
 # done
 # cd ../lib
-# for file in *; do
-#               fixlib "$file"
-# done)
+# for file in *.dylib; do
+#      echo "Rewriting dylib paths for $file..."
+#      fixlib "$file" "`pwd`"
+# done
+# )
 
 exit 0