r2805: Fix scrolling problem with GTK+-2.2.2 (reported by Alastair Porter, with
[rox-filer.git] / install.sh
blobdfdb68d2048764fa2d02d009bc028cb8c29d97ce
1 #!/bin/sh
3 die() {
4 echo "$*" >&2
5 echo "Aborting..." >&2
6 exit 1
9 get_dir() {
10 while [ 1 -eq 1 ]; do
11 printf "[$1] >>> "
12 read DIR
14 case "$DIR" in
15 /*) return;;
16 ?*) echo "The path must start with a \`/'";;
17 *) DIR="$1"
18 echo OK, using default value.
19 return;;
20 esac
21 done
24 # Create the directory if it doesn't exist. Exit if it can't be created.
25 endir() {
26 if [ ! -d "$1" ]; then
27 mkdir -p "$1" || die "Can't create $1 directory!"
31 confirm_or_die() {
32 while [ 1 -eq 1 ]; do
33 printf "[yes/no] >>> "
34 read CONFIRM
35 case "$CONFIRM" in
36 [yY]*) return;;
37 [nN]*) die "OK.";;
38 esac
39 done
42 cd `dirname $0`
44 echo Testing the filer...
45 ./ROX-Filer/AppRun -v
46 if [ $? -ne 0 ]; then
47 die "Filer doesn't work! Giving up..."
50 umask 022
53 cat << EOF
55 **************************************************************************
57 Where would you like to install the filer?
58 Normally, you should choose (1) if you have root access, or (2) if not.
60 1) Inside /usr/local
61 2) Inside my home directory
62 3) Inside /usr
63 4) Specify paths manually
65 Enter 1, 2, 3 or 4:
66 EOF
67 printf ">>> "
69 read REPLY
70 echo
72 case $REPLY in
73 1) APPDIR=/usr/local/apps
74 BINDIR=/usr/local/bin
75 SHAREDIR=/usr/local/share
76 CHOICESDIR=${SHAREDIR}/Choices
77 MANDIR=/usr/local/man # (not under share!)
79 2) APPDIR=${HOME}/Apps
80 BINDIR=${HOME}/bin
81 if [ -n "$CHOICESPATH" ]; then
82 CHOICESDIR=`echo $CHOICESPATH | sed -e 's/^\([^:]*\).*$/\\1/'`
84 if [ ! -n "$CHOICESDIR" ]; then
85 CHOICESDIR=${HOME}/Choices
87 if [ -n "$XDG_DATA_HOME" ]; then
88 SHAREDIR=${XDG_DATA_HOME}
89 else
90 SHAREDIR=${HOME}/.local/share
92 MANDIR=${HOME}/man
93 if [ ! -d "$MANDIR" ]; then
94 MANDIR=
97 3) APPDIR=/usr/apps
98 BINDIR=/usr/bin
99 SHAREDIR=/usr/share
100 CHOICESDIR=${SHAREDIR}/Choices
101 MANDIR=${SHAREDIR}/man
103 4) echo "Where should the ROX-Filer application go?"
104 get_dir "/usr/local/apps"
105 APPDIR="$DIR"
106 echo
107 echo "Where should the launcher script go?"
108 get_dir "/usr/local/bin"
109 BINDIR="$DIR"
110 echo
111 echo "Where should the shared resources (eg, MIME data) go?"
112 get_dir "/usr/local/share"
113 SHAREDIR="$DIR"
114 echo
115 echo "Where should the default icons and run actions go?"
116 get_dir "$SHAREDIR/Choices"
117 CHOICESDIR="$DIR"
118 echo
119 echo "Where should the man pages go?"
120 get_dir "/usr/local/man"
121 MANDIR="$DIR"
123 *) die "Invalid choice!";;
124 esac
126 MIMEDIR=${SHAREDIR}/mime
128 MIMEINFO="${MIMEDIR}/packages/rox.xml"
130 cat << EOF
131 The application directory will be:
132 $APPDIR/ROX-Filer
134 The launcher script will be:
135 $BINDIR/rox
137 Icons and run actions will be in:
138 $CHOICESDIR
140 MIME rules will be:
141 $MIMEINFO
144 if [ ! -f rox.1 ]; then
145 echo '*** The ROX-Filer manpage (rox.1) is missing.'
146 echo '*** It can be created from Manual.xml by running'
147 echo "*** 'make' in the ROX-Filer/src/Docs directory."
148 echo '*** The daily CVS snapshots have it ready-built'
149 echo
150 MANDIR=""
153 if [ -n "$MANDIR" ]; then
154 echo "The manual pages will be:"
155 echo " $MANDIR/man1/rox.1"
156 echo " $MANDIR/man1/ROX-Filer.1"
157 else
158 echo "The manual page will not be installed."
161 echo
162 echo "OK?"
163 confirm_or_die
164 echo
166 endir "$SHAREDIR"
168 if [ -n "$MANDIR" ]; then
169 echo "Installing manpage..."
170 endir "$MANDIR"
171 endir "$MANDIR/man1"
172 cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
173 rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
174 ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
177 echo "Installing icons (existing icons will not be replaced)..."
178 endir "$CHOICESDIR/MIME-icons"
179 endir "$CHOICESDIR/MIME-types"
180 cd Choices || die "Choices missing"
181 for file in MIME-*/*; do
182 if [ -f "$file" ]; then
183 dest="$CHOICESDIR/$file"
184 if [ ! -f "$dest" ]; then
185 if [ ! -d "$dest" ]; then
186 echo Install $file as $dest
187 cp "$file" "$dest"
191 done
192 cd ..
194 endir "$MIMEDIR"
195 endir "$MIMEDIR/packages"
196 cp rox.xml "$MIMEINFO" || die "Failed to create $MIMEINFO"
197 update-mime-database "$MIMEDIR" || die "update-mime-database failed
198 Make sure you have installed the shared MIME database from:
199 http://www.freedesktop.org/standards/shared-mime-info.html"
201 echo "Installing application..."
202 endir "$APPDIR"
204 (cd ROX-Filer/src && make clean) > /dev/null 2>&1
205 if [ -d "$APPDIR/ROX-Filer" ]; then
206 echo "ROX-Filer is already installed - delete the existing"
207 echo "copy?"
208 confirm_or_die
209 echo Deleting...
210 rm -rf "$APPDIR/ROX-Filer"
212 cp -r ROX-Filer "$APPDIR"
214 echo "Installing launcher script..."
215 endir "$BINDIR"
217 cat > "$BINDIR/rox" << EOF
218 #!/bin/sh
219 exec $APPDIR/ROX-Filer/AppRun "\$@"
221 [ $? -eq 0 ] || die "Failed to install 'rox' script"
222 chmod a+x "$BINDIR/rox"
224 cat << EOF
226 Script installed. You can run the filer by simply typing 'rox'
227 Make sure that $BINDIR is in your PATH though - if it isn't then
228 you must use
229 \$ $BINDIR/rox
230 to run it instead.
232 ****************************
233 *** Now read the manual! ***
234 ****************************
236 Run ROX and click on the help icon on the toolbar:
238 \$ rox