dmg-builder 26.5.0 → 26.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,331 +0,0 @@
1
- import os
2
-
3
- # based on https://github.com/argv-minus-one/dmg-license/blob/master/language-info-generator/Languages.tsv
4
- # note that this table specifies STR# Resource ID but it seems to have no effect
5
- language_info_map = {
6
- "da_DK": {"buttons": "Danish", "name": "Danish", "language_id": 9},
7
- "de_AT": {"buttons": "German", "name": "German (Austrian)", "language_id": 92},
8
- "de_CH": {"buttons": "German", "name": "German (Swiss)", "language_id": 19},
9
- "de_DE": {"buttons": "German", "name": "German", "language_id": 3},
10
- "en_AU": {"buttons": "English", "name": "English (Australian)", "language_id": 15},
11
- "en_GB": {"buttons": "English", "name": "English (UK)", "language_id": 2},
12
- "en_IE": {"buttons": "English", "name": "English (Ireland)", "language_id": 108},
13
- "en_SG": {
14
- "buttons": "English",
15
- "name": "English (Singaporean)",
16
- "language_id": 100,
17
- },
18
- "en_US": {"buttons": "English", "name": "English", "language_id": 0},
19
- "es_ES": {"buttons": "Spanish", "name": "Spanish", "language_id": 8},
20
- "fi_FI": {"buttons": "Finnish", "name": "Finnish", "language_id": 17},
21
- "fr_BE": {"buttons": "French", "name": "French (Belgian)", "language_id": 98},
22
- "fr_CA": {"buttons": "French", "name": "French (Canadian)", "language_id": 11},
23
- "fr_CH": {"buttons": "French", "name": "French (Swiss)", "language_id": 18},
24
- "fr_FR": {"buttons": "French", "name": "French", "language_id": 1},
25
- "it_IT": {"buttons": "Italian", "name": "Italian", "language_id": 4},
26
- "ja_JP": {
27
- "buttons": "Japanese",
28
- "name": "Japanese",
29
- "language_id": 14,
30
- # not sure if this is correct encoding, but seems to be working
31
- "encoding": "shift_jis",
32
- "multibyte": True,
33
- },
34
- "ko_KR": {
35
- "buttons": "Korean",
36
- "name": "Korean",
37
- "language_id": 51,
38
- "encoding": "ksx1001",
39
- "multibyte": True,
40
- },
41
- "nb_NO": {"buttons": "Norwegian", "name": "Norwegian", "language_id": 12},
42
- "nl_BE": {"buttons": "Dutch", "name": "Dutch", "language_id": 6},
43
- "nl_NL": {"buttons": "Dutch", "name": "Dutch", "language_id": 5},
44
- "pt_BR": {
45
- "buttons": "Portuguese",
46
- "name": "Portuguese (Brazilian)",
47
- "language_id": 71,
48
- },
49
- "pt_PT": {"buttons": "Portuguese", "name": "Portuguese", "language_id": 10},
50
- "ru_RU": {
51
- "buttons": "Russian",
52
- "name": "Russian",
53
- "language_id": 49,
54
- "encoding": "mac_cyrillic",
55
- },
56
- "sv_SE": {"buttons": "Swedish", "name": "Swedish", "language_id": 7},
57
- "zh_CN": {
58
- "buttons": "Simplified",
59
- "name": "Simplified Chinese",
60
- "language_id": 52,
61
- "encoding": "gb2312",
62
- "multibyte": True,
63
- },
64
- "zh_TW": {
65
- "buttons": "Traditional",
66
- "name": "Traditional Chinese",
67
- "language_id": 53,
68
- "encoding": "big5",
69
- "multibyte": True,
70
- },
71
- }
72
-
73
- # Buttons (these come from the SLAResources file which you can find in the SLA
74
- # SDK on developer.apple.com)
75
- default_buttons = {
76
- "English": (
77
- "English",
78
- "Agree",
79
- "Disagree",
80
- "Print",
81
- "Save",
82
- 'If you agree with the terms of this license, press "Agree" to install the software. If you do not agree, press "Disagree".', # noqa: E501
83
- ),
84
- "German": (
85
- "Deutsch",
86
- "Akzeptieren",
87
- "Ablehnen",
88
- "Drucken",
89
- "Sichern...",
90
- 'Klicken Sie in "Akzeptieren", wenn Sie mit den Bestimmungen des Software-Lizenzvertrags einverstanden sind. Falls nicht, bitte "Ablehnen" anklicken. Sie können die Software nur installieren, wenn Sie "Akzeptieren" angeklickt haben.', # noqa: E501
91
- ),
92
- "Spanish": (
93
- "Español",
94
- "Aceptar",
95
- "No aceptar",
96
- "Imprimir",
97
- "Guardar...",
98
- 'Si está de acuerdo con los términos de esta licencia, pulse "Aceptar" para instalar el software. En el supuesto de que no esté de acuerdo con los términos de esta licencia, pulse "No aceptar."', # noqa: E501
99
- ),
100
- "French": (
101
- "Français",
102
- "Accepter",
103
- "Refuser",
104
- "Imprimer",
105
- "Enregistrer...",
106
- 'Si vous acceptez les termes de la présente licence, cliquez sur "Accepter" afin d\'installer le logiciel. Si vous n\'êtes pas d\'accord avec les termes de la licence, cliquez sur "Refuser".', # noqa: E501
107
- ),
108
- "Italian": (
109
- "Italiano",
110
- "Accetto",
111
- "Rifiuto",
112
- "Stampa",
113
- "Registra...",
114
- 'Se accetti le condizioni di questa licenza, fai clic su "Accetto" per installare il software. Altrimenti fai clic su "Rifiuto".', # noqa: E501
115
- ),
116
- "Japanese": (
117
- "日本語",
118
- "同意します",
119
- "同意しません",
120
- "印刷する",
121
- "保存...",
122
- "本ソフトウエア使用許諾契約の条件に同意される場合には、ソフトウエアをインストールするために「同意します」を押してください。\u3000同意されない場合には、「同意しません」を押してください。", # noqa: E501
123
- ),
124
- "Dutch": (
125
- "Nederlands",
126
- "Ja",
127
- "Nee",
128
- "Print",
129
- "Bewaar...",
130
- "Indien u akkoord gaat met de voorwaarden van deze licentie, kunt u op 'Ja' klikken om de programmatuur te installeren. Indien u niet akkoord gaat, klikt u op 'Nee'.", # noqa: E501
131
- ),
132
- "Russian": (
133
- "Русский",
134
- "Согласен",
135
- "Не согласен",
136
- "Распечатать",
137
- "Сохранить",
138
- "Если вы согласны с условиями данной лицензии, нажмите «Согласен», чтобы установить программное обеспечение. Если вы не согласны, нажмите «Не согласен».", # noqa: E501
139
- ),
140
- "Swedish": (
141
- "Svensk",
142
- "Godkänns",
143
- "Avböjs",
144
- "Skriv ut",
145
- "Spara...",
146
- 'Om Du godkänner licensvillkoren klicka på "Godkänns" för att installera programprodukten. Om Du inte godkänner licensvillkoren, klicka på "Avböjs".', # noqa: E501
147
- ),
148
- "Portuguese": (
149
- "Português",
150
- "Concordar",
151
- "Discordar",
152
- "Imprimir",
153
- "Salvar...",
154
- 'Se está de acordo com os termos desta licença, pressione "Concordar" para instalar o software. Se não está de acordo, pressione "Discordar".', # noqa: E501
155
- ),
156
- "Simplified Chinese": (
157
- "汉语",
158
- "同意",
159
- "不同意",
160
- "打印",
161
- "存储…",
162
- "如果您同意本许可协议的条款,请按“同意”来安装此软件。如果您不同意,请按“不同意”。", # noqa: E501
163
- ),
164
- "Traditional Chinese": (
165
- "漢語",
166
- "同意",
167
- "不同意",
168
- "列印",
169
- "儲存…",
170
- "如果您同意本許可證裡的條款,請按“同意”以安裝軟體。如果不同意,請按“不同意”。", # noqa: E501
171
- ),
172
- "Danish": (
173
- "Dansk",
174
- "Enig",
175
- "Uenig",
176
- "Udskriv",
177
- "Arkiver...",
178
- "Hvis du accepterer betingelserne i licensaftalen, skal du klikke på “Enig” for at installere softwaren. Klik på “Uenig” for at annullere installeringen.", # noqa: E501
179
- ),
180
- "Finnish": (
181
- "Suomi",
182
- "Hyväksyn",
183
- "En hyväksy",
184
- "Tulosta",
185
- "Tallenna…",
186
- 'Hyväksy lisenssisopimuksen ehdot osoittamalla "Hyväksy". Jos et hyväksy sopimuksen ehtoja, osoita "En hyväksy".', # noqa: E501
187
- ),
188
- "Korean": (
189
- "한국어",
190
- "동의",
191
- "동의 안함",
192
- "프린트",
193
- "저장...",
194
- '사용 계약서의 내용에 동의하면, "동의" 단추를 눌러 소프트웨어를 설치하십시오. 동의하지 않는다면, "동의 안함" 단추를 누르십시오.', # noqa: E501
195
- ),
196
- "Norwegian": (
197
- "Norsk",
198
- "Enig",
199
- "Ikke enig",
200
- "Skriv ut",
201
- "Arkiver...",
202
- 'Hvis De er enig i bestemmelsene i denne lisensavtalen, klikker De på "Enig"-knappen for å installere programvaren. Hvis De ikke er enig, klikker De på "Ikke enig".', # noqa: E501
203
- ),
204
- }
205
-
206
- udifrezXMLtemplate = {
207
- "STR#": [],
208
- # ?? License text would be included in a block like this:
209
- # ?? 'TEXT': [
210
- # ?? {
211
- # ?? 'Attributes': '0x0000',
212
- # ?? 'Data': b'license text',
213
- # ?? 'ID': '5000',
214
- # ?? 'Name': 'English'
215
- # ?? }
216
- # ?? ],
217
- "TMPL": [
218
- {
219
- "Attributes": "0x0000",
220
- "Data": b"\x13Default Language IDDWRD\x05CountOCNT\x04****LSTC\x0bsys lang IDDWRD\x1elocal res ID (offset from 5000DWRD\x102-byte language?DWRD\x04****LSTE", # noqa: E501
221
- "ID": "128",
222
- "Name": "LPic",
223
- }
224
- ],
225
- }
226
-
227
-
228
- # Another implementation in TS:
229
- # https://github.com/argv-minus-one/dmg-license/blob/4268f2e822944fd670c1e197596396f233d6484e/src/makeLicensePlist.ts
230
-
231
-
232
- def build_license(license_info):
233
- """Add a license agreement to the specified disk image file, see
234
- https://developer.apple.com/forums/thread/668084."""
235
- # Copy the original template
236
- xml = dict(udifrezXMLtemplate)
237
-
238
- licenses = license_info.get(
239
- "licenses",
240
- {"en_US": default_buttons["English"][5].encode("utf-8")},
241
- )
242
-
243
- lpic = b""
244
- # The first field is the default language ID.
245
- lpic += (5000).to_bytes(2, "big")
246
- # The second field is the count of language ID to license resource mappings.
247
- lpic += len(licenses.items()).to_bytes(2, "big")
248
-
249
- for language, license_data in licenses.items():
250
- if language not in language_info_map:
251
- raise Exception(
252
- "Unknown language '"
253
- + language
254
- + "'. Valid languages are: "
255
- + ", ".join(sorted(language_info_map.keys()))
256
- )
257
-
258
- language_info = language_info_map[language]
259
- language_buttons = language_info["buttons"]
260
- language_name = language_info["name"]
261
- language_id = language_info["language_id"]
262
- # for simplicity we use the same id for the resource
263
- # as system language id + 5000
264
- resource_id = language_id + 5000
265
- language_encoding = language_info.get("encoding", "mac_roman")
266
- multibyte_encoding = language_info.get("multibyte_encoding", False)
267
-
268
- if os.path.isfile(license_data):
269
- mode = "rb" if license_data.endswith(".rtf") else "r"
270
- with open(license_data, mode=mode) as f:
271
- license_data = f.read()
272
-
273
- if isinstance(license_data, bytes):
274
- if license_data.startswith(b"{\\rtf1"):
275
- licenseDataFormat = "RTF "
276
- else:
277
- licenseDataFormat = "TEXT"
278
- else:
279
- licenseDataFormat = "TEXT"
280
- license_data = license_data.encode(language_encoding)
281
-
282
- if licenseDataFormat not in xml:
283
- xml[licenseDataFormat] = []
284
-
285
- xml[licenseDataFormat].append(
286
- {
287
- "Attributes": "0x0000",
288
- "Data": license_data,
289
- "ID": str(resource_id),
290
- "Name": f"{language_name} SLA",
291
- }
292
- )
293
-
294
- language_default_buttons = default_buttons.get(
295
- language_buttons, default_buttons["English"]
296
- )
297
- buttons = license_info.get("buttons", {}).get(
298
- language, language_default_buttons
299
- )
300
-
301
- assert len(buttons) == 6, "License buttons must have 6 entries."
302
-
303
- buttons = [b.encode(language_encoding) for b in buttons]
304
- buttons = [len(b).to_bytes(1, "big") + b for b in buttons]
305
- xml["STR#"].append(
306
- {
307
- "Attributes": "0x0000",
308
- # \x06 is apparently the number of buttons which is always 6
309
- "Data": b"\x00\x06" + b"".join(buttons),
310
- "ID": str(resource_id),
311
- "Name": language_name,
312
- }
313
- )
314
-
315
- # Finally, the list of resource ID mappings:
316
- # Mapping field 1: system language ID
317
- lpic += language_id.to_bytes(2, "big")
318
- # Mapping field 2: local resource ID minus 5000
319
- lpic += int(resource_id - 5000).to_bytes(2, "big")
320
- # Mapping field 3: 2-byte language?
321
- lpic += int(1 if multibyte_encoding else 0).to_bytes(2, "big")
322
-
323
- xml["LPic"] = [
324
- {
325
- "Attributes": "0x0000",
326
- "Data": lpic,
327
- "ID": "5000",
328
- "Name": "",
329
- }
330
- ]
331
- return xml
@@ -1,5 +0,0 @@
1
- from .store import DSStore, DSStoreEntry
2
-
3
- __version__ = "1.3.1"
4
-
5
- __all__ = ["__version__", "DSStore", "DSStoreEntry"]
@@ -1,102 +0,0 @@
1
- #!/usr/bin/env python
2
- #
3
- # ds_store: Examine .DS_Store files.
4
- #
5
-
6
- import argparse
7
- import os
8
- import os.path
9
- import pprint
10
- import re
11
- import sys
12
-
13
- from ds_store import DSStore
14
- from ds_store.buddy import BuddyError
15
-
16
- _not_printable_re = re.compile(rb"[\x00-\x1f\x7f-\x9f]")
17
-
18
-
19
- def usage():
20
- print(main.__doc__)
21
- sys.exit(0)
22
-
23
-
24
- def chunks(iterable, length):
25
- for i in range(0, len(iterable), length):
26
- yield i, iterable[i : i + length]
27
-
28
-
29
- def pretty(value):
30
- if isinstance(value, dict):
31
- return f"{{\n {pprint.pformat(value, indent=4)[1:-1]}\n}}"
32
- elif isinstance(value, bytearray):
33
- lines = ["["]
34
- for offset, chunk in chunks(value, 16):
35
- printable_chunk = _not_printable_re.sub(b".", chunk).decode("latin-1")
36
- hex_line = " ".join([f"{b:02x}" for b in chunk])
37
- line = f" {offset:08x} {hex_line:<47s} {printable_chunk}"
38
- lines.append(line)
39
- lines.append("]")
40
- return "\n".join(lines)
41
- elif isinstance(value, bytes):
42
- return value.decode("latin-1")
43
- else:
44
- return value
45
-
46
-
47
- def main(argv):
48
- """Display the contents of the .DS_Store file at the specified path.
49
-
50
- If you specify just a directory, ds_store will inspect the .DS_Store
51
- file in that directory. If no paths are specified, ds_store will
52
- display the contents of the .DS_Store file in the current directory.
53
- """
54
-
55
- parser = argparse.ArgumentParser(description=main.__doc__)
56
- parser.add_argument("paths", nargs="*")
57
- args = parser.parse_args(argv)
58
-
59
- if len(args.paths) == 0:
60
- args.paths = ["."]
61
-
62
- failed = False
63
- for path in args.paths:
64
- if os.path.isdir(path):
65
- path = os.path.join(path, ".DS_Store")
66
-
67
- if not os.path.exists(path) or not os.path.isfile(path):
68
- print(f"ds_store: {path} not found", file=sys.stderr)
69
- failed = True
70
- continue
71
-
72
- try:
73
- with DSStore.open(path, "r") as d:
74
- print(path)
75
- print("")
76
-
77
- max_name_len = 0
78
- for entry in d:
79
- name_len = len(entry.filename)
80
- if name_len > max_name_len:
81
- max_name_len = name_len
82
-
83
- for entry in d:
84
- print(
85
- "{:<{width}} {} {}".format(
86
- entry.filename,
87
- entry.code.decode("latin-1"),
88
- pretty(entry.value),
89
- width=max_name_len,
90
- )
91
- )
92
- print("")
93
- except BuddyError as e:
94
- print(f"ds_store: {path}: {e}")
95
- failed = True
96
-
97
- if failed:
98
- sys.exit(1)
99
-
100
-
101
- if __name__ == "__main__":
102
- main(sys.argv[1:])