Get the style color and number just once
[LibreOffice.git] / sysui / desktop / freedesktop / freedesktop-menus.spec
blob9c84305e51b6ce4939f05991d2d0c7b00460e111
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 w1T.xzdio
37 %define gnome_dir /usr
39 # only symlinks in the package that at the time of building point to non-existing files
40 %global dont_check_desktop_files 1
42 %description
43 %productname desktop integration for desktop-environments that implement
44 the menu- and mime-related specifications from http://www.freedesktop.org
45 These specifications are implemented by all current distributions.
47 %install
48 rm -rf $RPM_BUILD_ROOT
50 # hack/workaround to make SuSE's brp-symlink-script happy. It wants the targets of all links
51 # to be present on the build-system/the buildroot. But the point is that we generate stale
52 # links intentionally (until we find a better solution) #46226
53 export NO_BRP_STALE_LINK_ERROR=yes
55 mkdir -p $RPM_BUILD_ROOT
57 # set parameters for the create_tree script
58 export DESTDIR=$RPM_BUILD_ROOT
59 export KDEMAINDIR=/usr
60 export PREFIXDIR=/usr
61 export BINDIR=/usr/bin
63 (cd %libo_start_dir && ./create_tree.sh)
65 cd $RPM_BUILD_ROOT
67 # freedesktop-based desktop-environments don't need/use this.
68 rm -rf usr/share/applications.flag
69 rm -rf usr/share/applnk-redhat
70 #find usr/share/icons -name '*.png' -exec chmod g+w {} \;
72 %clean
73 rm -rf $RPM_BUILD_ROOT
75 %triggerin -- %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-math
76 # this is run when one of the above packages is already installed and the menu
77 # package gets installed OR when the menu-package is already installed and one
78 # of the above listed packages gets installed
80 # Due to a bug in rpm it is not possible to check why the script is triggered...
81 # This is how it should be: 1st arg: number of this package, 2nd arg: number of
82 # package that triggers - the bug is that rpm reports the same number for both
83 # (the value of the 2nd one), so just run this always...
84 # http://rhn.redhat.com/errata/RHBA-2004-098.html
85 # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=100509
87 if [ -x /opt/gnome/bin/update-desktop-database ]; then
88 /opt/gnome/bin/update-desktop-database -q
89 elif command -v update-desktop-database; then
90 update-desktop-database -q /usr/share/applications
93 %triggerun -- %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-math
94 if [ "$1" = "0" ] ; then
95 # the menu-package gets uninstalled/updated - postun will run the command
96 exit 0
98 if [ "$2" = "0" ] ; then
99 # the triggering package gets removed
100 if [ -x /opt/gnome/bin/update-desktop-database ]; then
101 /opt/gnome/bin/update-desktop-database -q
102 elif command -v update-desktop-database; then
103 update-desktop-database -q /usr/share/applications
107 %post
108 # no need to run it when updating, since %postun of the old package is run
109 # afterwards
111 if [ "$1" = "1" ] ; then # first install
112 if [ -x /opt/gnome/bin/update-desktop-database ]; then
113 /opt/gnome/bin/update-desktop-database -q
114 elif command -v update-desktop-database; then
115 update-desktop-database -q /usr/share/applications
118 if command -v update-mime-database; then
119 update-mime-database /usr/share/mime
123 # add symlinks so that nautilus can identify the mime-icons
124 # not strictly freedesktop-stuff but there is no common naming scheme yet.
125 # One proposal is "mime-application:vnd.oasis.opendocument.spreadsheet.png"
126 # for e.g. application/vnd.oasis.opendocument.spreadsheet
127 link_root="%{gnome_dir}/share/icons/hicolor"
129 for subdir in `cd ${link_root}; ls --ignore="*theme*"`
131 link_dir="${link_root}/$subdir/mimetypes"
133 test -d "${link_dir}" || mkdir -p "${link_dir}"
135 icon=${link_dir}/%iconprefix-drawing.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.draw.png
136 icon=${link_dir}/%iconprefix-drawing-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.draw.template.png
137 icon=${link_dir}/%iconprefix-formula.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.math.png
138 icon=${link_dir}/%iconprefix-master-document.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.writer.global.png
139 icon=${link_dir}/%iconprefix-oasis-database.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.base.png
140 icon=${link_dir}/%iconprefix-oasis-database.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.base.png
141 icon=${link_dir}/%iconprefix-oasis-drawing.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.graphics.png
142 icon=${link_dir}/%iconprefix-oasis-drawing-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.graphics-template.png
143 icon=${link_dir}/%iconprefix-oasis-formula.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.formula.png
144 icon=${link_dir}/%iconprefix-oasis-master-document.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-master.png
145 icon=${link_dir}/%iconprefix-oasis-master-document-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-master-template.png
146 icon=${link_dir}/%iconprefix-oasis-presentation.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.presentation.png
147 icon=${link_dir}/%iconprefix-oasis-presentation-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.presentation-template.png
148 icon=${link_dir}/%iconprefix-oasis-spreadsheet.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.spreadsheet.png
149 icon=${link_dir}/%iconprefix-oasis-spreadsheet-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.spreadsheet-template.png
150 icon=${link_dir}/%iconprefix-oasis-text.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text.png
151 icon=${link_dir}/%iconprefix-oasis-text-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-template.png
152 icon=${link_dir}/%iconprefix-oasis-web-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.oasis.opendocument.text-web.png
153 icon=${link_dir}/%iconprefix-presentation.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.impress.png
154 icon=${link_dir}/%iconprefix-presentation-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.impress.template.png
155 icon=${link_dir}/%iconprefix-spreadsheet.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.calc.png
156 icon=${link_dir}/%iconprefix-spreadsheet-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.calc.template.png
157 icon=${link_dir}/%iconprefix-text.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.writer.png
158 icon=${link_dir}/%iconprefix-text-template.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.sun.xml.writer.template.png
159 icon=${link_dir}/%iconprefix-extension.png; test -f ${icon} && ln -sf ${icon} ${link_dir}/gnome-mime-application-vnd.openofficeorg.extension.png
160 done
162 #run always
163 if [ -e /usr/share/icons/hicolor/icon-theme.cache ] ; then
164 # touch it, just in case we cannot find the binary...
165 touch /usr/share/icons/hicolor
166 if [ -x /opt/gnome/bin/gtk-update-icon-cache ]; then
167 /opt/gnome/bin/gtk-update-icon-cache -q /usr/share/icons/hicolor
168 elif command -v gtk-update-icon-cache; then
169 gtk-update-icon-cache -q /usr/share/icons/hicolor
171 # ignore errors (e.g. when there is a cache, but no index.theme)
172 true
176 # update /etc/mime.types
177 # backing out existing entries to avoid duplicates
178 sed '
179 /application\/vnd\.oasis\.opendocument/d
180 /application\/vnd\.sun/d
181 /application\/vnd\.stardivision/d
182 /application\/vnd\.openofficeorg/d
183 ' /etc/mime.types 2>/dev/null >> /etc/mime.types.tmp$$
185 # now append our stuff to the temporary file
186 cat >> /etc/mime.types.tmp$$ << END
187 application/vnd.oasis.opendocument.text odt
188 application/vnd.oasis.opendocument.text-flat-xml fodt
189 application/vnd.oasis.opendocument.text-template ott
190 application/vnd.oasis.opendocument.text-web oth
191 application/vnd.oasis.opendocument.text-master odm
192 application/vnd.oasis.opendocument.graphics odg
193 application/vnd.oasis.opendocument.graphics-flat-xml fodg
194 application/vnd.oasis.opendocument.graphics-template otg
195 application/vnd.oasis.opendocument.presentation odp
196 application/vnd.oasis.opendocument.presentation-flat-xml fodp
197 application/vnd.oasis.opendocument.presentation-template otp
198 application/vnd.oasis.opendocument.spreadsheet ods
199 application/vnd.oasis.opendocument.spreadsheet-flat-xml fods
200 application/vnd.oasis.opendocument.spreadsheet-template ots
201 application/vnd.oasis.opendocument.chart odc
202 application/vnd.oasis.opendocument.formula odf
203 application/vnd.oasis.opendocument.image odi
204 application/vnd.sun.xml.writer sxw
205 application/vnd.sun.xml.writer.template stw
206 application/vnd.sun.xml.writer.global sxg
207 application/vnd.stardivision.writer sdw vor
208 application/vnd.stardivision.writer-global sgl
209 application/vnd.sun.xml.calc sxc
210 application/vnd.sun.xml.calc.template stc
211 application/vnd.stardivision.calc sdc
212 application/vnd.stardivision.chart sds
213 application/vnd.sun.xml.impress sxi
214 application/vnd.sun.xml.impress.template sti
215 application/vnd.stardivision.impress sdd sdp
216 application/vnd.sun.xml.draw sxd
217 application/vnd.sun.xml.draw.template std
218 application/vnd.stardivision.draw sda
219 application/vnd.sun.xml.math sxm
220 application/vnd.sun.xml.base odb
221 application/vnd.stardivision.math smf
222 application/vnd.openofficeorg.extension oxt
223 application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
224 application/vnd.ms-word.document.macroEnabled.12 docm
225 application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
226 application/vnd.ms-word.template.macroEnabled.12 dotm
227 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
228 application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
229 application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
230 application/vnd.ms-excel.template.macroEnabled.12 xltm
231 application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
232 application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
233 application/vnd.openxmlformats-officedocument.presentationml.template potx
234 application/vnd.ms-powerpoint.template.macroEnabled.12 potm
237 # and replace the original file
238 mv -f /etc/mime.types.tmp$$ /etc/mime.types 2>/dev/null
240 # update /etc/mailcap only at initial install
241 if [ "$1" = 1 ]
242 then
243 # backing out existing entries to avoid duplicates
244 sed '
245 /^# LibreOffice/d
246 /^application\/vnd\.oasis\.opendocument/d
247 /^application\/vnd\.openofficeorg/d
248 /^application\/vnd\.sun/d
249 /^application\/vnd\.stardivision/d
250 /^application\/vnd\.ms-word/d
251 /^application\/vnd\.ms-excel/d
252 /^application\/vnd\.ms-powerpoint/d
253 /^application\/x-star/d
254 /excel/d
255 /ms[-]*word/d
256 /powerpoint/d
257 ' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
259 # now append our stuff to the temporary file
260 cat >> /etc/mailcap.tmp$$ << END
261 # LibreOffice
262 application/vnd.oasis.opendocument.text; %unixfilename -view %s
263 application/vnd.oasis.opendocument.text-flat-xml; %unixfilename -view %s
264 application/vnd.oasis.opendocument.text-template; %unixfilename -view %s
265 application/vnd.oasis.opendocument.text-web; %unixfilename -view %s
266 application/vnd.oasis.opendocument.text-master; %unixfilename -view %s
267 application/vnd.sun.xml.writer; %unixfilename -view %s
268 application/vnd.sun.xml.writer.template; %unixfilename -view %s
269 application/vnd.sun.xml.writer.global; %unixfilename -view %s
270 application/vnd.stardivision.writer; %unixfilename -view %s
271 application/vnd.stardivision.writer-global; %unixfilename -view %s
272 application/x-starwriter; %unixfilename -view %s
273 application/vnd.oasis.opendocument.formula; %unixfilename -view %s
274 application/vnd.sun.xml.math; %unixfilename -view %s
275 application/vnd.stardivision.math; %unixfilename -view %s
276 application/x-starmath; %unixfilename -view %s
277 application/msword; %unixfilename -view %s
278 application/vnd.oasis.opendocument.spreadsheet; %unixfilename -view %s
279 application/vnd.oasis.opendocument.spreadsheet-flat-xml; %unixfilename -view %s
280 application/vnd.oasis.opendocument.spreadsheet-template; %unixfilename -view %s
281 application/vnd.sun.xml.calc; %unixfilename -view %s
282 application/vnd.sun.xml.calc.template; %unixfilename -view %s
283 application/vnd.stardivision.calc; %unixfilename -view %s
284 application/x-starcalc; %unixfilename -view %s
285 application/vnd.stardivision.chart; %unixfilename -view %s
286 application/x-starchart; %unixfilename -view %s
287 application/excel; %unixfilename -view %s
288 application/msexcel; %unixfilename -view %s
289 application/vnd.ms-excel; %unixfilename -view %s
290 application/x-msexcel; %unixfilename -view %s
291 application/vnd.oasis.opendocument.presentation; %unixfilename -view %s
292 application/vnd.oasis.opendocument.presentation-flat-xml; %unixfilename -view %s
293 application/vnd.oasis.opendocument.presentation-template; %unixfilename -view %s
294 application/vnd.sun.xml.impress; %unixfilename -view %s
295 application/vnd.sun.xml.impress.template; %unixfilename -view %s
296 application/vnd.stardivision.impress; %unixfilename -view %s
297 application/x-starimpress; %unixfilename -view %s
298 application/powerpoint; %unixfilename -view %s
299 application/mspowerpoint; %unixfilename -view %s
300 application/vnd.ms-powerpoint; %unixfilename -view %s
301 application/x-mspowerpoint; %unixfilename -view %s
302 application/vnd.oasis.opendocument.graphics; %unixfilename -view %s
303 application/vnd.oasis.opendocument.graphics-flat-xml; %unixfilename -view %s
304 application/vnd.oasis.opendocument.graphics-template; %unixfilename -view %s
305 application/vnd.sun.xml.draw; %unixfilename -view %s
306 application/vnd.sun.xml.draw.template; %unixfilename -view %s
307 application/vnd.stardivision.draw; %unixfilename -view %s
308 application/x-stardraw; %unixfilename -view %s
309 application/vnd.oasis.opendocument.base; %unixfilename -view %s
310 application/vnd.sun.xml.base; %unixfilename -view %s
311 application/vnd.openofficeorg.extension; %unixfilename %s
312 application/vnd.openxmlformats-officedocument.wordprocessingml.document; %unixfilename -view %s
313 application/vnd.ms-word.document.macroEnabled.12;%unixfilename -view %s
314 application/vnd.openxmlformats-officedocument.wordprocessingml.template; %unixfilename -view %s
315 application/vnd.ms-word.template.macroEnabled.12; %unixfilename -view %s
316 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; %unixfilename -view %s
317 application/vnd.ms-excel.sheet.macroEnabled.12; %unixfilename -view %s
318 application/vnd.openxmlformats-officedocument.spreadsheetml.template; %unixfilename -view %s
319 application/vnd.ms-excel.template.macroEnabled.12; %unixfilename -view %s
320 application/vnd.openxmlformats-officedocument.presentationml.presentation; %unixfilename -view %s
321 application/vnd.ms-powerpoint.presentation.macroEnabled.12; %unixfilename -view %s
322 application/vnd.openxmlformats-officedocument.presentationml.template; %unixfilename -view %s
323 application/vnd.ms-powerpoint.template.macroEnabled.12; %unixfilename -view %s
326 # and replace the original file
327 mv -f /etc/mailcap.tmp$$ /etc/mailcap
330 if [ -x /opt/gnome/bin/update-desktop-database ]; then
331 /opt/gnome/bin/update-desktop-database -q
332 elif command -v update-desktop-database; then
333 update-desktop-database -q /usr/share/applications
336 %preun
337 # remove from /etc/mailcap only on de-install
338 if [ "$1" = 0 ]
339 then
340 # backing all entries pointing to our binary
341 sed '/%unixfilename/d' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
343 # and replace the original file
344 mv -f /etc/mailcap.tmp$$ /etc/mailcap
347 %postun
348 if [ "$1" = 0 ] ; then # only run when erasing the package - other cases handled by the triggers
349 if [ -x /opt/gnome/bin/update-desktop-database ]; then
350 /opt/gnome/bin/update-desktop-database -q
351 elif command -v update-desktop-database; then
352 update-desktop-database -q
354 # run always - both when upgrading as well as when erasing the package
355 if command -v update-mime-database; then
356 update-mime-database /usr/share/mime
360 #run always
361 if [ -e /usr/share/icons/hicolor/icon-theme.cache ] ; then
362 # touch it, just in case we cannot find the binary...
363 touch /usr/share/icons/hicolor
364 if [ -x /opt/gnome/bin/gtk-update-icon-cache ]; then
365 /opt/gnome/bin/gtk-update-icon-cache -q /usr/share/icons/hicolor
366 elif command -v gtk-update-icon-cache; then
367 gtk-update-icon-cache -q /usr/share/icons/hicolor
369 # ignore errors (e.g. when there is a cache, but no index.theme)
370 true
373 %files
374 # specify stale symlinks verbatim, not as glob - a change in recent versions of
375 # glibc breaks rpm unless rpm is build with internal glob-matching (issue 49374)
376 # https://bugzilla.redhat.com/beta/show_bug.cgi?id=134362
377 %defattr(-, root, root)
378 %if "%unixfilename" != "libreoffice%productversion" && "%unixfilename" != "libreofficedev%productversion"
379 # compat symlinks
380 %attr(0755,root,root) /opt/%unixfilename
381 %endif
382 /usr/bin/*
383 /usr/share/applications/%unixfilename-base.desktop
384 /usr/share/applications/%unixfilename-calc.desktop
385 /usr/share/applications/%unixfilename-draw.desktop
386 /usr/share/applications/%unixfilename-impress.desktop
387 /usr/share/applications/%unixfilename-math.desktop
388 /usr/share/applications/%unixfilename-writer.desktop
389 /usr/share/applications/%unixfilename-startcenter.desktop
390 /usr/share/applications/%unixfilename-xsltfilter.desktop
391 /usr/share/icons/hicolor/*/apps/*png
392 /usr/share/icons/hicolor/*/apps/*svg
393 /usr/share/icons/hicolor/*/mimetypes/*png
394 /usr/share/metainfo/*
395 /usr/share/mime/packages/*