This repository has been archived by the owner on May 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrapper
executable file
·270 lines (230 loc) · 9.27 KB
/
wrapper
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/bin/bash
###############################################
# Launcher common exports for any desktop app #
###############################################
export HOME="$SNAP_USER_COMMON"
# Set XDG runtime directory
export XDG_RUNTIME_DIR=/run/shm/snap.$SNAP_NAME.$SNAP_REVISION
mkdir -p $XDG_RUNTIME_DIR
needs_update=true
. ~/.last_revision 2>/dev/null || true
if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then
needs_update=false
fi
[ $needs_update = true ] && echo "Updating of Qucs environment. Please wait..."
[ $needs_update = true ] && echo "SNAP_DESKTOP_LAST_REVISION=$SNAP_REVISION" > ~/.last_revision
if [ "$SNAP_ARCH" == "amd64" ]; then
ARCH="x86_64-linux-gnu"
elif [ "$SNAP_ARCH" == "armhf" ]; then
ARCH="arm-linux-gnueabihf"
elif [ "$SNAP_ARCH" == "arm64" ]; then
ARCH="aarch64-linux-gnu"
else
ARCH="$SNAP_ARCH-linux-gnu"
fi
export SNAP_LAUNCHER_ARCH_TRIPLET=$ARCH
# XKB config
export XKB_CONFIG_ROOT=$SNAP/usr/share/X11/xkb
# Mesa Libs for OpenGL support
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH
# Tell libGL where to find the drivers
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri
export LD_LIBRARY_PATH=$LIBGL_DRIVERS_PATH:$LD_LIBRARY_PATH
# Tell where to find the client libraries for Mir
export MIR_CLIENT_PLATFORM_PATH=$SNAP/usr/lib/$ARCH/mir/client-platform
# Pulseaudio export
##export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/pulseaudio:$LD_LIBRARY_PATH
# Tell GStreamer where to find its system plugins
export GST_PLUGIN_SYSTEM_PATH=$SNAP/usr/lib/$ARCH/gstreamer-1.0
# XDG Config
export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$SNAP/usr/xdg:$XDG_CONFIG_DIRS
# Define snaps' own data dir
export XDG_DATA_DIRS=$SNAP_USER_COMMON:$SNAP/usr/share:$XDG_DATA_DIRS
# Set XDG_DATA_HOME to local path
export XDG_DATA_HOME=$SNAP_USER_COMMON/.local/share
export XDG_DATA_DIRS=$XDG_DATA_HOME:$XDG_DATA_DIRS
mkdir -p $XDG_DATA_HOME
# Set cache folder to local path
export XDG_CACHE_HOME=$SNAP_USER_COMMON/.cache
mkdir -p $XDG_CACHE_HOME
# GI repository
export GI_TYPELIB_PATH=$SNAP/usr/lib/girepository-1.0:$SNAP/usr/lib/$ARCH/girepository-1.0
# Font Config and themes
export FONTCONFIG_PATH=$SNAP/etc/fonts/conf.d
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/{fontconfig,fonts,fonts-*,themes,.themes}
ln -sf $SNAP/usr/share/{fontconfig,fonts,fonts-*,themes} $XDG_DATA_HOME
ln -sfn $SNAP/usr/share/themes $SNAP_USER_COMMON/.themes
fi
# Build mime.cache
# needed for gtk and qt icon
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/mime
if [ `which update-mime-database` ]; then
cp --preserve=timestamps -dR $SNAP/usr/share/mime $XDG_DATA_HOME
update-mime-database $XDG_DATA_HOME/mime
fi
fi
# Ensure the app finds locale definitions (requires locales-all to be installed)
export LOCPATH=$SNAP/usr/lib/locale
# Gio modules and cache (including gsettings module)
export GIO_MODULE_DIR=$XDG_CACHE_HOME/gio-modules
function compile_giomodules {
if [ -f $1/glib-2.0/gio-querymodules ]; then
rm -rf $GIO_MODULE_DIR
mkdir -p $GIO_MODULE_DIR
ln -s $1/gio/modules/*.so $GIO_MODULE_DIR
$1/glib-2.0/gio-querymodules $GIO_MODULE_DIR
fi
}
if [ $needs_update = true ]; then
compile_giomodules $SNAP/usr/lib/$ARCH
fi
# Keep an array of data dirs, for looping through them
IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS"
# Setup compiled gsettings schema
GS_SCHEMA_DIR=$XDG_DATA_HOME/glib-2.0/schemas
function compile_schemas {
if [ -f "$1" ]; then
rm -rf $GS_SCHEMA_DIR
mkdir -p $GS_SCHEMA_DIR
for d in "${data_dirs_array[@]}"; do
schema_dir=$d/glib-2.0/schemas
if [ "$(ls -A $schema_dir/*.xml 2>/dev/null)" ]; then
ln -s $schema_dir/*.xml $GS_SCHEMA_DIR
fi
done
"$1" $GS_SCHEMA_DIR
fi
}
if [ $needs_update = true ]; then
compile_schemas $SNAP/usr/lib/$ARCH/glib-2.0/glib-compile-schemas
fi
# Enable gsettings user changes
# symlink the dconf file if home plug is connected for read
DCONF_DEST_USER_DIR=$SNAP_USER_DATA/.config/dconf
if [ ! -f $DCONF_DEST_USER_DIR/user ]; then
if [ -f /home/$USER/.config/dconf/user ]; then
mkdir -p $DCONF_DEST_USER_DIR
ln -s /home/$USER/.config/dconf/user $DCONF_DEST_USER_DIR
fi
fi
#############################
# QT launcher specific part #
#############################
# select qt version
. $SNAP/flavor-select
# Qt Platform to Mir
export QTCHOOSER_NO_GLOBAL_DIR=1
if [ "$USE_qt5" = true ]; then
export QT_SELECT=snappy-qt5
elif [ "$USE_qt5appplatform" = true ]; then
if [ ! -d $SNAP/ubuntu-app-platform/usr ] ; then
echo "You need to connect the ubuntu-app-platform package with your application "
echo "to reuse shared assets, please run:"
echo "snap install ubuntu-app-platform"
echo "snap connect $SNAP_NAME:platform ubuntu-app-platform:platform"
exit 1
fi
export QT_SELECT=snappy-qt5-app-platform
else
export QT_SELECT=snappy-qt4
fi
# Removes Qt warning: Could not find a location
# of the system Compose files
export QTCOMPOSE=$SNAP/usr/share/X11/locale
# Qt Libs, Modules and helpers
if [ "$USE_qt5" = true ]; then
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$SNAP/usr/lib/$ARCH/qt5/plugins
export QML2_IMPORT_PATH=$SNAP/lib/$ARCH:$SNAP/usr/lib/$ARCH/qt5/qml:$QML2_IMPORT_PATH
PATH=$SNAP/usr/lib/$ARCH/qt5/bin:$PATH
elif [ "$USE_qt5appplatform" = true ]; then
# GL and general libs coming from app platform
export LD_LIBRARY_PATH=$SNAP/ubuntu-app-platform/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$SNAP/ubuntu-app-platform/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH
export LIBGL_DRIVERS_PATH=$SNAP/ubuntu-app-platform/usr/lib/$ARCH/dri
export LD_LIBRARY_PATH=$LIBGL_DRIVERS_PATH:$LD_LIBRARY_PATH
export XKB_CONFIG_ROOT=$SNAP/ubuntu-app-platform/usr/share/X11/xkb
export FONTCONFIG_PATH=$SNAP/ubuntu-app-platform/etc/fonts/conf.d
export FONTCONFIG_FILE=$SNAP/ubuntu-app-platform/etc/fonts/fonts.conf
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/{fontconfig,fonts,fonts-*,themes,.themes}
ln -sf $SNAP/ubuntu-app-platform/usr/share/{fontconfig,fonts,fonts-*,themes} $XDG_DATA_HOME
ln -sfn $SNAP/ubuntu-app-platform/usr/share/themes $SNAP_USER_DATA/.themes
fi
export LOCPATH=$SNAP/ubuntu-app-platform/usr/lib/locale
export QTCOMPOSE=$SNAP/ubuntu-app-platform/usr/share/X11/locale
XDG_DATA_DIRS=$XDG_DATA_DIRS:$SNAP/ubuntu-app-platform/usr/share
export MIR_CLIENT_PLATFORM_PATH=$SNAP/ubuntu-app-platform/usr/lib/$ARCH/mir/client-platform
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$SNAP/ubuntu-app-platform/usr/lib/$ARCH:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$SNAP/usr/lib/$ARCH/qt5/plugins:$SNAP/ubuntu-app-platform/usr/lib/$ARCH/qt5/plugins
export QML2_IMPORT_PATH=$SNAP/usr/lib/$ARCH/qt5/qml:$SNAP/lib/$ARCH:$SNAP/ubuntu-app-platform/usr/lib/$ARCH/qt5/qml:$SNAP/ubuntu-app-platform/lib/$ARCH:$QML2_IMPORT_PATH
PATH=$SNAP/ubuntu-app-platform/usr/lib/$ARCH/qt5/bin:$PATH
else
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/qt4:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$SNAP/usr/lib/$ARCH/qt4/plugins
export QML_IMPORT_PATH=$SNAP/usr/lib/$ARCH/qt4/qml:$SNAP/lib/$ARCH:$QML_IMPORT_PATH
PATH=$SNAP/usr/lib/$ARCH/qt4/bin:$PATH
fi
# Necessary for the SDK to find the translations directory
export APP_DIR=$SNAP
# Use GTK styling for running under Unity 7
export GTK_PATH=$SNAP/usr/lib/$ARCH/gtk-2.0
# Gdk-pixbuf loaders
export GDK_PIXBUF_MODULE_FILE=$XDG_CACHE_HOME/gdk-pixbuf-loaders.cache
export GDK_PIXBUF_MODULEDIR=$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/2.10.0/loaders
if [ $needs_update = true ]; then
rm -f $GDK_PIXBUF_MODULE_FILE
if [ -f $SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders ]; then
$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders > $GDK_PIXBUF_MODULE_FILE
fi
fi
# Keep an array of data dirs, for looping through them
# Refresh it with potential new XDG_DATA_DIRS DIRS
IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS"
# Icon themes cache
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/icons
mkdir -p $XDG_DATA_HOME/icons
for d in "${data_dirs_array[@]}"; do
for i in $d/icons/*; do
if [ -d "$i" ]; then
theme_dir=$XDG_DATA_HOME/icons/$(basename "$i")
if [ ! -d "$theme_dir" ]; then
mkdir -p "$theme_dir"
ln -s $i/* "$theme_dir"
if [ -f $SNAP/usr/sbin/update-icon-caches ]; then
$SNAP/usr/sbin/update-icon-caches "$theme_dir"
elif [ -f $SNAP/usr/sbin/update-icon-cache.gtk2 ]; then
$SNAP/usr/sbin/update-icon-cache.gtk2 "$theme_dir"
fi
fi
fi
done
done
fi
# compile real schema files now that we have the executable as part of the platform snap
if [ "$USE_qt5appplatform" = true ]; then
if [ $needs_update = true ]; then
compile_giomodules $SNAP/ubuntu-app-platform/usr/lib/$ARCH
compile_schemas $SNAP/ubuntu-app-platform/usr/lib/$ARCH/glib-2.0/glib-compile-schemas
fi
fi
# Necessary for the SDK to find the translations directory
if [ "$USE_qt5appplatform" = true ]; then
export APP_DIR=$SNAP
fi
if [ $needs_update = true ]; then
# Init user libs directory
if [ ! -d ~/.qucs/user_lib ]; then
mkdir -p ~/.qucs/user_lib
fi
# Add link to content
ln -sf $SNAP/usr/share/qucs ~/content
fi
# Set ngspice library directory
export SPICE_LIB_DIR=$SNAP/usr/share/ngspice
exec "$@"