Skip to content

Commit b4983d0

Browse files
committed
Merge branch 'recovery-environment'
* recovery-environment: (44 commits) Update metadata for new release Rationalize report initialization Rationalize setting font parameters and organize imports Move output directory field above the source field Fix warning Rewrite SysdiagnoseMethod to write logs as JSONL. Fixes #34 Unified logs are collected manually in order to have more data. Fixes #23 Formatting Clarified wording and removed reference to DMG format in the GUI Sysdiagnose produces a ZIP file now. Fixes #31 Better description for recovery environment Better descriptions and new order for methods. Fixes #32 Copy temporary DMG (move does not make sense) Encourage the user to acquire the Data volume on APFS - Fixes #33 Clean up hyperlink code + bypass corner case (no space left on device) Fix browser for Intel-based macOS recovery Show timezone in acquisition date and time Adaptive link control to allow opening a website from the recovery environment Caffeinate the "moving DMG" phase Formatting ...
2 parents a0c831a + ed2629e commit b4983d0

File tree

19 files changed

+831
-359
lines changed

19 files changed

+831
-359
lines changed

Fuji.spec

Lines changed: 83 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
import importlib
44
import subprocess
55
import sys
6+
from os import remove
67
from pathlib import Path
7-
from shutil import copy, move
8+
from shutil import copy, copytree, move
9+
10+
import dmgbuild
811

912
sys.path.insert(0, ".")
1013
meta = importlib.import_module("meta")
1114

1215

13-
a = Analysis(
16+
a = Analysis( # type: ignore
1417
["fuji.py"],
1518
pathex=[],
1619
binaries=[],
@@ -23,9 +26,9 @@ a = Analysis(
2326
noarchive=False,
2427
optimize=0,
2528
)
26-
pyz = PYZ(a.pure)
29+
pyz = PYZ(a.pure) # type: ignore
2730

28-
exe = EXE(
31+
exe = EXE( # type: ignore
2932
pyz,
3033
a.scripts,
3134
[],
@@ -43,7 +46,7 @@ exe = EXE(
4346
entitlements_file=None,
4447
icon=["packaging/Fuji.icns"],
4548
)
46-
coll = COLLECT(
49+
coll = COLLECT( # type: ignore
4750
exe,
4851
a.binaries,
4952
a.datas,
@@ -52,24 +55,90 @@ coll = COLLECT(
5255
upx_exclude=[],
5356
name="Fuji",
5457
)
55-
app = BUNDLE(
58+
app = BUNDLE( # type: ignore
5659
coll,
5760
name="Fuji.app",
5861
icon="./packaging/Fuji.icns",
5962
bundle_identifier="com.andrealazzarotto.fuji",
6063
version=meta.VERSION,
6164
)
6265

63-
executable_path = Path("./dist/Fuji.app/Contents/MacOS")
66+
# Add language file for recovery environment
67+
app_bundle_path = Path("./dist/Fuji.app")
68+
copytree("./recovery/en.lproj", app_bundle_path / "Contents" / "Resources" / "en.lproj")
69+
70+
executable_path = app_bundle_path / "Contents" / "MacOS"
6471
move(executable_path / "Fuji", executable_path / "Fuji.bin")
6572
copy("./packaging/Fuji.sh", executable_path / "Fuji")
6673

67-
dmg_path = "./dist/FujiApp.dmg"
68-
print("Building", dmg_path)
69-
result = subprocess.call(
70-
["dmgbuild", "-s", "./packaging/dmgbuild.py", "FujiApp", dmg_path]
74+
dmg_path = f"./dist/FujiApp-{meta.VERSION}.dmg"
75+
temp_dmg_path = f"./dist/FujiApp-{meta.VERSION}-temp.dmg"
76+
volume_name = meta.VOLUME_NAME
77+
78+
print("Building temporary DMG", temp_dmg_path)
79+
try:
80+
dmgbuild.build_dmg(
81+
temp_dmg_path,
82+
volume_name,
83+
settings_file="packaging/dmgbuild.py",
84+
)
85+
except Exception as e:
86+
print(e)
87+
print("DMG build failed")
88+
sys.exit(1)
89+
90+
print("Exporting final DMG", dmg_path)
91+
92+
# Attach temporary image and get mount point
93+
attach_process = subprocess.Popen(
94+
[
95+
"hdiutil",
96+
"attach",
97+
"-nobrowse",
98+
"-noverify",
99+
"-noautoopen",
100+
"-owners",
101+
"off",
102+
temp_dmg_path,
103+
],
104+
stdout=subprocess.PIPE,
105+
stderr=subprocess.PIPE,
71106
)
72-
if result == 0:
73-
print("Done")
107+
stdout, stderr = attach_process.communicate()
108+
if attach_process.returncode != 0:
109+
print("Failed to attach DMG:", stderr.decode().strip())
110+
sys.exit(1)
111+
112+
mount_point = None
113+
for line in stdout.decode().splitlines():
114+
if f"/Volumes/{volume_name}" in line:
115+
mount_point = line.split("\t")[-1]
116+
break
117+
118+
# Make the mounted file system "read-only"
119+
if mount_point:
120+
print("Making mounted image read-only")
121+
subprocess.call(["chmod", "-R", "a-w", mount_point])
122+
123+
# Detach the mounted image
124+
subprocess.call(["hdiutil", "detach", mount_point])
74125
else:
75-
print("Failed!!!")
126+
print("Mount point not found.")
127+
sys.exit(1)
128+
129+
# Convert to zlib-compressed image
130+
subprocess.call(
131+
[
132+
"hdiutil",
133+
"convert",
134+
temp_dmg_path,
135+
"-format",
136+
"UDZO",
137+
"-ov",
138+
"-o",
139+
dmg_path,
140+
]
141+
)
142+
remove(temp_dmg_path)
143+
144+
print("Done!")

0 commit comments

Comments
 (0)