1- # -*- coding: utf-8 -*-
2- from __future__ import unicode_literals
3-
4- import biplist
51import os .path
2+ import plistlib
63
74#
8- # Settings file for dmgbuild
5+ # Example settings file for dmgbuild
96#
107
118# Use like this: dmgbuild -s settings.py "Test Volume" test.dmg
129
13- # You can actually use this file for any application (not just TextEdit)
10+ # You can actually use this file for your own application (not just TextEdit)
1411# by doing e.g.
1512#
1613# dmgbuild -s settings.py -D app=/path/to/My.app "My Application" MyApp.dmg
1714
1815# .. Useful stuff ..............................................................
1916
20- application = defines .get (' app' , '/ Applications/TextEdit.app' ) # default
17+ application = defines .get (" app" , "/System/ Applications/TextEdit.app" ) # noqa: F821
2118appname = os .path .basename (application )
2219
20+
2321def icon_from_app (app_path ):
24- plist_path = os .path .join (app_path , 'Contents' , 'Info.plist' )
25- plist = biplist .readPlist (plist_path )
26- icon_name = plist ['CFBundleIconFile' ]
27- icon_root ,icon_ext = os .path .splitext (icon_name )
22+ plist_path = os .path .join (app_path , "Contents" , "Info.plist" )
23+ with open (plist_path , "rb" ) as f :
24+ plist = plistlib .load (f )
25+ icon_name = plist ["CFBundleIconFile" ]
26+ icon_root , icon_ext = os .path .splitext (icon_name )
2827 if not icon_ext :
29- icon_ext = ' .icns'
28+ icon_ext = " .icns"
3029 icon_name = icon_root + icon_ext
31- return os .path .join (app_path , 'Contents' , 'Resources' , icon_name )
30+ return os .path .join (app_path , "Contents" , "Resources" , icon_name )
31+
3232
3333# .. Basics ....................................................................
3434
@@ -39,31 +39,38 @@ def icon_from_app(app_path):
3939# volume_name = 'Test'
4040
4141# Volume format (see hdiutil create -help)
42- format = defines .get ('format' , 'UDBZ' )
42+ format = defines .get ("format" , "UDBZ" ) # noqa: F821
43+
44+ # Compression level (if relevant)
45+ # compression_level = 9
4346
4447# Volume size
45- size = defines .get (' size' , None )
48+ size = defines .get (" size" , None ) # noqa: F821
4649
4750# Files to include
48- files = [ application ]
51+ files = [application ]
4952
5053# Symlinks to create
51- symlinks = { 'Applications' : '/Applications' }
54+ symlinks = {"Applications" : "/Applications" }
55+
56+ # Files to hide
57+ # hide = [ 'Secret.data' ]
58+
59+ # Files to hide the extension of
60+ # hide_extension = [ 'README.rst' ]
5261
5362# Volume icon
5463#
5564# You can either define icon, in which case that icon file will be copied to the
5665# image, *or* you can define badge_icon, in which case the icon file you specify
57- # will be used to badge the system's Removable Disk icon
66+ # will be used to badge the system's Removable Disk icon. Badge icons require
67+ # pyobjc-framework-Quartz.
5868#
59- #icon = '/path/to/icon.icns'
69+ # icon = '/path/to/icon.icns'
6070badge_icon = icon_from_app (application )
6171
6272# Where to put the icons
63- icon_locations = {
64- appname : (140 , 120 ),
65- 'Applications' : (500 , 120 )
66- }
73+ icon_locations = {appname : (140 , 120 ), "Applications" : (500 , 120 )}
6774
6875# .. Window configuration ......................................................
6976
@@ -87,7 +94,7 @@ def icon_from_app(app_path):
8794#
8895# Other color components may be expressed either in the range 0 to 1, or
8996# as percentages (e.g. 60% is equivalent to 0.6).
90- background = ' builtin-arrow'
97+ background = " builtin-arrow"
9198
9299show_status_bar = False
93100show_tab_view = False
@@ -106,23 +113,23 @@ def icon_from_app(app_path):
106113# 'column-view'
107114# 'coverflow'
108115#
109- default_view = ' icon-view'
116+ default_view = " icon-view"
110117
111118# General view configuration
112119show_icon_preview = False
113120
114121# Set these to True to force inclusion of icon/list view settings (otherwise
115122# we only include settings for the default view)
116- include_icon_view_settings = ' auto'
117- include_list_view_settings = ' auto'
123+ include_icon_view_settings = " auto"
124+ include_list_view_settings = " auto"
118125
119126# .. Icon view configuration ...................................................
120127
121128arrange_by = None
122129grid_offset = (0 , 0 )
123130grid_spacing = 100
124131scroll_position = (0 , 0 )
125- label_pos = ' bottom' # or 'right'
132+ label_pos = " bottom" # or 'right'
126133text_size = 16
127134icon_size = 128
128135
@@ -144,34 +151,34 @@ def icon_from_app(app_path):
144151list_icon_size = 16
145152list_text_size = 12
146153list_scroll_position = (0 , 0 )
147- list_sort_by = ' name'
154+ list_sort_by = " name"
148155list_use_relative_dates = True
149- list_calculate_all_sizes = False ,
150- list_columns = (' name' , ' date-modified' , ' size' , ' kind' , ' date-added' )
156+ list_calculate_all_sizes = ( False ,)
157+ list_columns = (" name" , " date-modified" , " size" , " kind" , " date-added" )
151158list_column_widths = {
152- ' name' : 300 ,
153- ' date-modified' : 181 ,
154- ' date-created' : 181 ,
155- ' date-added' : 181 ,
156- ' date-last-opened' : 181 ,
157- ' size' : 97 ,
158- ' kind' : 115 ,
159- ' label' : 100 ,
160- ' version' : 75 ,
161- ' comments' : 300 ,
162- }
159+ " name" : 300 ,
160+ " date-modified" : 181 ,
161+ " date-created" : 181 ,
162+ " date-added" : 181 ,
163+ " date-last-opened" : 181 ,
164+ " size" : 97 ,
165+ " kind" : 115 ,
166+ " label" : 100 ,
167+ " version" : 75 ,
168+ " comments" : 300 ,
169+ }
163170list_column_sort_directions = {
164- ' name' : ' ascending' ,
165- ' date-modified' : ' descending' ,
166- ' date-created' : ' descending' ,
167- ' date-added' : ' descending' ,
168- ' date-last-opened' : ' descending' ,
169- ' size' : ' descending' ,
170- ' kind' : ' ascending' ,
171- ' label' : ' ascending' ,
172- ' version' : ' ascending' ,
173- ' comments' : ' ascending' ,
174- }
171+ " name" : " ascending" ,
172+ " date-modified" : " descending" ,
173+ " date-created" : " descending" ,
174+ " date-added" : " descending" ,
175+ " date-last-opened" : " descending" ,
176+ " size" : " descending" ,
177+ " kind" : " ascending" ,
178+ " label" : " ascending" ,
179+ " version" : " ascending" ,
180+ " comments" : " ascending" ,
181+ }
175182
176183# .. License configuration .....................................................
177184
@@ -193,54 +200,67 @@ def icon_from_app(app_path):
193200# pt_PT, ro_RO, ru_RU, se, sk_SK, sl_SI, sr_RS, sv_SE, th_TH, to_TO, tr_TR,
194201# uk_UA, ur_IN, ur_PK, uz_UZ, vi_VN, zh_CN, zh_TW
195202
196- # license = {
197- # 'default-language': 'en_US',
198- # 'licenses': {
199- # # For each language, the text of the license. This can be plain text,
200- # # RTF (in which case it must start "{\rtf1"), or a path to a file
201- # # containing the license text. If you're using RTF,
202- # # watch out for Python escaping (or read it from a file).
203- # 'English': b'''{\\rtf1\\ansi\\ansicpg1252\\cocoartf1504\\cocoasubrtf820
204- # {\\fonttbl\\f0\\fnil\\fcharset0 Helvetica-Bold;\\f1\\fnil\\fcharset0 Helvetica;}
205- # {\\colortbl;\\red255\\green255\\blue255;\\red0\\green0\\blue0;}
206- # {\\*\\expandedcolortbl;;\\cssrgb\\c0\\c0\\c0;}
207- # \\paperw11905\\paperh16837\\margl1133\\margr1133\\margb1133\\margt1133
208- # \\deftab720
209- # \\pard\\pardeftab720\\sa160\\partightenfactor0
210-
211- # \\f0\\b\\fs60 \\cf2 \\expnd0\\expndtw0\\kerning0
212- # \\up0 \\nosupersub \\ulnone \\outl0\\strokewidth0 \\strokec2 Test License\\
213- # \\pard\\pardeftab720\\sa160\\partightenfactor0
214-
215- # \\fs36 \\cf2 \\strokec2 What is this?\\
216- # \\pard\\pardeftab720\\sa160\\partightenfactor0
217-
218- # \\f1\\b0\\fs22 \\cf2 \\strokec2 This is the English license. It says what you are allowed to do with this software.\\
219- # \\
220- # }''',
221- # },
222- # 'buttons': {
223- # # For each language, text for the buttons on the licensing window.
224- # #
225- # # Default buttons and text are built-in for the following languages:
226- # #
227- # # English (en_US), German (de_DE), Spanish (es_ES), French (fr_FR),
228- # # Italian (it_IT), Japanese (ja_JP), Dutch (nl_NL), Swedish (sv_SE),
229- # # Brazilian Portuguese (pt_BR), Simplified Chinese (zh_CN),
230- # # Traditional Chinese (zh_TW), Danish (da_DK), Finnish (fi_FI),
231- # # Korean (ko_KR), Norwegian (nb_NO)
232- # #
233- # # You don't need to specify them for those languages; if you fail to
234- # # specify them for some other language, English will be used instead.
235-
236- # 'en_US': (
237- # b'English',
238- # b'Agree',
239- # b'Disagree',
240- # b'Print',
241- # b'Save',
242- # b'If you agree with the terms of this license, press "Agree" to '
243- # b'install the software. If you do not agree, press "Disagree".'
244- # ),
245- # },
246- # }
203+ license = {
204+ "default-language" : "en_US" ,
205+ "licenses" : {
206+ # For each language, the text of the license. This can be plain text,
207+ # RTF (in which case it must start "{\rtf1"), or a path to a file
208+ # containing the license text. If you're using RTF,
209+ # watch out for Python escaping (or read it from a file).
210+ "en_GB" : b"""{\\ rtf1\\ ansi\\ ansicpg1252\\ cocoartf1504\\ cocoasubrtf820
211+ {\\ fonttbl\\ f0\\ fnil\\ fcharset0 Helvetica-Bold;\\ f1\\ fnil\\ fcharset0 Helvetica;}
212+ {\\ colortbl;\\ red255\\ green255\\ blue255;\\ red0\\ green0\\ blue0;}
213+ {\\ *\\ expandedcolortbl;;\\ cssrgb\\ c0\\ c0\\ c0;}
214+ \\ paperw11905\\ paperh16837\\ margl1133\\ margr1133\\ margb1133\\ margt1133
215+ \\ deftab720
216+ \\ pard\\ pardeftab720\\ sa160\\ partightenfactor0
217+
218+ \\ f0\\ b\\ fs60 \\ cf2 \\ expnd0\\ expndtw0\\ kerning0
219+ \\ up0 \\ nosupersub \\ ulnone \\ outl0\\ strokewidth0 \\ strokec2 Test License\\
220+ \\ pard\\ pardeftab720\\ sa160\\ partightenfactor0
221+
222+ \\ fs36 \\ cf2 \\ strokec2 What is this?\\
223+ \\ pard\\ pardeftab720\\ sa160\\ partightenfactor0
224+
225+ \\ f1\\ b0\\ fs22 \\ cf2 \\ strokec2 This is the English license. It says what you are allowed to do with this software.\\
226+ \\
227+ }""" ,
228+ "de_DE" : "Ich bin ein Berliner. Bielefeld gibt's doch gar nicht." ,
229+ },
230+ "buttons" : {
231+ # For each language, text for the buttons on the licensing window.
232+ #
233+ # Default buttons and text are built-in for the following languages:
234+ #
235+ # da_DK: Danish
236+ # de_DE: German
237+ # en_AU: English (Australian)
238+ # en_GB: English (UK)
239+ # en_NZ: English (New Zealand)
240+ # en_US: English (US)
241+ # es_ES: Spanish
242+ # fr_CA: French (Canadian)
243+ # fr_FR: French
244+ # it_IT: Italian
245+ # ja_JP: Japanese
246+ # nb_NO: Norsk
247+ # nl_BE: Flemish
248+ # nl_NL: Dutch
249+ # pt_BR: Brazilian Portuguese
250+ # pt_PT: Portugese
251+ # sv_SE: Swedish
252+ # zh_CN: Simplified Chinese
253+ # zh_TW: Traditional Chinese
254+ #
255+ # You don't need to specify them for those languages; if you fail to
256+ # specify them for some other language, English will be used instead.
257+ "en_US" : (
258+ b"English" ,
259+ b"Agree!" ,
260+ b"Disagree!" ,
261+ b"Print!" ,
262+ b"Save!" ,
263+ b'Do you agree or not? Press "Agree" or "Disagree".' ,
264+ ),
265+ },
266+ }
0 commit comments