Merge commit 'tony/master'
[rox-filer/translations.git] / install.sh
blob060aa56d1d92620407ccdc49aa14939065635b05
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 # Note: must use full path due to bug in xterm
46 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=342782
47 "`pwd`/ROX-Filer/AppRun" -v
48 if [ $? -ne 0 ]; then
49 die "Filer doesn't work! Giving up..."
52 umask 022
55 cat << EOF
57 **************************************************************************
59 Where would you like to install the filer?
60 Normally, you should choose (1) if you have root access, or (2) if not.
62 1) Inside /usr/local
63 2) Inside my home directory
64 3) Inside /usr
65 4) Specify paths manually
66 5) Specify the prefix
68 Enter 1, 2, 3, 4 or 5:
69 EOF
70 printf ">>> "
72 read REPLY
73 echo
75 case $REPLY in
76 1) APPDIR=/usr/local/apps
77 BINDIR=/usr/local/bin
78 SHAREDIR=/usr/local/share
79 #CHOICESDIR=${SHAREDIR}/Choices
80 XDGDATADIR=/usr/local/share
81 CHOICESDIR=/etc/xdg
82 MANDIR=/usr/local/man # (not under share!)
84 2) APPDIR=${HOME}/Apps
85 BINDIR=${HOME}/bin
86 if [ -n "$XDG_DATA_HOME" ]; then
87 SHAREDIR=${XDG_DATA_HOME}
88 else
89 SHAREDIR=${HOME}/.local/share
91 if [ -n "$XDG_CONFIG_HOME" ]; then
92 CHOICESDIR=${XDG_CONFIG_HOME}
93 else
94 CHOICESDIR=${HOME}/.config
97 MANDIR=${HOME}/man
98 if [ ! -d "$MANDIR" ]; then
99 MANDIR=
102 3) APPDIR=/usr/apps
103 BINDIR=/usr/bin
104 SHAREDIR=/usr/share
105 CHOICESDIR=/etc/xdg
106 MANDIR=${SHAREDIR}/man
108 4) echo "Where should the ROX-Filer application go?"
109 get_dir "/usr/local/apps"
110 APPDIR="$DIR"
111 echo
112 echo "Where should the launcher script go?"
113 get_dir "/usr/local/bin"
114 BINDIR="$DIR"
115 echo
116 echo "Where should the shared resources (eg, MIME data) go?"
117 get_dir "/usr/local/share"
118 SHAREDIR="$DIR"
119 echo
120 echo "Where should the default run actions go?"
121 get_dir "/etc/xdg"
122 CHOICESDIR="$DIR"
123 echo
124 echo "Where should the man pages go?"
125 get_dir "/usr/local/man"
126 MANDIR="$DIR"
128 5) echo "What prefix should I use?"
129 get_dir "/usr/local"
130 APPDIR="$DIR/apps"
131 BINDIR="$DIR/bin"
132 SHAREDIR="$DIR/share"
133 CHOICESDIR=/etc/xdg
134 MANDIR="$DIR/man" # (not under share!)
137 *) die "Invalid choice!";;
138 esac
140 MIMEDIR=${SHAREDIR}/mime
142 MIMEINFO="${MIMEDIR}/packages/rox.xml"
144 cat << EOF
145 The application directory will be:
146 $APPDIR/ROX-Filer
148 The launcher script will be:
149 $BINDIR/rox
151 Run actions will be in:
152 $CHOICESDIR
154 MIME rules will be:
155 $MIMEINFO
158 if [ ! -f rox.1 ]; then
159 echo '*** The ROX-Filer manpage (rox.1) is missing.'
160 echo '*** It can be created from Manual.xml by running'
161 echo "*** 'make' in the ROX-Filer/src/Docs directory."
162 echo '*** The daily CVS snapshots have it ready-built'
163 echo
164 MANDIR=""
167 if [ -n "$MANDIR" ]; then
168 echo "The manual pages will be:"
169 echo " $MANDIR/man1/rox.1"
170 echo " $MANDIR/man1/ROX-Filer.1"
171 else
172 echo "The manual page will not be installed."
175 echo
176 echo "OK?"
177 confirm_or_die
178 echo
180 endir "$SHAREDIR"
182 if [ -n "$MANDIR" ]; then
183 echo "Installing manpage..."
184 endir "$MANDIR"
185 endir "$MANDIR/man1"
186 cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
187 rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
188 ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
191 echo "Installing run actions (existing actions will not be replaced)..."
192 endir "$CHOICESDIR/rox.sourceforge.net/MIME-types"
193 cd Choices || die "Choices missing"
194 for file in MIME-types/*; do
195 if [ -f "$file" ]; then
196 dest="$CHOICESDIR/rox.sourceforge.net/$file"
197 if [ ! -f "$dest" ]; then
198 if [ ! -d "$dest" ]; then
199 echo Install $file as $dest
200 cp "$file" "$dest"
204 done
205 cd ..
207 endir "$MIMEDIR"
208 endir "$MIMEDIR/packages"
209 cp rox.xml "$MIMEINFO" || die "Failed to create $MIMEINFO"
210 update-mime-database "$MIMEDIR" || die "update-mime-database failed
211 Make sure you have installed the shared MIME database from:
212 http://www.freedesktop.org/wiki/Software_2fshared_2dmime_2dinfo"
214 echo "Installing application..."
215 endir "$APPDIR"
217 (cd ROX-Filer/src && make clean) > /dev/null 2>&1
218 if [ -d "$APPDIR/ROX-Filer" ]; then
219 echo "ROX-Filer is already installed - delete the existing"
220 echo "copy?"
221 confirm_or_die
222 echo Deleting...
223 # Move it away first. If $APPDIR is on an nfs mount then deleting
224 # the binary may fail.
225 old="$APPDIR/.ROX-Filer.old"
226 if [ -d "$old" ]; then
227 echo "Cleaning up old copy from previous install."
228 rm -rf "$old"
230 mv "$APPDIR/ROX-Filer" "$old"
231 rm -rf "$old" || echo "Could not delete old copy.
232 This is usually because it is still executing. When it exits you may like
233 to delete $old"
235 cp -r ROX-Filer "$APPDIR"
237 echo "Installing launcher script..."
238 endir "$BINDIR"
240 cat > "$BINDIR/rox" << EOF
241 #!/bin/sh
242 exec $APPDIR/ROX-Filer/AppRun "\$@"
244 [ $? -eq 0 ] || die "Failed to install 'rox' script"
245 chmod a+x "$BINDIR/rox"
247 cat << EOF
249 Script installed. You can run the filer by simply typing 'rox'
250 Make sure that $BINDIR is in your PATH though - if it isn't then
251 you must use
252 \$ $BINDIR/rox
253 to run it instead.
255 ****************************
256 *** Now read the manual! ***
257 ****************************
259 Run ROX and click on the help icon on the toolbar:
261 \$ rox