blob: 6315af1c30535f7deb8d43fc7707eba276007aea (
plain)
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
|
post_install() {
xdg-icon-resource forceupdate --theme hicolor &> /dev/null
set -e
set -u
DISPLAY=''
echo "Running post install script..."
SCRIPT_DIR="/opt/myoffice-standard-home-edition"
CO_PRODUCT_ARTIFACT_SUFFIX="-home-edition"
source "${SCRIPT_DIR}/Common.2.7.0.sh"
createHardwareIdCache()
{
local boardSerial=$(cat /sys/devices/virtual/dmi/id/board_serial | tr -d '\n')
local productUuid=$(cat /sys/devices/virtual/dmi/id/product_uuid | tr -d '\n' | tr '[:lower:]' '[:upper:]')
local idFile="${RESOURCES_DIR}/"
mkdir -p "${RESOURCES_DIR}"
echo "${boardSerial} | ${productUuid}" > "${idFile}"
chmod go=r "${idFile}"
}
if [[ "" != "" ]]; then
createHardwareIdCache
fi
mkdir -p /usr/share/desktop-directories/
registerAppMime()
{
xdg-mime default "$1" $(grep ^MimeType "/usr/share/applications/$1" | cut -d = -f 2- | tr ';' ' ') > /dev/null 2> /dev/null || true
}
for name in "${APPS[@]}"; do
registerAppMime "${name}.desktop"
done
if [[ "${ENABLE_MIME_REGISTRATION}" != "0" ]]; then
xdg-mime install --mode system --novendor "${SCRIPT_DIR}/myoffice_mimes.xml" > /dev/null 2> /dev/null
fi
registerIcon()
{
xdg-icon-resource install --noupdate --theme "$1" --mode system --novendor --context "$2" --size "$4" /usr/share/icons/hicolor/$4x$4/$3${CO_PRODUCT_ARTIFACT_SUFFIX}_$4.png "$5"
}
for size in "${IFW_ICON_SIZE[@]}"; do
for (( i=0; i<${#APP_ICON_SRC[*]}; i++ )); do
registerIcon hicolor apps "${APP_ICON_SRC[i]}" "${size}" "${APPS[i]}"
done
done
if [[ "${INSTALL_SVG_ICONS}" == "0" ]]; then
IFW_ICON_THEME_NAME="hicolor"
for size in "${IFW_ICON_SIZE[@]}"; do
for (( i=0; i<${#MIME_ICON_SRC[*]}; i++ )); do
registerIcon "${IFW_ICON_THEME_NAME}" mimetypes "${MIME_ICON_SRC[i]}" "${size}" "${MIME_ICON_DEST[i]}"
done
done
fi
if [[ ${UPDATE_MIME_DATABASE_WORKAROUND} -eq 0 ]]; then
update-mime-database /usr/share/mime
else
PKGSYSTEM_ENABLE_FSYNC=0 update-mime-database /usr/share/mime
fi
fc-cache
backupFontConfig()
{
local fontConfigFolder="/etc/fonts/conf.avail"
if [ -f "${fontConfigFolder}/${1}" ]; then
mv "${fontConfigFolder}/${1}" "${fontConfigFolder}/${1}.backup"
fi
}
if [[ "$IFW_LINUX_DISTRIBUTION" == "astra" ]]; then
backupFontConfig "19-fly-no-antialiasing.conf" # Used in version 1.4
backupFontConfig "29-fly-rendering.conf" # Used in version 1.5
fi
xdg-icon-resource forceupdate --theme hicolor --mode system
gtk-update-icon-cache -ft "${DEFAULT_ICON_PREFIX}/hicolor" > /dev/null 2> /dev/null || true
echo "Done."
update-desktop-database -q
}
post_upgrade() {
post_install
}
pre_remove() {
set -e
set -u
DISPLAY=''
SCRIPT_DIR="/opt/myoffice-standard-home-edition"
CONFIG_DIR="New Cloud Technologies Ltd."
source "${SCRIPT_DIR}/Common.2.7.0.sh"
if [[ "${TAG}" == "upgrade" || "${TAG}" == "1" ]]; then
echo "Skipping uninstall step..."
exit 0
fi
IFW_MENU_DEST_DIR=$(probe_menu_installation_path)
for size in "${IFW_ICON_SIZE[@]}"; do
for name in "${APPS[@]}"; do
xdg-icon-resource uninstall --theme hicolor --mode system --size "${size}" --context apps --size "${size}" "${name}"
done
done
uninstallIconsForTheme()
{
for size in "${IFW_ICON_SIZE[@]}"; do
for name in "${MIME_ICON_DEST[@]}"; do
xdg-icon-resource uninstall --theme "${1}" --mode system --context mimetypes --size "${size}" "${name}"
done
done
}
if [[ "${INSTALL_SVG_ICONS}" == "0" ]]; then
uninstallIconsForTheme hicolor
fi
if [[ "${INSTALL_RASTER_ICONS_ONLY}" == "1" ]]; then
for IFW_ICON_THEME_NAME in ${ICON_THEMES}; do
INDEX_FILE="${DEFAULT_ICON_PREFIX}/${IFW_ICON_THEME_NAME}/index.theme"
if [ ! -e "${INDEX_FILE}" ]; then
continue
fi
if [[ "${IFW_ICON_THEME_NAME}" == "hicolor" ]]; then
continue
fi
uninstallIconsForTheme "${IFW_ICON_THEME_NAME}"
done
fi
restoreFileFromBackup()
{
local target=$1
if [ -f "${target}" ]; then
local backupHash=$(cat "${BACKUP_DIR}/icons/${target}.md5")
local targetHash=$(md5sum "${target}" | cut -d ' ' -f 1)
if [[ "${backupHash}" == "${targetHash}" ]]; then
cp --remove-destination -f "${BACKUP_DIR}/icons/${target}" "${target}" || true
fi
elif [[ -L "${target}" && ! -e "${target}" ]]; then
cp --remove-destination -f "${BACKUP_DIR}/icons/${target}" "${target}" || true
fi
}
findAndRestore()
{
if [ -f "$1" ]; then
if [[ "$1" == *.png || "$1" == *.svg ]]; then
restoreFileFromBackup "${1#'.'}"
fi
elif [ -d "$1" ]; then
for f in "$1"/*; do
findAndRestore "${f}"
done
fi
}
if [ -d "${BACKUP_DIR}/icons" ]; then
cd "${BACKUP_DIR}/icons/"
findAndRestore .
cd "${MAINTENANCE_DIR}"
rm -rf "${BACKUP_DIR}/icons"
fi
if [ -f "${MAINTENANCE_DIR}/icons.list" ]; then
for f in $(cat "${MAINTENANCE_DIR}/icons.list"); do
rm -f "${f}" || true
done
fi
restoreFontConfig()
{
local fontConfigFolder="/etc/fonts/conf.avail"
if [ -f "${fontConfigFolder}/${1}.backup" ]; then
mv "${fontConfigFolder}/${1}.backup" "${fontConfigFolder}/${1}"
fi
}
if [[ "$IFW_LINUX_DISTRIBUTION" == "astra" ]]; then
restoreFontConfig "19-fly-no-antialiasing.conf" # Used in version 1.4
restoreFontConfig "29-fly-rendering.conf" # Used in version 1.5
fi
updateCacheForTheme()
{
xdg-icon-resource forceupdate --theme "${1}" --mode system || true
gtk-update-icon-cache -ft "${DEFAULT_ICON_PREFIX}/${1}" > /dev/null 2> /dev/null || true
}
for IFW_ICON_THEME_NAME in ${ICON_THEMES}; do
INDEX_FILE="${DEFAULT_ICON_PREFIX}/${IFW_ICON_THEME_NAME}/index.theme"
if [ ! -e "${INDEX_FILE}" ]; then
continue
fi
updateCacheForTheme "${IFW_ICON_THEME_NAME}"
done
echo "Done"
}
post_remove() {
xdg-icon-resource forceupdate --theme hicolor &> /dev/null
update-desktop-database -q
}
|