forked from fontforge/fontforge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathffosxbuild.sh
executable file
·77 lines (63 loc) · 2.42 KB
/
ffosxbuild.sh
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
#!/usr/bin/env bash
set -e -o pipefail
SCRIPT_BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INVOKE_BASE="$(pwd)"
APPDIR=$(realpath $1)
HASH=${2:0:7}
if [ -z "$APPDIR" ]; then
echo "Usage: `basename $0` appdir hash"
echo " appdir is the location to the FontForge.app that cmake generated"
echo " hash is the version hash of this build"
echo
echo " This script does not support overwriting an existing bundle."
exit 1
fi
builddate=`date +%Y-%m-%d`
if [ -z "$LDDX" ]; then
LDDX="$SCRIPT_BASE/lddx"
if [ ! -f "$LDDX" ]; then
LDDX="$INVOKE_BASE/lddx"
if [ ! -f "$LDDX" ]; then
echo "Fetching lddx..."
curl -L https://github.com/jtanx/lddx/releases/download/v0.1.0/lddx-0.1.0.tar.xz | tar -Jxf - -C "$INVOKE_BASE"
fi
fi
fi
# Now we bundle the Python libraries
echo "Bundling Python libraries..."
PYLIB=$(otool -L $APPDIR/Contents/Resources/opt/local/bin/fontforge | grep -i python | sed -e 's/ \(.*\)//')
PYVER=$(echo $PYLIB | rev | cut -d/ -f2 | rev)
PYTHON=python$PYVER
pycruft=$(realpath $(dirname $PYLIB)/../../..)
echo "pycruft: $pycruft"
mkdir -p $APPDIR/Contents/Frameworks
cp -a $pycruft/Python.framework $APPDIR/Contents/Frameworks
pushd $APPDIR/Contents/Frameworks/Python.framework/Versions/$PYVER/lib/$PYTHON/
rm site-packages || rm -rf site-packages
ln -s ../../../../../../Resources/opt/local/lib/$PYTHON/site-packages
popd
pushd $APPDIR/Contents/Resources/opt/local/lib/$PYTHON/site-packages
cp -Rn "$pycruft/Python.framework/Versions/$PYVER/lib/$PYTHON/site-packages/" .
popd
find "$APPDIR/Contents/Frameworks/Python.framework" -type f -name '*.pyc' | xargs rm -rf
pushd $APPDIR/Contents/Resources/opt/local
echo "Collecting and patching dependent libraries..."
$LDDX --overwrite --modify-special-paths --recursive --ignore-prefix /opt/X11 --collect lib \
bin/ $APPDIR/Contents/Frameworks/Python.framework/ lib/
popd
mkdir -p $APPDIR/Contents/MacOS
ln -s ../Frameworks/Python.framework/Versions/$PYVER/bin/$PYTHON "$APPDIR/Contents/MacOS/FFPython"
# Package it up
if [ ! -z "$CI" ]; then
echo "Creating the dmg..."
if [[ "$PYVER" < "3" ]]; then
dmgname=FontForge-$builddate-${HASH:0:7}-$PYTHON.app.dmg
else
dmgname=FontForge-$builddate-${HASH:0:7}.app.dmg
fi
hdiutil create -size 800m \
-volname FontForge \
-srcfolder $APPDIR \
-ov -format UDBZ \
$dmgname
fi