Commit a7847f6f authored by Marvin Scholz's avatar 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.
parent 5074dc0c
# -*- 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
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
...@@ -57,23 +57,24 @@ endif ...@@ -57,23 +57,24 @@ endif
package-macosx: VLC.app 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" 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/ ## Symlink to Applications so users can easily drag-and-drop the App to it
$(LN_S) -f /Applications $(top_builddir)/vlc-$(VERSION)/ $(LN_S) -f /Applications "$(top_builddir)/vlc-$(VERSION)/"
rm -f "$(top_builddir)/vlc-$(VERSION)-rw.dmg" ## Create DMG
hdiutil create -verbose -srcfolder "$(top_builddir)/vlc-$(VERSION)" "$(top_builddir)/vlc-$(VERSION)-rw.dmg" -scrub -format UDRW hdiutil create -srcfolder "$(top_builddir)/vlc-$(VERSION)" -volname "VLC Media Player" \
mkdir -p ./mount -format UDBZ -o "$(top_builddir)/vlc-$(VERSION).dmg"
hdiutil attach -readwrite -noverify -noautoopen -mountRoot ./mount "vlc-$(VERSION)-rw.dmg" ## Cleanup
-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"
rm -rf "$(top_builddir)/vlc-$(VERSION)" rm -rf "$(top_builddir)/vlc-$(VERSION)"
endif
package-macosx-zip: VLC.app package-macosx-zip: VLC.app
mkdir -p $(top_builddir)/vlc-$(VERSION)/Goodies/ mkdir -p $(top_builddir)/vlc-$(VERSION)/Goodies/
...@@ -112,7 +113,9 @@ EXTRA_DIST += \ ...@@ -112,7 +113,9 @@ EXTRA_DIST += \
extras/package/macosx/build.sh \ extras/package/macosx/build.sh \
extras/package/macosx/codesign.sh \ extras/package/macosx/codesign.sh \
extras/package/macosx/configure.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/fullscreen_panel.svg \
extras/package/macosx/vlc_status_icon.svg \ extras/package/macosx/vlc_status_icon.svg \
extras/package/macosx/vlc_app_icon.svg \ extras/package/macosx/vlc_app_icon.svg \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment