mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
This originally is a patch from @Alexander Zolotov, see context here: https://jetbrains.team/im/group/aXRAL08f2vZ?message=9ISsF0SXSlD&channel=aXRAL08f2vZ. It removes the assumption that `$2.exploded` exists, allowing a custom folder path to be passed as parameters, it may be absolute. It also allows source directory not to be cleaned up at the request of the script user. GitOrigin-RevId: 4c42cee1e00315c7ed7127261a14722cde1aa59c
80 lines
2.3 KiB
Python
80 lines
2.3 KiB
Python
#!/usr/local/bin/python3 -w
|
|
import os.path
|
|
import sys
|
|
import struct
|
|
|
|
from ds_store import *
|
|
from mac_alias import *
|
|
|
|
"""
|
|
Script generates needed configuration for MacOS installation dialog.
|
|
Original available docs for options are in perl module
|
|
https://metacpan.org/dist/Mac-Finder-DSStore/view/DSStoreFormat.pod
|
|
|
|
Python module docs are not so great:
|
|
https://ds-store.readthedocs.io/en/latest/
|
|
|
|
Many options, which are used here could be found in
|
|
https://dmgbuild.readthedocs.io/en/latest/settings.html
|
|
https://github.com/al45tair/dmgbuild/blob/master/dmgbuild/core.py
|
|
|
|
Some details about binary formats
|
|
https://0day.work/parsing-the-ds_store-file-format/
|
|
|
|
"""
|
|
name = sys.argv[1]
|
|
bgPic = sys.argv[2]
|
|
mountName = sys.argv[3]
|
|
print(f"Process ds store in /Volumes/{mountName}/.DS_Store")
|
|
with DSStore.open(f"/Volumes/{mountName}/.DS_Store", "w+") as d:
|
|
|
|
d[".background"]["Iloc"] = (560, 170)
|
|
d[".DS_Store"]["Iloc"] = (610, 170)
|
|
d[".fseventsd"]["Iloc"] = (660, 170)
|
|
d[".Trashes"]["Iloc"] = (710, 170)
|
|
d["Applications"]["Iloc"] = (340, 167)
|
|
|
|
byte_stream = struct.pack('>H', 100) + struct.pack('>H', 400) + \
|
|
struct.pack('>H', 396) + struct.pack('>H', 855) + \
|
|
bytes('icnv', 'ascii') + bytearray([0] * 4)
|
|
d['.']['fwi0'] = ('blob', byte_stream)
|
|
d['.']['fwsw'] = ('long', 170)
|
|
d['.']['fwvh'] = ('shor', 296)
|
|
d['.']['ICVO'] = ('bool', True)
|
|
|
|
icvp = {
|
|
'viewOptionsVersion': 1,
|
|
'backgroundColorRed': 1.0,
|
|
'backgroundColorGreen': 1.0,
|
|
'backgroundColorBlue': 1.0,
|
|
'gridOffsetX': 0,
|
|
'gridOffsetY': 0,
|
|
'gridSpacing': 100,
|
|
|
|
'arrangeBy': 'none',
|
|
'showIconPreview': True,
|
|
'showItemInfo': False,
|
|
'labelOnBottom': True,
|
|
'textSize': 12.0,
|
|
'iconSize': 100.0,
|
|
'scrollPositionX': 0.0,
|
|
'scrollPositionY': 0.0
|
|
}
|
|
|
|
bg_path = f"/Volumes/{mountName}/.background/{bgPic}"
|
|
if os.path.exists(bg_path):
|
|
print(f"Using background file {bg_path}")
|
|
alias = Alias.for_file(bg_path)
|
|
icvp['backgroundType'] = 2
|
|
icvp['backgroundImageAlias'] = alias.to_bytes()
|
|
else:
|
|
print(f"No background file found at {bg_path}")
|
|
icvp['backgroundType'] = 1
|
|
|
|
d['.']['icvp'] = icvp
|
|
|
|
d['.']['icvt'] = ('shor', 12)
|
|
|
|
d[f"{name}.app"]["Iloc"] = (110, 167)
|
|
|