1# *************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20# *************************************************************
21# version and release passed by command-line
22Version: %version
23Release: %release
24Summary: %productname desktop integration
25Name: %pkgprefix-freedesktop-menus
26#BuildRequires: sed
27#BuildRequires: perl
28Group: Office
29License: ALv2
30Provides: openoffice-desktop-integration
31Conflicts: %pkgprefix-suse-menus
32Conflicts: %pkgprefix-debian-menus
33Conflicts: %pkgprefix-redhat-menus
34Conflicts: %pkgprefix-mandriva-menus
35Obsoletes: openoffice.org3.0-freedesktop-menus
36Obsoletes: openoffice.org3.1-freedesktop-menus
37Obsoletes: openoffice.org3.2-freedesktop-menus
38Obsoletes: openoffice.org3.3-freedesktop-menus
39Obsoletes: openoffice.org3.4-freedesktop-menus
40BuildArch: noarch
41AutoReqProv: no
42%define _binary_filedigest_algorithm 1
43%define _binary_payload w9.gzdio
44
45%description
46%productname desktop integration for desktop-environments that implement
47the menu- and mime-related specifications from http://www.freedesktop.org
48Install this package if you're using a distribution not covered by any of
49the other %pkgprefix-<distribution>-menus packages.
50
51%install
52rm -rf $RPM_BUILD_ROOT
53
54# hack/workaround to make SuSE's brp-symlink-script happy. It wants the targets of all links
55# to be present on the build-system/the buildroot. But the point is that we generate stale
56# links intentionally (until we find a better solution) #46226
57export NO_BRP_STALE_LINK_ERROR=yes
58
59mkdir -p $RPM_BUILD_ROOT
60
61# FIXME: remove - only purpose is to create packages identical to OOF680 m8
62umask 0000
63
64# set parameters for the create_tree script
65export DESTDIR=$RPM_BUILD_ROOT
66export KDEMAINDIR=/usr
67export GNOMEDIR=/usr
68export GNOME_MIME_THEME=hicolor
69
70./create_tree.sh
71
72cd $RPM_BUILD_ROOT
73
74# freedesktop-based desktop-environments don't need/use this.
75rm -rf usr/share/application-registry
76rm -rf usr/share/applications.flag
77rm -rf usr/share/mime-info
78rm -rf usr/share/mimelnk
79rm -rf usr/share/applnk-redhat
80#find usr/share/icons -name '*.png' -exec chmod g+w {} \;
81
82%clean
83rm -rf $RPM_BUILD_ROOT
84
85%triggerin -- %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-math
86# this is run when one of the above packages is already installed and the menu
87# package gets installed OR when the menu-package is already installed and one
88# of the above listed packages gets installed
89
90# Dut to a bug in rpm it is not possible to check why the script is triggered...
91# This is how it should be: 1st arg: number of this package, 2nd arg: number of
92# package that triggers - the bug is that rpm reports the same number for both
93# (the value of the 2nd one), so just run this always...
94# http://rhn.redhat.com/errata/RHBA-2004-098.html
95# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=100509
96
97if [ -x /opt/gnome/bin/update-desktop-database ]; then
98    /opt/gnome/bin/update-desktop-database -q
99elif (which update-desktop-database); then
100  update-desktop-database -q /usr/share/applications
101fi
102
103%triggerun -- %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-math
104if [ "$1" = "0" ] ; then
105  # the menu-package gets uninstalled/updated - postun will run the command
106  exit 0
107fi
108if [ "$2" = "0" ] ; then
109  # the triggering package gets removed
110  if [ -x /opt/gnome/bin/update-desktop-database ]; then
111      /opt/gnome/bin/update-desktop-database -q
112  elif (which update-desktop-database); then
113    update-desktop-database -q /usr/share/applications
114  fi
115fi
116
117%post
118# no need to run it when updating, since %postun of the old package is run
119# afterwards
120
121if [ "$1" = "1" ] ; then  # first install
122  if [ -x /opt/gnome/bin/update-desktop-database ]; then
123    /opt/gnome/bin/update-desktop-database -q
124  elif (which update-desktop-database); then
125    update-desktop-database -q /usr/share/applications
126  fi
127
128  if (which update-mime-database); then
129    update-mime-database /usr/share/mime
130  fi
131fi
132
133
134#run always
135for theme in gnome hicolor locolor; do
136    if [ -e /usr/share/icons/$theme/icon-theme.cache ] ; then
137        # touch it, just in case we cannot find the binary...
138        touch /usr/share/icons/$theme
139        if [ -x /opt/gnome/bin/gtk-update-icon-cache ]; then
140            /opt/gnome/bin/gtk-update-icon-cache -q /usr/share/icons/$theme
141        elif (which gtk-update-icon-cache); then
142            gtk-update-icon-cache -q /usr/share/icons/$theme
143        fi
144        # ignore errors (e.g. when there is a cache, but no index.theme)
145        true
146    fi
147done
148
149
150# update /etc/mime.types
151# backing out existing entries to avoid duplicates
152sed '
153/application\/vnd\.oasis\.opendocument/d
154/application\/vnd\.sun/d
155/application\/vnd\.stardivision/d
156/application\/vnd\.openofficeorg/d
157' /etc/mime.types 2>/dev/null >> /etc/mime.types.tmp$$
158
159# now append our stuff to the temporary file
160cat >> /etc/mime.types.tmp$$ << END
161application/vnd.oasis.opendocument.text	odt
162application/vnd.oasis.opendocument.text-template ott
163application/vnd.oasis.opendocument.text-web oth
164application/vnd.oasis.opendocument.text-master odm
165application/vnd.oasis.opendocument.graphics odg
166application/vnd.oasis.opendocument.graphics-template otg
167application/vnd.oasis.opendocument.presentation odp
168application/vnd.oasis.opendocument.presentation-template otp
169application/vnd.oasis.opendocument.spreadsheet ods
170application/vnd.oasis.opendocument.spreadsheet-template ots
171application/vnd.oasis.opendocument.chart odc
172application/vnd.oasis.opendocument.formula odf
173application/vnd.oasis.opendocument.image odi
174application/vnd.sun.xml.writer sxw
175application/vnd.sun.xml.writer.template stw
176application/vnd.sun.xml.writer.global sxg
177application/vnd.stardivision.writer sdw vor
178application/vnd.stardivision.writer-global sgl
179application/vnd.sun.xml.calc sxc
180application/vnd.sun.xml.calc.template stc
181application/vnd.stardivision.calc sdc
182application/vnd.stardivision.chart sds
183application/vnd.sun.xml.impress sxi
184application/vnd.sun.xml.impress.template sti
185application/vnd.stardivision.impress sdd sdp
186application/vnd.sun.xml.draw sxd
187application/vnd.sun.xml.draw.template std
188application/vnd.stardivision.draw sda
189application/vnd.sun.xml.math sxm
190application/vnd.sun.xml.base odb
191application/vnd.stardivision.math smf
192application/vnd.openofficeorg.extension oxt
193application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
194application/vnd.ms-word.document.macroenabled.12 docm
195application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
196application/vnd.ms-word.template.macroenabled.12 dotm
197application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
198application/vnd.ms-excel.sheet.macroenabled.12 xlsm
199application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
200application/vnd.ms-excel.template.macroenabled.12 xltm
201application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
202application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm
203application/vnd.openxmlformats-officedocument.presentationml.template potx
204application/vnd.ms-powerpoint.template.macroenabled.12 potm
205END
206
207# and replace the original file
208mv -f /etc/mime.types.tmp$$ /etc/mime.types 2>/dev/null
209
210# update /etc/mailcap only at initial install
211if [ "$1" = 1 ]
212then
213  # backing out existing entries to avoid duplicates
214  sed '
215/^# OpenOffice.org/d
216/^application\/vnd\.oasis\.opendocument/d
217/^application\/vnd\.openofficeorg/d
218/^application\/vnd\.sun/d
219/^application\/vnd\.stardivision/d
220/^application\/vnd\.ms-word/d
221/^application\/vnd\.ms-excel/d
222/^application\/vnd\.ms-powerpoint/d
223/^application\/x-star/d
224/excel/d
225/ms[-]*word/d
226/powerpoint/d
227' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
228
229  # now append our stuff to the temporary file
230  cat >> /etc/mailcap.tmp$$ << END
231# Apache OpenOffice
232application/vnd.oasis.opendocument.text; %unixfilename -view %s
233application/vnd.oasis.opendocument.text-template; %unixfilename -view %s
234application/vnd.oasis.opendocument.text-web; %unixfilename -view %s
235application/vnd.oasis.opendocument.text-master; %unixfilename -view %s
236application/vnd.sun.xml.writer; %unixfilename -view %s
237application/vnd.sun.xml.writer.template; %unixfilename -view %s
238application/vnd.sun.xml.writer.global; %unixfilename -view %s
239application/vnd.stardivision.writer; %unixfilename -view %s
240application/vnd.stardivision.writer-global; %unixfilename -view %s
241application/x-starwriter; %unixfilename -view %s
242application/vnd.oasis.opendocument.formula; %unixfilename -view %s
243application/vnd.sun.xml.math; %unixfilename -view %s
244application/vnd.stardivision.math; %unixfilename -view %s
245application/x-starmath; %unixfilename -view %s
246application/msword; %unixfilename -view %s
247application/vnd.oasis.opendocument.spreadsheet; %unixfilename -view %s
248application/vnd.oasis.opendocument.spreadsheet-template; %unixfilename -view %s
249application/vnd.sun.xml.calc; %unixfilename -view %s
250application/vnd.sun.xml.calc.template; %unixfilename -view %s
251application/vnd.stardivision.calc; %unixfilename -view %s
252application/x-starcalc; %unixfilename -view %s
253application/vnd.stardivision.chart; %unixfilename -view %s
254application/x-starchart; %unixfilename -view %s
255application/excel; %unixfilename -view %s
256application/msexcel; %unixfilename -view %s
257application/vnd.ms-excel; %unixfilename -view %s
258application/x-msexcel; %unixfilename -view %s
259application/vnd.oasis.opendocument.presentation; %unixfilename -view %s
260application/vnd.oasis.opendocument.presentation-template; %unixfilename -view %s
261application/vnd.sun.xml.impress; %unixfilename -view %s
262application/vnd.sun.xml.impress.template; %unixfilename -view %s
263application/vnd.stardivision.impress; %unixfilename -view %s
264application/x-starimpress; %unixfilename -view %s
265application/powerpoint; %unixfilename -view %s
266application/mspowerpoint; %unixfilename -view %s
267application/vnd.ms-powerpoint; %unixfilename -view %s
268application/x-mspowerpoint; %unixfilename -view %s
269application/vnd.oasis.opendocument.graphics; %unixfilename -view %s
270application/vnd.oasis.opendocument.graphics-template; %unixfilename -view %s
271application/vnd.sun.xml.draw; %unixfilename -view %s
272application/vnd.sun.xml.draw.template; %unixfilename -view %s
273application/vnd.stardivision.draw; %unixfilename -view %s
274application/x-stardraw; %unixfilename -view %s
275application/vnd.oasis.opendocument.database; %unixfilename -view %s
276application/vnd.sun.xml.base; %unixfilename -view %s
277application/vnd.openofficeorg.extension; %unixfilename %s
278application/vnd.openxmlformats-officedocument.wordprocessingml.document; %unixfilename -view %s
279application/vnd.ms-word.document.macroenabled.12;%unixfilename -view %s
280application/vnd.openxmlformats-officedocument.wordprocessingml.template; %unixfilename -view %s
281application/vnd.ms-word.template.macroenabled.12; %unixfilename -view %s
282application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; %unixfilename -view %s
283application/vnd.ms-excel.sheet.macroenabled.12; %unixfilename -view %s
284application/vnd.openxmlformats-officedocument.spreadsheetml.template; %unixfilename -view %s
285application/vnd.ms-excel.template.macroenabled.12; %unixfilename -view %s
286application/vnd.openxmlformats-officedocument.presentationml.presentation; %unixfilename -view %s
287application/vnd.ms-powerpoint.presentation.macroenabled.12; %unixfilename -view %s
288application/vnd.openxmlformats-officedocument.presentationml.template; %unixfilename -view %s
289application/vnd.ms-powerpoint.template.macroenabled.12; %unixfilename -view %s
290END
291
292  # and replace the original file
293  mv -f /etc/mailcap.tmp$$ /etc/mailcap
294fi
295
296if [ -x /opt/gnome/bin/update-desktop-database ]; then
297    /opt/gnome/bin/update-desktop-database -q
298elif (which update-desktop-database); then
299  update-desktop-database -q /usr/share/applications
300fi
301
302%preun
303# remove from /etc/mailcap only on de-install
304if [ "$1" = 0 ]
305then
306  # backing all entries pointing to our binary
307  sed '/%unixfilename/d' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
308
309  # and replace the original file
310  mv -f /etc/mailcap.tmp$$ /etc/mailcap
311fi
312
313%postun
314if [ "$1" = 0 ] ; then # only run when erasing the package - other cases handled by the triggers
315  if [ -x /opt/gnome/bin/update-desktop-database ]; then
316    /opt/gnome/bin/update-desktop-database -q
317  elif (which update-desktop-database); then
318    update-desktop-database -q
319  fi
320# run always - both when upgrading as well as when erasing the package
321  if (which update-mime-database); then
322    update-mime-database /usr/share/mime
323  fi
324fi
325
326#run always
327for theme in gnome hicolor locolor; do
328  if [ -e /usr/share/icons/$theme/icon-theme.cache ] ; then
329   # touch it, just in case we cannot find the binary...
330    touch /usr/share/icons/$theme
331    if [ -x /opt/gnome/bin/gtk-update-icon-cache ]; then
332      /opt/gnome/bin/gtk-update-icon-cache -q /usr/share/icons/$theme
333    elif (which gtk-update-icon-cache); then
334      gtk-update-icon-cache -q /usr/share/icons/$theme
335    fi
336    # ignore errors (e.g. when there is a cache, but no index.theme)
337    true
338  fi
339done
340
341%files
342# specify stale symlinks verbatim, not as glob - a change in recent versions of
343# glibc breaks rpm unless rpm is build with internal glob-matching (issue 49374)
344# https://bugzilla.redhat.com/beta/show_bug.cgi?id=134362
345%defattr(-, root, root)
346%attr(0755, root, root) /usr/bin/*
347/usr/share/applications/%unixfilename-base.desktop
348/usr/share/applications/%unixfilename-calc.desktop
349/usr/share/applications/%unixfilename-draw.desktop
350/usr/share/applications/%unixfilename-impress.desktop
351/usr/share/applications/%unixfilename-math.desktop
352/usr/share/applications/%unixfilename-printeradmin.desktop
353/usr/share/applications/%unixfilename-writer.desktop
354/usr/share/applications/%unixfilename-startcenter.desktop
355/usr/share/applications/%unixfilename-javafilter.desktop
356/usr/share/icons/gnome/*/apps/*png
357/usr/share/icons/gnome/*/mimetypes/*png
358/usr/share/icons/hicolor/*/apps/*png
359/usr/share/icons/hicolor/*/mimetypes/*png
360/usr/share/icons/locolor/*/apps/*png
361/usr/share/icons/locolor/*/mimetypes/*png
362/usr/share/mime/packages/*
363