[vlc-commits] macOS: Rework dmg creation

Marvin Scholz git at videolan.org
Sat Feb 25 19:52:38 CET 2017


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Sat Feb 25 19:30:23 2017 +0100| [a7847f6fd681c9bc7c90b501f4dcb766072f240b] | committer: Marvin Scholz

macOS: Rework dmg creation

This adds the possibility to build fancy DMGs with background, dmg icon
and special icon positions using the dmgbuild python tool.

If dmgbuild is not available, it will fallback and make a normal DMG.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a7847f6fd681c9bc7c90b501f4dcb766072f240b
---

 extras/package/macosx/dmg/dmg_settings.py | 73 +++++++++++++++++++++++++++++++
 extras/package/macosx/dmg_setup.scpt      | 25 -----------
 extras/package/macosx/package.mak         | 35 ++++++++-------
 3 files changed, 92 insertions(+), 41 deletions(-)

diff --git a/extras/package/macosx/dmg/dmg_settings.py b/extras/package/macosx/dmg/dmg_settings.py
new file mode 100644
index 0000000..19cb215
--- /dev/null
+++ b/extras/package/macosx/dmg/dmg_settings.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+import os
+
+# Configuration file for the dmgbuild tool, used to build
+# a fancy DMG for VLC, with background image and aligned
+# icons.
+#
+# This is python, so make sure to write valid python,
+# do NOT indent using tabs.
+#
+# To build a fancy dmg, make sure configure finds dmgbuild
+# in your PATH and just do:
+#    make package-macosx
+#
+# To use directly, use this:
+#    dmgbuild -s dmgsettings.py "VLC Media Player" VLC.dmg
+#
+# To specify a different App location:
+#    dmgbuild -s dmgsettings.py -D app=/path/to/My.app "My Application" MyApp.dmg
+
+# Application settings
+application = defines.get('app', 'VLC.app')
+appname = os.path.basename(application)
+
+# Volume format (see hdiutil create -help)
+format = defines.get('format', 'UDBZ')
+
+# Volume size (must be large enough for your files)
+size = defines.get('size', '150M')
+
+# Files to include
+files = [ application ]
+
+# Symlinks to create
+symlinks = { 'Applications': '/Applications' }
+
+# Location of the icons
+icon_locations = {
+    appname:        (181, 108),
+    'Applications': (392, 108),
+}
+
+# Background
+background = 'background.tiff'
+
+# Window configuration
+show_status_bar = False
+show_tab_view = False
+show_toolbar = False
+show_pathbar = False
+show_sidebar = False
+sidebar_width = 180
+default_view = 'icon-view'
+
+# Window rect in ((x, y), (w, h)) format
+window_rect = ((100, 100), (573, 340))
+
+# Volume icon or badge icon
+icon = 'disk_image.icns'
+#badge_icon = '/path/to/icon.icns'
+
+# General view configuration
+show_icon_preview = False
+
+# Icon view configuration
+arrange_by = None
+grid_offset = (0, 0)
+grid_spacing = 100
+scroll_position = (0, 0)
+label_pos = 'bottom' # or 'right'
+text_size = 14
+icon_size = 95
diff --git a/extras/package/macosx/dmg_setup.scpt b/extras/package/macosx/dmg_setup.scpt
deleted file mode 100644
index 678175e..0000000
--- a/extras/package/macosx/dmg_setup.scpt
+++ /dev/null
@@ -1,25 +0,0 @@
-on run argv
-    tell application "Finder"
-        tell disk (item 1 of argv)
-            open
-            set current view of container window to icon view
-            set toolbar visible of container window to false
-            set statusbar visible of container window to false
-            set the bounds of container window to {300, 100, 750, 500}
-            set theViewOptions to the icon view options of container window
-            set arrangement of theViewOptions to not arranged
-            set icon size of theViewOptions to 104
-            # Don't set a background image, for now
-            # set background picture of theViewOptions to file ".background/background.png"
-            set position of item "VLC.app" of container window to {110, 100}
-            set position of item "Applications" of container window to {335, 100}
-            set position of item "Read Me.rtf" of container window to {110, 275}
-            set position of item "Goodies" of container window to {335, 275}
-            # Force saving changes to the disk by closing and opening the window
-            close
-            open
-            update without registering applications
-            delay 5
-        end tell
-    end tell
-end run
diff --git a/extras/package/macosx/package.mak b/extras/package/macosx/package.mak
index 1d912d7..1c35e92 100644
--- a/extras/package/macosx/package.mak
+++ b/extras/package/macosx/package.mak
@@ -57,23 +57,24 @@ endif
 
 
 package-macosx: VLC.app
-	mkdir -p "$(top_builddir)/vlc-$(VERSION)/Goodies/"
+if HAVE_DMGBUILD
+	@echo "Packaging fancy DMG using dmgbuild"
+	cd "$(top_srcdir)/extras/package/macosx/dmg" && dmgbuild -s "dmg_settings.py" \
+		-D app="$(abs_top_builddir)/VLC.app" "VLC Media Player" "$(abs_top_builddir)/vlc-$(VERSION).dmg"
+else !HAVE_DMGBUILD
+	@echo "Packaging non-fancy DMG"
+	## Create directory for DMG contents
+	mkdir -p "$(top_builddir)/vlc-$(VERSION)"
+	## Copy contents
 	cp -R "$(top_builddir)/VLC.app" "$(top_builddir)/vlc-$(VERSION)/VLC.app"
-	cd $(srcdir); cp AUTHORS COPYING README THANKS NEWS $(abs_top_builddir)/vlc-$(VERSION)/Goodies/
-	$(LN_S) -f /Applications $(top_builddir)/vlc-$(VERSION)/
-	rm -f "$(top_builddir)/vlc-$(VERSION)-rw.dmg"
-	hdiutil create -verbose -srcfolder "$(top_builddir)/vlc-$(VERSION)" "$(top_builddir)/vlc-$(VERSION)-rw.dmg" -scrub -format UDRW
-	mkdir -p ./mount
-	hdiutil attach -readwrite -noverify -noautoopen -mountRoot ./mount "vlc-$(VERSION)-rw.dmg"
-	-osascript "$(srcdir)"/extras/package/macosx/dmg_setup.scpt "vlc-$(VERSION)"
-	hdiutil detach ./mount/"vlc-$(VERSION)"
-# Make sure the image is not writable
-# Note: We can't directly create a read only dmg as we do the bless stuff
-	rm -f "$(top_builddir)/vlc-$(VERSION).dmg"
-	hdiutil convert "$(top_builddir)/vlc-$(VERSION)-rw.dmg" -format UDBZ -o "$(top_builddir)/vlc-$(VERSION).dmg"
-	ls -l "$(top_builddir)/vlc-$(VERSION).dmg"
-	rm -f "$(top_builddir)/vlc-$(VERSION)-rw.dmg"
+	## Symlink to Applications so users can easily drag-and-drop the App to it
+	$(LN_S) -f /Applications "$(top_builddir)/vlc-$(VERSION)/"
+	## Create DMG
+	hdiutil create -srcfolder "$(top_builddir)/vlc-$(VERSION)" -volname "VLC Media Player" \
+		-format UDBZ -o "$(top_builddir)/vlc-$(VERSION).dmg"
+	## Cleanup
 	rm -rf "$(top_builddir)/vlc-$(VERSION)"
+endif
 
 package-macosx-zip: VLC.app
 	mkdir -p $(top_builddir)/vlc-$(VERSION)/Goodies/
@@ -112,7 +113,9 @@ EXTRA_DIST += \
 	extras/package/macosx/build.sh \
 	extras/package/macosx/codesign.sh \
 	extras/package/macosx/configure.sh \
-	extras/package/macosx/dmg_setup.scpt \
+	extras/package/macosx/dmg/dmg_settings.py \
+	extras/package/macosx/dmg/disk_image.icns \
+	extras/package/macosx/dmg/background.tiff \
 	extras/package/macosx/fullscreen_panel.svg \
 	extras/package/macosx/vlc_status_icon.svg \
 	extras/package/macosx/vlc_app_icon.svg \



More information about the vlc-commits mailing list