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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
#!/bin/sh
die() {
echo "$*" >&2
echo "Aborting..." >&2
exit 1
}
get_dir() {
while [ 1 -eq 1 ]; do
printf "[$1] >>> "
read DIR
case "$DIR" in
/*) return;;
?*) echo "The path must start with a \`/'";;
*) DIR="$1"
echo OK, using default value.
return;;
esac
done
}
# Create the directory if it doesn't exist. Exit if it can't be created.
endir() {
if [ ! -d "$1" ]; then
mkdir -p "$1" || die "Can't create $1 directory!"
fi
}
confirm_or_die() {
while [ 1 -eq 1 ]; do
printf "[yes/no] >>> "
read CONFIRM
case "$CONFIRM" in
[yY]*) return;;
[nN]*) die "OK.";;
esac
done
}
cd `dirname $0`
echo Testing the filer...
./ROX-Filer/AppRun -v
if [ $? -ne 0 ]; then
die "Filer doesn't work! Giving up..."
fi
umask 022
cat << EOF
**************************************************************************
Where would you like to install the filer?
Normally, you should choose (1) if you have root access, or (2) if not.
1) Inside /usr/local
2) Inside my home directory
3) Inside /usr
4) Specify paths manually
5) Specify the prefix
Enter 1, 2, 3, 4 or 5:
EOF
printf ">>> "
read REPLY
echo
case $REPLY in
1) APPDIR=/usr/local/apps
BINDIR=/usr/local/bin
SHAREDIR=/usr/local/share
CHOICESDIR=${SHAREDIR}/Choices
MANDIR=/usr/local/man # (not under share!)
;;
2) APPDIR=${HOME}/Apps
BINDIR=${HOME}/bin
if [ -n "$CHOICESPATH" ]; then
CHOICESDIR=`echo $CHOICESPATH | sed -e 's/^\([^:]*\).*$/\\1/'`
fi
if [ ! -n "$CHOICESDIR" ]; then
CHOICESDIR=${HOME}/Choices
fi
if [ -n "$XDG_DATA_HOME" ]; then
SHAREDIR=${XDG_DATA_HOME}
else
SHAREDIR=${HOME}/.local/share
fi
MANDIR=${HOME}/man
if [ ! -d "$MANDIR" ]; then
MANDIR=
fi
;;
3) APPDIR=/usr/apps
BINDIR=/usr/bin
SHAREDIR=/usr/share
CHOICESDIR=${SHAREDIR}/Choices
MANDIR=${SHAREDIR}/man
;;
4) echo "Where should the ROX-Filer application go?"
get_dir "/usr/local/apps"
APPDIR="$DIR"
echo
echo "Where should the launcher script go?"
get_dir "/usr/local/bin"
BINDIR="$DIR"
echo
echo "Where should the shared resources (eg, MIME data) go?"
get_dir "/usr/local/share"
SHAREDIR="$DIR"
echo
echo "Where should the default run actions go?"
get_dir "$SHAREDIR/Choices"
CHOICESDIR="$DIR"
echo
echo "Where should the man pages go?"
get_dir "/usr/local/man"
MANDIR="$DIR"
;;
5) echo "What prefix should I use?"
get_dir "/usr/local"
APPDIR="$DIR/apps"
BINDIR="$DIR/bin"
SHAREDIR="$DIR/share"
CHOICESDIR=${SHAREDIR}/Choices
MANDIR="$DIR/man" # (not under share!)
;;
*) die "Invalid choice!";;
esac
MIMEDIR=${SHAREDIR}/mime
MIMEINFO="${MIMEDIR}/packages/rox.xml"
cat << EOF
The application directory will be:
$APPDIR/ROX-Filer
The launcher script will be:
$BINDIR/rox
Run actions will be in:
$CHOICESDIR
MIME rules will be:
$MIMEINFO
EOF
if [ ! -f rox.1 ]; then
echo '*** The ROX-Filer manpage (rox.1) is missing.'
echo '*** It can be created from Manual.xml by running'
echo "*** 'make' in the ROX-Filer/src/Docs directory."
echo '*** The daily CVS snapshots have it ready-built'
echo
MANDIR=""
fi
if [ -n "$MANDIR" ]; then
echo "The manual pages will be:"
echo " $MANDIR/man1/rox.1"
echo " $MANDIR/man1/ROX-Filer.1"
else
echo "The manual page will not be installed."
fi
echo
echo "OK?"
confirm_or_die
echo
endir "$SHAREDIR"
if [ -n "$MANDIR" ]; then
echo "Installing manpage..."
endir "$MANDIR"
endir "$MANDIR/man1"
cp rox.1 "$MANDIR/man1/rox.1" || die "Can't install manpage!"
rm -f "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
ln -s "$MANDIR/man1/rox.1" "$MANDIR/man1/ROX-Filer.1" || die "Can't install manpage!"
fi
echo "Installing run actions (existing actions will not be replaced)..."
endir "$CHOICESDIR/MIME-types"
cd Choices || die "Choices missing"
for file in MIME-types/*; do
if [ -f "$file" ]; then
dest="$CHOICESDIR/$file"
if [ ! -f "$dest" ]; then
if [ ! -d "$dest" ]; then
echo Install $file as $dest
cp "$file" "$dest"
fi
fi
fi
done
cd ..
endir "$MIMEDIR"
endir "$MIMEDIR/packages"
cp rox.xml "$MIMEINFO" || die "Failed to create $MIMEINFO"
update-mime-database "$MIMEDIR" || die "update-mime-database failed
Make sure you have installed the shared MIME database from:
http://www.freedesktop.org/software/shared-mime-info"
echo "Installing application..."
endir "$APPDIR"
(cd ROX-Filer/src && make clean) > /dev/null 2>&1
if [ -d "$APPDIR/ROX-Filer" ]; then
echo "ROX-Filer is already installed - delete the existing"
echo "copy?"
confirm_or_die
echo Deleting...
# Move it away first. If $APPDIR is on an nfs mount then deleting
# the binary may fail.
mv "$APPDIR/ROX-Filer" "$APPDIR/.ROX-Filer"
rm -rf "$APPDIR/.ROX-Filer"
fi
cp -r ROX-Filer "$APPDIR"
echo "Installing launcher script..."
endir "$BINDIR"
cat > "$BINDIR/rox" << EOF
#!/bin/sh
exec $APPDIR/ROX-Filer/AppRun "\$@"
EOF
[ $? -eq 0 ] || die "Failed to install 'rox' script"
chmod a+x "$BINDIR/rox"
cat << EOF
Script installed. You can run the filer by simply typing 'rox'
Make sure that $BINDIR is in your PATH though - if it isn't then
you must use
\$ $BINDIR/rox
to run it instead.
****************************
*** Now read the manual! ***
****************************
Run ROX and click on the help icon on the toolbar:
\$ rox
EOF
|