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