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