Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tools/install.sh
34672 views
1
#! /bin/sh
2
#
3
# Copyright (c) 1999 Marcel Moolenaar
4
# All rights reserved.
5
#
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
8
# are met:
9
# 1. Redistributions of source code must retain the above copyright
10
# notice, this list of conditions and the following disclaimer
11
# in this position and unchanged.
12
# 2. Redistributions in binary form must reproduce the above copyright
13
# notice, this list of conditions and the following disclaimer in the
14
# documentation and/or other materials provided with the distribution.
15
# 3. The name of the author may not be used to endorse or promote products
16
# derived from this software without specific prior written permission
17
#
18
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#
29
30
# parse install's options and ignore them completely.
31
dirmode=""
32
linkmode=""
33
while [ $# -gt 0 ]; do
34
case $1 in
35
-d) dirmode="YES"; shift;;
36
-[bCcpSsUv]) shift;;
37
-[BDfghMmNoT]) shift; shift;;
38
-[BDfghMmNoT]*) shift;;
39
-l)
40
shift
41
case $1 in
42
*[sm]*) linkmode="symbolic";; # XXX: 'm' should prefer hard
43
*h*) linkmode="hard";;
44
*) echo "invalid link mode"; exit 1;;
45
esac
46
shift
47
;;
48
*) break;
49
esac
50
done
51
52
if [ "$#" -eq 0 ]; then
53
echo "$0: no files/dirs specified" >&2
54
exit 1
55
fi
56
57
if [ -z "$dirmode" ] && [ "$#" -lt 2 ]; then
58
echo "$0: no target specified" >&2
59
exit 1
60
fi
61
62
# the remaining arguments are assumed to be files/dirs only.
63
if [ -n "${linkmode}" ]; then
64
if [ "${linkmode}" = "symbolic" ]; then
65
ln -fsn "$@"
66
else
67
ln -f "$@"
68
fi
69
elif [ -z "$dirmode" ]; then
70
exec install -p "$@"
71
else
72
exec install -d "$@"
73
fi
74
75