From 9acb6734576b0175b9036aa03288a2153898f90d Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 12 Sep 2023 14:55:21 +0200 Subject: [PATCH 1/3] Also add Dark Mode option on OSX While it's not actually exposed there, it's used internally in various GUI code. --- src/libresrc/osx/default_config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libresrc/osx/default_config.json b/src/libresrc/osx/default_config.json index 59f2ed05f..bc55f1996 100644 --- a/src/libresrc/osx/default_config.json +++ b/src/libresrc/osx/default_config.json @@ -16,7 +16,8 @@ "Save Charset" : "UTF-8", "Save UI State" : true, "Show Toolbar" : true, - "Toolbar Icon Size" : 16 + "Toolbar Icon Size" : 16, + "Dark Mode" : false }, From d10ffebe355b0bbd2d2c32cecc701d6e691b47cf Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 12 Sep 2023 14:57:42 +0200 Subject: [PATCH 2/3] Fix dictionary download on mac when osx-bundle is run more than once --- tools/osx-bundle.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/osx-bundle.sh b/tools/osx-bundle.sh index a1563a481..29e0fbfd9 100755 --- a/tools/osx-bundle.sh +++ b/tools/osx-bundle.sh @@ -61,10 +61,12 @@ echo "---- Copying dictionaries ----" if test -f "${DICT_DIR}"; then cp -v "${DICT_DIR}/*" "${PKG_DIR}/Contents/SharedSupport/dictionaries" else - echo "Specified dictionary directory ${DICT_DIR} not found. Downloading dictionaries:" - mkdir "${BUILD_DIR}/dictionaries" - curl -L "https://downloads.sourceforge.net/project/openofficeorg.mirror/contrib/dictionaries/en_US.zip" -o "${BUILD_DIR}/dictionaries/en_US.zip" - unzip "${BUILD_DIR}/dictionaries/en_US.zip" -d "${BUILD_DIR}/dictionaries" + mkdir -p "${BUILD_DIR}/dictionaries" + if ! test -f "${BUILD_DIR}/dictionaries/en_US.aff"; then + echo "Specified dictionary directory ${DICT_DIR} not found. Downloading dictionaries:" + curl -L "https://downloads.sourceforge.net/project/openofficeorg.mirror/contrib/dictionaries/en_US.zip" -o "${BUILD_DIR}/dictionaries/en_US.zip" + unzip "${BUILD_DIR}/dictionaries/en_US.zip" -d "${BUILD_DIR}/dictionaries" + fi cp -v "${BUILD_DIR}/dictionaries/en_US.aff" "${PKG_DIR}/Contents/SharedSupport/dictionaries" cp -v "${BUILD_DIR}/dictionaries/en_US.dic" "${PKG_DIR}/Contents/SharedSupport/dictionaries" fi From 49139f0a22af16f384622d7cb69f3df53639b3d5 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 12 Sep 2023 16:16:40 +0200 Subject: [PATCH 3/3] Fix OSX library wrangling when libs use @rpath or @loader_path Fixes arch1t3cht/Aegisub#77 --- tools/osx-fix-libs.py | 70 ++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 18 deletions(-) mode change 100755 => 100644 tools/osx-fix-libs.py diff --git a/tools/osx-fix-libs.py b/tools/osx-fix-libs.py old mode 100755 new mode 100644 index d853e20ee..7a7930d88 --- a/tools/osx-fix-libs.py +++ b/tools/osx-fix-libs.py @@ -9,10 +9,10 @@ import subprocess is_bad_lib = re.compile(r'(/usr/local|/opt)').match is_sys_lib = re.compile(r'(/usr|/System)').match -otool_libname_extract = re.compile(r'\s+(/.*?)[(\s:]').search -otool_loader_path_extract = re.compile(r'\s+@loader_path/(.*?)[(\s:]').search +otool_libname_extract = re.compile(r'\s+([/@].*?)[(\s:]').search goodlist = [] badlist = [] +badlist_orig = [] link_map = {} @@ -22,23 +22,58 @@ def otool(cmdline): return p.stdout.readlines() +def get_rpath(lib): + info = otool(['-l', lib]) + commands = [] + command = [] + for line in info: + line = line.strip() + if line.startswith("Load command "): + commands.append(command) + command = [] + else: + command.append(line) + commands.append(command) + + # yuck + return [line.split()[1] for command in commands if "cmd LC_RPATH" in command for line in command if line.startswith("path")] + + def collectlibs(lib, masterlist, targetdir): global goodlist, link_map liblist = otool(['-L', lib]) locallist = [] for l in liblist: - lr = otool_libname_extract(l) - if lr: - l = lr.group(1) - else: - lr = otool_loader_path_extract(l) - if lr: - l = os.path.join(os.path.dirname(lib), lr.group(1)) - else: - continue - if is_bad_lib(l) and l not in badlist: - badlist.append(l) + l = otool_libname_extract(l) + if not l: + continue + + l = l.group(1) + l_orig = l + + if l.startswith("@rpath/"): + rpath = get_rpath(lib) + + if not rpath: + print(f"{lib} uses @rpath but has no rpath set!") + exit(-1) + + # all cases of libs using rpath so far just had a single directory in rpath... + # so let's just hope it stays that way and worry about the other cases when we get to them + if len(rpath) >= 2: + print(f"Warning: {lib} uses @rpath with more than one entry in rpath. Guessing one entry...") + + l = os.path.join(rpath[0], l[len("@rpath/"):]) + + if l.startswith("@loader_path/"): + l = os.path.join(os.path.dirname(lib), l[len("@loader_path/"):]) + + if is_bad_lib(l): + if l not in badlist: + badlist.append(l) + if l_orig not in badlist_orig: + badlist_orig.append(l_orig) if ((not is_sys_lib(l)) or is_bad_lib(l)) and l not in masterlist: locallist.append(l) print("found %s:" % l) @@ -76,7 +111,6 @@ def collectlibs(lib, masterlist, targetdir): print(" LINK %s ... copied to target" % check) link_list.append(basename) check = os.path.join(os.path.dirname(check), link_dst) - elif l not in goodlist and l not in masterlist: goodlist.append(l) masterlist.extend(locallist) @@ -101,10 +135,13 @@ if __name__ == '__main__': print() print("Fixing library install names...") in_tool_cmdline = ['install_name_tool'] - for lib in libs: + for lib in badlist_orig: libbase = os.path.basename(lib) if libbase in link_map: + print("%s -> @executable_path/%s (REMAPPED)" % (lib, libbase)) libbase = link_map[libbase] + else: + print("%s -> @executable_path/%s" % (lib, libbase)) in_tool_cmdline = in_tool_cmdline + ['-change', lib, '@executable_path/' + libbase] for lib in libs: @@ -112,9 +149,6 @@ if __name__ == '__main__': if libbase in link_map: libbase = link_map[libbase] - print("%s -> @executable_path/%s (REMAPPED)" % (lib, libbase)) - else: - print("%s -> @executable_path/%s" % (lib, libbase)) targetlib = targetdir + '/' + libbase orig_permission = os.stat(targetlib).st_mode