Installers for all platforms and related fixes #1
+10
-3
@@ -446,11 +446,17 @@ def force_macos_user_install(pkg: Path) -> None:
|
|||||||
raise RuntimeError("Unexpected distribution.xml: <domains> not found")
|
raise RuntimeError("Unexpected distribution.xml: <domains> not found")
|
||||||
dist_xml.write_text(new_xml)
|
dist_xml.write_text(new_xml)
|
||||||
|
|
||||||
# Edit postinstall inside the (still archived) component pkg.
|
# Edit postinstall inside the component pkg. Depending on the macOS
|
||||||
components = [p for p in expanded.glob("*.pkg") if p.is_file()]
|
# version, --expand leaves the component as an archived file (needs a
|
||||||
|
# nested expand/flatten round) or as an already-expanded directory.
|
||||||
|
components = list(expanded.glob("*.pkg"))
|
||||||
if len(components) != 1:
|
if len(components) != 1:
|
||||||
raise RuntimeError(f"Unexpected pkg layout: components={components}")
|
contents = sorted(p.name for p in expanded.iterdir())
|
||||||
|
raise RuntimeError(f"Unexpected pkg layout: components={components} in {contents}")
|
||||||
component = components[0]
|
component = components[0]
|
||||||
|
if component.is_dir():
|
||||||
|
comp_dir = component
|
||||||
|
else:
|
||||||
comp_dir = expanded / (component.stem + "-component")
|
comp_dir = expanded / (component.stem + "-component")
|
||||||
subprocess.run(["pkgutil", "--expand", str(component), str(comp_dir)], check=True)
|
subprocess.run(["pkgutil", "--expand", str(component), str(comp_dir)], check=True)
|
||||||
postinstall = comp_dir / "Scripts" / "postinstall"
|
postinstall = comp_dir / "Scripts" / "postinstall"
|
||||||
@@ -458,6 +464,7 @@ def force_macos_user_install(pkg: Path) -> None:
|
|||||||
if 'sudo -u "$USER" ' not in script:
|
if 'sudo -u "$USER" ' not in script:
|
||||||
raise RuntimeError("Unexpected postinstall script: sudo prefix not found")
|
raise RuntimeError("Unexpected postinstall script: sudo prefix not found")
|
||||||
postinstall.write_text(script.replace('sudo -u "$USER" ', ""))
|
postinstall.write_text(script.replace('sudo -u "$USER" ', ""))
|
||||||
|
if comp_dir is not component:
|
||||||
subprocess.run(["pkgutil", "--flatten", str(comp_dir), str(component)], check=True)
|
subprocess.run(["pkgutil", "--flatten", str(comp_dir), str(component)], check=True)
|
||||||
shutil.rmtree(comp_dir)
|
shutil.rmtree(comp_dir)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user