Code

- Fix bug #396322: "Spell checker crashes the OS X package"
[inkscape.git] / packaging / macosx / osx-app.sh
index ac7cafd3cabdf740844f290e245679c50388a8e3..f28b9c4bf145ff2b5daeb27c597c4dd9f9e1edf3 100755 (executable)
@@ -121,6 +121,22 @@ if [ ! -e "$LIBPREFIX" ]; then
        exit 1
 fi
 
+if [ ! -e "$LIBPREFIX/share/themes/Clearlooks-Quicksilver" ]; then
+       echo "Missing Clearlooks -- please install gtk2-clearlooks and try again." >&2
+       exit 1
+fi
+
+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 [ ! -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
+
 if [ ! -f "$binary" ]; then
        echo "Need Inkscape binary" >&2
        exit 1
@@ -175,6 +191,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 +199,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 +235,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,12 +288,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}
+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
@@ -271,7 +305,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`
@@ -302,42 +336,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