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