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-redhat-menus
26Group: Office
27License: ALv2
28Vendor: Apache Software Foundation
29AutoReqProv: no
30BuildArch: noarch
31Obsoletes: openoffice.org3.0-redhat-menus
32Obsoletes: openoffice.org3.1-redhat-menus
33Obsoletes: openoffice.org3.2-redhat-menus
34Obsoletes: openoffice.org3.3-redhat-menus
35Obsoletes: openoffice.org3.4-redhat-menus
36Requires: redhat-release
37Provides: openoffice-desktop-integration
38%define _unpackaged_files_terminate_build 0
39%define _binary_filedigest_algorithm 1
40%define _binary_payload w9.gzdio
41%description
42%productname desktop integration
43
44%install
45# hack/workaround to make SuSE's brp-symlink-script happy. It wants the targets of all links
46# to be present on the build-system/the buildroot. But the point is that we generate stale
47# links intentionally (until we find a better solution) #46226
48export NO_BRP_STALE_LINK_ERROR=yes
49
50mkdir -p $RPM_BUILD_ROOT
51
52# set parameters for the create_tree script
53export DESTDIR=$RPM_BUILD_ROOT
54export KDEMAINDIR=/usr
55export GNOMEDIR=/usr
56export GNOME_MIME_THEME=hicolor
57
58./create_tree.sh
59
60# legacy redhat KDE location for .desktop files
61mkdir -p $RPM_BUILD_ROOT/usr/share/applnk-redhat/Office
62for i in `cat launcherlist`; do
63  ln -sf /opt/%unixfilename/share/xdg/$i $RPM_BUILD_ROOT/usr/share/applnk-redhat/Office/%unixfilename-$i
64done
65
66%clean
67rm -rf $RPM_BUILD_ROOT
68
69%triggerin --  %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-base, %pkgprefix-math
70if [ -x /usr/bin/update-desktop-database ]; then
71  update-desktop-database -q /usr/share/applications
72fi
73
74%triggerun --  %pkgprefix, %pkgprefix-writer, %pkgprefix-calc, %pkgprefix-draw, %pkgprefix-impress, %pkgprefix-base, %pkgprefix-math
75if [ "$1" = "0" ] ; then
76  # the menu-package gets uninstalled/updated - postun will run the command
77  exit 0
78fi
79if [ "$2" = "0" ] ; then
80  # the triggering package gets removed
81  if [ -x /usr/bin/update-desktop-database ]; then
82    update-desktop-database -q /usr/share/applications
83  fi
84fi
85
86%post
87# run always, since there are versions of this package that did not include
88# a shared-mime-info xml file
89if [ -x /usr/bin/update-mime-database ]; then
90  update-mime-database /usr/share/mime
91fi
92
93# run only on first install, since postun is run when updating
94# post would be run before the old files are removed
95if [ "$1" = "1" ] ; then  # first install
96  for theme in gnome hicolor locolor; do
97    if [ -e /usr/share/icons/$theme/icon-theme.cache ] ; then
98      # touch it, just in case we cannot find the binary...
99      touch /usr/share/icons/$theme
100      if (which gtk-update-icon-cache); then
101        gtk-update-icon-cache /usr/share/icons/$theme
102      fi
103      # ignore errors (e.g. when there is a cache, but no index.theme)
104      true
105    fi
106  done
107fi
108
109# update /etc/mime.types
110# backing out existing entries to avoid duplicates
111sed '
112/application\/vnd\.oasis\.opendocument/d
113/application\/vnd\.openofficeorg/d
114/application\/vnd\.sun/d
115/application\/vnd\.stardivision/d
116' /etc/mime.types 2>/dev/null >> /etc/mime.types.tmp$$
117
118# now append our stuff to the temporary file
119cat >> /etc/mime.types.tmp$$ << END
120application/vnd.oasis.opendocument.text	odt
121application/vnd.oasis.opendocument.text-template ott
122application/vnd.oasis.opendocument.text-web oth
123application/vnd.oasis.opendocument.text-master odm
124application/vnd.oasis.opendocument.graphics odg
125application/vnd.oasis.opendocument.graphics-template otg
126application/vnd.oasis.opendocument.presentation odp
127application/vnd.oasis.opendocument.presentation-template otp
128application/vnd.oasis.opendocument.spreadsheet ods
129application/vnd.oasis.opendocument.spreadsheet-template ots
130application/vnd.oasis.opendocument.chart odc
131application/vnd.oasis.opendocument.formula odf
132application/vnd.oasis.opendocument.image odi
133application/vnd.sun.xml.writer sxw
134application/vnd.sun.xml.writer.template stw
135application/vnd.sun.xml.writer.global sxg
136application/vnd.stardivision.writer sdw vor
137application/vnd.stardivision.writer-global sgl
138application/vnd.sun.xml.calc sxc
139application/vnd.sun.xml.calc.template stc
140application/vnd.stardivision.calc sdc
141application/vnd.stardivision.chart sds
142application/vnd.sun.xml.impress sxi
143application/vnd.sun.xml.impress.template sti
144application/vnd.stardivision.impress sdd sdp
145application/vnd.sun.xml.draw sxd
146application/vnd.sun.xml.draw.template std
147application/vnd.stardivision.draw sda
148application/vnd.sun.xml.math sxm
149application/vnd.stardivision.math smf
150application/vnd.sun.xml.base odb
151application/vnd.openofficeorg.extension oxt
152application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
153application/vnd.ms-word.document.macroenabled.12 docm
154application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
155application/vnd.ms-word.template.macroenabled.12 dotm
156application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
157application/vnd.ms-excel.sheet.macroenabled.12 xlsm
158application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
159application/vnd.ms-excel.template.macroenabled.12 xltm
160application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
161application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm
162application/vnd.openxmlformats-officedocument.presentationml.template potx
163application/vnd.ms-powerpoint.template.macroenabled.12 potm
164END
165
166# and replace the original file
167mv -f /etc/mime.types.tmp$$ /etc/mime.types 2>/dev/null
168
169# update /etc/mailcap only at initial install
170if [ "$1" = 1 ]
171then
172  # backing out existing entries to avoid duplicates
173  sed '
174/^# OpenOffice.org/d
175/^application\/vnd\.oasis\.opendocument/d
176/^application\/vnd\.openofficeorg/d
177/^application\/vnd\.sun/d
178/^application\/vnd\.stardivision/d
179/^application\/vnd\.ms-word/d
180/^application\/vnd\.ms-excel/d
181/^application\/vnd\.ms-powerpoint/d
182/^application\/x-star/d
183/excel/d
184/ms[-]*word/d
185/powerpoint/d
186' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
187
188  # now append our stuff to the temporary file
189  cat >> /etc/mailcap.tmp$$ << END
190# Apache OpenOffice
191application/vnd.oasis.opendocument.text; %unixfilename -view %s
192application/vnd.oasis.opendocument.text-template; %unixfilename -view %s
193application/vnd.oasis.opendocument.text-web; %unixfilename -view %s
194application/vnd.oasis.opendocument.text-master; %unixfilename -view %s
195application/vnd.sun.xml.writer; %unixfilename -view %s
196application/vnd.sun.xml.writer.template; %unixfilename -view %s
197application/vnd.sun.xml.writer.global; %unixfilename -view %s
198application/vnd.stardivision.writer; %unixfilename -view %s
199application/vnd.stardivision.writer-global; %unixfilename -view %s
200application/x-starwriter; %unixfilename -view %s
201application/vnd.oasis.opendocument.formula; %unixfilename -view %s
202application/vnd.sun.xml.math; %unixfilename -view %s
203application/vnd.stardivision.math; %unixfilename -view %s
204application/x-starmath; %unixfilename -view %s
205application/msword; %unixfilename -view %s
206application/vnd.oasis.opendocument.spreadsheet; %unixfilename -view %s
207application/vnd.oasis.opendocument.spreadsheet-template; %unixfilename -view %s
208application/vnd.sun.xml.calc; %unixfilename -view %s
209application/vnd.sun.xml.calc.template; %unixfilename -view %s
210application/vnd.stardivision.calc; %unixfilename -view %s
211application/x-starcalc; %unixfilename -view %s
212application/vnd.stardivision.chart; %unixfilename -view %s
213application/x-starchart; %unixfilename -view %s
214application/excel; %unixfilename -view %s
215application/msexcel; %unixfilename -view %s
216application/vnd.ms-excel; %unixfilename -view %s
217application/x-msexcel; %unixfilename -view %s
218application/vnd.oasis.opendocument.presentation; %unixfilename -view %s
219application/vnd.oasis.opendocument.presentation-template; %unixfilename -view %s
220application/vnd.sun.xml.impress; %unixfilename -view %s
221application/vnd.sun.xml.impress.template; %unixfilename -view %s
222application/vnd.stardivision.impress; %unixfilename -view %s
223application/x-starimpress; %unixfilename -view %s
224application/powerpoint; %unixfilename -view %s
225application/mspowerpoint; %unixfilename -view %s
226application/vnd.ms-powerpoint; %unixfilename -view %s
227application/x-mspowerpoint; %unixfilename -view %s
228application/vnd.oasis.opendocument.graphics; %unixfilename -view %s
229application/vnd.oasis.opendocument.graphics-template; %unixfilename -view %s
230application/vnd.sun.xml.draw; %unixfilename -view %s
231application/vnd.sun.xml.draw.template; %unixfilename -view %s
232application/vnd.stardivision.draw; %unixfilename -view %s
233application/x-stardraw; %unixfilename -view %s
234application/vnd.oasis.opendocument.database; %unixfilename -view %s
235application/vnd.sun.xml.base; %unixfilename -view %s
236application/wordperfect5.1; %unixfilename -view %s
237application/x-wordperfect; %unixfilename -view %s
238application/wordperfect; %unixfilename -view %s
239application/wpwin; %unixfilename -view %s
240application/vnd.openofficeorg.extension; %unixfilename %s
241application/vnd.openxmlformats-officedocument.wordprocessingml.document; %unixfilename -view %s
242application/vnd.ms-word.document.macroenabled.12;%unixfilename -view %s
243application/vnd.openxmlformats-officedocument.wordprocessingml.template; %unixfilename -view %s
244application/vnd.ms-word.template.macroenabled.12; %unixfilename -view %s
245application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; %unixfilename -view %s
246application/vnd.ms-excel.sheet.macroenabled.12; %unixfilename -view %s
247application/vnd.openxmlformats-officedocument.spreadsheetml.template; %unixfilename -view %s
248application/vnd.ms-excel.template.macroenabled.12; %unixfilename -view %s
249application/vnd.openxmlformats-officedocument.presentationml.presentation; %unixfilename -view %s
250application/vnd.ms-powerpoint.presentation.macroenabled.12; %unixfilename -view %s
251application/vnd.openxmlformats-officedocument.presentationml.template; %unixfilename -view %s
252application/vnd.ms-powerpoint.template.macroenabled.12; %unixfilename -view %s
253END
254
255  # and replace the original file
256  mv -f /etc/mailcap.tmp$$ /etc/mailcap
257fi
258
259%preun
260# remove from /etc/mailcap only on de-install
261if [ "$1" = 0 ]
262then
263  # backing all entries pointing to our binary
264  sed '/%unixfilename/d' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
265
266  # and replace the original file
267  mv -f /etc/mailcap.tmp$$ /etc/mailcap
268fi
269
270%postun
271# run only when erasing this package, since %post of the new package ran
272# previously or updates already handled by triggers.
273if [ "$1" = 0 ] ; then
274  if [ -x /usr/bin/update-desktop-database ]; then
275    update-desktop-database -q /usr/share/applications
276  fi
277  if [ -x /usr/bin/update-mime-database ]; then
278    update-mime-database /usr/share/mime
279  fi
280fi
281#run always
282for theme in gnome hicolor locolor; do
283  if [ -e /usr/share/icons/$theme/icon-theme.cache ] ; then
284    # touch it, just in case we cannot find the binary...
285    touch /usr/share/icons/$theme
286    if (which gtk-update-icon-cache); then
287      gtk-update-icon-cache /usr/share/icons/$theme
288    fi
289    # ignore errors (e.g. when there is a cache, but no index.theme)
290    true
291  fi
292done
293
294%files
295%attr(0755,root,root) /usr/bin/soffice
296%attr(0755,root,root) %verify(not size md5) /usr/bin/%unixfilename
297%attr(0755,root,root) /usr/bin/%unixfilename-printeradmin
298%defattr(0644, root, root)
299/usr/share/application-registry/*.applications
300/usr/share/applications/%unixfilename-writer.desktop
301/usr/share/applications/%unixfilename-calc.desktop
302/usr/share/applications/%unixfilename-draw.desktop
303/usr/share/applications/%unixfilename-impress.desktop
304/usr/share/applications/%unixfilename-math.desktop
305/usr/share/applications/%unixfilename-base.desktop
306/usr/share/applications/%unixfilename-printeradmin.desktop
307/usr/share/applications/%unixfilename-startcenter.desktop
308/usr/share/applications/%unixfilename-javafilter.desktop
309/usr/share/applnk-redhat/Office/%unixfilename-writer.desktop
310/usr/share/applnk-redhat/Office/%unixfilename-calc.desktop
311/usr/share/applnk-redhat/Office/%unixfilename-draw.desktop
312/usr/share/applnk-redhat/Office/%unixfilename-impress.desktop
313/usr/share/applnk-redhat/Office/%unixfilename-math.desktop
314/usr/share/applnk-redhat/Office/%unixfilename-base.desktop
315/usr/share/applnk-redhat/Office/%unixfilename-printeradmin.desktop
316/usr/share/applnk-redhat/Office/%unixfilename-startcenter.desktop
317/usr/share/applnk-redhat/Office/%unixfilename-javafilter.desktop
318/usr/share/mime-info/*.keys
319/usr/share/mime-info/*.mime
320/usr/share/mimelnk/application/*.desktop
321/usr/share/icons/gnome/*/apps/*png
322/usr/share/icons/gnome/*/mimetypes/*png
323/usr/share/icons/hicolor/*/apps/*png
324/usr/share/icons/hicolor/*/mimetypes/*png
325/usr/share/icons/locolor/*/apps/*png
326/usr/share/icons/locolor/*/mimetypes/*png
327/usr/share/mime/packages/*
328