1250835Ssjg#!/bin/sh 2250835Ssjg 3250835Ssjg# NAME: 4250835Ssjg# stage-install.sh - wrapper around install 5250835Ssjg# 6250835Ssjg# SYNOPSIS: 7250835Ssjg# stage-install.sh [variable="value"] "args" "dest" 8250835Ssjg# 9250835Ssjg# DESCRIPTION: 10250835Ssjg# This script is a wrapper around the normal install(1). 11250835Ssjg# Its role is to add '.dirdep' files to the destination. 12250835Ssjg# The variables we might use are: 13250835Ssjg# 14250835Ssjg# INSTALL 15250835Ssjg# Path to actual install(1), default is 16250835Ssjg# $REAL_INSTALL 17250835Ssjg# 18250835Ssjg# OBJDIR 19250835Ssjg# Path to the dir where '.dirdep' was generated, 20250835Ssjg# default is '.' 21250835Ssjg# 22250835Ssjg# _DIRDEP 23250835Ssjg# Path to actual '.dirdep' file, default is 24250835Ssjg# $OBJDIR/.dirdep 25250835Ssjg# 26250835Ssjg# The "args" and "dest" are passed as is to install(1), and if a 27250835Ssjg# '.dirdep' file exists it will be linked or copied to each 28250835Ssjg# "file".dirdep placed in "dest" or "dest".dirdep if it happed 29250835Ssjg# to be a file rather than a directory. 30250835Ssjg# 31250835Ssjg# SEE ALSO: 32250835Ssjg# meta.stage.mk 33250835Ssjg# 34250835Ssjg 35250835Ssjg# RCSid: 36250835Ssjg# $Id: stage-install.sh,v 1.5 2013/04/19 16:32:24 sjg Exp $ 37250835Ssjg# 38250835Ssjg# @(#) Copyright (c) 2013, Simon J. Gerraty 39250835Ssjg# 40250835Ssjg# This file is provided in the hope that it will 41250835Ssjg# be of use. There is absolutely NO WARRANTY. 42250835Ssjg# Permission to copy, redistribute or otherwise 43250835Ssjg# use this file is hereby granted provided that 44250835Ssjg# the above copyright notice and this notice are 45250835Ssjg# left intact. 46250835Ssjg# 47250835Ssjg# Please send copies of changes and bug-fixes to: 48250835Ssjg# sjg@crufty.net 49250835Ssjg# 50250835Ssjg 51250835SsjgINSTALL=${REAL_INSTALL:-install} 52250835SsjgOBJDIR=. 53250835Ssjg 54250835Ssjgwhile : 55250835Ssjgdo 56250835Ssjg case "$1" in 57250835Ssjg *=*) eval "$1"; shift;; 58250835Ssjg *) break;; 59250835Ssjg esac 60250835Ssjgdone 61250835Ssjg 62250835Ssjg# if .dirdep doesn't exist, just run install and be done 63250835Ssjg_DIRDEP=${_DIRDEP:-$OBJDIR/.dirdep} 64250835Ssjg[ -s $_DIRDEP ] && EXEC= || EXEC=exec 65250835Ssjg$EXEC $INSTALL "$@" || exit 1 66250835Ssjg 67250835Ssjg# from meta.stage.mk 68250835SsjgLnCp() { 69250835Ssjg rm -f $2 2> /dev/null 70250835Ssjg ln $1 $2 2> /dev/null || cp -p $1 $2 71250835Ssjg} 72250835Ssjg 73250835SsjgStageDirdep() { 74250835Ssjg t=$1 75250835Ssjg if [ -s $t.dirdep ]; then 76250835Ssjg cmp -s $_DIRDEP $t.dirdep && return 77250835Ssjg echo "ERROR: $t installed by `cat $t.dirdep` not `cat $_DIRDEP`" >&2 78250835Ssjg exit 1 79250835Ssjg fi 80250835Ssjg LnCp $_DIRDEP $t.dirdep || exit 1 81250835Ssjg} 82250835Ssjg 83250835Ssjgargs="$@" 84250835Ssjgwhile [ $# -gt 8 ] 85250835Ssjgdo 86250835Ssjg shift 8 87250835Ssjgdone 88250835Ssjgeval dest=\$$# 89250835Ssjgif [ -f $dest ]; then 90250835Ssjg # a file, there can be only one .dirdep needed 91250835Ssjg StageDirdep $dest 92250835Ssjgelif [ -d $dest ]; then 93250835Ssjg for f in $args 94250835Ssjg do 95250835Ssjg test -f $f || continue 96250835Ssjg StageDirdep $dest/${f##*/} 97250835Ssjg done 98250835Ssjgfi 99