File: hginstall

package info (click to toggle)
vrweb 1.5-5.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 15,124 kB
  • ctags: 27,485
  • sloc: cpp: 134,333; ansic: 95,670; sh: 1,072; asm: 712; makefile: 610; pascal: 536; perl: 347; csh: 26
file content (133 lines) | stat: -rwxr-xr-x 1,763 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#! /bin/sh
#
#  @(#)install.sh	4.1	ULTRIX	7/17/90
#
# $Id: hginstall,v 1.1 1995/11/27 07:58:10 gpani Exp $
# $Log: hginstall,v $
# Revision 1.1  1995/11/27 07:58:10  gpani
# Initial revision
#
# Revision 1.1  1995/11/15 07:50:01  gpani
# Initial revision
#

cmd=/bin/mv
strip=""
chmod="/bin/chmod 755"
if [ -f "/etc/chown" ]
then
    chownprg="/etc/chown"
else
    chownprg="/bin/chown"
fi

chown="$chownprg -f root"
chgrp="/bin/chgrp -f system"
newer=0
friendly=0

while :
do
	case $1 in
	-s )	strip="/usr/bin/strip"
		;;
	-c )	cmd="/bin/cp"
		;;
	-m )	chmod="/bin/chmod $2"
		shift
		;;
	-o )	chown="$chownprg -f $2"
		shift
		;;
	-g )	chgrp="/bin/chgrp -f $2"
		shift
		;;
	-n )	newer=1
		;;
	-f )	friendly=1
		;;
	* )	break
		;;
	esac
	shift
done

case "$2" in
"")	echo "install: no destination specified"
	exit 1
	;;
.|"$1")	echo "install: can't move $1 onto itself"
	exit 1
	;;
esac
case "$3" in
"")	;;
*)	echo "install: too many files specified -> $*"
	exit 1
	;;
esac
if [ -d $2 ]
then	file=$2/$1
else	file=$2
fi
if [ -r $1 ]
then
	if [ -r $file ]
	then
		if [ $newer = 1 ]
		then
			if `testnewer $1 $file` 
			then
				if [ $friendly = 1 ]
				then
					/bin/mv -f $file $file.old
				else 
					/bin/rm -f $file
				fi
			else
				# echo "install: file $file is up to date."
				exit 0
			fi
		else
			if [ $friendly = 1 ]
			then
				/bin/mv -f $file $file.old
			else
				/bin/rm -f $file
			fi
		fi
	else
		echo ""
	fi
else
	echo "install: file $1 does not exist."
	exit 1
fi


#
# mkdir if directory does not exist.
#

echo "hginstall: installing $file"

tmpvar=`dirname $file`




if [ ! -d "$tmpvar" ]
then
    mkdir -p $tmpvar
fi
	
$cmd $1 $file
[ $strip ] && $strip $file

# 
# gpani 9 Jan 95    
# 
# $chown $file
# $chgrp $file

$chmod $file