freebsd-src/install-sh
Simon J. Gerraty a6b892e1c7 Import bmake-20240309
Intersting/relevant changes since bmake-20240108

ChangeLog since bmake-20240108

2024-03-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* boot-strap: tests can take a long time; use a cookie to
	skip them if bmake has not been updated since tests last
	ran successfully.

	* Makefile: Cygwin handles MANTARGET man

	* unit-tests/Makefile: set BROKEN_TESTS for Cygwin

2024-03-09  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240309
	Merge with NetBSD make, pick up
	o set .ERROR_EXIT to the exit status of .ERROR_TARGET
	this allows a .ERROR target to ignore the case of
	.ERROR_EXIT==6 which just means that the build actually
	failed somewhere else.

2024-03-04  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240303

	* var.c: on IRIX we need both inttypes.h and stdint.h

2024-03-01  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240301
	Merge with NetBSD make, pick up
	o export variables with value from target scope
	when appropriate.

2024-02-12  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240212
	Merge with NetBSD make, pick up
	o remove unneeded conditional-compilation toggles
	INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
	GMAKEEXPORT NO_REGEX and SUNSHCMD

	* configure.in: add check for regex.h

	* var.c: replace use of NO_REGEX with HAVE_REGEX_H

2024-02-04  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240204
	Merge with NetBSD make, pick up
	o var.c: fix some lint (-dL) mode parsing issues

2024-02-02  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION: (_MAKE_VERSION): 20240202
	Merge with NetBSD make, pick up
	o make.1: note that arg to :D and :U can be empty
	o var.c: $$ is not a parse error when .MAKE.SAVE_DOLLARS=no

mk/ChangeLog since bmake-20240108

2024-03-09  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240309

	* meta.sys.mk: _metaError: if .ERROR_EXIT == 6, we do not
	want to save the .ERROR_META_FILE

2024-02-20  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240220

	* sys.dirdeps.mk, dirdeps-targets.mk, init.mk:
	do not set .MAIN: dirdeps in sys.dirdeps.mk
	dirdeps-targets.mk will do that for top-level builds
	and init.mk will do it for others.
	This allows a Makefile which has no need of 'dirdeps' to
	set .MAIN for itself and "just work".

2024-02-18  Simon J Gerraty  <sjg@beast.crufty.net>

	* bsd.*.mk: for makefiles that get a bsd. symlink,
	use _this in  multiple inclusion tags since .PARSEFILE will not
	DTRT when such a makefile is included directly by Makefile and
	automatically (without bsd. prefix).
	Since we cannot guarantee that our sys.mk will be used, we provide
	a default _this in each makefile that gets a bsd. prefix such that
	the value is the same regardless of bsd. prefix.

	* subdir.mk: drop the !target guard on $SUBDIR_TARGETS

2024-02-12  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240212

	* SPDX-License-Identifier: BSD-2-Clause
	Add SPDX-License-Identifier to inidicate that I consider
	my copyright on any of these makefiles equivalent to BSD-2-Clause

	* autoconf.mk: allow for configure.ac as currently recommended

	* subdir.mk: support @auto
	which is replaced with each subdir that
	has a [Mm]akefile.

	* subdir.mk: include local.subdir.mk if it exists.

	* subdir.mk: rework to handle .WAIT

2024-02-11  Simon J Gerraty  <sjg@beast.crufty.net>

	* subdir.mk: _SUBDIRUSE report the target we are entering subdirs for.

2024-02-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* prog.mk: treat empty SRCS the same as undefined

2024-02-02  Simon J Gerraty  <sjg@beast.crufty.net>

	* Avoid undefined errors in lint (-dL) mode

	* man.mk (CMT2DOC_FLAGS): note that -mm does mdoc(7)

2024-01-28  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240128

	* FILES: add ccm.dep.mk for C++ modules
	add suffixes.mk for common location for generic SUFFIX rules.

	* auto.dep.mk autodep.mk meta.autodep.mk: include ccm.dep.mk
	replace OBJ_EXTENSIONS with OBJ_SUFFIXES

	* autodep.mk: leverage CXX_SUFFIXES for __depsrcs
	and update style (spaces around = etc)

	* init.mk: add OBJS_SRCS_FILTER to filter SRCS when
	setting OBJS

	* meta2deps.py: handle multiple ./ embedded in path better.
2024-03-13 19:14:41 -07:00

229 lines
4.2 KiB
Bash
Executable File

#!/bin/sh
# NAME:
# install.sh - portable version of install(1)
#
# SYNOPSIS:
# install [-CNcs] [-f flags] [-i errs] [-o owner] [-g group] [-m mode] file1 file2 ...
# install -d [-i errs] [-o owner] [-g group] [-m mode] directory ...
#
# DESCRIPTION:
# Compatible with BSD install(1). Except that '-c' is always
# true and we always move an already installed target aside as
# this is important on many systems. Recent BSD install(1)
# versions have a '-b' option for this.
#
#
# OPTIONS:
# -b move previous target file aside (always true).
#
# -B "suffix"
# use "suffix" instead of .old for saving existing target.
#
# -c copy rather than move the file into place (always true).
#
# -C compare. Only install if target is missing or
# different.
#
# -N newer. Only install if target is missing or older.
#
# -s strip target
#
# -o "owner"
# make target owned by "owner"
#
# -g "group"
# make target group owned by "group"
#
# -m "mode"
# set permissions to "mode"
#
# -f "flags"
# Pass "flags" onto chflags(1)
#
# -i "errs"
# Ignore errors from steps indicated by "errs" (``s,o,g,m'').
#
# BUGS:
# The '-i' option is to save your sanity when 'bsd.prog.mk'
# insists on haveing a '-o' "owner" option which is doomed to
# fail on many systems. We ignore '-b' and '-c' options.
#
# AUTHOR:
# Simon J. Gerraty <sjg@crufty.net>
#
# SPDX-License-Identifier: BSD-2-Clause
#
# RCSid:
# $Id: install-sh,v 1.26 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 1993-2023 Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
set -- `getopt B:bpxCNcsdo:g:m:i:f: $*`
Mydir=`dirname $0`
[ -s $Mydir/.installrc ] && . $Mydir/.installrc
OLD_EXT=.old
owner=:
group=:
mode=:
MODE=0
strip=:
mkdirs=
compare=:
newer=:
chflags=:
LS_1=
CP_p=
while :
do
case "$1" in
--) shift; break;;
-[bc]) ;; # ignore
-p) CP_p=-p;;
-x) set -x;;
-B) OLD_EXT=$2; shift;;
-C) compare=Different;;
-N) newer=Newer;
# check if /bin/ls supports -1
'ls' -1 $0 > /dev/null 2>&1 && LS_1=1
;;
-o) owner="${CHOWN:-chown} $2 "; shift;;
-g) group="${CHGRP:-chgrp} $2 "; shift;;
-m) MODE=$2 mode="${CHMOD:-chmod} $2 "; shift;;
-s) strip=${STRIP:-strip};;
-d) mkdirs="mkdir -p";;
-i) ignore_err="$ignore_err$2"; shift;;
-f) chflags="${CHFLAGS:-chflags} $2 "; shift;;
*) break;;
esac
shift
done
Newer() {
n=`'ls' -t$LS_1 $* 2> /dev/null | head -1`
[ $1 = $n ]
}
Different() {
cmp -s $*
[ $? != 0 ]
}
Err() {
case "$ignore_err" in
*$1*) ;;
*) exit 1;;
esac
}
Setem() {
# the order is important
if [ ! -d $1 ]; then
$strip $1 || Err s
fi
$group $1 || Err g
$owner $1 || Err o
$mode $1 || Err m
$chflags $1 || Err f
return 0
}
# a bug in HP-UX's /bin/sh, means we need to re-set $*
# after any calls to add_path()
args="$*"
add_path () {
test -d $1 || return
case ":$PATH:" in
*:$1:*) return;;
esac
PATH=$PATH:$1
}
add_path /sbin
add_path /usr/sbin
case "$owner" in
:) ;;
*) # some systems put chown in odd places
add_path /etc
add_path /usr/etc
;;
esac
# restore saved $*
set -- $args
# make directories if needed
# and ensure mode etc are as desired
if [ "$mkdirs" ]; then
case "$MODE" in
[1-7]*)
# make sure umask is compatible
case "$MODE" in
????*) MODE=`echo $MODE | sed 's,.*\(...\)$,\1,'`;;
esac
umask `expr 0777 - 0$MODE |
sed 's,^,000,;s,^.*\(...\)$,\1,'`;;
esac
for d in $*
do
[ ! -d $d ] && $mkdirs $d
Setem $d
done
exit 0 # that's all we do
fi
# install files
if [ $# -eq 1 ]; then
echo "what should I do with $*?" >&2
exit 1
fi
# get list of files
files=
while [ $# -gt 1 ]
do
test "x$files" = x || dest_dir=yes
files="$files $1"
shift
done
# last one is dest
dest=$1
shift
if [ "$dest_dir" = yes -a ! -d $dest ]; then
echo "no directory $dest" >&2
exit 1
fi
for f in $files
do
b=`basename $f`
if [ -d $dest ]; then
t=$dest/$b
else
t=$dest
fi
$newer $f $t || continue
$compare $f $t || continue
[ -f $t ] && { mv -f $t $t$OLD_EXT || exit 1; }
{ cp $CP_p $f $t && Setem $t; } || exit 1
done
exit 0