Branch libreoffice-5-0-4
[LibreOffice.git] / bin / distro-install-desktop-integration
blob4cf652decc41fbf19e727ab65e26b84550d3a048
1 #!/bin/sh
3 if test -z "${SRC_ROOT}"; then
4 echo "distro-install-clean-up: No environment set!"
5 exit 1
6 fi
8 PRODUCTVERSION_NODOT=`echo $PRODUCTVERSION | sed -e "s/\.//"`
10 mkdir -p $DESTDIR$PREFIXDIR/bin
13 create_wrapper()
15 echo "Install $PREFIXDIR/bin/$1"
17 if test -L "$DESTDIR$PREFIXDIR/bin/$1" ; then
18 # do not overwrite $PREFIXDIR/bin/libreoffice symlink created by create_tree.sh
19 # the symlink is necessary by java UNO components to find
20 # the UNO installation using $PATH; this function used to be provided
21 # by $PREFIXDIR/bin/soffice symlink, see
22 # http://udk.openoffice.org/common/man/spec/transparentofficecomponents.html
23 # Note: if you want to support parallel installation of more OOo versions
24 # you cannot include this link directly into the package
25 # For example, the Novell package mark this symlink as %ghost
26 # and update it in %post and %postun
27 echo " skip already existing symlink $PREFIXDIR/bin/$1"
28 else
29 mkdir -p $DESTDIR$PREFIXDIR/bin
30 cat <<EOT >$DESTDIR$PREFIXDIR/bin/$1
31 #!/bin/sh
32 $INSTALLDIR/program/$2 $3 "\$@"
33 EOT
34 chmod 755 $DESTDIR$PREFIXDIR/bin/$1
36 # put into file list
37 test -f "$DESTDIR/$4" && echo "$PREFIXDIR/bin/$1" >>$DESTDIR/$4
40 create_man_link()
42 echo "Install $MANDIR/man1/$1.1.gz"
44 mkdir -p $DESTDIR$MANDIR/man1
45 echo ".so man1/$2.1" >| $DESTDIR$MANDIR/man1/$1.1
46 gzip -f $DESTDIR$MANDIR/man1/$1.1
47 test -f "$DESTDIR/$3" && echo "$MANDIR/man1/$1.1.gz" >>"$DESTDIR/$3"
50 install_man()
52 echo "Install $MANDIR/man1/$1.1.gz"
54 mkdir -p $DESTDIR$MANDIR/man1
55 cp sysui/desktop/man/$1.1 $DESTDIR$MANDIR/man1 || exit 1;
56 gzip -f $DESTDIR$MANDIR/man1/$1.1
57 test -f "$DESTDIR/$2" && echo "$MANDIR/man1/$1.1.gz" >>"$DESTDIR/$2"
61 add_wrapper()
63 lowrapper_name="$1"
64 target_binary="$2"
65 target_option_1="$3"
66 used_man_page="$4"
67 desktop_file="$5"
68 file_list="$6"
70 # do we want compat oowrapper?
71 oowrapper_name=""
72 if test "$WITH_COMPAT_OOWRAPPERS" = 'TRUE' ; then
73 oowrapper_name=`echo "$lowrapper_name" | sed -e "s/^lo/oo/"`
74 # "oo" prefix only for wrappers stating with "lo" prefix
75 test "$oowrapper_name" = "$lowrapper_name" && oowrapper_name=
78 # wrappers
79 create_wrapper "$lowrapper_name" "$target_binary" "$target_option_1" "$file_list"
80 test -n "$oowrapper_name" && create_wrapper "$oowrapper_name" "$target_binary" "$target_option_1" "$file_list"
82 # man pages
83 if test "$used_man_page" = "$lowrapper_name" ; then
84 # need to install the manual page
85 install_man "$lowrapper_name" "$file_list"
86 else
87 # just link the manual page
88 create_man_link "$lowrapper_name" "$used_man_page" "$file_list"
90 test -n "$oowrapper_name" && create_man_link "$oowrapper_name" "$used_man_page" "$file_list"
92 # add desktop file to the right file list
93 test -n "$desktop_file" -a -f "$DESTDIR/$file_list" && echo "$PREFIXDIR/share/applications/$desktop_file" >>"$DESTDIR/$file_list"
96 # install desktop integration from plain packages
97 sysui_temp=`mktemp -t -d distro-pack-desktop-integration-XXXXXX`
98 cp -a workdir/CustomTarget/sysui/share/libreoffice/* "$sysui_temp"
99 cp -a sysui/desktop/share/create_tree.sh "$sysui_temp"
100 builddir=`pwd`
101 cd $sysui_temp
102 # we want non-versioned stuff in the distro packages
103 sed -i \
104 -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION_NODOT/\1/" \
105 -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION/\1/" \
106 -e "s/\($PRODUCTNAME\) $PRODUCTVERSION/\1/" \
108 # call in subshell to do not malfrom PRODUCTVERSION, ...
110 export OFFICE_PREFIX=$LIBDIR
111 export PREFIX=$INSTALLDIRNAME
112 export ICON_PREFIX=$INSTALLDIRNAME
113 export ICON_SOURCE_DIR=$builddir/sysui/desktop/icons
114 export PRODUCTVERSION=
115 export KDEMAINDIR=$PREFIXDIR
116 export PREFIXDIR=${PREFIXDIR}
117 export GNOMEDIR=$PREFIXDIR
118 export GNOME_MIME_THEME=hicolor
119 bash ./create_tree.sh
121 cd -
122 rm -rf $sysui_temp
124 # we do not want some stuff from the plain packages
125 if test -d $DESTDIR/opt ; then
126 rm -f $DESTDIR/opt/$INSTALLDIRNAME
127 rmdir --ignore-fail-on-non-empty $DESTDIR/opt
130 # we want non-versioned desktop files
131 cd $DESTDIR/$INSTALLDIR/share/xdg
132 # we want non-versioned stuff in the distro packages
133 sed -i \
134 -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION_NODOT/\1/" \
135 -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION/\1/" \
136 -e "s/\($PRODUCTNAME\) $PRODUCTVERSION/\1/" \
137 *.desktop
138 cd -
140 # put the stuff installed by create_tree.sh into the right file lists
141 # desktop files will be added by the corresponding add_wrapper command
142 if test -f $DESTDIR/gid_Module_Root_Brand ; then
143 for dir in $PREFIXDIR/share/application-registry \
144 $PREFIXDIR/share/mimelnk/application \
145 $PREFIXDIR/share/mime/packages \
146 $PREFIXDIR/share/mime-info \
147 $PREFIXDIR/share/icons ; do
148 find "$DESTDIR$dir" \( -type f -o -type l \) -printf "$dir/%P\n" >>$DESTDIR/gid_Module_Root_Brand
149 done
152 # wrappers and man pages
153 # FIXME: do not have desktop file and MIME icon for unopkg
154 add_wrapper lobase soffice "--base" "libreoffice" "libreoffice-base.desktop" "gid_Module_Brand_Prg_Base"
155 add_wrapper localc soffice "--calc" "libreoffice" "libreoffice-calc.desktop" "gid_Module_Brand_Prg_Calc"
156 add_wrapper lodraw soffice "--draw" "libreoffice" "libreoffice-draw.desktop" "gid_Module_Brand_Prg_Draw"
157 add_wrapper lomath soffice "--math" "libreoffice" "libreoffice-math.desktop" "gid_Module_Brand_Prg_Math"
158 add_wrapper loimpress soffice "--impress" "libreoffice" "libreoffice-impress.desktop" "gid_Module_Brand_Prg_Impress"
159 add_wrapper loweb soffice "--web" "libreoffice" "" "gid_Module_Brand_Prg_Wrt"
160 add_wrapper lowriter soffice "--writer" "libreoffice" "libreoffice-writer.desktop" "gid_Module_Brand_Prg_Wrt"
161 add_wrapper lofromtemplate soffice ".uno:NewDoc" "libreoffice" "" "gid_Module_Root_Brand"
162 add_wrapper libreoffice soffice "" "libreoffice" "libreoffice-startcenter.desktop" "gid_Module_Root_Brand"
163 add_wrapper loffice soffice "" "libreoffice" "" "gid_Module_Root_Brand"
164 add_wrapper unopkg unopkg "" "unopkg" "" "gid_Module_Root_Brand"
166 # there are two more desktop files for optional filters
167 test -f $DESTDIR/gid_Module_Optional_Xsltfiltersamples && echo "$PREFIXDIR/share/applications/libreoffice-xsltfilter.desktop" >>"$DESTDIR/gid_Module_Optional_Xsltfiltersamples"
169 # $PREFIXDIR/bin/ooffice symlink is necessary by java UNO components to find
170 # the UNO installation using $PATH, see
171 # http://udk.openoffice.org/common/man/spec/transparentofficecomponents.html
172 # Note: if you want to support parallel installation of more OOo versions
173 # you cannot include this link directly into the package
174 # For example, the Novell package mark this symlink as %ghost
175 # and update it in %post and %postun
176 ln -sf $INSTALLDIR/program/soffice $DESTDIR$PREFIXDIR/bin/soffice
177 test -f $DESTDIR/gid_Module_Root_Brand && echo "$PREFIXDIR/bin/soffice" >>$DESTDIR/gid_Module_Root_Brand
179 # create bash completion
180 mkdir -p $DESTDIR/etc/bash_completion.d
181 ./bin/generate-bash-completion bin/bash-completion.in $DESTDIR/etc/bash_completion.d/$INSTALLDIRNAME.sh
182 test -f $DESTDIR/gid_Module_Root_Brand && echo "/etc/bash_completion.d/$INSTALLDIRNAME.sh" >>$DESTDIR/gid_Module_Root_Brand
183 if test "$WITH_COMPAT_OOWRAPPERS" = "TRUE" ; then
184 ./bin/generate-bash-completion --compat-oowrappers bin/bash-completion.in $DESTDIR/etc/bash_completion.d/ooffice.sh
185 test -f $DESTDIR/gid_Module_Root_Brand && echo "/etc/bash_completion.d/ooffice.sh" >>$DESTDIR/gid_Module_Root_Brand
188 echo "Install $OOINSTDIR/basis$VERSION/program/java-set-classpath";
189 mkdir -p $DESTDIR$INSTALLDIR/program
190 sed -e "s|@INSTALLDIR@|$INSTALLDIR|g" bin/java-set-classpath.in >| "$DESTDIR$INSTALLDIR/program/java-set-classpath" || exit 1;
191 chmod 755 "$DESTDIR$INSTALLDIR/program/java-set-classpath"
192 test -f $DESTDIR/gid_Module_Root_Brand && echo "$INSTALLDIR/program/java-set-classpath" >>$DESTDIR/gid_Module_Root_Brand
194 exit 0