forked from Komodo/KomodoEdit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-komodo-layout.sh
More file actions
executable file
·84 lines (73 loc) · 3.48 KB
/
Copy pathmake-komodo-layout.sh
File metadata and controls
executable file
·84 lines (73 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
OUT=${1:-"$ROOT/Komodo-Edit-local"}
copy_tree() {
src=$1
dest=$2
mkdir -p "$dest"
cp -aL "$src"/. "$dest"/
}
rm -rf "$OUT"
mkdir -p "$OUT/bin" "$OUT/lib" "$OUT/share"
# Launcher stub with portable runtime env bootstrap.
cp "$ROOT/src/main/stub/komodo" "$OUT/bin/komodo"
chmod +x "$OUT/bin/komodo"
# Build-tree runtime payload.
copy_tree "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/bin" "$OUT/lib/mozilla"
copy_tree "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/lib" "$OUT/lib/mozilla"
copy_tree "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/komodo-bits/support" "$OUT/lib/support"
copy_tree "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/komodo-bits/sdk" "$OUT/lib/sdk"
# A portable bundle must not advertise itself as a dev tree, otherwise
# runtime directory lookup points into a non-existent lib/komodo-bits tree.
rm -f "$OUT/lib/mozilla/is_dev_tree.txt"
# PyXPCOM runtime bits live under the Python extension payload as well.
if [ -d "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/extensions/python/dist" ]; then
copy_tree "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/extensions/python/dist" "$OUT/lib/mozilla/extensions/python/dist"
fi
# Optional convenience links if present.
if [ -d "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/python" ]; then
copy_tree "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/python" "$OUT/lib/python"
fi
if [ -d "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/bin/icons" ]; then
copy_tree "$ROOT/mozilla/build/moz3500-ko12.10/mozilla/ko-rel/dist/bin/icons" "$OUT/share/icons"
fi
# The actual application icons (komodo16/32/48/64/128/256.edit.png) come
# from Komodo's own top-level "bk build" output (build/release/main/),
# not from the Mozilla ko-rel tree -- install_desktop_entry expects them
# as share/icons/komodoNN.png (no ".edit" product-type infix).
if [ -d "$ROOT/build/release/main" ]; then
mkdir -p "$OUT/share/icons"
for f in "$ROOT"/build/release/main/komodo*.edit.png; do
[ -f "$f" ] || continue
base=$(basename "$f")
cp -aL "$f" "$OUT/share/icons/$(echo "$base" | sed 's/\.edit\././')"
done
fi
# The siloed Python's "relocatable" build leaves some extension modules
# (and libpython itself) with a hardcoded absolute RPATH pointing back at
# the build-tree ko-rel/dist/lib, instead of a portable $ORIGIN-relative
# one. That breaks the install once the build tree is gone (or on any
# other machine). bin/komodo already builds a correct LD_LIBRARY_PATH
# (covering lib/mozilla and lib/python/lib) before exec'ing, and a
# leftover absolute RPATH takes priority over LD_LIBRARY_PATH and wins
# with the wrong, non-existent path -- so just strip those, and let
# LD_LIBRARY_PATH do its job.
if command -v patchelf >/dev/null 2>&1; then
find "$OUT" -type f \( -name "*.so" -o -name "*.so.*" \) 2>/dev/null | while IFS= read -r so; do
cur_rpath=$(patchelf --print-rpath "$so" 2>/dev/null || true)
case "$cur_rpath" in
*'$ORIGIN'*|"") continue ;;
/*)
perms=$(stat -c '%a' "$so")
chmod u+w "$so"
patchelf --remove-rpath "$so"
chmod "$perms" "$so"
;;
esac
done
else
echo "WARNING: patchelf not found; leaving broken absolute RPATHs in place (install '\''patchelf'\'' to fix)" >&2
fi
echo "Created layout: $OUT"
echo "Start with: $OUT/bin/komodo"