Mercurial > pkg
diff previous-work/more_control_helpers/lib/install @ 1:d6bef198ae71
add work by Matthias S. Benkmann which is the inspiration for this project.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 08 Jan 2013 11:45:01 +0000 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/previous-work/more_control_helpers/lib/install Tue Jan 08 11:45:01 2013 +0000 1.3 @@ -0,0 +1,127 @@ 1.4 +#!/bin/bash 1.5 +# Copyright (c) 2000,2004 Matthias S. Benkmann <article AT winterdrache DOT de> 1.6 +# You may do everything with this code except misrepresent its origin. 1.7 +# PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND! 1.8 + 1.9 +manpagesowner=man-pages 1.10 +localedir=/usr/share/locale 1.11 +cmdline="$@" 1.12 + 1.13 +DAISY_CHAIN="" 1.14 + 1.15 +for p in $(type -ap install) ; do 1.16 + if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p ; break ; fi 1.17 +done 1.18 + 1.19 +if [ ! -n "$DAISY_CHAIN" ]; then 1.20 + echo Cannot find real ${0##*/} command 1.21 + exit 1 1.22 +fi 1.23 + 1.24 +if [ $UID == 0 ]; then 1.25 + exec $DAISY_CHAIN "$@" 1.26 +fi 1.27 + 1.28 +#kill unused -c parameter if we get it 1.29 +if [ z"$1" = z"-c" ]; then shift 1 ; fi 1.30 + 1.31 + #********** test if we create directories ******************** 1.32 +if [ \( z"$1" = z"-d" \) -o \( z"$1" = z"-m" -a z"$3" = z"-d" \) ]; then 1.33 + locdirs="" 1.34 + notify=0 1.35 + havedir=0 1.36 + for((i=$#; $i>0; )) 1.37 + do 1.38 + a="$1" 1.39 + shift 1; i=$(($i-1)) 1.40 + case "$a" in 1.41 + -o|-g|--owner|--group) notify=1 1.42 + shift 1; i=$(($i-1)) 1.43 + set -- "$@" 1.44 + ;; 1.45 + $localedir/*) if [ ! -d "$a" ]; then 1.46 + locdirs="$locdirs ""`expr $a : "$localedir/\(.*\)"`" 1.47 + set -- "$@" "$a" 1.48 + havedir=1 1.49 + else 1.50 + notify=1 1.51 + set -- "$@" 1.52 + fi 1.53 + ;; 1.54 + */*|/sbin) if [ ! -d "$a" ]; then 1.55 + set -- "$@" "$a" 1.56 + havedir=1 1.57 + else 1.58 + notify=1 1.59 + set -- "$@" 1.60 + fi 1.61 + ;; 1.62 + *) set -- "$@" "$a" ;; 1.63 + esac 1.64 + done 1.65 + 1.66 + test $notify -eq 1 -o z"$locdirs" != z && \ 1.67 + echo 1>&2 '***' install "$cmdline" 1.68 + 1.69 + test $havedir -eq 0 && exit 0 1.70 + 1.71 + $DAISY_CHAIN "$@" || exit $? 1.72 + 1.73 + test z"$locdirs" != z && 1.74 + for dir in $locdirs ; do 1.75 + cumuldir="" 1.76 + for d in `echo $locdirs | sed 's#/# #g' -` ; do 1.77 + cumuldir=$cumuldir$d/ 1.78 + if [ -d $localedir/$cumuldir ]; then 1.79 + chgrp install $localedir/$cumuldir 1.80 + chmod g+w,o+t $localedir/$cumuldir 1.81 + fi 1.82 + done 1.83 + done 1.84 + 1.85 +else #if "$1" != "-d" ,i.e. we do not create directories ***************** 1.86 + notify=0 1.87 + for((i=$# ; $i>0; )) 1.88 + do 1.89 + a="$1" 1.90 + shift 1; i=$(($i-1)) 1.91 + case "$a" in 1.92 + -m) set -- "$@" "$a" 1.93 + a="$1" 1.94 + shift 1; i=$(($i-1)) 1.95 + case "$a" in 1.96 + 4755) notify=1 ; set -- "$@" "755" ;; 1.97 + 4775) notify=1 ; set -- "$@" "755" ;; 1.98 + 4711) notify=1 ; set -- "$@" "711" ;; 1.99 + *) set -- "$@" "$a" ;; 1.100 + esac 1.101 + ;; 1.102 + -m4755) notify=1 ; set -- "$@" "-m755" ;; 1.103 + -m4775) notify=1 ; set -- "$@" "-m755" ;; 1.104 + -m4711) notify=1 ; set -- "$@" "-m711" ;; 1.105 + -o|-g|--owner|--group) notify=1 1.106 + shift 1; i=$(($i-1)) 1.107 + set -- "$@" 1.108 + ;; 1.109 + */man/man?/*) 1.110 + if [ -e "$a" -a ! -O "$a" ]; then 1.111 + if [ `find "$a" -printf \%u` = $manpagesowner ]; then 1.112 + notify=1 1.113 + set -- "$@" not_installed 1.114 + else 1.115 + set -- "$@" "$a" 1.116 + fi 1.117 + else 1.118 + set -- "$@" "$a" 1.119 + fi 1.120 + ;; 1.121 + *) set -- "$@" "$a" ;; 1.122 + esac 1.123 + done 1.124 + 1.125 + test $notify -eq 1 && echo 1>&2 '***' install "$cmdline" 1.126 + 1.127 + $DAISY_CHAIN "$@" || exit $? 1.128 +fi 1.129 + 1.130 +exit 0