summaryrefslogtreecommitdiff
path: root/setup_native/scripts/install_solaris.sh
blob: b52c0005b6beefb318db7e11e461726e697a4b0f (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
189
190
#!/bin/bash

error()
{
    echo
    printf "ERROR:\t$1\n"
    echo
    echo "User Mode Installation script for developer and knowledgeable early access tester"
    echo
    echo "This installation method is not intended for use in a production environment!"
    echo "Using this script is unsupported and completely at your own risk"
    echo
    echo "Usage:" $0 "<pkg-source-dir> <inst-destination-dir> [-l]"
    echo "    <pkg-source-dir>:       directory *only* containing the Solaris pkg packages to be installed"
    echo "    <inst-destination-dir>: absolute path to where the office and the pkg database will get installed"
    echo "    -l:                     optional parameter to create a link \"soffice\" in $HOME"
    echo
    exit 2
}

cannot_install()
{
    echo
    printf "ERROR:\tCannot install to directory $MY_ROOT\n"
    printf "\t$1\n"
    printf "\tPlease check/cleanup $MY_ROOT or choose a different directory\n"
    echo
    exit 2
}

#
# expect either two or three arguments
#

if [ \( $# -ne 2 -a $# -ne 3 \) -o -z "$1" -o -z "$2" ]
then
    error "Wrong number of arguments"
fi

#
# this script is for userland not for root
#

if [ $UID -eq 0 ]
then
    error "This script is for installation without administrative rights only\n\tPlease use pkgadd to install as root"
fi

#
# Evaluate command line arguments
#

PACKAGE_PATH=$1
MY_ROOT=$2

LINK="nolink"
if [ $# -eq 3 ]
then
  LINK=$3
fi

if [ ! -d $PACKAGE_PATH ]
then
    error "Directory $PACKAGE_PATH does not exist"
fi

if [ ! "${MY_ROOT:0:1}" = "/" ]
then
    error "Invalid installation directory $MY_ROOT, has to be an absolute path"
fi

#
# the admin file is expected to be in the same directory as this script
#

DIRECTORY=`dirname $0`
ADMINFILE=$DIRECTORY/admin
if [ ! -r $ADMINFILE ]
then
    error "Admin file $ADMINFILE does not exist or is not readable"
fi

#
# Check and get the list of packages to install
#

COREPKG01=`find $PACKAGE_PATH/* -type d -prune -name "*-core01*" -print`
COREPKGLIST=`find $PACKAGE_PATH/* -type d -prune -name "*-core*" -print`
PKGLIST=`find $PACKAGE_PATH/* -type d -prune ! -name "*adabas*" ! -name "*j5*" ! -name "*-desktop-int*" ! -name "*-cde*" ! -name "*-core*" ! -name "*-gnome*" -print`

if [ -z "$COREPKG01" ]
then
    error "No core package found in directory $PACKAGE_PATH"
fi

# Do not install gnome-integration package on systems without GNOME
pkginfo -q SUNWgnome-vfs
if [ $? -eq 0 ]
then
  GNOMEPKG=`find $PACKAGE_PATH/* -type d -prune -name "*-gnome*" -print`
fi

echo "Packages found:"
for i in $COREPKGLIST $PKGLIST $GNOMEPKG; do
  echo `basename $i`
done

#
# Check/Create installation directory
#

CORENAME=`basename $COREPKG01`
INSTALLDIR=$MY_ROOT`pkgparam -d $PACKAGE_PATH $CORENAME BASEDIR`

# We expect that $INSTALLDIR does not exist, however if it is empty we ignore it
if [ -d $INSTALLDIR ]
then
    # if it is not empty we cannot rm it (might be a permission problem as well)
    rmdir $INSTALLDIR
fi
if [ -d $INSTALLDIR ]
then
    cannot_install "Directory $INSTALLDIR exists and is not empty or cannot be removed"
fi

if [ -d $MY_ROOT/var/sadm ]
then
    cannot_install "pkg database does already exist $MY_ROOT/var/sadm"
fi

# Create the installation directory (otherwise the user would be asked)
mkdir -p $INSTALLDIR
if [ ! -d $INSTALLDIR ]
then
    cannot_install "Unable to create directory $INSTALLDIR"
fi

#
# the tail of the script contains a shared object for overloading the getuid() call
#

GETUID_SO=/tmp/getuid.so.$$
linenum=???
tail +$linenum $0 > $GETUID_SO
if [ ! -r $GETUID_SO ]
then
    error "Cannot create getuid wrapper library $GETUID_SO"
fi

#
# Perform the installation
#

echo "####################################################################"
echo "#     Installation of the found packages                           #"
echo "####################################################################"
echo
echo "Path to the packages       : " $PACKAGE_PATH
echo "Path to the installation   : " $MY_ROOT

export LD_PRELOAD=$GETUID_SO

for i in $COREPKGLIST $PKGLIST $GNOMEPKG; do
  echo /usr/sbin/pkgadd -a $ADMINFILE -d $PACKAGE_PATH -R $MY_ROOT `basename $i`
  /usr/sbin/pkgadd -a $ADMINFILE -d $PACKAGE_PATH -R $MY_ROOT `basename $i`
done

export -n LD_PRELOAD
rm -f $GETUID_SO

#
# Create a link into the users home directory
#

if [ "$LINK" = "-l" ]
then
  echo
  echo "Creating link from $INSTALLDIR/program/soffice to $HOME/soffice"
  rm -f $HOME/soffice
  ln -s $INSTALLDIR/program/soffice $HOME/soffice
fi

# patch the "bootstraprc" to create a self-containing installation
mv $INSTALLDIR/program/bootstraprc $INSTALLDIR/program/bootstraprc.orig
sed 's/UserInstallation=$SYSUSERCONFIG\/.staroffice8/UserInstallation=$ORIGIN\/..\/UserInstallation/g' $INSTALLDIR/program/bootstraprc.orig > $INSTALLDIR/program/bootstraprc

echo
echo "Installation done ..."

exit 0