OSDN Git Service

Bug fixed: makegeneral ln Makfile -> cp Makefile
[eos/base.git] / sbin / eosinstall
1 #!/bin/sh
2 #
3 # This accepts bsd-style install arguments and makes the appropriate calls
4 # to the System V install.
5 #
6
7 flags=""
8 dst=""
9 src=""
10 dostrip=""
11 owner="tacyas"
12 mode=""
13
14 while [ x$1 != x ]; do
15     case $1 in 
16         -c) shift
17             continue;;
18
19         -m) flags="$flags $1 $2 "
20             mode="$2"
21             shift
22             shift
23             continue;;
24
25         -o) flags="$flags -u $2 "
26             owner="$2"
27             shift
28             shift
29             continue;;
30
31         -g) flags="$flags $1 $2 "
32             shift
33             shift
34             continue;;
35
36         -s) dostrip="strip"
37             shift
38             continue;;
39
40         *)  if [ x$src = x ] 
41             then
42                 src=$1
43             else
44                 dst=$1
45             fi
46             shift
47             continue;;
48     esac
49 done
50
51 case "$mode" in
52 "")
53         ;;
54 *)
55         case "$owner" in
56         "")
57                 flags="$flags -u root"
58                 ;;
59         esac
60         ;;
61 esac
62
63 if [ x$src = x ] 
64 then
65         echo "$0:  no input file specified: src $src dst $dst"
66         exit 1
67 fi
68
69 if [ x$dst = x ] 
70 then
71         echo "$0:  no destination specified: src $src dst $dst"
72         exit 1
73 fi
74
75
76 # set up some variable to be used later
77
78 rmcmd=""
79 srcdir="."
80
81 # if the destination isn't a directory we'll need to copy it first
82
83 if [ ! -d $dst ]
84 then
85         dstbase=`basename $dst`
86         rmcmd="rm -f /tmp/$dstbase"
87         $rmcmd
88         cp $src /tmp/$dstbase
89         src=$dstbase
90         srcdir=/tmp
91         dst="`echo $dst | sed 's,^\(.*\)/.*$,\1,'`"
92         if [ x$dst = x ]
93         then
94                 dst="."
95         fi
96 fi
97
98
99 # If the src file has a directory, copy it to /tmp to make install happy
100
101 srcbase=`basename $src`
102
103 if [ "$src" != "$srcbase" -a "$src" != "./$srcbase" ] 
104 then
105         rm /tmp/$srcbase
106         cp $src /tmp/$srcbase
107         src=$srcbase
108         srcdir=/tmp
109         rmcmd="rm -f /tmp/$srcbase"
110 fi
111
112 # do the actual install
113
114 if [ -f /usr/sbin/install ]
115 then
116         installcmd=/usr/sbin/install 
117 elif [ -f /etc/install ]
118 then
119         installcmd=/etc/install
120 else
121         installcmd=install
122 fi
123
124 # This rm is commented out because some people want to be able to
125 # install through symbolic links.  Uncomment it if it offends you.
126 rm -f $dst/$srcbase
127 (cd $srcdir ; $installcmd -f $dst $flags $src)
128
129 if [ x$dostrip = xstrip ]
130 then
131         strip $dst/$srcbase
132 fi
133
134 # and clean up
135
136 $rmcmd
137