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-mandriva-menus
26Obsoletes: openoffice.org3.0-mandriva-menus
27Obsoletes: openoffice.org3.1-mandriva-menus
28Obsoletes: openoffice.org3.2-mandriva-menus
29Obsoletes: openoffice.org3.3-mandriva-menus
30Obsoletes: openoffice.org3.4-mandriva-menus
31Group: Office
32License: ALv2
33AutoReqProv: no
34BuildArch: noarch
35#
36# FIXME: Limited Edition 2005 contains package mandrakelinux-release,
37#        which provides 'mandrake-release'. We should leave 'mandrake-release'
38#        here and check for the 'mandriva-release' in the future (next year).
39#
40Requires: mandrake-release
41Provides: openoffice-desktop-integration
42
43%define _unpackaged_files_terminate_build 0
44%define _binary_filedigest_algorithm 1
45%define _binary_payload w9.gzdio
46
47%define menuversion %(echo %version|cut -d'.' -f 1-2)
48%{?!update_menus:%define update_menus if [ -x /usr/bin/update-menus ]; then /usr/bin/update-menus || true ; fi}
49%{?!trigger_clean_menus:%define trigger_clean_menus if [ "$2" = "0" -a -x /usr/bin/update-menus ]; then /usr/bin/update-menus || true ; fi}
50
51%description
52%productname desktop integration
53
54# Update menus
55#
56# - core02 for spadmin (printeradmin)
57#
58%triggerin -- %pkgprefix, %pkgprefix-core01 %pkgprefix-calc %pkgprefix-draw %pkgprefix-impress %pkgprefix-writer %pkgprefix-math %pkgprefix-core02
59%{update_menus}
60
61# Update menus
62#
63# - core02 for spadmin (printeradmin)
64#
65%triggerpostun -- %pkgprefix, %pkgprefix-core01 %pkgprefix-calc %pkgprefix-draw %pkgprefix-impress %pkgprefix-writer %pkgprefix-math %pkgprefix-core02
66%{trigger_clean_menus}
67
68%post
69
70# update /etc/mime.types
71# backing out existing entries to avoid duplicates
72sed '
73/application\/vnd\.oasis\.opendocument/d
74/application\/vnd\.openofficeorg/d
75/application\/vnd\.sun/d
76/application\/vnd\.stardivision/d
77' /etc/mime.types 2>/dev/null >> /etc/mime.types.tmp$$
78
79# now append our stuff to the temporary file
80cat >> /etc/mime.types.tmp$$ << END
81application/vnd.oasis.opendocument.text	odt
82application/vnd.oasis.opendocument.text-template ott
83application/vnd.oasis.opendocument.text-web oth
84application/vnd.oasis.opendocument.text-master odm
85application/vnd.oasis.opendocument.graphics odg
86application/vnd.oasis.opendocument.graphics-template otg
87application/vnd.oasis.opendocument.presentation odp
88application/vnd.oasis.opendocument.presentation-template otp
89application/vnd.oasis.opendocument.spreadsheet ods
90application/vnd.oasis.opendocument.spreadsheet-template ots
91application/vnd.oasis.opendocument.chart odc
92application/vnd.oasis.opendocument.formula odf
93application/vnd.oasis.opendocument.image odi
94application/vnd.sun.xml.writer sxw
95application/vnd.sun.xml.writer.template stw
96application/vnd.sun.xml.writer.global sxg
97application/vnd.stardivision.writer sdw vor
98application/vnd.stardivision.writer-global sgl
99application/vnd.sun.xml.calc sxc
100application/vnd.sun.xml.calc.template stc
101application/vnd.stardivision.calc sdc
102application/vnd.stardivision.chart sds
103application/vnd.sun.xml.impress sxi
104application/vnd.sun.xml.impress.template sti
105application/vnd.stardivision.impress sdd sdp
106application/vnd.sun.xml.draw sxd
107application/vnd.sun.xml.draw.template std
108application/vnd.stardivision.draw sda
109application/vnd.sun.xml.math sxm
110application/vnd.stardivision.math smf
111application/vnd.sun.xml.base odb
112application/vnd.openofficeorg.extension oxt
113application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
114application/vnd.ms-word.document.macroenabled.12 docm
115application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
116application/vnd.ms-word.template.macroenabled.12 dotm
117application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
118application/vnd.ms-excel.sheet.macroenabled.12 xlsm
119application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
120application/vnd.ms-excel.template.macroenabled.12 xltm
121application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
122application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm
123application/vnd.openxmlformats-officedocument.presentationml.template potx
124application/vnd.ms-powerpoint.template.macroenabled.12 potm
125END
126
127# and replace the original file
128mv -f /etc/mime.types.tmp$$ /etc/mime.types 2>/dev/null
129
130# update /etc/mailcap only at initial install
131if [ "$1" = 1 ]
132then
133  # backing out existing entries to avoid duplicates
134  sed '
135/^# OpenOffice.org/d
136/^application\/vnd\.oasis\.opendocument/d
137/^application\/vnd\.openofficeorg/d
138/^application\/vnd\.sun/d
139/^application\/vnd\.stardivision/d
140/^application\/vnd\.ms-word/d
141/^application\/vnd\.ms-excel/d
142/^application\/vnd\.ms-powerpoint/d
143/^application\/x-star/d
144/excel/d
145/ms[-]*word/d
146/powerpoint/d
147' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
148
149  # now append our stuff to the temporary file
150  cat >> /etc/mailcap.tmp$$ << END
151# Apache OpenOffice
152application/vnd.oasis.opendocument.text; %unixfilename -view %s
153application/vnd.oasis.opendocument.text-template; %unixfilename -view %s
154application/vnd.oasis.opendocument.text-web; %unixfilename -view %s
155application/vnd.oasis.opendocument.text-master; %unixfilename -view %s
156application/vnd.sun.xml.writer; %unixfilename -view %s
157application/vnd.sun.xml.writer.template; %unixfilename -view %s
158application/vnd.sun.xml.writer.global; %unixfilename -view %s
159application/vnd.stardivision.writer; %unixfilename -view %s
160application/vnd.stardivision.writer-global; %unixfilename -view %s
161application/x-starwriter; %unixfilename -view %s
162application/vnd.oasis.opendocument.formula; %unixfilename -view %s
163application/vnd.sun.xml.math; %unixfilename -view %s
164application/vnd.stardivision.math; %unixfilename -view %s
165application/x-starmath; %unixfilename -view %s
166application/msword; %unixfilename -view %s
167application/vnd.oasis.opendocument.spreadsheet; %unixfilename -view %s
168application/vnd.oasis.opendocument.spreadsheet-template; %unixfilename -view %s
169application/vnd.sun.xml.calc; %unixfilename -view %s
170application/vnd.sun.xml.calc.template; %unixfilename -view %s
171application/vnd.stardivision.calc; %unixfilename -view %s
172application/x-starcalc; %unixfilename -view %s
173application/vnd.stardivision.chart; %unixfilename -view %s
174application/x-starchart; %unixfilename -view %s
175application/excel; %unixfilename -view %s
176application/msexcel; %unixfilename -view %s
177application/vnd.ms-excel; %unixfilename -view %s
178application/x-msexcel; %unixfilename -view %s
179application/vnd.oasis.opendocument.presentation; %unixfilename -view %s
180application/vnd.oasis.opendocument.presentation-template; %unixfilename -view %s
181application/vnd.sun.xml.impress; %unixfilename -view %s
182application/vnd.sun.xml.impress.template; %unixfilename -view %s
183application/vnd.stardivision.impress; %unixfilename -view %s
184application/x-starimpress; %unixfilename -view %s
185application/powerpoint; %unixfilename -view %s
186application/mspowerpoint; %unixfilename -view %s
187application/vnd.ms-powerpoint; %unixfilename -view %s
188application/x-mspowerpoint; %unixfilename -view %s
189application/vnd.oasis.opendocument.graphics; %unixfilename -view %s
190application/vnd.oasis.opendocument.graphics-template; %unixfilename -view %s
191application/vnd.sun.xml.draw; %unixfilename -view %s
192application/vnd.sun.xml.draw.template; %unixfilename -view %s
193application/vnd.stardivision.draw; %unixfilename -view %s
194application/x-stardraw; %unixfilename -view %s
195application/vnd.oasis.opendocument.database; %unixfilename -view %s
196application/vnd.sun.xml.base; %unixfilename -view %s
197application/vnd.openofficeorg.extension; %unixfilename %s
198application/vnd.openxmlformats-officedocument.wordprocessingml.document; %unixfilename -view %s
199application/vnd.ms-word.document.macroenabled.12;%unixfilename -view %s
200application/vnd.openxmlformats-officedocument.wordprocessingml.template; %unixfilename -view %s
201application/vnd.ms-word.template.macroenabled.12; %unixfilename -view %s
202application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; %unixfilename -view %s
203application/vnd.ms-excel.sheet.macroenabled.12; %unixfilename -view %s
204application/vnd.openxmlformats-officedocument.spreadsheetml.template; %unixfilename -view %s
205application/vnd.ms-excel.template.macroenabled.12; %unixfilename -view %s
206application/vnd.openxmlformats-officedocument.presentationml.presentation; %unixfilename -view %s
207application/vnd.ms-powerpoint.presentation.macroenabled.12; %unixfilename -view %s
208application/vnd.openxmlformats-officedocument.presentationml.template; %unixfilename -view %s
209application/vnd.ms-powerpoint.template.macroenabled.12; %unixfilename -view %s
210END
211
212  # and replace the original file
213  mv -f /etc/mailcap.tmp$$ /etc/mailcap
214fi
215
216%{update_menus}
217
218
219%install
220rm -rf $RPM_BUILD_ROOT/*
221
222# hack/workaround to make SuSE's brp-symlink-script happy. It wants the targets of all links
223# to be present on the build-system/the buildroot. But the point is that we generate stale
224# links intentionally (until we find a better solution) #46226
225export NO_BRP_STALE_LINK_ERROR=yes
226
227mkdir -p $RPM_BUILD_ROOT
228
229export DESTDIR=$RPM_BUILD_ROOT
230export KDEMAINDIR=/usr
231export GNOMEDIR=/usr
232
233./create_tree.sh
234
235#
236# Mandriva menus fun
237#
238# For more info, see:
239#
240#   http://qa.mandriva.com/twiki/bin/view/Main/MenuSystem
241#
242%define _menudir /usr/lib/menu
243mkdir -p $RPM_BUILD_ROOT%{_menudir}
244rm -f "$RPM_BUILD_ROOT%{_menudir}/%{name}"
245
246GenerateMenu() {
247[ -f "$RPM_BUILD_ROOT%{_menudir}/%{name}" ] || touch $RPM_BUILD_ROOT%{_menudir}/%{name}
248mimetypes_item=
249[ "$7" != "" ] && mimetypes_item="mimetypes=\"$7\""
250cat >> $RPM_BUILD_ROOT%{_menudir}/%{name} << EOF
251?package(%pkgprefix-$6): needs=x11 section="$2" icon="%iconprefix-$3.png" title="$4" longtitle="$5" command="$1" \
252$mimetypes_item kde_opt="InitialPreference=100" startup_notify="true"
253EOF
254}
255
256#
257# FIXME: Office/Database request in the Cooker ML, leave in Spreadsheets
258# until new group will be created
259#
260GenerateMenu "%unixfilename -base" \
261	"More Applications/Databases" \
262	"base" \
263	"%productname %{menuversion} Base" \
264	"%productname %{menuversion} Database" \
265	"core01" \
266	"application/vnd.oasis.opendocument.database,application/vnd.sun.xml.base"
267
268GenerateMenu "%unixfilename -calc" \
269	"Office/Spreadsheets" \
270	"calc" \
271	"%productname %{menuversion} Calc" \
272	"%productname %{menuversion} Spreadsheet" \
273	"calc" \
274	"application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.spreadsheet-template,application/vnd.sun.xml.calc,application/vnd.sun.xml.calc.template,application/vnd.stardivision.calc,application/vnd.stardivision.chart,application/msexcel,application/vnd.ms-excel"
275
276GenerateMenu "%unixfilename -draw" \
277	"Office/Drawing" \
278	"draw" \
279	"%productname %{menuversion} Draw" \
280	"%productname %{menuversion} Drawing" \
281	"draw" \
282	"application/vnd.oasis.opendocument.graphics,application/vnd.oasis.opendocument.graphics-template,application/vnd.sun.xml.draw,application/vnd.sun.xml.draw.template,application/vnd.stardivision.draw"
283
284GenerateMenu "%unixfilename -impress" \
285	"Office/Presentations" \
286	"impress" \
287	"%productname %{menuversion} Impress" \
288	"%productname %{menuversion} Presentation" \
289	"impress" \
290	"application/vnd.oasis.opendocument.presentation,application/vnd.oasis.opendocument.presentation-template,application/vnd.sun.xml.impress,application/vnd.sun.xml.impress.template,application/vnd.stardivision.impress,application/mspowerpoint"
291
292GenerateMenu "%unixfilename -writer" \
293	"Office/Wordprocessors" \
294	"writer" \
295	"%productname %{menuversion} Writer" \
296	"%productname %{menuversion} Word Processing Component" \
297	"writer" \
298	"application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.text-web,application/vnd.oasis.opendocument.text-master,application/vnd.sun.xml.writer,application/vnd.sun.xml.writer.template,application/vnd.sun.xml.writer.global,application/vnd.stardivision.writer,application/msword,application/vnd.ms-word,application/x-doc,application/rtf"
299
300GenerateMenu "%unixfilename -math" \
301	"Office/Wordprocessors" \
302	"math" \
303	"%productname %{menuversion} Math" \
304	"%productname %{menuversion} Formula Editor" \
305	"math" \
306	"application/vnd.oasis.opendocument.formula,application/vnd.sun.xml.math,application/vnd.stardivision.math"
307
308#
309# FIXME: Is there a better group than System/Configuration/Printing? I think no ...
310#
311GenerateMenu "%unixfilename-printeradmin" \
312    "System/Configuration/Printing" \
313    "printeradmin" \
314    "%productname %{menuversion} Printeradmin" \
315    "%productname %{menuversion} Printer Administration" \
316	"core02"
317
318%clean
319rm -rf $RPM_BUILD_ROOT
320
321%preun
322# remove from /etc/mailcap only on de-install
323if [ "$1" = 0 ]
324then
325  # backing all entries pointing to our binary
326  sed '/%unixfilename/d' /etc/mailcap 2>/dev/null >> /etc/mailcap.tmp$$
327
328  # and replace the original file
329  mv -f /etc/mailcap.tmp$$ /etc/mailcap
330fi
331
332%postun
333%{update_menus}
334
335
336%files
337%attr(0755,root,root) /usr/bin/soffice
338%attr(0755,root,root) %verify(not size md5) /usr/bin/%unixfilename
339%attr(0755,root,root) /usr/bin/%unixfilename-printeradmin
340%defattr(0644, root, root)
341%{_menudir}/%{name}
342/usr/share/application-registry/*.applications
343/usr/share/applications/%unixfilename-writer.desktop
344/usr/share/applications/%unixfilename-calc.desktop
345/usr/share/applications/%unixfilename-draw.desktop
346/usr/share/applications/%unixfilename-impress.desktop
347/usr/share/applications/%unixfilename-math.desktop
348/usr/share/applications/%unixfilename-base.desktop
349/usr/share/applications/%unixfilename-printeradmin.desktop
350/usr/share/applications/%unixfilename-startcenter.desktop
351/usr/share/mime-info/*.keys
352/usr/share/mime-info/*.mime
353/usr/share/mimelnk/application/*.desktop
354/usr/share/icons/gnome/*/apps/*png
355/usr/share/icons/gnome/*/mimetypes/*png
356/usr/share/icons/hicolor/*/apps/*png
357/usr/share/icons/hicolor/*/mimetypes/*png
358/usr/share/icons/locolor/*/apps/*png
359/usr/share/icons/locolor/*/mimetypes/*png
360
361