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