Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / bin / distro-install-desktop-integration
blobb335dd4d814b5bc96c5b2fd980f86c9819fa30c2
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 "${SRCDIR?}"/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 -d -t distro-pack-desktop-integration-XXXXXX`
98 cp -a workdir/CustomTarget/sysui/share/libreoffice/* "$sysui_temp"
99 cp -a "${SRCDIR?}"/sysui/desktop/share/create_tree.sh "$sysui_temp"
100 cd $sysui_temp
101 # we want non-versioned stuff in the distro packages
102 sed -i \
103 -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION_NODOT/\1/" \
104 -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION/\1/" \
105 -e "s/\($PRODUCTNAME\) $PRODUCTVERSION/\1/" \
107 # call in subshell to do not malfrom PRODUCTVERSION, ...
109 export OFFICE_PREFIX=$LIBDIR
110 export PREFIX=$INSTALLDIRNAME
111 export ICON_PREFIX=$INSTALLDIRNAME
112 export ICON_SOURCE_DIR="${SRCDIR?}"/sysui/desktop/icons
113 export PRODUCTVERSION=
114 export KDEMAINDIR=$PREFIXDIR
115 export PREFIXDIR=${PREFIXDIR}
116 export GNOMEDIR=$PREFIXDIR
117 export GNOME_MIME_THEME=hicolor
118 export APPDATA_SOURCE_DIR="${SRCDIR?}"/sysui/desktop/appstream-appdata
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 $DESTDIR/opt 2>/dev/null || true
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/usr/share/bash-completion/completions
181 "${SRCDIR?}"/bin/generate-bash-completion bin/bash-completion.in $DESTDIR/usr/share/bash-completion/completions/$INSTALLDIRNAME.sh
182 test -f $DESTDIR/gid_Module_Root_Brand && echo "/usr/share/bash-completion/completions/$INSTALLDIRNAME.sh" >>$DESTDIR/gid_Module_Root_Brand
183 if test "$WITH_COMPAT_OOWRAPPERS" = "TRUE" ; then
184 "${SRCDIR?}"/bin/generate-bash-completion --compat-oowrappers bin/bash-completion.in $DESTDIR/usr/share/bash-completion/completions/ooffice.sh
185 test -f $DESTDIR/gid_Module_Root_Brand && echo "/usr/share/bash-completion/completions/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" "${SRCDIR?}"/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