Skip to content

Commit a3fc259

Browse files
Merge pull request #98 from salopensource/apple_silicon
Apple silicon pt 2
2 parents e7bab64 + 9bffc03 commit a3fc259

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ build-python:
5555
@find ./Python.framework -name '*.pyc' -delete
5656

5757
sign: remove-xattrs
58-
@sudo ./sign_python_framework.py -v -S "${DEV_APP_CERT}"
58+
@sudo ./sign_python_framework.py -v -S "${DEV_APP_CERT}" -L ${WORK_D}/usr/local/sal/Python.framework
5959

6060
remove-xattrs:
6161
@sudo xattr -rd com.dropbox.attributes ${WORK_D}

payload/usr/local/sal/checkin_modules/machine_checkin.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,20 @@ def process_system_profile():
4242
# We can't continue if system_profiler dies.
4343
return machine_results
4444

45-
machine_results["serial"] = system_profile["SPHardwareDataType"][0]["serial_number"]
46-
os_version = system_profile["SPSoftwareDataType"][0]["os_version"].split()[1]
45+
machine_results["serial"] = system_profile["SPHardwareDataType"][0].get(
46+
"serial_number"
47+
)
48+
os_version = system_profile["SPSoftwareDataType"][0].get("os_version").split()[1]
4749
if os_version == "X":
48-
os_version = system_profile["SPSoftwareDataType"][0]["os_version"].split()[2]
50+
os_version = (
51+
system_profile["SPSoftwareDataType"][0].get("os_version").split()[2]
52+
)
4953
machine_results["operating_system"] = os_version
50-
machine_results["machine_model"] = system_profile["SPHardwareDataType"][0][
54+
machine_results["machine_model"] = system_profile["SPHardwareDataType"][0].get(
5155
"machine_model"
52-
]
56+
)
5357

54-
udid = system_profile["SPHardwareDataType"][0]["provisioning_UDID"]
58+
udid = system_profile["SPHardwareDataType"][0].get("provisioning_UDID")
5559
friendly_model = get_friendly_model(serial=machine_results["serial"], udid=udid)
5660
if friendly_model:
5761
machine_results["machine_model_friendly"] = friendly_model
@@ -63,12 +67,12 @@ def process_system_profile():
6367
machine_results["cpu_type"] = system_profile["SPHardwareDataType"][0].get(
6468
"cpu_type", ""
6569
)
66-
machine_results["cpu_speed"] = system_profile["SPHardwareDataType"][0][
67-
"current_processor_speed"
68-
]
69-
machine_results["memory"] = system_profile["SPHardwareDataType"][0][
70-
"physical_memory"
71-
]
70+
machine_results["cpu_speed"] = system_profile["SPHardwareDataType"][0].get(
71+
"current_processor_speed", ""
72+
)
73+
machine_results["memory"] = system_profile["SPHardwareDataType"][0].get(
74+
"physical_memory", ""
75+
)
7276
machine_results["memory_kb"] = process_memory(machine_results["memory"])
7377

7478
for device in system_profile["SPStorageDataType"]:
@@ -116,7 +120,13 @@ def get_friendly_model(serial, udid):
116120
try:
117121
data = plistlib.loads(out)
118122
if len(data) != 0:
119-
return data[0].get("product-name").decode("utf-8")
123+
return (
124+
data[0]
125+
.get("product-name")
126+
.encode("ascii", "ignore")
127+
.decode()
128+
.strip()
129+
)
120130
except:
121131
pass
122132

sal_python_pkg/sal/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.2.0"
1+
__version__ = "4.2.1"

sign_python_framework.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@
3737

3838
PYTHON_VERSION = "3.9.7"
3939
SHORT_PYTHON_VERSION = "3.9"
40-
TOOLS_DIR = os.path.dirname(os.path.realpath(__file__))
41-
42-
43-
PY_FWK = os.path.join(TOOLS_DIR, "Python.Framework")
44-
PY_CUR = os.path.join(PY_FWK, "Versions/Current")
45-
4640

4741
PRODUCTSIGN = "/usr/bin/productsign"
4842
CODESIGN = "/usr/bin/codesign"
@@ -136,11 +130,20 @@ def main():
136130
"-S",
137131
"--sign-binaries",
138132
action="store",
133+
dest="sign_binaries",
139134
default=None,
140135
help="A Developer ID Application certificate from keychain. "
141136
"Provide the certificate's Common Name. e.g.: "
142137
"'Developer ID Application Munki (U8PN57A5N2)'",
143138
),
139+
p.add_argument(
140+
"-L",
141+
"--location",
142+
action="store",
143+
dest="location",
144+
default=None,
145+
help="Path to python framework to sign.",
146+
),
144147
p.add_argument("-v", "--verbose", action="store_true", help="Be more verbose"),
145148

146149
args = p.parse_args()
@@ -159,7 +162,11 @@ def main():
159162
global verbose
160163
verbose = args.verbose
161164

162-
root_dir = os.path.join(TOOLS_DIR, "Python.framework")
165+
if not args.location:
166+
print("Path to Python.framework must be provided.")
167+
sys.exit(1)
168+
root_dir = args.location
169+
PY_CUR = os.path.join(root_dir, "Versions/Current")
163170
# Set root:admin throughout payload
164171
for root, dirs, files in os.walk(root_dir):
165172
for dir_ in dirs:
@@ -227,7 +234,7 @@ def main():
227234
entitlements=ent_file,
228235
)
229236
# Finally sign python framework
230-
py_fwkpath = os.path.join(root_dir, PY_FWK)
237+
py_fwkpath = os.path.join(root_dir, root_dir)
231238
if verbose:
232239
print(f"Signing {py_fwkpath}...")
233240
sign_binary(args.sign_binaries, py_fwkpath, deep=True, force=True)

0 commit comments

Comments
 (0)