Skip to content

Commit 666d85a

Browse files
authored
chore: fix dmg background by updating vendor dmgbuild (#9512)
1 parent 6c20eeb commit 666d85a

7 files changed

Lines changed: 66 additions & 54 deletions

File tree

.changeset/empty-goats-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"dmg-builder": patch
3+
---
4+
5+
chore: fix dmg background by updating vendor dmgbuild
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .core import build_dmg
22

3-
__version__ = "1.6.5"
3+
__version__ = "1.6.6"
44

55
__all__ = ["__version__", "build_dmg"]

packages/dmg-builder/vendor/dmgbuild/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ def main():
99
parser.add_argument(
1010
"volume_name",
1111
metavar="volume-name",
12-
help="The name to give to the volume (this will appear in the title bar when the user mounts the disk image).",
12+
help=(
13+
"The name to give to the volume (this will appear in the title "
14+
"bar when the user mounts the disk image)."
15+
),
1316
)
1417
parser.add_argument(
1518
"filename",

packages/dmg-builder/vendor/dmgbuild/badge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def badge_disk_icon(badge_file, output_file):
4343
# Load the badge
4444
url = CFURLCreateWithFileSystemPath(None, badge_file, kCFURLPOSIXPathStyle, False)
4545
badge = CGImageSourceCreateWithURL(url, None)
46-
assert badge is not None, "Unable to process image file: %s" % badge_file
46+
assert badge is not None, f"Unable to process image file: {badge_file}"
4747
badgeCount = CGImageSourceGetCount(badge)
4848

4949
# Set up a destination for our target

packages/dmg-builder/vendor/dmgbuild/colors.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def to_rgb(self):
1818

1919

2020
class HSL(Color):
21-
def __init__(self, h, s, l): # noqa; E741
21+
def __init__(self, h, s, l): # noqa: E741
2222
self.h = h
2323
self.s = s
24-
self.l = l # noqa; E741
24+
self.l = l # noqa: E741
2525

2626
@staticmethod
2727
def _hue_to_rgb(t1, t2, hue):
@@ -41,7 +41,7 @@ def _hue_to_rgb(t1, t2, hue):
4141

4242
def to_rgb(self):
4343
hue = self.h / 60.0
44-
if self.l <= 0.5: # noqa; E741
44+
if self.l <= 0.5: # noqa: E741
4545
t2 = self.l * (self.s + 1)
4646
else:
4747
t2 = self.l + self.s - (self.l * self.s)
@@ -281,7 +281,7 @@ def expect(self, s, context=""):
281281

282282
def expectEnd(self):
283283
if self._pos != len(self._string):
284-
raise ValueError('junk at end of color "%s"' % self._string)
284+
raise ValueError(f'junk at end of color "{self._string}"')
285285

286286
def getToken(self):
287287
m = _token_re.match(self._string, self._pos)
@@ -318,7 +318,7 @@ def parseColor(self):
318318
try:
319319
r, g, b = _x11_colors[token]
320320
except KeyError:
321-
raise ValueError('unknown color name "%s"' % token)
321+
raise ValueError(f'unknown color name "{token}"')
322322

323323
self.expectEnd()
324324

@@ -344,7 +344,7 @@ def parseColor(self):
344344

345345
return RGB(r / 255.0, g / 255.0, b / 255.0)
346346

347-
raise ValueError('bad color syntax "%s"' % self._string)
347+
raise ValueError(f'bad color syntax "{self._string}"')
348348

349349
def parseRGB(self):
350350
self.expect("(", 'after "rgb"')
@@ -388,7 +388,7 @@ def parseHSL(self):
388388
self.expect(",", 'in "hsl"')
389389
self.skipws()
390390

391-
l = self.parseValue() # noqa; E741
391+
l = self.parseValue() # noqa: E741
392392

393393
self.skipws()
394394
self.expect(")", 'at end of "hsl"')
@@ -487,12 +487,12 @@ def parseAngle(self):
487487
elif tok == "grad" or tok == "gon":
488488
n = n * 0.9
489489
elif tok != "deg":
490-
raise ValueError('bad angle unit "%s"' % tok)
490+
raise ValueError(f'bad angle unit "{tok}"')
491491
return n
492492

493493

494494
_color_re = re.compile(
495-
r"\s*(#|rgb|hsl|hwb|cmyk|gray|grey|%s)" % "|".join(_x11_colors.keys())
495+
r"\s*(#|rgb|hsl|hwb|cmyk|gray|grey|{})".format("|".join(_x11_colors.keys()))
496496
)
497497

498498

packages/dmg-builder/vendor/dmgbuild/core.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from importlib import resources
1616

1717
from ds_store import DSStore
18-
from mac_alias import Alias, Bookmark
18+
from mac_alias import Alias
1919

2020
from . import colors, licensing
2121

@@ -159,16 +159,20 @@ def load_json(filename, settings):
159159
settings["icon_locations"] = icon_locations
160160

161161

162-
def build_dmg( # noqa; C901
162+
def build_dmg( # noqa: C901
163163
filename,
164164
volume_name,
165165
settings_file=None,
166-
settings={},
167-
defines={},
166+
settings=None,
167+
defines=None,
168168
lookForHiDPI=True,
169169
detach_retries=12,
170170
callback=quiet_callback,
171171
):
172+
if defines is None:
173+
defines = {}
174+
if settings is None:
175+
settings = {}
172176
options = {
173177
# Default settings
174178
"filename": filename,
@@ -269,8 +273,8 @@ def build_dmg( # noqa; C901
269273
# Set up the finder data
270274
bounds = options["window_rect"]
271275

272-
bounds_string = "{{{{{}, {}}}, {{{}, {}}}}}".format(
273-
bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]
276+
bounds_string = (
277+
f"{{{{{bounds[0][0]}, {bounds[0][1]}}}, {{{bounds[1][0]}, {bounds[1][1]}}}}}"
274278
)
275279
bwsp = {
276280
"ShowStatusBar": options["show_status_bar"],
@@ -373,8 +377,11 @@ def build_dmg( # noqa; C901
373377
for n, column in enumerate(options["list_columns"]):
374378
cndx[column] = n
375379
width = options["list_column_widths"].get(column, default_widths[column])
376-
asc = "ascending" == options["list_column_sort_directions"].get(
377-
column, default_sort_directions[column]
380+
asc = (
381+
options["list_column_sort_directions"].get(
382+
column, default_sort_directions[column]
383+
)
384+
== "ascending"
378385
)
379386

380387
lsvp["columns"][columns[column]] = {
@@ -387,10 +394,10 @@ def build_dmg( # noqa; C901
387394

388395
n = len(options["list_columns"])
389396
for k in columns:
390-
if cndx.get(k, None) is None:
397+
if cndx.get(k) is None:
391398
cndx[k] = n
392399
width = default_widths[k]
393-
asc = "ascending" == default_sort_directions[k]
400+
asc = default_sort_directions[k] == "ascending"
394401

395402
lsvp["columns"][columns[column]] = {
396403
"index": n,
@@ -453,7 +460,7 @@ def roundup(x, n):
453460
path = path[0]
454461

455462
if not os.path.islink(path) and os.path.isdir(path):
456-
for dirpath, dirnames, filenames in os.walk(path):
463+
for dirpath, _dirnames, filenames in os.walk(path):
457464
for f in filenames:
458465
fp = os.path.join(dirpath, f)
459466
total_size += roundup(os.lstat(fp).st_size, 4096)
@@ -566,8 +573,6 @@ def roundup(x, n):
566573
if icon or badge_icon:
567574
subprocess.call(["/usr/bin/SetFile", "-a", "C", mount_point])
568575

569-
background_bmk = None
570-
571576
callback(
572577
{
573578
"type": "operation::start",
@@ -627,8 +632,8 @@ def roundup(x, n):
627632
except Exception as e:
628633
output.seek(0)
629634
raise ValueError(
630-
'unable to compile combined HiDPI file "%s" got error: %s\noutput: %s'
631-
% (background, str(e), output.read())
635+
f"unable to compile combined HiDPI file {background!r} "
636+
f"got error: {str(e)}\noutput: {output.read()}"
632637
)
633638

634639
_, kind = os.path.splitext(background)
@@ -645,10 +650,9 @@ def roundup(x, n):
645650
with open(path_in_image, "wb") as out_file:
646651
out_file.write(in_file.read())
647652
else:
648-
raise ValueError('background file "%s" not found' % background)
653+
raise ValueError(f'background file "{background}" not found')
649654

650655
alias = Alias.for_file(path_in_image)
651-
background_bmk = Bookmark.for_file(path_in_image)
652656

653657
icvp["backgroundType"] = 2
654658
icvp["backgroundImageAlias"] = alias.to_bytes()
@@ -767,7 +771,7 @@ def roundup(x, n):
767771
}
768772
)
769773

770-
userfn = options.get("create_hook", None)
774+
userfn = options.get("create_hook")
771775
if callable(userfn):
772776
userfn(mount_point, options)
773777

@@ -785,8 +789,6 @@ def roundup(x, n):
785789
d["."]["bwsp"] = bwsp
786790
if include_icon_view_settings:
787791
d["."]["icvp"] = icvp
788-
if background_bmk:
789-
d["."]["pBBk"] = background_bmk
790792
if include_list_view_settings:
791793
d["."]["lsvp"] = lsvp
792794
d["."]["icvl"] = icvl
@@ -819,7 +821,7 @@ def roundup(x, n):
819821
subprocess.check_call(("sync", "--file-system", mount_point))
820822

821823
retry_time = 1
822-
for tries in range(detach_retries):
824+
for _ in range(detach_retries):
823825
callback(
824826
{
825827
"type": "command::start",
@@ -833,8 +835,8 @@ def roundup(x, n):
833835
{
834836
"type": "command::finished",
835837
"command": "hdiutil::detach",
836-
"ret:": ret,
837-
"output:": output,
838+
"ret": ret,
839+
"output": output,
838840
}
839841
)
840842

0 commit comments

Comments
 (0)