This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Enable -Dusesitecustomize from Configure command line
[metaconfig.git] / dist-3.0at70b / install
1 #!/bin/sh
2 # @(#) Installing script accepting bsd-style arguments
3
4 # $Id: install.SH,v 3.0.1.1 1993/08/19 06:42:10 ram Exp $
5 #
6 #  Copyright (c) 1991-1993, Raphael Manfredi
7 #  
8 #  You may redistribute only under the terms of the Artistic Licence,
9 #  as specified in the README file that comes with the distribution.
10 #  You may reuse parts of this distribution only within the terms of
11 #  that same Artistic Licence; a copy of which may be found at the root
12 #  of the source tree for dist 3.0.
13 #
14 # $Log: install.SH,v $
15 # Revision 3.0.1.1  1993/08/19  06:42:10  ram
16 # patch1: leading config.sh searching was not aborting properly
17 #
18 # Revision 3.0  1993/08/18  12:04:08  ram
19 # Baseline for dist 3.0 netwide release.
20 #
21
22 chown='/usr/bin/chown'
23 chmod='/usr/bin/chmod'
24 chgrp='/usr/bin/chgrp'
25 rm='/usr/bin/rm'
26 mv='/usr/bin/mv'
27 test='test'
28 sed='/usr/bin/sed'
29
30 mode=""
31 dst=""
32 src=""
33 dostrip=""
34 newdir=""
35 uid=""
36 gid=""
37
38 # simulates mkdir -p
39 mkdir_p='
40 name=$1;
41 create="";
42 while $test $name; do
43         if $test ! -d "$name"; then
44                 create="$name $create";
45                 name=`echo $name | $sed -e "s|^[^/]*$||"`;
46                 name=`echo $name | $sed -e "s|\(.*\)/.*|\1|"`;
47         else
48                 name="";
49         fi;
50 done;
51 for file in $create; do
52         mkdir $file && $test $verbose &&
53         echo "install: created directory $file" >&2;
54 done
55 '
56
57 verbose=''
58
59 while $test x$1 != x
60 do
61         case $1 in 
62         -c) shift
63                 continue
64                 ;;
65         -m) mode="$2 "
66                 shift
67                 shift
68                 continue
69                 ;;
70         -o) uid="$2 "
71                 shift
72                 shift
73                 continue
74                 ;;
75         -g) gid="$2 "
76                 shift
77                 shift
78                 continue
79                 ;;
80         -s) dostrip="strip"
81                 shift
82                 continue
83                 ;;
84         -d) newdir="$newdir$2 "
85                 shift
86                 shift
87                 continue
88                 ;;
89         -v) verbose='true'
90                 shift
91                 ;;
92         *) if $test x$src = x
93                 then
94                         src=$1
95                 else
96                         dst=$1
97                 fi
98                 shift
99                 continue
100                 ;;
101         esac
102 done
103
104 # if -d option is used, we have to create the path given
105 if $test ! x$newdir = x
106 then
107         for i in $newdir
108         do
109                 set x $i
110                 shift
111                 eval $mkdir_p
112         done
113         exit 0          # -d is the only action
114 fi
115
116 if $test x$src = x
117 then
118         echo "install: no input file specified" >&2
119         exit 1
120 fi
121
122 if $test x$dst = x
123 then
124         echo "install: no destination specified" >&2
125         exit 1
126 fi
127
128 srcbase=`basename $src`
129 dstbase=`basename $dst`
130
131 # If the destination is a directory, the target name is srcbase...
132 if $test -d $dst; then
133         dstbase=$srcbase
134 else
135         dst="`echo $dst | sed 's,^\(.*\)/.*$,\1,'`"
136         if $test ! -d $dst; then
137                 dstbase=$dst
138                 dst="."
139         fi
140 fi
141
142 # If the src has a directory, extract the dir name...
143 if $test "$src" != "$srcbase" -a "$src" != "./$srcbase"; then
144         src="`echo $src | sed 's,^\(.*\)/.*$,\1,'`"
145 else
146         src="."
147 fi
148
149 # dst is the destination directory and dstbase the base name.
150 # srcbase is the base name of source and src the source dir.
151
152 srcpth=`(cd $src; pwd)`/$srcbase
153 destpth=`(cd $dst; pwd)`/$dstbase
154 if $test x$srcpth = x$destpth; then
155         $test $verbose && \
156         echo "install: destination and source are identical"
157         exit 0
158 fi
159
160 # Do the install
161 (
162         cd $src
163
164         if $test -f $dst/$dstbase; then
165                 $rm -f $dst/$dstbase && $test $verbose &&
166                 echo "install: $dst/$dstbase removed"
167         fi
168         if $test -f $dst/$dstbase; then
169                 $mv $dst/$dstbase $dst/OLD$dstbase && $test $verbose &&
170                 echo "install: $dst/$dstbase renamed as OLD$dstbase"
171         fi
172
173         cp $srcbase $dst/$dstbase && $test $verbose &&
174         echo "install: $srcbase installed as $dst/$dstbase"
175
176         if $test ! x$dostrip = x; then
177                 strip $dst/$dstbase 2>/dev/null && $test $verbose &&
178                 echo "install: stripped $dst/$dstbase"
179         fi
180
181         if $test ! x$uid = x; then
182                 $chown $uid $dst/$dstbase
183         fi
184         if $test ! x$gid = x; then
185                 $chgrp $gid $dst/$dstbase
186         fi
187         if $test ! x$mode = x
188         then
189                 $chmod $mode $dst/$dstbase
190         fi
191 )
192
193 exit 0