[gedit/wip/3.14-osx] [osx] Reorganize bundle making



commit 4125fdf2d627e2cfceadae3502a962ec4acc94e6
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Mon Aug 25 18:54:43 2014 +0200

    [osx] Reorganize bundle making

 Makefile.am                                    |    2 +-
 configure.ac                                   |    2 +-
 osx/bundle/bundle                              |  205 ++++++++++++++++++++++++
 osx/{ => bundle/data}/Info.plist.in            |    4 +-
 osx/{ => bundle/data}/Makefile.am              |    0
 osx/{launcher.sh => bundle/data/gedit}         |   36 ++---
 osx/{ => bundle/data}/gedit.bundle             |   59 ++-----
 osx/{ => bundle/data}/gedit.icns               |  Bin 262019 -> 262019 bytes
 osx/{ => bundle/data}/geditdoc.icns            |  Bin 38861 -> 38861 bytes
 osx/{ => bundle/data}/template.dmg             |  Bin 19345408 -> 19345408 bytes
 osx/{dmg-data => bundle/images}/background.png |  Bin 31115 -> 31115 bytes
 osx/{dmg-data => bundle/images}/background.svg |    0
 osx/{ => bundle}/makedmg.sh                    |    0
 osx/makebundle.sh                              |   50 ------
 14 files changed, 238 insertions(+), 120 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 6859fd3..d5725e6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -92,7 +92,7 @@ CLEANFILES                =
 include data/Makefile.am
 include pixmaps/Makefile.am
 include win32/Makefile.am
-include osx/Makefile.am
+include osx/bundle/data/Makefile.am
 include tests/Makefile.am
 include plugins/Makefile.am
 include gedit/Makefile.am
diff --git a/configure.ac b/configure.ac
index d23fd23..ff9d843 100644
--- a/configure.ac
+++ b/configure.ac
@@ -461,7 +461,7 @@ plugins/filebrowser/org.gnome.gedit.plugins.filebrowser.gschema.xml.in
 plugins/pythonconsole/org.gnome.gedit.plugins.pythonconsole.gschema.xml.in
 plugins/time/org.gnome.gedit.plugins.time.gschema.xml.in
 po/Makefile.in
-osx/Info.plist])
+osx/bundle/data/Info.plist])
 
 AC_OUTPUT
 
diff --git a/osx/bundle/bundle b/osx/bundle/bundle
new file mode 100755
index 0000000..d9b658e
--- /dev/null
+++ b/osx/bundle/bundle
@@ -0,0 +1,205 @@
+#!/bin/bash
+
+pushd $(dirname "$0") > /dev/null
+D=$(pwd -P)
+popd > /dev/null
+
+ME="$0"
+BUNDLE="$D/gedit.app"
+
+function do_strip {
+       tp=$(file -b --mime-type "$1")
+
+       if [ "$tp" != "application/octet-stream" ]; then
+               return
+       fi
+
+       name=$(mktemp -t bundle)
+       st=$(stat -f %p "$1")
+
+       strip -o "$name" -S "$1"
+       mv -f "$name" "$1"
+
+       chmod "$st" "$1"
+       chmod u+w "$1"
+}
+
+function make_help_usage() {
+       echo "[-f]"
+}
+
+function make_help_short() {
+       echo "Make the gedit.app bundle"
+}
+
+function build_gtk_mac_bundler() {
+       b="$D/../build/build"
+       lbin=$("$b" env local-bin)
+
+       if [ -x "$lbin/gtk-mac-bundler" ]; then
+               return
+       fi
+
+       echo "Installing gtk-mac-bundler..."
+
+       home=$("$b" env home)
+       sbin="$home/source"
+
+       mkdir -p "$sbin"
+
+       (
+               cd "$sbin"
+
+               if [ ! -d gtk-mac-bundler ]; then
+                       git clone https://github.com/jessevdk/gtk-mac-bundler || exit 1
+               fi
+
+               (
+                       cd gtk-mac-bundler
+                       git checkout -b stable f1a829521fabda2266f346dfe86bf09c9401f87d || exit 1
+                       HOME="$home" make install
+               ) || exit 1
+       ) || exit 1
+}
+
+function cmd_make() {
+       build_gtk_mac_bundler
+
+       if [ -d "$BUNDLE" ] && [ "$1x" = "-fx" ]; then
+               rm -rf "$BUNDLE"
+       fi
+
+       b="$D/../build/build"
+
+       # No idea why it's not writable, but we need it to be so that install_name_tool
+       # can change the link paths
+       inst=$("$b" env inst)
+       chmod u+w "$inst/lib/libpython3.3m.dylib"
+
+       if [ ! -d "$BUNDLE" ]; then
+               lbin=$("$b" env local-bin)
+
+               echo "Generating bundle from gedit.bundle specification..."
+           "$b" run "$lbin/gtk-mac-bundler" "$D/data/gedit.bundle" || exit 1
+
+           mv "$D/data/gedit.app" "$BUNDLE"
+       else
+               echo "$BUNDLE bundle already exists, only stripping it..."
+       fi
+
+       echo "Removing unneeded files from bundle"
+
+       # Remove pyc and pyo files
+       for i in $(find "$BUNDLE/Contents/Resources/lib/python3"* -type f -regex '.*\.py[oc]' 2>/dev/null); do
+           rm -f "$i"
+       done
+
+       echo "Strip debug symbols from bundle binaries"
+
+       # Strip debug symbols from libraries/modules
+       for i in $(find -E "$BUNDLE/Contents/Resources" -type f -regex '.*\.(so|dylib)$' 2>/dev/null); do
+           do_strip "$i"
+       done
+
+       # Strip debug symbols from binaries
+       for i in $(find "$BUNDLE/Contents/Resources/bin" -type f 2>/dev/null); do
+           if [ -x "$i" ]; then
+               do_strip "$i"
+           fi
+       done
+
+       # Strip debug symbols from main binary
+       do_strip "$BUNDLE/Contents/MacOS/gedit-bin"
+}
+
+function help_help_short() {
+       echo "Shows this help message"
+}
+
+function cmd_help() {
+       if [ -z "$1" ]; then
+               echo "Usage: $ME [command]"
+               echo ""
+               echo "Available commands:"
+               echo ""
+
+               for cmd in "${commands[ ]}"; do
+                       printf "  \033[1m$cmd\x1B[0m "
+
+                       l=${#cmd}
+                       let d="$commandsmaxlen - $l + 1"
+
+                       printf "%${d}s" ""
+                       echo -n "- "
+
+                       if [[ $(type -t "${cmd}_help_short") = "function" ]]; then
+                               "${cmd}_help_short"
+                       else
+                               echo ""
+                       fi
+               done
+
+               echo ""
+       else
+               cmd="cmd_$1"
+
+               if [[ $(type -t "$cmd") != "function" ]]; then
+                       printf "Invalid command \033[1m$1\033[0m, available commands are: $cmds\n"
+                       exit 1
+               fi
+
+               printf "Usage: $ME \033[1m$1\033[0m "
+
+               if [[ $(type -t "$1_help_usage") = "function" ]]; then
+                       "$1_help_usage"
+               else
+                       echo ""
+               fi
+
+               echo ""
+
+               if [[ $(type -t "$1_help_long") != "function" ]]; then
+                       "$1_help_short"
+               else
+                       "$1_help_long"
+               fi
+       fi
+}
+
+commands=()
+commandsmaxlen=0
+
+while read line
+do
+       cmd=${line#declare -f }
+
+       if [[ "$cmd" = cmd_* ]]; then
+               cname=${cmd#cmd_}
+
+               commands+=($cname)
+
+               l=${#cname}
+
+               if [[ $l > $commandsmaxlen ]]; then
+                       commandsmaxlen=$l
+               fi
+       fi
+done < <(declare -F)
+
+cmds=$(printf ", \033[1m%s\033[0m" "${commands[ ]}")
+cmds=${cmds:2}
+
+if [ -z "$1" ]; then
+       cmd_help
+       exit 0
+fi
+
+cmd="cmd_$1"
+
+if [[ $(type -t "$cmd") != "function" ]]; then
+       printf "Invalid command $1, available commands are: $cmds\n"
+       exit 1
+fi
+
+shift 1
+"$cmd" "$@"
diff --git a/osx/Info.plist.in b/osx/bundle/data/Info.plist.in
similarity index 99%
rename from osx/Info.plist.in
rename to osx/bundle/data/Info.plist.in
index 538edc6..34e6e65 100644
--- a/osx/Info.plist.in
+++ b/osx/bundle/data/Info.plist.in
@@ -25,7 +25,9 @@
        <key>NSHumanReadableCopyright</key>
        <string>Copyright 2009 gedit, GNU General Public License.</string>
        <key>LSMinimumSystemVersion</key>
-       <string>10.4</string>
+       <string>10.7</string>
+       <key>CFBundleName</key>
+       <string>gedit</string>
        <key>CFBundleDocumentTypes</key>
        <array>
                <dict>
diff --git a/osx/Makefile.am b/osx/bundle/data/Makefile.am
similarity index 100%
rename from osx/Makefile.am
rename to osx/bundle/data/Makefile.am
diff --git a/osx/launcher.sh b/osx/bundle/data/gedit
similarity index 68%
rename from osx/launcher.sh
rename to osx/bundle/data/gedit
index 25f8e39..391fbbb 100755
--- a/osx/launcher.sh
+++ b/osx/bundle/data/gedit
@@ -5,9 +5,9 @@ if test "x$GTK_DEBUG_LAUNCHER" != x; then
 fi
 
 if test "x$GTK_DEBUG_GDB" != x; then
-       EXEC="gdb --args"
+       EXEC="lldb --"
 elif test "x$GTK_DEBUG_DTRUSS" != x; then
-       EXEC="dtruss"
+       EXEC="sudo dtruss sudo -u $USER"
 else
        EXEC=exec
 fi
@@ -15,7 +15,10 @@ fi
 name=$(basename "$0")
 dirn=$(dirname "$0")
 
-bundle=$(cd "$dirn/../../" && pwd)
+pushd "$dirn/../../" > /dev/null
+bundle=$(pwd -P)
+popd > /dev/null
+
 bundle_contents="$bundle"/Contents
 bundle_res="$bundle_contents"/Resources
 bundle_lib="$bundle_res"/lib
@@ -31,14 +34,15 @@ export GTK_DATA_PREFIX="$bundle_res"
 export GTK_EXE_PREFIX="$bundle_res"
 export GTK_PATH="$bundle_res"
 export GDK_PIXBUF_MODULE_FILE="$bundle_lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"
-export GIO_EXTRA_MODULES="$bundle_lib/gio/modules"
+#export GIO_EXTRA_MODULES="$bundle_lib/gio/modules"
 export GI_TYPELIB_PATH="$bundle_lib/girepository-1.0"
-export PYTHONPATH="$bundle_lib/python2.7/site-packages:$PYTHONPATH"
+export PYTHONPATH="$bundle_lib/python3.3/site-packages"
 export PYTHONHOME="$bundle_res"
 export PANGO_LIBDIR="$bundle_lib"
 export PANGO_SYSCONFDIR="$bundle_etc"
 export PEAS_PLUGIN_LOADERS_DIR="$bundle_lib/libpeas-1.0/loaders"
-export DBUS_REPLACE_INSTALL_PREFIX=$(printf '%q' "$bundle_res/")
+export ENCHANT_MODULES_DIR="$bundle_lib/enchant"
+export ENCHANT_DATA_DIR="$bundle_data/enchant"
 
 if test -f "$bundle_lib/charset.alias"; then
        export CHARSETALIASDIR="$bundle_lib"
@@ -50,31 +54,11 @@ if test -f "$bundle_res/environment.sh"; then
        source "$bundle_res/environment.sh"
 fi
 
-if test -f "$HOME/.geditenv"; then
-       source "$HOME/.geditenv"
-fi
-
 # Strip out the argument added by the OS.
 if [ x`echo "x$1" | sed -e "s/^x-psn_.*//"` == x ]; then
        shift 1
 fi
 
-# Launch dbus if needed
-dbusenv="$TMPDIR/gedit-$USER.dbus"
-
-if [ -f "$dbusenv" ]; then
-       source "$dbusenv"
-fi
-
-if [ -z "$DBUS_SESSION_BUS_PID" ] || ! ps -p "$DBUS_SESSION_BUS_PID" >/dev/null; then
-       "$bundle_bin/dbus-launch" --config-file "$bundle_etc/dbus-1/session.conf" > "$dbusenv"
-
-       source "$dbusenv"
-fi
-
-export DBUS_SESSION_BUS_PID
-export DBUS_SESSION_BUS_ADDRESS
-
 if [ "x$GTK_DEBUG_SHELL" != "x" ]; then
        exec bash
 else
diff --git a/osx/gedit.bundle b/osx/bundle/data/gedit.bundle
similarity index 65%
rename from osx/gedit.bundle
rename to osx/bundle/data/gedit.bundle
index 6806bf1..f477a78 100644
--- a/osx/gedit.bundle
+++ b/osx/bundle/data/gedit.bundle
@@ -21,17 +21,14 @@
     <destination overwrite="yes">${env:HOME}/Desktop</destination>
     -->
 
-    <image>
-      <!-- Not implemented yet (DMG image). -->
-    </image>
-
     <!-- Optionally specify a launcher script to use. If the
          application sets up everything needed itself, like
          environment variable, linker paths, etc, a launcher script is
          not needed. If the source path is left out, the default
          script will be used.
     -->
-    <launcher-script>${project}/launcher.sh</launcher-script>
+    <launcher-script>${project}/gedit</launcher-script>
+    <run-install-name-tool/>
   </meta>
 
   <!-- The special macro "${project}" refers to the directory where
@@ -48,9 +45,6 @@
   <!-- Copy in GTK+ im modules -->
   <binary>${prefix}/lib/gtk-3.0/${pkg:gtk+-3.0:gtk_binary_version}/immodules/*.so</binary>
 
-  <!-- Copy in GTK+ theming engines -->
-  <binary>${prefix}/lib/gtk-3.0/${pkg:gtk+-3.0:gtk_binary_version}/theming-engines/*.so</binary>
-
   <!-- Copy in pango modules -->
   <binary>${prefix}/lib/pango/${pkg:pango:pango_module_version}/modules/*.so</binary>
 
@@ -64,47 +58,32 @@
   <!-- Take the applespell enchant provider -->
   <binary>${prefix}/lib/enchant/libenchant_applespell.so</binary>
 
-  <!-- Copy in gio modules -->
-  <binary>${prefix}/lib/gio/modules/*.so</binary>
+  <!-- Copy in peas modules -->
+  <binary>${prefix}/lib/libpeas-1.0/loaders/*.so</binary>
 
   <!-- Copy in girepository typelibs -->
   <data>${prefix}/lib/girepository-1.0</data>
 
-  <!-- DBUS -->
-  <binary>${prefix}/bin/dbus-*</binary>
-  <data>${prefix}/etc/dbus-1</data>
-  <data>${prefix}/share/dbus-1</data>
-  <binary>${prefix}/libexec/dbus-daemon-launch-helper</binary>
+  <!-- Copy in gedit private girepository typelibs -->
+  <data>${prefix}/lib/gedit/girepository-1.0</data>
 
-  <!-- Copy in peas modules -->
-  <binary>${prefix}/lib/libpeas-1.0/loaders/*.so</binary>
 
   <!-- python -->
-  <binary>${prefix}/lib/python2.7/site-packages/cairo/*.so</binary>
-  <binary>${prefix}/lib/python2.7/site-packages/gi/*.so</binary>
-  <binary>${prefix}/lib/python2.7/site-packages/gi/_glib/*.so</binary>
-  <binary>${prefix}/lib/python2.7/site-packages/gi/_gobject/*.so</binary>
-  <binary>${prefix}/lib/python2.7/site-packages/libxml2mod.so</binary>
+  <binary>${prefix}/lib/python3.3/site-packages/cairo/*.so</binary>
+  <binary>${prefix}/lib/python3.3/site-packages/gi/*.so</binary>
+
+  <!--<data>${prefix}/lib/python3.3/site-packages/cairo</data>
+  <data>${prefix}/lib/python2.3/site-packages/gi</data>-->
 
-  <data>${prefix}/lib/python2.7/site-packages/cairo</data>
-  <data>${prefix}/lib/python2.7/site-packages/gi</data>
-  <data>${prefix}/lib/python2.7/site-packages/libxml2.py</data>
-  <data>${prefix}/include/python2.7/pyconfig.h</data>
+  <data>${prefix}/include/python3.3m/pyconfig.h</data>
 
-  <binary>${prefix}/lib/python2.7/lib-dynload/*.so</binary>
-  <data>${prefix}/lib/python2.7</data>
-  <binary>${prefix}/bin/python*</binary>
+  <binary>${prefix}/lib/python3.3/lib-dynload/*.so</binary>
+  <data>${prefix}/lib/python3.3</data>
+  <binary>${prefix}/bin/python3</binary>
 
   <!-- GTK+3 data -->
   <data>${prefix}/etc/gtk-3.0/*</data>
 
-  <!-- dconf -->
-  <binary>${prefix}/libexec/dconf-service</binary>
-
-  <!-- gvfs -->
-  <binary>${prefix}/libexec/gvfsd-*</binary>
-  <data>${prefix}/share/gvfs</data>
-
   <!-- gtksourceview -->
   <data>${prefix}/share/gtksourceview-3.0</data>
 
@@ -122,6 +101,8 @@
   <!-- Themes -->
   <data>${prefix}/share/themes/Default</data>
   <data>${prefix}/share/themes/Adwaita</data>
+  <data>${prefix}/share/themes/HighContrast</data>
+  <data>${prefix}/share/themes/Mac</data>
 
   <!-- App icon -->
   <data dest="${bundle}/Contents/Resources">${project}/gedit.icns</data>
@@ -131,10 +112,6 @@
   <data>${prefix}/share/glib-2.0/schemas/gschemas.compiled</data>
 
   <!-- Icon theme -->
+  <icon-theme icons="auto">Adwaita</icon-theme>
   <icon-theme icons="auto">gnome</icon-theme>
-  <!--<data>${prefix}/share/icons/gnome/16x16/apps/system-file-manager.png</data>
-  <data>${prefix}/share/icons/gnome/22x22/apps/system-file-manager.png</data>
-  <data>${prefix}/share/icons/gnome/24x24/apps/system-file-manager.png</data>
-  <data>${prefix}/share/icons/gnome/32x32/apps/system-file-manager.png</data>
-  <data>${prefix}/share/icons/gnome/scalable/apps/system-file-manager.svg</data>-->
 </app-bundle>
diff --git a/osx/dmg-data/background.svg b/osx/bundle/images/background.svg
similarity index 100%
rename from osx/dmg-data/background.svg
rename to osx/bundle/images/background.svg
diff --git a/osx/makedmg.sh b/osx/bundle/makedmg.sh
similarity index 100%
rename from osx/makedmg.sh
rename to osx/bundle/makedmg.sh


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]