forked from Lucterios2/setup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_mac.sh
More file actions
executable file
·246 lines (207 loc) · 9.28 KB
/
install_mac.sh
File metadata and controls
executable file
·246 lines (207 loc) · 9.28 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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/env bash
if [ "${OSTYPE:0:6}" != "darwin" ]
then # Not Mac OS X
echo ">>> This script must be run only for Mac OS X (darwin) <<<" 1>&2
exit 1
fi
PACKAGES="@@PACKAGE@@"
APP_NAME="@@NAME@@"
function usage
{
echo "${0##*/}: installation for @@NAME@@"
echo " ${0##*/} -h"
echo " ${0##*/} [-p <packages>] [-n <application_name>]"
echo "option:"
echo " -h: show this help"
echo " -p: define the packages list to install (default: '$PACKAGES')"
echo " -n: define the application name for shortcut (default: '$APP_NAME')"
exit 0
}
function finish_error
{
msg=$1
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!">&2
echo " Error: $msg">&2
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!">&2
exit 1
}
while getopts "i:p:n:h" opt ; do
case $opt in
p) PACKAGES="$OPTARG"
;;
n) APP_NAME="$OPTARG"
;;
h) usage $0
exit 0
;;
\?) finish_error "Unrecognized parameter -$OPTARG"
;;
:) finish_error "Option -$OPTARG requires an argument."
;;
esac
done
PIP_OPTION="@@PIPOPTION@@"
if [ ! -z "$http_proxy" ]
then
PIP_OPTION="$PIP_OPTION --proxy=$http_proxy"
fi
LUCTERIOS_PATH="$HOME/lucterios2"
if [ -d "/var/lucterios2" ] # conversion from old installation
then
if [ -d $LUCTERIOS_PATH ]
then
sudo rm -rf "/var/lucterios2"
else
sudo mv "/var/lucterios2" "$LUCTERIOS_PATH"
sudo chown -R $LOGNAME "$LUCTERIOS_PATH"
fi
fi
echo "====== install @@NAME@@ #@@BUILD@@ ======"
echo "install: packages=$PACKAGES application_name=$APP_NAME"
echo
echo "------ check perquisite -------"
echo
BREW_PATH="$HOME/lucterios2_brew"
export PKG_CONFIG_PATH="$BREW_PATH/opt/openssl/lib/pkgconfig"
export PATH="$BREW_PATH/bin/:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
mkdir -p $BREW_PATH && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C $BREW_PATH
if [ ! -z "$(which brew 2>/dev/null)" ]; then
brew update
liblist="libxml2 libxslt libjpeg libpng libtiff giflib tcl-tk cairo pango gdk-pixbuf libffi python3 poppler"
for libname in $liblist
do
brew uninstall --force $libname || echo "-- no $libname --"
done
brew install libxml2 libxslt libjpeg libpng libtiff giflib tcl-tk
brew install cairo pango gdk-pixbuf libffi
brew install poppler
brew install python@3.11
brew install python-tk@3.11
brew install python-gdbm@3.11
else
finish_error "brew not installed on Mac OS X!"
fi
[ -z "$(grep $HOSTNAME /etc/hosts)" ] && sudo sh -c "echo 127.0.0.1 $HOSTNAME >> /etc/hosts"
echo
echo "------ configure virtual environment ------"
echo
py_version=$(python3 --version | egrep -o '([0-9]+\.[0-9]+)')
if [ "$py_version" != "3.10" -a "$py_version" != "3.11" -a "$py_version" != "3.12" -a "$py_version" != "3.13" ]
then
finish_error "Not Python 3.10, 3.11, 3.12 or 3.13 (but $py_version) !"
fi
PYTHON_CMD="python3"
set -e
echo "$PYTHON_CMD -m pip install -U $PIP_OPTION pip virtualenv"
sudo $PYTHON_CMD -m pip install -U $PIP_OPTION pip virtualenv
mkdir -p $LUCTERIOS_PATH
cd $LUCTERIOS_PATH
echo "$PYTHON_CMD -m virtualenv virtual_for_lucterios"
sudo rm -rf virtual_for_lucterios
$PYTHON_CMD -m virtualenv virtual_for_lucterios
echo
echo "------ install @@NAME@@ ------"
echo
. $LUCTERIOS_PATH/virtual_for_lucterios/bin/activate
pip uninstall PIL
pip uninstall Pillow
pip install -U $PIP_OPTION $PACKAGES
[ -z "$(pip list 2>/dev/null | grep 'Django ')" ] && finish_error "Django not installed !"
[ -z "$(pip list 2>/dev/null | grep 'lucterios ')" ]&& finish_error "Lucterios not installed !"
if [ -f virtual_for_lucterios/lib/python$py_version/site-packages/lucterios/framework/settings.py ]
then
sed 's|!= "nt"|!= "nt" and False|g' virtual_for_lucterios/lib/python$py_version/site-packages/lucterios/framework/settings.py > /tmp/settings.py
cp /tmp/settings.py virtual_for_lucterios/lib/python$py_version/site-packages/lucterios/framework/settings.py
rm /tmp/settings.py
fi
lucterios_admin.py update || lucterios_admin.py refreshall || echo '--no update/refresh--'
[ -f "$LUCTERIOS_PATH/extra_url" ] || echo "# Pypi server" > "$LUCTERIOS_PATH/extra_url"
echo
echo "------ refresh shortcut ------"
echo
rm -rf $LUCTERIOS_PATH/launch_lucterios.sh
touch $LUCTERIOS_PATH/launch_lucterios.sh
echo "#!/usr/bin/env bash" >> $LUCTERIOS_PATH/launch_lucterios.sh
echo >> $LUCTERIOS_PATH/launch_lucterios.sh
echo "export LUCTERIOS_INSTALL='@@BUILD@@'" >> $LUCTERIOS_PATH/launch_lucterios.sh
echo >> $LUCTERIOS_PATH/launch_lucterios.sh
echo ". $LUCTERIOS_PATH/virtual_for_lucterios/bin/activate" >> $LUCTERIOS_PATH/launch_lucterios.sh
echo "cd $LUCTERIOS_PATH/" >> $LUCTERIOS_PATH/launch_lucterios.sh
if [ -z "$LANG" -o "$LANG" == "C" ]
then
echo "export LANG=en_US.UTF-8" >> $LUCTERIOS_PATH/launch_lucterios.sh
fi
qt_version=$($PYTHON_CMD -c 'from PyQt6.QtCore import QT_VERSION_STR;print(QT_VERSION_STR)' 2>/dev/null)
cp $LUCTERIOS_PATH/launch_lucterios.sh $LUCTERIOS_PATH/launch_lucterios_gui.sh
echo "lucterios_gui.py" >> $LUCTERIOS_PATH/launch_lucterios_gui.sh
chmod +x $LUCTERIOS_PATH/launch_lucterios_gui.sh
cp $LUCTERIOS_PATH/launch_lucterios.sh $LUCTERIOS_PATH/launch_lucterios_qt.sh
echo "lucterios_qt.py" >> $LUCTERIOS_PATH/launch_lucterios_qt.sh
chmod +x $LUCTERIOS_PATH/launch_lucterios_qt.sh
echo 'lucterios_admin.py $@' >> $LUCTERIOS_PATH/launch_lucterios.sh
chmod +x $LUCTERIOS_PATH/launch_lucterios.sh
chmod -R ogu+w $LUCTERIOS_PATH
ln -sf $LUCTERIOS_PATH/launch_lucterios.sh /usr/local/bin/launch_lucterios
ln -sf $LUCTERIOS_PATH/launch_lucterios_gui.sh /usr/local/bin/launch_lucterios_gui
ln -sf $LUCTERIOS_PATH/launch_lucterios_qt.sh /usr/local/bin/launch_lucterios_qt
icon_path=$(find "$LUCTERIOS_PATH/virtual_for_lucterios" -name "$APP_NAME.png" | head -n 1)
APPDIR="$PWD/$APP_NAME.command"
echo '#!/usr/bin/env bash' > $APPDIR
echo 'launch_lucterios_gui' >> $APPDIR
chmod ogu+rx "$APPDIR"
rm -rf $APP_NAME.iconset
if [ ! -z "$icon_path" ]
then
mkdir $APP_NAME.iconset
sips -z 16 16 $icon_path --out "$APP_NAME.iconset/icon_16x16.png"
sips -z 32 32 $icon_path --out "$APP_NAME.iconset/icon_16x16@2x.png"
sips -z 32 32 $icon_path --out "$APP_NAME.iconset/icon_32x32.png"
sips -z 64 64 $icon_path --out "$APP_NAME.iconset/icon_32x32@2x.png"
sips -z 128 128 $icon_path --out "$APP_NAME.iconset/icon_128x128.png"
sips -z 256 256 $icon_path --out "$APP_NAME.iconset/icon_128x128@2x.png"
sips -z 256 256 $icon_path --out "$APP_NAME.iconset/icon_256x256.png"
sips -z 512 512 $icon_path --out "$APP_NAME.iconset/icon_256x256@2x.png"
sips -z 512 512 $icon_path --out "$APP_NAME.iconset/icon_512x512.png"
cp $icon_path $APP_NAME.iconset/icon_512x512@2x.png
iconutil -c icns $APP_NAME.iconset
rm -rf $APP_NAME.iconset
fi
[ -d "/Applications/$APP_NAME.app" ] && rm -rf /Applications/$APP_NAME.app
mkdir -p /Applications/$APP_NAME.app/Contents/MacOS
mkdir -p /Applications/$APP_NAME.app/Contents/Resources
cp $HOME/lucterios2/$APP_NAME.icns /Applications/$APP_NAME.app/Contents/Resources/
echo '#!/usr/bin/env bash' > /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
echo '' >> /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
echo '. $HOME/lucterios2/virtual_for_lucterios/bin/activate' >> /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
echo 'cd $HOME/lucterios2/' >> /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
echo 'export LANG=fr_FR.UTF-8' >> /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
if [ "${qt_version:0:2}" == "6." ]
then
echo 'lucterios_qt.py | lucterios_gui.py' >> /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
else
echo 'lucterios_gui.py' >> /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
fi
chmod ugo+rx /Applications/$APP_NAME.app/Contents/MacOS/$APP_NAME
echo '<?xml version="1.0" encoding="UTF-8"?>' > /Applications/$APP_NAME.app/Contents/Info.plist
echo '<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" " www.apple.com/DTDs/PropertyList-1.0.dtd ">' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo '<plist version="1.0">' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo '<dict>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <key>CFBundleExecutable</key>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <string>'$APP_NAME'</string>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <key>CFBundleGetInfoString</key>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <string>'$APP_NAME'</string>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <key>CFBundleIconFile</key>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <string>'$APP_NAME'.icns</string>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <key>CFBundleName</key>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <string>'$APP_NAME'</string>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <key>CFBundlePackageType</key>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <string>APPL</string>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <key>CFBundleShortVersionString</key>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo ' <string>@@BUILD@@</string>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo '</dict>' >> /Applications/$APP_NAME.app/Contents/Info.plist
echo '</plist>' >> /Applications/$APP_NAME.app/Contents/Info.plist
chmod -R ogu+rw "$LUCTERIOS_PATH"
echo "=================================="
echo " Installation finish with success."
echo "============== END ==============="
exit 0