Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bundle and modify all the necessary files to allow printing via Gtk.PrintOperation in Xamarin.Mac
echo 'etc/fonts/fonts.conf etc/pango/pango.modules lib/gtk-2.0/2.10.0/engines/libclearlooks.so lib/gtk-2.0/2.10.0/engines/libmurrine.so lib/gtk-2.0/2.10.0/engines/libquartz.so lib/gtk-2.0/2.10.0/engines/libsvg.so lib/gtk-2.0/2.10.0/engines/libxamarin.so lib/gtk-2.0/2.10.0/printbackends/libprintbackend-cups.so lib/gtk-2.0/2.10.0/printbackends/libprintbackend-file.so lib/gtk-2.0/2.10.0/printbackends/libprintbackend-lpr.so lib/gtk-2.0/modules/libferret.so lib/gtk-2.0/modules/libgail.so lib/pango/1.8.0/modules/pango-arabic-lang.so lib/pango/1.8.0/modules/pango-arabic-lang.so.dSYM/Contents/Info.plist lib/pango/1.8.0/modules/pango-arabic-lang.so.dSYM/Contents/Resources/DWARF/pango-arabic-lang.so lib/pango/1.8.0/modules/pango-basic-coretext.so lib/pango/1.8.0/modules/pango-basic-coretext.so.dSYM/Contents/Info.plist lib/pango/1.8.0/modules/pango-basic-coretext.so.dSYM/Contents/Resources/DWARF/pango-basic-coretext.so lib/pango/1.8.0/modules/pango-indic-lang.so lib/pango/1.8.0/modules/pango-indic-lang.so.dSYM/Contents/Info.plist lib/pango/1.8.0/modules/pango-indic-lang.so.dSYM/Contents/Resources/DWARF/pango-indic-lang.so' | tr ' ' '\n' | rsync -rlpt --files-from=/dev/stdin /Library/Frameworks/Mono.framework/Versions/Current/ "$1/Contents/MonoBundle/"
echo 'libatk-1.0.0.dylib libatksharpglue-2.so libcroco-0.6.3.dylib libffi.6.dylib libgailutil.18.dylib libgdk-quartz-2.0.0.dylib libgdk_pixbuf-2.0.0.dylib libgdksharpglue-2.so libgio-2.0.0.dylib libglibsharpglue-2.so libgmodule-2.0.0.dylib libgobject-2.0.0.dylib libgthread-2.0.0.dylib libgtk-quartz-2.0.0.dylib libgtksharpglue-2.so libpango-1.0.0.dylib libpangocairo-1.0.0.dylib libpangosharpglue-2.so librsvg-2.2.dylib libxml2.2.dylib' | tr ' ' '\n' | rsync -rlpt --files-from=/dev/stdin /Library/Frameworks/Mono.framework/Versions/Current/lib/ "$1/Contents/MonoBundle/"
sed -i '' 's:/Library/Frameworks/Mono.framework/Versions/3.12.1/:@executable_path/../MonoBundle/:' "$1/Contents/MonoBundle/etc/pango/pango.modules"
pushd "$1/Contents/MacOS"
NAME="`ls`"
mv -n "$NAME" "$NAME""-bin"
cat > "$NAME" << EOF
#!/bin/sh
name=\`basename "\$0"\`
macos=\$( cd \$( dirname \$0 ) && pwd )
contents=\`dirname "\$macos"\`
mono_bundle="\$contents/MonoBundle"
export FONTCONFIG_FILE="\$mono_bundle/etc/fonts/fonts.conf"
export PANGO_SYSCONFDIR="\$mono_bundle/etc"
export GTK_EXE_PREFIX="\$mono_bundle"
exec "\$contents/MacOS/\$name-bin" "\$@"
EOF
chmod +x "$NAME"
popd
sed -i '' 's/dll="libcairo-2.dll" target="libcairo.so.2"/dll="libcairo-2.dll" target="libcairo.2.dylib"/' "$1/Contents/MonoBundle/config"
cat >> "$1/Contents/MonoBundle/config" << EOF
<dllmap dll="gdiplus" target="libgdiplus.dylib" os="!windows"/>
<dllmap dll="gdiplus.dll" target="libgdiplus.dylib" os="!windows"/>
<dllmap dll="gdi32" target="libgdiplus.dylib" os="!windows"/>
<dllmap dll="gdi32.dll" target="libgdiplus.dylib" os="!windows"/>
<dllmap os="osx" dll="glibsharpglue-2" target="libglibsharpglue-2.so" />
<dllmap os="osx" dll="gthread-2.0.0" target="libgthread-2.0.0.dylib" />
<dllmap os="osx" dll="gthread-2.0" target="libgthread-2.0.dylib" />
<dllmap os="osx" dll="glib-2.0.0" target="libglib-2.0.0.dylib" />
<dllmap os="osx" dll="glib-2.0" target="libglib-2.0.dylib" />
<dllmap os="osx" dll="glibsharpglue-2" target="libglibsharpglue-2.so" />
<dllmap os="osx" dll="gtksharpglue-2" target="libgtksharpglue-2.so" />
<dllmap os="osx" dll="gobject-2.0.0" target="libgobject-2.0.0.dylib" />
<dllmap os="osx" dll="gobject-2.0" target="libgobject-2.0.dylib" />
<dllmap os="osx" dll="gtk-quartz-2.0.0" target="libgtk-quartz-2.0.0.dylib" />
<dllmap os="osx" dll="gtk-quartz-2.0" target="libgtk-quartz-2.0.dylib" />
EOF
sed -i '' -e '/\/configuration/ {N;H;d;}' -e '$ {p;x;s/\n//;}' "$1/Contents/MonoBundle/config"
find $1 -name "*.config" | while read FILE; do
sed -i "" 's:/Library/Frameworks/Mono.framework/Versions/3.12.1/lib/::' "$FILE";
done
find $1 -name "*.dylib" -or -name "*.so" | while read FILE; do
otool -L "$FILE" |
grep Mono\.framework |
sed 's/\s*//' | sed 's/ .*//' | while read LIB; do
install_name_tool -change "$LIB" '@executable_path/../MonoBundle/'"${LIB##*lib/}" "$FILE";
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.