r4015: Bugfix: The path entry buffer didn't work in /, due to recent changes
[rox-filer/th.git] / install.sh
blob1f524f680de8300e49dec141a6652f04c33a561e
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
64 5) Specify the prefix
66 Enter 1, 2, 3, 4 or 5:
67 EOF
68 printf ">>> "
70 read REPLY
71 echo
73 case $REPLY in
74 1) APPDIR=/usr/local/apps
75 BINDIR=/usr/local/bin
76 SHAREDIR=/usr/local/share
77 #CHOICESDIR=${SHAREDIR}/Choices
78 XDGDATADIR=/usr/local/share
79 CHOICESDIR=/etc/xdg
80 MANDIR=/usr/local/man # (not under share!)
82 2) APPDIR=${HOME}/Apps
83 BINDIR=${HOME}/bin
84 if [ -n "$XDG_DATA_HOME" ]; then
85 SHAREDIR=${XDG_DATA_HOME}
86 else
87 SHAREDIR=${HOME}/.local/share
89 if [ -n "$XDG_CONFIG_HOME" ]; then
90 CHOICESDIR=${XDG_CONFIG_HOME}
91 else
92 CHOICESDIR=${HOME}/.config
95 MANDIR=${HOME}/man
96 if [ ! -d "$MANDIR" ]; then
97 MANDIR=
100 3) APPDIR=/usr/apps
101 BINDIR=/usr/bin
102 SHAREDIR=/usr/share
103 CHOICESDIR=/etc/xdg
104 MANDIR=${SHAREDIR}/man
106 4) echo "Where should the ROX-Filer application go?"
107 get_dir "/usr/local/apps"
108 APPDIR="$DIR"
109 echo
110 echo "Where should the launcher script go?"
111 get_dir "/usr/local/bin"
112 BINDIR="$DIR"
113 echo
114 echo "Where should the shared resources (eg, MIME data) go?"
115 get_dir "/usr/local/share"
116 SHAREDIR="$DIR"
117 echo
118 echo "Where should the default run actions go?"
119 get_dir "/etc/xdg"
120 CHOICESDIR="$DIR"
121 echo
122 echo "Where should the man pages go?"
123 get_dir "/usr/local/man"
124 MANDIR="$DIR"
126 5) echo "What prefix should I use?"
127 get_dir "/usr/local"
128 APPDIR="$DIR/apps"
129 BINDIR="$DIR/bin"
130 SHAREDIR="$DIR/share"
131 CHOICESDIR=/etc/xdg
132 MANDIR="$DIR/man" # (not under share!)
135 *) die "Invalid choice!";;
136 esac
138 MIMEDIR=${SHAREDIR}/mime
140 MIMEINFO="${MIMEDIR}/packages/rox.xml"
142 cat << EOF
143 The application directory will be:
144 $APPDIR/ROX-Filer
146 The launcher script will be:
147 $BINDIR/rox
149 Run actions will be in:
150 $CHOICESDIR
152 MIME rules will be:
153 $MIMEINFO
156 if [ ! -f rox.1 ]; then
157 echo '*** The ROX-Filer manpage (rox.1) is missing.'
158 echo '*** It can be created from Manual.xml by running'
159 echo "*** 'make' in the ROX-Filer/src/Docs directory."
160 echo '*** The daily CVS snapshots have it ready-built'
161 echo
162 MANDIR=""
165 if [ -n "$MANDIR" ]; then
166 echo "The manual pages will be:"
167 echo " $MANDIR/man1/rox.1"
168 echo " $MANDIR/man1/ROX-Filer.1"
169 else
170 echo "The manual page will not be installed."
173 echo
174 echo "OK?"
175 confirm_or_die
176 echo
178 endir "$SHAREDIR"
180 if [ -n "$MANDIR" ]; then
181 echo "Installing manpage..."
182 endir "$MANDIR"
183 endir "$MANDIR/man1"
184 cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
185 rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
186 ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
189 echo "Installing run actions (existing actions will not be replaced)..."
190 endir "$CHOICESDIR/rox.sourceforge.net/MIME-types"
191 cd Choices || die "Choices missing"
192 for file in MIME-types/*; do
193 if [ -f "$file" ]; then
194 dest="$CHOICESDIR/rox.sourceforge.net/$file"
195 if [ ! -f "$dest" ]; then
196 if [ ! -d "$dest" ]; then
197 echo Install $file as $dest
198 cp "$file" "$dest"
202 done
203 cd ..
205 endir "$MIMEDIR"
206 endir "$MIMEDIR/packages"
207 cp rox.xml "$MIMEINFO" || die "Failed to create $MIMEINFO"
208 update-mime-database "$MIMEDIR" || die "update-mime-database failed
209 Make sure you have installed the shared MIME database from:
210 http://www.freedesktop.org/software/shared-mime-info"
212 echo "Installing application..."
213 endir "$APPDIR"
215 (cd ROX-Filer/src && make clean) > /dev/null 2>&1
216 if [ -d "$APPDIR/ROX-Filer" ]; then
217 echo "ROX-Filer is already installed - delete the existing"
218 echo "copy?"
219 confirm_or_die
220 echo Deleting...
221 # Move it away first. If $APPDIR is on an nfs mount then deleting
222 # the binary may fail.
223 old="$APPDIR/.ROX-Filer.old"
224 if [ -d "$old" ]; then
225 echo "Cleaning up old copy from previous install."
226 rm -rf "$old"
228 mv "$APPDIR/ROX-Filer" "$old"
229 rm -rf "$old" || echo "Could not delete old copy.
230 This is usually because it is still executing. When it exits you may like
231 to delete $old"
233 cp -r ROX-Filer "$APPDIR"
235 echo "Installing launcher script..."
236 endir "$BINDIR"
238 cat > "$BINDIR/rox" << EOF
239 #!/bin/sh
240 exec $APPDIR/ROX-Filer/AppRun "\$@"
242 [ $? -eq 0 ] || die "Failed to install 'rox' script"
243 chmod a+x "$BINDIR/rox"
245 cat << EOF
247 Script installed. You can run the filer by simply typing 'rox'
248 Make sure that $BINDIR is in your PATH though - if it isn't then
249 you must use
250 \$ $BINDIR/rox
251 to run it instead.
253 ****************************
254 *** Now read the manual! ***
255 ****************************
257 Run ROX and click on the help icon on the toolbar:
259 \$ rox