Skip to content

Commit

Permalink
Merge branches 'bugfixes' and 'workarounds' into feature
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1t3cht committed Sep 12, 2023
3 parents 1fde843 + 49139f0 + 9acb673 commit 8fb8e90
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.
3 changes: 2 additions & 1 deletion src/libresrc/osx/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},


Expand Down
10 changes: 6 additions & 4 deletions tools/osx-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
70 changes: 52 additions & 18 deletions tools/osx-fix-libs.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

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 = {}


Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -101,20 +135,20 @@ def collectlibs(lib, masterlist, targetdir):
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:
libbase = os.path.basename(lib)

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
Expand Down

0 comments on commit 8fb8e90

Please sign in to comment.