4 # stage-install.sh - wrapper around install
7 # stage-install.sh [variable="value"] "args" "dest"
10 # This script is a wrapper around the normal install(1).
11 # Its role is to add '.dirdep' files to the destination.
12 # The variables we might use are:
15 # Path to actual install(1), default is
19 # Path to the dir where '.dirdep' was generated,
23 # Path to actual '.dirdep' file, default is
26 # The "args" and "dest" are passed as is to install(1), and if a
27 # '.dirdep' file exists it will be linked or copied to each
28 # "file".dirdep placed in "dest" or "dest".dirdep if it happed
29 # to be a file rather than a directory.
31 # Before we run install(1), we check if "dest" needs to be a
32 # directory (more than one file in "args") and create it
40 # $Id: stage-install.sh,v 1.9 2020/08/28 01:04:13 sjg Exp $
42 # @(#) Copyright (c) 2013-2020, Simon J. Gerraty
44 # This file is provided in the hope that it will
45 # be of use. There is absolutely NO WARRANTY.
46 # Permission to copy, redistribute or otherwise
47 # use this file is hereby granted provided that
48 # the above copyright notice and this notice are
51 # Please send copies of changes and bug-fixes to:
55 INSTALL=${REAL_INSTALL:-install}
61 *=*) eval "$1"; shift;;
66 # get last entry from "$@" without side effects
76 # mkdir $dest if needed (more than one file)
87 [ $f = $dest ] && continue
89 # dest must be a directory
99 dest=`last_entry "$@"`
102 *) [ -e $dest ] || mkdir_if_needed "$@";;
105 # if .dirdep doesn't exist, just run install and be done
106 _DIRDEP=${_DIRDEP:-$OBJDIR/.dirdep}
107 [ -s $_DIRDEP ] && EXEC= || EXEC=exec
108 $EXEC $INSTALL "$@" || exit 1
112 rm -f $2 2> /dev/null
113 ln $1 $2 2> /dev/null || cp -p $1 $2
118 if [ -s $t.dirdep ]; then
119 cmp -s $_DIRDEP $t.dirdep && return
120 echo "ERROR: $t installed by `cat $t.dirdep` not `cat $_DIRDEP`" >&2
123 LnCp $_DIRDEP $t.dirdep || exit 1
126 if [ -f $dest ]; then
127 # a file, there can be only one .dirdep needed
129 elif [ -d $dest ]; then
132 test -f $f || continue
133 StageDirdep $dest/${f##*/}