forked from Arelle/Arelle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildMacDist39.sh
194 lines (152 loc) · 6.5 KB
/
buildMacDist39.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/sh
# DO_CODESIGN is either false or true
DO_CODESIGN=false
IDENTAPP="Developer ID Application: Mark V Systems Limited (UUN8V38Y3D)"
IDENTPKG="Developer ID Installer: Mark V Systems Limited (UUN8V38Y3D)"
echo DO_CODESIGN=$DO_CODESIGN
echo IDENTAPP="$IDENTAPP"
echo IDENTPKG="$IDENTPKG"
PYTHON=python3.9 # built-in framework accessed via /usr/local/bin
# PYTHON=$HOME/Python39/bin/$PYTHON
# export LD_LIBRARY_PATH=$HOME/Python39/lib
# remove old build
/bin/rm -rf build/*.app build/lib build/exe.macos* build/*.dmg build/*.command
/bin/rm -rf dist_dmg/arelle-macOS*
/bin/rm -rf dist/arelle-macOS*
/bin/rm -rf dist_dmg/*.dmg
# set the build date in version.py
$PYTHON buildVersion.py
# Regenerate messages catalog (doc/messagesCatalog.xml)
$PYTHON generateMessagesCatalog.py
# create new app
$PYTHON setup.py bdist_mac
# 3.9 patches
#cp -r /Library/Frameworks/Python.framework/Versions/3.9/lib/$PYTHON/site-packages/pycountry-20.7.3-py3.9.egg-info build/Arelle.app/Contents/MacOS/lib
cp -r /Library/Frameworks/Python.framework/Versions/3.9/lib/tcl8.6 build/Arelle.app/Contents/MacOS
cp -r /Library/Frameworks/Python.framework/Versions/3.9/lib/tk8.6 build/Arelle.app/Contents/MacOS
rm -fr build/Arelle.app/Contents/MacOS/lib/arelle/plugin build/Arelle.app/Contents/MacOS/lib/arelle/config build/Arelle.app/Contents/MacOS/lib/arelle/images
# move python modules to Resources
if [ $DO_CODESIGN = true ]
then
for f in config doc examples images locale plugin scripts tcl8.6 tk8.6 Tktable2.11 ;
do
mv build/Arelle.app/Contents/MacOS/$f build/Arelle.app/Contents/Resources
done
for f in `ls build/Arelle.app/Contents/MacOS/lib | grep -v "Python\|encodings\|codecs\|importlib\|matplotlib\|zlib\|library.zip\|so$"`
do
mv build/Arelle.app/Contents/MacOS/lib/$f build/Arelle.app/Contents/Resources/lib
done
fi
# code signing
codesign --remove-signature build/Arelle.app/Contents/MacOS/lib/Python
for f in `find build/Arelle.app/Contents/MacOS \( -name '*.so' -o -name '*.dylib' \)`
do
codesign --remove-signature $f
done
if [ $DO_CODESIGN = true ]
then
for f in `ls build/Arelle.app/Contents/MacOS/*dylib`
do
codesign -s "$IDENTAPP" $f
done
for f in `ls build/Arelle.app/Contents/MacOS/lib/*so`
do
codesign -s "$IDENTAPP" $f
done
for f in `find build/Arelle.app/Contents/Resources \( -name '*.so' -o -name '*.dylib' \)`
do
codesign --remove-signature $f
codesign -s "$IDENTAPP" $f
done
codesign -s "$IDENTAPP" build/Arelle.app/Contents/MacOS/lib/Python
codesign --options runtime --deep -s "$IDENTAPP" build/Arelle.app/Contents/MacOS/arelleCmdLine
codesign --options runtime --deep -s "$IDENTAPP" build/Arelle.app/Contents/MacOS/arelleGUI
fi
# remove .git subdirectories
find build/Arelle.app/Contents/Resources -name .git -exec rm -fR {} \;
# copy scripts to get packaged with app in distribution directory
mkdir dist
cp arelle/scripts-macOS/* build
mkdir dist_dmg
# simple way to create the .dmg file
# hdiutil create -fs HFS+ -volname "ARELLE" -srcfolder dist dist_dmg/arelle.dmg
if [ ! -e build/Applications ]
then
osascript -e 'tell application "Finder" to make alias file to POSIX file "/Applications" at POSIX file "/Users/arelle/hfdev/build"'
fi
#hdiutil create -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDZO dist_dmg/arelle.dmg -imagekey zlib-level=9 -srcfolder build/Arelle.app -volname Arelle -srcfolder build/Applications
# rename the .dmg file with the exact same version date as Version.py
#sh -x buildRenameDmg.sh
#exit
# create .dmg with background image and positioned icons
# make an image dmg
# set up your app name, version number, and background image file name
DMG_BACKGROUND_IMG="arelle/images/dmg_background.png"
# figure out how big our DMG needs to be
# assumes our contents are at least 1M!
SIZE=`du -sh build/Arelle.app | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
# +1 is not enough, try +2 SIZE=`echo "${SIZE} + 1.0" | bc | awk '{print int($1+0.5)}'`
SIZE=`echo "${SIZE} + 20.0" | bc | awk '{print int($1+0.5)}'`
if [ $? -ne 0 ]; then
echo "Error: Cannot compute size of staging dir"
exit
fi
# create the temp DMG file
hdiutil create -srcfolder build/Arelle.app -volname Arelle -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M dist_dmg/arelle_tmp.dmg
echo "Created DMG: arelle_tmp.dmg"
# mount it and save the device
DEVICE=$(hdiutil attach -readwrite -noverify dist_dmg/arelle_tmp.dmg | \
egrep '^/dev/' | sed 1q | awk '{print $1}')
sleep 2
# add a link to the Applications dir
echo "Add link to /Applications"
pushd /Volumes/Arelle
ln -s /Applications
popd
# add a background image
mkdir /Volumes/Arelle/.background
cp arelle/images/dmg_background.png /Volumes/Arelle/.background/
# tell the Finder to resize the window, set the background,
# change the icon size, place the icons in the right position, etc.
echo '
tell application "Finder"
tell disk "Arelle"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {400, 100, 920, 440}
set viewOptions to the icon view options of container window
set arrangement of viewOptions to not arranged
set icon size of viewOptions to 72
set background picture of viewOptions to file ".background:dmg_background.png"
set position of item ".background" of container window to {999,999}
set position of item ".DS_Store" of container window to {999,1099}
set position of item ".Trashes" of container window to {999,1199}
set position of item ".fseventsd" of container window to {999,1299}
set position of item "Arelle.app" of container window to {150, 70}
set position of item "startWebServer.command" of container window to {360, 70}
set position of item "Applications" of container window to {260, 240}
close
open
update without registering applications
delay 2
end tell
end tell
' | osascript
sync
# unmount it
hdiutil detach "${DEVICE}"
# now make the final image a compressed disk image
echo "Creating compressed image"
hdiutil convert dist_dmg/arelle_tmp.dmg -format UDZO -imagekey zlib-level=9 -o dist_dmg/arelle.dmg
rm dist_dmg/arelle_tmp.dmg
# sign package
build/Arelle.app/Contents/
if [ $DO_CODESIGN = true ]
then
codesign -s "$IDENTAPP" dist_dmg/arelle.dmg
fi
# rename the .dmg file with the exact same version date as Version.py
sh -x buildRenameDmg.sh