]> mj.ucw.cz Git - libucw.git/blob - build/installer
Patch to allow processing of multiple occurences of the same argument.
[libucw.git] / build / installer
1 #!/bin/sh
2 set -e
3 DEST=`eval echo $1`
4 shift
5 echo "Installing to $DEST"
6 if [ ! -d $DEST/cf ] ; then
7         echo "Creating $DEST and the whole directory hierarchy under it."
8         mkdir -p $DEST/{cf,db,index,log,tmp}
9 fi
10 echo "Installing binaries..."
11 rm -rf $DEST/{bin,lib}
12 mkdir -p $DEST/{bin,lib}
13 cp -aL run/bin/* $DEST/bin/
14 cp -aL run/lib/* $DEST/lib/
15 echo "Installing config files..."
16 for a in "$@" ; do
17         if [ -f run/cf/$a ] ; then
18                 if [ ! -f $DEST/cf/$a ] ; then
19                         echo "cf/$a: new, installed"
20                         cp run/cf/$a $DEST/cf/$a
21                 elif [ $a == catalog-rules ] ; then
22                         echo "cf/$a: will be regenerated automatically"
23                 elif diff -u $DEST/cf/$a run/cf/$a ; then
24                         echo "cf/$a: no differences"
25                 else
26                         echo -n "cf/$a differs, replace it [Yn]? "
27                         read x
28                         if [ -z "$x" -o "$x" == "y" -o "$x" == "Y" ] ; then
29                                 echo "cf/$a: replacing and keeping the old version as cf/$a.old"
30                                 mv $DEST/cf/$a $DEST/cf/$a.old
31                                 cp run/cf/$a $DEST/cf/$a
32                         else
33                                 echo "cf/$a: installing the new version as cf/$a.dist"
34                                 cp run/cf/$a $DEST/cf/$a.dist
35                         fi
36                 fi
37         fi
38 done
39 echo "Done."