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