Branch libreoffice-5-0-4
[LibreOffice.git] / sysui / desktop / freedesktop / freedesktop-menus.spec
blob9c952a50ff01a4194aac119b55bde680bd6497e9
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 # version and release passed by command-line
19 Version: %version
20 Release: %release
21 Summary: %productname desktop integration
22 Name: %pkgprefix-freedesktop-menus
23 #BuildRequires: sed
24 #BuildRequires: perl
25 Group: Office
26 License: LGPLv3 with MPLv2, ALv2 and others
27 Provides: libreoffice-desktop-integration
28 Conflicts: %pkgprefix-suse-menus
29 Conflicts: %pkgprefix-debian-menus
30 Conflicts: %pkgprefix-redhat-menus
31 Conflicts: %pkgprefix-mandriva-menus
32 BuildArch: noarch
33 AutoReqProv: no
34 %define _binary_filedigest_algorithm 1
35 %define _binary_payload w9.gzdio
37 %define gnome_dir /usr
38 %define gnome_mime_theme hicolor
40 %description
41 %productname desktop integration for desktop-environments that implement
42 the menu- and mime-related specifications from http://www.freedesktop.org
43 These specifications are implemented by all current distributions.
45 %install
46 rm -rf $RPM_BUILD_ROOT
48 # hack/workaround to make SuSE's brp-symlink-script happy. It wants the targets of all links
49 # to be present on the build-system/the buildroot. But the point is that we generate stale
50 # links intentionally (until we find a better solution) #46226
51 export NO_BRP_STALE_LINK_ERROR=yes
53 mkdir -p $RPM_BUILD_ROOT
55 # set parameters for the create_tree script
56 export DESTDIR=$RPM_BUILD_ROOT
57 export KDEMAINDIR=/usr
58 export PREFIXDIR=/usr
59 export GNOMEDIR=%{gnome_dir}
61 ./create_tree.sh
63 cd $RPM_BUILD_ROOT
65 # freedesktop-based desktop-environments don't need/use this.
66 rm -rf usr/share/application-registry
67 rm -rf usr/share/applications.flag
68 rm -rf usr/share/mime-info
69 rm -rf usr/share/mimelnk
70 rm -rf usr/share/applnk-redhat
71 #find usr/share/icons -name '*.png' -exec chmod g+w {} \;
73 %clean
74 rm -rf $RPM_BUILD_ROOT
76 %triggerin -- %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-math
77 # this is run when one of the above packages is already installed and the menu
78 # package gets installed OR when the menu-package is already installed and one
79 # of the above listed packages gets installed
81 # Dut to a bug in rpm it is not possible to check why the script is triggered...
82 # This is how it should be: 1st arg: number of this package, 2nd arg: number of
83 # package that triggers - the bug is that rpm reports the same number for both
84 # (the value of the 2nd one), so just run this always...
85 # http://rhn.redhat.com/errata/RHBA-2004-098.html
86 # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=100509
88 if [ -x /opt/gnome/bin/update-desktop-database ]; then
89 /opt/gnome/bin/update-desktop-database -q
90 elif (which update-desktop-database); then
91 update-desktop-database -q /usr/share/applications
94 %triggerun -- %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-math
95 if [ "$1" = "0" ] ; then
96 # the menu-package gets uninstalled/updated - postun will run the command
97 exit 0
99 if [ "$2" = "0" ] ; then
100 # the triggering package gets removed
101 if [ -x /opt/gnome/bin/update-desktop-database ]; then
102 /opt/gnome/bin/update-desktop-database -q
103 elif (which update-desktop-database); then
104 update-desktop-database -q /usr/share/applications
108 %post
109 # no need to run it when updating, since %postun of the old package is run
110 # afterwards
112 if [ "$1" = "1" ] ; then # first install
113 if [ -x /opt/gnome/bin/update-desktop-database ]; then
114 /opt/gnome/bin/update-desktop-database -q
115 elif (which update-desktop-database); then
116 update-desktop-database -q /usr/share/applications
119 if (which update-mime-database); then
120 update-mime-database /usr/share/mime
124 # add symlinks so that nautilus can identify the mime-icons
125 # not strictly freedesktop-stuff but there is no common naming scheme yet.
126 # One proposal is "mime-application:vnd.oasis.opendocument.spreadsheet.png"
127 # for e.g. application/vnd.oasis.opendocument.spreadsheet
128 link_target_root="%{gnome_dir}/share/icons/%{gnome_mime_theme}"
130 if [ ! -d "${link_target_root}" ]
131 then
132 link_target_root="%{gnome_dir}/share/icons/gnome"
135 for subdir in `cd ${link_target_root}; ls -d *`
137 link_dir="%{gnome_dir}/share/icons/%{gnome_mime_theme}/$subdir/mimetypes"
138 link_target_dir="../../../gnome/$subdir/mimetypes/"
140 test -d "${link_dir}" || mkdir -p "${link_dir}"
141 test -d ${link_dir}/${link_target_dir} || continue
143 icon=${link_target_dir}%iconprefix-drawing.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.draw.png
144 icon=${link_target_dir}%iconprefix-drawing-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.draw.template.png
145 icon=${link_target_dir}%iconprefix-formula.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.math.png
146 icon=${link_target_dir}%iconprefix-master-document.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.writer.global.png
147 icon=${link_target_dir}%iconprefix-oasis-database.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.base.png
148 icon=${link_target_dir}%iconprefix-oasis-database.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.database.png
149 icon=${link_target_dir}%iconprefix-oasis-drawing.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.graphics.png
150 icon=${link_target_dir}%iconprefix-oasis-drawing-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.graphics-template.png
151 icon=${link_target_dir}%iconprefix-oasis-formula.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.formula.png
152 icon=${link_target_dir}%iconprefix-oasis-master-document.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-master.png
153 icon=${link_target_dir}%iconprefix-oasis-master-document-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-master-template.png
154 icon=${link_target_dir}%iconprefix-oasis-presentation.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.presentation.png
155 icon=${link_target_dir}%iconprefix-oasis-presentation-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.presentation-template.png
156 icon=${link_target_dir}%iconprefix-oasis-spreadsheet.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.spreadsheet.png
157 icon=${link_target_dir}%iconprefix-oasis-spreadsheet-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.spreadsheet-template.png
158 icon=${link_target_dir}%iconprefix-oasis-text.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text.png
159 icon=${link_target_dir}%iconprefix-oasis-text-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-template.png
160 icon=${link_target_dir}%iconprefix-oasis-web-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-web.png
161 icon=${link_target_dir}%iconprefix-presentation.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.impress.png
162 icon=${link_target_dir}%iconprefix-presentation-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.impress.template.png
163 icon=${link_target_dir}%iconprefix-spreadsheet.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.calc.png
164 icon=${link_target_dir}%iconprefix-spreadsheet-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.calc.template.png
165 icon=${link_target_dir}%iconprefix-text.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.writer.png
166 icon=${link_target_dir}%iconprefix-text-template.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.writer.template.png
167 icon=${link_target_dir}%iconprefix-extension.png; test -f ${link_dir}/$icon && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.openofficeorg.extension.png
168 done
170 #run always
171 for theme in gnome hicolor locolor; do
172 if [ -e /usr/share/icons/$theme/icon-theme.cache ] ; then
173 # touch it, just in case we cannot find the binary...
174 touch /usr/share/icons/$theme
175 if [ -x /opt/gnome/bin/gtk-update-icon-cache ]; then
176 /opt/gnome/bin/gtk-update-icon-cache -q /usr/share/icons/$theme
177 elif (which gtk-update-icon-cache); then
178 gtk-update-icon-cache -q /usr/share/icons/$theme
180 # ignore errors (e.g. when there is a cache, but no index.theme)
181 true
183 done
186 # update /etc/mime.types
187 # backing out existing entries to avoid duplicates
188 sed '
189 /application\/vnd\.oasis\.opendocument/d
190 /application\/vnd\.sun/d
191 /application\/vnd\.stardivision/d
192 /application\/vnd\.openofficeorg/d
193 ' /etc/mime.types 2>/dev/null >> /etc/mime.types.tmp$$
195 # now append our stuff to the temporary file
196 cat >> /etc/mime.types.tmp$$ << END
197 application/vnd.oasis.opendocument.text odt
198 application/vnd.oasis.opendocument.text-flat-xml fodt
199 application/vnd.oasis.opendocument.text-template ott
200 application/vnd.oasis.opendocument.text-web oth
201 application/vnd.oasis.opendocument.text-master odm
202 application/vnd.oasis.opendocument.graphics odg
203 application/vnd.oasis.opendocument.graphics-flat-xml fodg
204 application/vnd.oasis.opendocument.graphics-template otg
205 application/vnd.oasis.opendocument.presentation odp
206 application/vnd.oasis.opendocument.presentation-flat-xml fodp
207 application/vnd.oasis.opendocument.presentation-template otp
208 application/vnd.oasis.opendocument.spreadsheet ods
209 application/vnd.oasis.opendocument.spreadsheet-flat-xml fods
210 application/vnd.oasis.opendocument.spreadsheet-template ots
211 application/vnd.oasis.opendocument.chart odc
212 application/vnd.oasis.opendocument.formula odf
213 application/vnd.oasis.opendocument.image odi
214 application/vnd.sun.xml.writer sxw
215 application/vnd.sun.xml.writer.template stw
216 application/vnd.sun.xml.writer.global sxg
217 application/vnd.stardivision.writer sdw vor
218 application/vnd.stardivision.writer-global sgl
219 application/vnd.sun.xml.calc sxc
220 application/vnd.sun.xml.calc.template stc
221 application/vnd.stardivision.calc sdc
222 application/vnd.stardivision.chart sds
223 application/vnd.sun.xml.impress sxi
224 application/vnd.sun.xml.impress.template sti
225 application/vnd.stardivision.impress sdd sdp
226 application/vnd.sun.xml.draw sxd
227 application/vnd.sun.xml.draw.template std
228 application/vnd.stardivision.draw sda
229 application/vnd.sun.xml.math sxm
230 application/vnd.sun.xml.base odb
231 application/vnd.stardivision.math smf
232 application/vnd.openofficeorg.extension oxt
233 application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
234 application/vnd.ms-word.document.macroenabled.12 docm
235 application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
236 application/vnd.ms-word.template.macroenabled.12 dotm
237 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
238 application/vnd.ms-excel.sheet.macroenabled.12 xlsm
239 application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
240 application/vnd.ms-excel.template.macroenabled.12 xltm
241 application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
242 application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm
243 application/vnd.openxmlformats-officedocument.presentationml.template potx
244 application/vnd.ms-powerpoint.template.macroenabled.12 potm
247 # and replace the original file
248 mv -f /etc/mime.types.tmp$$ /etc/mime.types 2>/dev/null
250 # update /etc/mailcap only at initial install
251 if [ "$1" = 1 ]
252 then
253 # backing out existing entries to avoid duplicates
254 sed '
255 /^# LibreOffice/d
256 /^application\/vnd\.oasis\.opendocument/d
257 /^application\/vnd\.openofficeorg/d
258 /^application\/vnd\.sun/d
259 /^application\/vnd\.stardivision/d
260 /^application\/vnd\.ms-word/d
261 /^application\/vnd\.ms-excel/d
262 /^application\/vnd\.ms-powerpoint/d
263 /^application\/x-star/d
264 /excel/d
265 /ms[-]*word/d
266 /powerpoint/d
267 ' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
269 # now append our stuff to the temporary file
270 cat >> /etc/mailcap.tmp$$ << END
271 # LibreOffice
272 application/vnd.oasis.opendocument.text; %unixfilename -view %s
273 application/vnd.oasis.opendocument.text-flat-xml; %unixfilename -view %s
274 application/vnd.oasis.opendocument.text-template; %unixfilename -view %s
275 application/vnd.oasis.opendocument.text-web; %unixfilename -view %s
276 application/vnd.oasis.opendocument.text-master; %unixfilename -view %s
277 application/vnd.sun.xml.writer; %unixfilename -view %s
278 application/vnd.sun.xml.writer.template; %unixfilename -view %s
279 application/vnd.sun.xml.writer.global; %unixfilename -view %s
280 application/vnd.stardivision.writer; %unixfilename -view %s
281 application/vnd.stardivision.writer-global; %unixfilename -view %s
282 application/x-starwriter; %unixfilename -view %s
283 application/vnd.oasis.opendocument.formula; %unixfilename -view %s
284 application/vnd.sun.xml.math; %unixfilename -view %s
285 application/vnd.stardivision.math; %unixfilename -view %s
286 application/x-starmath; %unixfilename -view %s
287 application/msword; %unixfilename -view %s
288 application/vnd.oasis.opendocument.spreadsheet; %unixfilename -view %s
289 application/vnd.oasis.opendocument.spreadsheet-flat-xml; %unixfilename -view %s
290 application/vnd.oasis.opendocument.spreadsheet-template; %unixfilename -view %s
291 application/vnd.sun.xml.calc; %unixfilename -view %s
292 application/vnd.sun.xml.calc.template; %unixfilename -view %s
293 application/vnd.stardivision.calc; %unixfilename -view %s
294 application/x-starcalc; %unixfilename -view %s
295 application/vnd.stardivision.chart; %unixfilename -view %s
296 application/x-starchart; %unixfilename -view %s
297 application/excel; %unixfilename -view %s
298 application/msexcel; %unixfilename -view %s
299 application/vnd.ms-excel; %unixfilename -view %s
300 application/x-msexcel; %unixfilename -view %s
301 application/vnd.oasis.opendocument.presentation; %unixfilename -view %s
302 application/vnd.oasis.opendocument.presentation-flat-xml; %unixfilename -view %s
303 application/vnd.oasis.opendocument.presentation-template; %unixfilename -view %s
304 application/vnd.sun.xml.impress; %unixfilename -view %s
305 application/vnd.sun.xml.impress.template; %unixfilename -view %s
306 application/vnd.stardivision.impress; %unixfilename -view %s
307 application/x-starimpress; %unixfilename -view %s
308 application/powerpoint; %unixfilename -view %s
309 application/mspowerpoint; %unixfilename -view %s
310 application/vnd.ms-powerpoint; %unixfilename -view %s
311 application/x-mspowerpoint; %unixfilename -view %s
312 application/vnd.oasis.opendocument.graphics; %unixfilename -view %s
313 application/vnd.oasis.opendocument.graphics-flat-xml; %unixfilename -view %s
314 application/vnd.oasis.opendocument.graphics-template; %unixfilename -view %s
315 application/vnd.sun.xml.draw; %unixfilename -view %s
316 application/vnd.sun.xml.draw.template; %unixfilename -view %s
317 application/vnd.stardivision.draw; %unixfilename -view %s
318 application/x-stardraw; %unixfilename -view %s
319 application/vnd.oasis.opendocument.database; %unixfilename -view %s
320 application/vnd.sun.xml.base; %unixfilename -view %s
321 application/vnd.openofficeorg.extension; %unixfilename %s
322 application/vnd.openxmlformats-officedocument.wordprocessingml.document; %unixfilename -view %s
323 application/vnd.ms-word.document.macroenabled.12;%unixfilename -view %s
324 application/vnd.openxmlformats-officedocument.wordprocessingml.template; %unixfilename -view %s
325 application/vnd.ms-word.template.macroenabled.12; %unixfilename -view %s
326 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; %unixfilename -view %s
327 application/vnd.ms-excel.sheet.macroenabled.12; %unixfilename -view %s
328 application/vnd.openxmlformats-officedocument.spreadsheetml.template; %unixfilename -view %s
329 application/vnd.ms-excel.template.macroenabled.12; %unixfilename -view %s
330 application/vnd.openxmlformats-officedocument.presentationml.presentation; %unixfilename -view %s
331 application/vnd.ms-powerpoint.presentation.macroenabled.12; %unixfilename -view %s
332 application/vnd.openxmlformats-officedocument.presentationml.template; %unixfilename -view %s
333 application/vnd.ms-powerpoint.template.macroenabled.12; %unixfilename -view %s
336 # and replace the original file
337 mv -f /etc/mailcap.tmp$$ /etc/mailcap
340 if [ -x /opt/gnome/bin/update-desktop-database ]; then
341 /opt/gnome/bin/update-desktop-database -q
342 elif (which update-desktop-database); then
343 update-desktop-database -q /usr/share/applications
346 %preun
347 # remove from /etc/mailcap only on de-install
348 if [ "$1" = 0 ]
349 then
350 # backing all entries pointing to our binary
351 sed '/%unixfilename/d' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
353 # and replace the original file
354 mv -f /etc/mailcap.tmp$$ /etc/mailcap
357 %postun
358 if [ "$1" = 0 ] ; then # only run when erasing the package - other cases handled by the triggers
359 if [ -x /opt/gnome/bin/update-desktop-database ]; then
360 /opt/gnome/bin/update-desktop-database -q
361 elif (which update-desktop-database); then
362 update-desktop-database -q
364 # run always - both when upgrading as well as when erasing the package
365 if (which update-mime-database); then
366 update-mime-database /usr/share/mime
370 #run always
371 for theme in gnome hicolor locolor; do
372 if [ -e /usr/share/icons/$theme/icon-theme.cache ] ; then
373 # touch it, just in case we cannot find the binary...
374 touch /usr/share/icons/$theme
375 if [ -x /opt/gnome/bin/gtk-update-icon-cache ]; then
376 /opt/gnome/bin/gtk-update-icon-cache -q /usr/share/icons/$theme
377 elif (which gtk-update-icon-cache); then
378 gtk-update-icon-cache -q /usr/share/icons/$theme
380 # ignore errors (e.g. when there is a cache, but no index.theme)
381 true
383 done
385 %files
386 # specify stale symlinks verbatim, not as glob - a change in recent versions of
387 # glibc breaks rpm unless rpm is build with internal glob-matching (issue 49374)
388 # https://bugzilla.redhat.com/beta/show_bug.cgi?id=134362
389 %defattr(-, root, root)
390 %if "%unixfilename" != "libreoffice%productversion" && "%unixfilename" != "libreofficedev%productversion"
391 # compat symlinks
392 %attr(0755,root,root) /opt/%unixfilename
393 %endif
394 %attr(0755, root, root) /usr/bin/*
395 /usr/share/applications/%unixfilename-base.desktop
396 /usr/share/applications/%unixfilename-calc.desktop
397 /usr/share/applications/%unixfilename-draw.desktop
398 /usr/share/applications/%unixfilename-impress.desktop
399 /usr/share/applications/%unixfilename-math.desktop
400 /usr/share/applications/%unixfilename-writer.desktop
401 /usr/share/applications/%unixfilename-startcenter.desktop
402 /usr/share/applications/%unixfilename-xsltfilter.desktop
403 /usr/share/icons/gnome/*/apps/*png
404 /usr/share/icons/gnome/*/mimetypes/*png
405 /usr/share/icons/gnome/scalable/apps/*svg
406 /usr/share/icons/gnome/scalable/mimetypes/*svg
407 /usr/share/icons/hicolor/*/apps/*png
408 /usr/share/icons/hicolor/*/mimetypes/*png
409 /usr/share/icons/hicolor/scalable/apps/*svg
410 /usr/share/icons/hicolor/scalable/mimetypes/*svg
411 /usr/share/icons/locolor/*/apps/*png
412 /usr/share/icons/locolor/*/mimetypes/*png
413 /usr/share/mime/packages/*
414 /usr/share/appdata/*