-
Notifications
You must be signed in to change notification settings - Fork 82
/
installch.in
66 lines (59 loc) · 1.63 KB
/
installch.in
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
#! /bin/sh
#
# installch - install a program, script, or datafile if changed
#
# Copyright (c) 2006 Mazu Networks, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, subject to the conditions
# listed in the Click LICENSE file. These conditions include: you must
# preserve this copyright notice, and you cannot mention the copyright
# holders in advertising related to the Software without their permission.
# The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
# notice is a summary of the Click LICENSE file; the license in that file is
# legally binding.
install=${INSTALL-@INSTALL@}
src=
dst=
multi=
mode=0755
user=`id -u`
group=`id -g`
while [ x"$1" != x ]; do
case $1 in
-m)
mode="$2"; install="$install -m $2"; shift; shift; continue;;
-*)
echo "installch: unknown option $1" 1>&2; exit 1;;
*)
if [ x"$src" = x ]; then
src="$1"
elif [ x"$dst" = x ]; then
dst="$1"
else
multi=1; src="$src $dst"; dst="$1"
fi
shift; continue;;
esac
done
if [ x"$dst" = x ]; then
echo "installch: too few arguments" 1>&2; exit 1
fi
if [ x"$multi" = 1 -a ! -d "$dst" ]; then
echo "installch: last argument must be directory" 1>&2; exit 1
fi
doinstall () {
while [ x"$1" != x ]; do
if [ -d "$dst" ]; then d="$dst/"`basename "$1"`; else d="$dst"; fi
if [ -r "$d" ] && cmp "$1" "$d" >/dev/null; then
chmod $mode "$d" || exit 1
chgrp $group "$d" || exit 1
else
$install "$1" "$d" || exit 1
fi
shift
done
}
doinstall $src
exit 0