summaryrefslogtreecommitdiff
path: root/bin/distro-install-desktop-integration
blob: 7e1428ffba69ec5e39a9cc331dab9c69ef4970f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/bin/sh

if test -z "${SRC_ROOT}"; then
    echo "distro-install-clean-up: No environment set!"
    exit 1
fi

PRODUCTVERSION_NODOT=`echo $PRODUCTVERSION | sed -e "s/\.//"`

mkdir -p "$DESTDIR$BINDIR"

create_wrapper()
{
    echo "Install $BINDIR/$1"

    if test -L "$DESTDIR$BINDIR/$1" ; then
        # do not overwrite $BINDIR/libreoffice symlink created by create_tree.sh
        # the symlink is necessary by java UNO components to find
        # the UNO installation using $PATH; this function used to be provided
        # by $BINDIR/soffice symlink, see
        # http://udk.openoffice.org/common/man/spec/transparentofficecomponents.html
        # Note: if you want to support parallel installation of more OOo versions
        #       you cannot include this link directly into the package
        #       For example, the Novell package mark this symlink as %ghost
        #	and update it in %post and %postun
        echo "     skip already existing symlink $BINDIR/$1"
    else
        mkdir -p "$DESTDIR$BINDIR"
        cat <<EOT >"$DESTDIR$BINDIR/$1"
#!/bin/sh
$INSTALLDIR/program/$2 $3 "\$@"
EOT
        chmod 755 "$DESTDIR$BINDIR/$1"
    fi
    # put into file list
    test -f "$DESTDIR/$4" && echo "$BINDIR/$1" >>$DESTDIR/$4
}

create_man_link()
{
    echo "Install $MANDIR/man1/$1.1.gz"

    mkdir -p $DESTDIR$MANDIR/man1
    echo ".so man1/$2.1" >| $DESTDIR$MANDIR/man1/$1.1
    gzip -f $DESTDIR$MANDIR/man1/$1.1
    test -f "$DESTDIR/$3" && echo "$MANDIR/man1/$1.1.gz" >>"$DESTDIR/$3"
}

install_man()
{
    echo "Install $MANDIR/man1/$1.1.gz"

    mkdir -p $DESTDIR$MANDIR/man1
    cp "${SRCDIR?}"/sysui/desktop/man/$1.1 $DESTDIR$MANDIR/man1 || exit 1;
    gzip -f $DESTDIR$MANDIR/man1/$1.1
    test -f "$DESTDIR/$2" && echo "$MANDIR/man1/$1.1.gz" >>"$DESTDIR/$2"
}


add_wrapper()
{
    lowrapper_name="$1"
    target_binary="$2"
    target_option_1="$3"
    used_man_page="$4"
    desktop_file="$5"
    file_list="$6"

    # do we want compat oowrapper?
    oowrapper_name=""
    if test "$WITH_COMPAT_OOWRAPPERS" = 'TRUE' ; then
        oowrapper_name=`echo "$lowrapper_name" | sed -e "s/^lo/oo/"`
        # "oo" prefix only for wrappers stating with "lo" prefix
        test "$oowrapper_name" = "$lowrapper_name" && oowrapper_name=
    fi

    # wrappers
    create_wrapper "$lowrapper_name" "$target_binary" "$target_option_1" "$file_list"
    test -n "$oowrapper_name" && create_wrapper "$oowrapper_name" "$target_binary" "$target_option_1" "$file_list"

    # man pages
    if test "$used_man_page" = "$lowrapper_name" ; then
        # need to install the manual page
        install_man "$lowrapper_name" "$file_list"
    else
        # just link the manual page
        create_man_link "$lowrapper_name" "$used_man_page" "$file_list"
    fi
    test -n "$oowrapper_name" && create_man_link "$oowrapper_name" "$used_man_page" "$file_list"

    # add desktop file to the right file list
    test -n "$desktop_file" -a -f "$DESTDIR/$file_list" && echo "$PREFIXDIR/share/applications/$desktop_file" >>"$DESTDIR/$file_list"
}

# install desktop integration from plain packages
sysui_temp=`mktemp -d -t distro-pack-desktop-integration-XXXXXX`
cp -a workdir/CustomTarget/sysui/share/libreoffice/* "$sysui_temp"
cp -a "${SRCDIR?}"/sysui/desktop/share/create_tree.sh "$sysui_temp"
cd $sysui_temp
# we want non-versioned stuff in the distro packages
sed -i \
    -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION_NODOT/\1/" \
    -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION/\1/" \
    -e "s/\($PRODUCTNAME\) $PRODUCTVERSION/\1/" \
    *
# call in subshell to do not malform PRODUCTVERSION, ...
(
    export OFFICE_PREFIX=$LIBDIR
    export PREFIX=$INSTALLDIRNAME
    export ICON_PREFIX=$INSTALLDIRNAME
    export ICON_SOURCE_DIR="${SRCDIR?}"/sysui/desktop/icons
    export PRODUCTVERSION=
    export KDEMAINDIR=$PREFIXDIR
    export PREFIXDIR=${PREFIXDIR}
    export APPDATA_SOURCE_DIR="${SRCDIR?}"/sysui/desktop/appstream-appdata
    bash ./create_tree.sh
)
cd -
rm -rf $sysui_temp

# we do not want some stuff from the plain packages
if test -d $DESTDIR/opt ; then
    rm -f $DESTDIR/opt/$INSTALLDIRNAME
    rmdir $DESTDIR/opt 2>/dev/null || true
fi

# we want non-versioned desktop files
cd $DESTDIR/$INSTALLDIR/share/xdg
# we want non-versioned stuff in the distro packages
sed -i \
    -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION_NODOT/\1/" \
    -e "s/\($INSTALLDIRNAME\)$PRODUCTVERSION/\1/" \
    -e "s/\($PRODUCTNAME\) $PRODUCTVERSION/\1/" \
    *.desktop
cd -

# put the stuff installed by create_tree.sh into the right file lists
# desktop files will be added by the corresponding add_wrapper command
if test -f $DESTDIR/gid_Module_Root_Brand ; then
    for dir in $PREFIXDIR/share/mime/packages \
               $PREFIXDIR/share/icons ; do
        find "$DESTDIR$dir" \( -type f -o -type l \) -printf "$dir/%P\n" >>$DESTDIR/gid_Module_Root_Brand
    done
fi

# wrappers and man pages
# FIXME: do not have desktop file and MIME icon for unopkg
add_wrapper lobase         soffice "--base"       "libreoffice" "libreoffice-base.desktop"        "gid_Module_Brand_Prg_Base"
add_wrapper localc         soffice "--calc"       "libreoffice" "libreoffice-calc.desktop"        "gid_Module_Brand_Prg_Calc"
add_wrapper lodraw         soffice "--draw"       "libreoffice" "libreoffice-draw.desktop"        "gid_Module_Brand_Prg_Draw"
add_wrapper lomath         soffice "--math"       "libreoffice" "libreoffice-math.desktop"        "gid_Module_Brand_Prg_Math"
add_wrapper loimpress      soffice "--impress"    "libreoffice" "libreoffice-impress.desktop"     "gid_Module_Brand_Prg_Impress"
add_wrapper loweb          soffice "--web"        "libreoffice" ""                                "gid_Module_Brand_Prg_Wrt"
add_wrapper lowriter       soffice "--writer"     "libreoffice" "libreoffice-writer.desktop"      "gid_Module_Brand_Prg_Wrt"
add_wrapper lofromtemplate soffice ".uno:NewDoc"  "libreoffice" ""                                "gid_Module_Root_Brand"
add_wrapper libreoffice    soffice ""            "libreoffice" "libreoffice-startcenter.desktop" "gid_Module_Root_Brand"
add_wrapper loffice        soffice ""            "libreoffice" ""                                "gid_Module_Root_Brand"
add_wrapper unopkg         unopkg  ""            "unopkg"      ""                                "gid_Module_Root_Brand"

# there are two more desktop files for optional filters
test -f $DESTDIR/gid_Module_Optional_Xsltfiltersamples && echo "$PREFIXDIR/share/applications/libreoffice-xsltfilter.desktop" >>"$DESTDIR/gid_Module_Optional_Xsltfiltersamples"

# $BINDIR/ooffice symlink is necessary by java UNO components to find
# the UNO installation using $PATH, see
# http://udk.openoffice.org/common/man/spec/transparentofficecomponents.html
# Note: if you want to support parallel installation of more OOo versions
#       you cannot include this link directly into the package
#       For example, the Novell package mark this symlink as %ghost
#	and update it in %post and %postun
ln -sf "$INSTALLDIR/program/soffice" "$DESTDIR$BINDIR/soffice"
test -f $DESTDIR/gid_Module_Root_Brand && echo "$BINDIR/soffice" >>$DESTDIR/gid_Module_Root_Brand

# create bash completion
mkdir -p $DESTDIR/usr/share/bash-completion/completions
"${SRCDIR?}"/bin/generate-bash-completion.py bin/bash-completion.in $DESTDIR/usr/share/bash-completion/completions/$INSTALLDIRNAME.sh
test -f $DESTDIR/gid_Module_Root_Brand && echo "/usr/share/bash-completion/completions/$INSTALLDIRNAME.sh" >>$DESTDIR/gid_Module_Root_Brand
if test "$WITH_COMPAT_OOWRAPPERS" = "TRUE" ; then
    "${SRCDIR?}"/bin/generate-bash-completion.py --compat-oowrappers bin/bash-completion.in $DESTDIR/usr/share/bash-completion/completions/ooffice.sh
    test -f $DESTDIR/gid_Module_Root_Brand && echo "/usr/share/bash-completion/completions/ooffice.sh" >>$DESTDIR/gid_Module_Root_Brand
fi

echo "Install $OOINSTDIR/basis$VERSION/program/java-set-classpath";
mkdir -p $DESTDIR$INSTALLDIR/program
sed -e "s|@INSTALLDIR@|$INSTALLDIR|g" "${SRCDIR?}"/bin/java-set-classpath.in >| "$DESTDIR$INSTALLDIR/program/java-set-classpath" || exit 1;
chmod 755 "$DESTDIR$INSTALLDIR/program/java-set-classpath"
test -f $DESTDIR/gid_Module_Root_Brand && echo "$INSTALLDIR/program/java-set-classpath" >>$DESTDIR/gid_Module_Root_Brand

exit 0