xref: /freebsd/tools/install.sh (revision d0b2dbfa)
1d33ed111SMarcel Moolenaar#! /bin/sh
2d33ed111SMarcel Moolenaar#
3d33ed111SMarcel Moolenaar# Copyright (c) 1999 Marcel Moolenaar
4d33ed111SMarcel Moolenaar# All rights reserved.
5d33ed111SMarcel Moolenaar#
6d33ed111SMarcel Moolenaar# Redistribution and use in source and binary forms, with or without
7d33ed111SMarcel Moolenaar# modification, are permitted provided that the following conditions
8d33ed111SMarcel Moolenaar# are met:
9d33ed111SMarcel Moolenaar# 1. Redistributions of source code must retain the above copyright
10d33ed111SMarcel Moolenaar#    notice, this list of conditions and the following disclaimer
11d33ed111SMarcel Moolenaar#    in this position and unchanged.
12d33ed111SMarcel Moolenaar# 2. Redistributions in binary form must reproduce the above copyright
13d33ed111SMarcel Moolenaar#    notice, this list of conditions and the following disclaimer in the
14d33ed111SMarcel Moolenaar#    documentation and/or other materials provided with the distribution.
15d33ed111SMarcel Moolenaar# 3. The name of the author may not be used to endorse or promote products
1621dc7d4fSJens Schweikhardt#    derived from this software without specific prior written permission
17d33ed111SMarcel Moolenaar#
18d33ed111SMarcel Moolenaar# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19d33ed111SMarcel Moolenaar# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20d33ed111SMarcel Moolenaar# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21d33ed111SMarcel Moolenaar# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22d33ed111SMarcel Moolenaar# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23d33ed111SMarcel Moolenaar# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24d33ed111SMarcel Moolenaar# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25d33ed111SMarcel Moolenaar# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26d33ed111SMarcel Moolenaar# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27d33ed111SMarcel Moolenaar# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28d33ed111SMarcel Moolenaar#
29d33ed111SMarcel Moolenaar
30d33ed111SMarcel Moolenaar# parse install's options and ignore them completely.
313dfe8ce9SUlrich Spörleindirmode=""
32aaea7970SBrooks Davislinkmode=""
33285c7935SRuslan Ermilovwhile [ $# -gt 0 ]; do
34d33ed111SMarcel Moolenaar    case $1 in
353dfe8ce9SUlrich Spörlein    -d) dirmode="YES"; shift;;
36a812deb1SBrad Davis    -[bCcpSsUv]) shift;;
37a812deb1SBrad Davis    -[BDfghMmNoT]) shift; shift;;
38a812deb1SBrad Davis    -[BDfghMmNoT]*) shift;;
39aaea7970SBrooks Davis    -l)
40aaea7970SBrooks Davis	shift
41aaea7970SBrooks Davis	case $1 in
42aaea7970SBrooks Davis	*[sm]*) linkmode="symbolic";;	# XXX: 'm' should prefer hard
43aaea7970SBrooks Davis	*h*) linkmode="hard";;
44aaea7970SBrooks Davis	*) echo "invalid link mode"; exit 1;;
45aaea7970SBrooks Davis	esac
46aaea7970SBrooks Davis	shift
47aaea7970SBrooks Davis	;;
48d33ed111SMarcel Moolenaar    *) break;
49d33ed111SMarcel Moolenaar    esac
50d33ed111SMarcel Moolenaardone
51d33ed111SMarcel Moolenaar
523dfe8ce9SUlrich Spörleinif [ "$#" -eq 0 ]; then
533dfe8ce9SUlrich Spörlein	echo "$0: no files/dirs specified" >&2
543dfe8ce9SUlrich Spörlein	exit 1
553dfe8ce9SUlrich Spörleinfi
563dfe8ce9SUlrich Spörlein
573dfe8ce9SUlrich Spörleinif [ -z "$dirmode" ] && [ "$#" -lt 2 ]; then
583dfe8ce9SUlrich Spörlein	echo "$0: no target specified" >&2
593dfe8ce9SUlrich Spörlein	exit 1
603dfe8ce9SUlrich Spörleinfi
613dfe8ce9SUlrich Spörlein
62168f8d16SMarcel Moolenaar# the remaining arguments are assumed to be files/dirs only.
63aaea7970SBrooks Davisif [ -n "${linkmode}" ]; then
646d12634cSBrooks Davis	if [ "${linkmode}" = "symbolic" ]; then
657359fe7aSBryan Drewery		ln -fsn "$@"
66aaea7970SBrooks Davis	else
67aaea7970SBrooks Davis		ln -f "$@"
68aaea7970SBrooks Davis	fi
69aaea7970SBrooks Daviselif [ -z "$dirmode" ]; then
703dfe8ce9SUlrich Spörlein	exec install -p "$@"
713dfe8ce9SUlrich Spörleinelse
723dfe8ce9SUlrich Spörlein	exec install -d "$@"
733dfe8ce9SUlrich Spörleinfi
74