Skip to content

Commit

Permalink
iTerm2: macOS 13 codesign build failure fix
Browse files Browse the repository at this point in the history
temporary python 3 patch for macOS 12
  • Loading branch information
i0ntempest committed Jun 14, 2022
1 parent a72bfa8 commit 3834a9b
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 2 deletions.
19 changes: 17 additions & 2 deletions aqua/iTerm2/Portfile
Expand Up @@ -13,7 +13,8 @@ if {${os.major} > 17} {
size 29047663
patchfiles patch-Makefile-XC10.diff \
patch-remove-sparkle-3.4.diff \
patch-nsur.diff
patch-nsur.diff \
patch-python3.diff
} elseif {${os.major} > 16} {
version 3.3.12
revision 2
Expand Down Expand Up @@ -52,9 +53,23 @@ homepage https://iterm2.com/

github.livecheck.regex {(\d+(?:\.\d+)*)}

# manually fix python interpreter before upstream has a fix
if {${os.major} >= 21} {
depends_build-append \
port:python310 \
port:py310-pyobjc
post-patch {
reinplace "s|#!/usr/bin/python3|#!${prefix}/bin/python3.10|" ${worksrcpath}/tools/updateVersion.py
}
}

post-patch {
reinplace "s|CODE_SIGN_IDENTITY = \".*\";|CODE_SIGN_IDENTITY = \"\";|g" ${worksrcpath}/iTerm2.xcodeproj/project.pbxproj
# macOS 13/Xcode 14 seems to be requiring code signing
if {[vercmp ${xcodeversion} 14] >= 0} {
reinplace "s|CODE_SIGN_IDENTITY = \".*\";|CODE_SIGN_IDENTITY = \"-\";|g" ${worksrcpath}/iTerm2.xcodeproj/project.pbxproj
} else {
reinplace "s|CODE_SIGN_IDENTITY = \".*\";|CODE_SIGN_IDENTITY = \"\";|g" ${worksrcpath}/iTerm2.xcodeproj/project.pbxproj
}
reinplace "s|enableUBSanitizer = \"YES\"||g" ${worksrcpath}/iTerm2.xcodeproj/xcshareddata/xcschemes/iTerm2.xcscheme
}

Expand Down
73 changes: 73 additions & 0 deletions aqua/iTerm2/files/patch-python3.diff
@@ -0,0 +1,73 @@
diff --git a/sources/PTYSession.m b/sources/PTYSession.m
index 28724c40c3..8132d872b3 100644
--- sources/PTYSession.m
+++ sources/PTYSession.m
@@ -2261,7 +2261,7 @@ - (NSDictionary *)environmentForNewJobFromEnvironment:(NSDictionary *)environmen
substitutions:(NSDictionary *)substitutions {
DLog(@"environmentForNewJobFromEnvironment:%@ substitutions:%@",
environment, substitutions);
- NSMutableDictionary *env = [[environment mutableCopy] autorelease];
+ NSMutableDictionary *env = environment ? [[environment mutableCopy] autorelease] : [NSMutableDictionary dictionary];

This comment has been minimized.

Copy link
@ryandesign

ryandesign Jun 14, 2022

Contributor

Is this related to the python change?

This changes the compiled code so the revision (when this patch is used) needs to be increased.

This comment has been minimized.

Copy link
@i0ntempest

i0ntempest Jun 14, 2022

Author Member

I'm not sure, it's in the same upstream commit mentioning the python fix so I presume it probably is.

if (env[TERM_ENVNAME] == nil) {
env[TERM_ENVNAME] = _termVariable;
}
diff --git a/tools/updateVersion.py b/tools/updateVersion.py
index 82ec7ce5c5..e5c58aff9f 100755
--- tools/updateVersion.py
+++ tools/updateVersion.py
@@ -1,41 +1,37 @@
-#!/usr/bin/python
+#!/usr/bin/python3

-import commands
import os
-import sys
import time
+import subprocess

try:
- del os.environ["MACOSX_DEPLOYMENT_TARGET"]
+ del os.environ["MACOSX_DEPLOYMENT_TARGET"]
except KeyError:
- pass
+ pass
from Foundation import NSMutableDictionary

if os.environ["CONFIGURATION"] == "Development":
- cmd = "git log -1 --format=\"%H\""
- status, output = commands.getstatusoutput(cmd)
- if status != 0:
- sys.exit(status)
+ cmd = "git log -1 --format=\"%H\""
+ output = subprocess.check_output(cmd, shell=True).decode("utf-8")

- revision = "git.unknown"
- for line in output.split("\n"):
- if len(line.strip()) > 0:
- revision = "git." + line.strip()[:10]
- break
+ revision = "git.unknown"
+ for line in output.split("\n"):
+ if len(line.strip()) > 0:
+ revision = "git." + line.strip()[:10]
+ break

elif os.environ["CONFIGURATION"] == "Nightly":
- revision = time.strftime("%Y%m%d-nightly")
+ revision = time.strftime("%Y%m%d-nightly")
else:
- revision = time.strftime("%Y%m%d")
+ revision = time.strftime("%Y%m%d")

buildDir = os.environ["BUILT_PRODUCTS_DIR"]
infoFile = os.environ["INFOPLIST_PATH"]
path = os.path.join(buildDir, infoFile)
plist = NSMutableDictionary.dictionaryWithContentsOfFile_(path)
version = open("version.txt").read().strip() % {"extra": revision}
-print "Updating versions:", infoFile, version
+print("Updating versions:", infoFile, version)
plist["CFBundleShortVersionString"] = version
plist["CFBundleGetInfoString"] = version
plist["CFBundleVersion"] = version
plist.writeToFile_atomically_(path, 1)
-

0 comments on commit 3834a9b

Please sign in to comment.