about summary refs log tree commit diff
path: root/pkgs/applications/office/openoffice/builder.sh
blob: 2c6e04e049be595c6f70bbcbff056f1b3c506a9e (plain) (blame)
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
source $stdenv/setup

export nodep=TRUE
export NO_HIDS=TRUE

export PATH=$icu/sbin:$PATH

postUnpack() {
  tar xvjf $src_system
}

preConfigure() {
    ./configure --help

    for i in sysui/desktop/share/makefile.mk; do 
	substituteInPlace $i --replace /bin/bash $shell
    done

    SRCDIR=

    sed -e '/CURL_NO_OLDIES/d' -i ucb/source/ucp/ftp/makefile.mk
}

postConfigure() {
    for i in LinuxX86*Env.Set; do
	substituteInPlace $i --replace /usr /no-such-path
    done
    substituteInPlace solenv/inc/libs.mk \
	--replace /usr/lib/libjpeg.so $libjpeg/lib/libjpeg.so \
	--replace /usr/lib64/libjpeg.so $libjpeg/lib/libjpeg.so
}

buildPhase() {
    source LinuxX86*Env.Set.sh
    ./bootstrap
    # bootstrap defines the alias 'build', that mostly runs this perl script:
    (cd instsetoo_native; perl ../solenv/bin/build.pl --all) # wait a few hours... add -P4 for quadcores
}

wrapSOffice() {
    local fn=$1
    local arg=$2

    # !!! should use makeWrapper for this.

    cat > $out/bin/$fn <<EOF 
#! $shell
# Add fontconfig to the library search path; apparently OpenOffice
# looks for it at runtime.
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH\${LD_LIBRARY_PATH:+:}$fontconfig/lib:$libjpeg/lib:$cups/lib
export JAVA_HOME=$jdk
exec $ooFiles/openoffice.org3/program/soffice $arg "\$@"
EOF
    chmod +x $out/bin/$fn
}

installPhase() {
    ooFiles=$out/lib/openoffice

    # This was all borrowed from ooo-build-2.2.1's bin/ooinstall.
    # This needs the ./bootstrap having run in the buildPhase to get some env vars.
    eval $(grep 'BUILD\|LAST_MINOR' $SOLARENV/inc/minor.mk)
    export PYTHONPATH=$SOLARVERSION/$INPATH/lib:$SRC_ROOT/instsetoo_native/$INPATH/bin:$PYTHONPATH 
    export OUT=../$INPATH
    export LOCAL_OUT=../$INPATH
    export LOCAL_COMMON_OUT=../$INPATH

    # Do the actual installation into $out.
    (cd $SRC_ROOT/instsetoo_native/util && perl -w $SOLARENV/bin/make_installer.pl \
	-f openoffice.lst -l en-US -p OpenOffice \
	-buildid $BUILD -simple $ooFiles)

    mkdir -p $out/bin
    for i in soffice ooffice; do wrapSOffice $i; done
    
    # Create some wrappers to start individual OpenOffice components.
    for i in writer calc draw impress base math web; do wrapSOffice oo$i -$i; done
    
    # Create symlinks to desktop files, so that openoffice.org apps can be picked from
    # the application menu in KDE and GNOME
    mkdir -p $out/share
    ln -s $out/lib/openoffice/openoffice.org3/share/xdg $out/share/applications

    # Apply a minor correction to the *.desktop files in order to correctly address the icons
    # The openoffice- prefix should be removed from the icon identifiers
    for appl in $out/share/applications/*.desktop
    do
        chmod 644 $appl # What's wrong with the file permissions?
        sed -i '/Icon/d' $appl
        echo "Icon=$(echo $(basename $appl) | sed 's/.desktop//')" >> $appl    
    done
    
    # Copy icons so that the menu items in KDE and GNOME will look much nicer
    (cd $SRC_ROOT/sysui/desktop/icons
     install -v -d $out/share/icons/{hicolor,locolor} -m 755
     cp -rv hicolor/*x* $out/share/icons/hicolor
     cp -rv locolor/*x* $out/share/icons/locolor
    )
        
    # The desktop files expect a openoffice.org3 executable in the PATH, which is a symlink to soffice
    ln -s $out/bin/soffice $out/bin/openoffice.org3
}

genericBuild