annotate previous-work/more_control_helpers/lib/install @ 16:cd47c42f1d0a

reorganizing.
author Robert McIntyre <rlm@mit.edu>
date Wed, 09 Jan 2013 11:38:31 +0000
parents d6bef198ae71
children
rev   line source
rlm@1 1 #!/bin/bash
rlm@1 2 # Copyright (c) 2000,2004 Matthias S. Benkmann <article AT winterdrache DOT de>
rlm@1 3 # You may do everything with this code except misrepresent its origin.
rlm@1 4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
rlm@1 5
rlm@1 6 manpagesowner=man-pages
rlm@1 7 localedir=/usr/share/locale
rlm@1 8 cmdline="$@"
rlm@1 9
rlm@1 10 DAISY_CHAIN=""
rlm@1 11
rlm@1 12 for p in $(type -ap install) ; do
rlm@1 13 if [ ! $p -ef $0 ]; then DAISY_CHAIN=$p ; break ; fi
rlm@1 14 done
rlm@1 15
rlm@1 16 if [ ! -n "$DAISY_CHAIN" ]; then
rlm@1 17 echo Cannot find real ${0##*/} command
rlm@1 18 exit 1
rlm@1 19 fi
rlm@1 20
rlm@1 21 if [ $UID == 0 ]; then
rlm@1 22 exec $DAISY_CHAIN "$@"
rlm@1 23 fi
rlm@1 24
rlm@1 25 #kill unused -c parameter if we get it
rlm@1 26 if [ z"$1" = z"-c" ]; then shift 1 ; fi
rlm@1 27
rlm@1 28 #********** test if we create directories ********************
rlm@1 29 if [ \( z"$1" = z"-d" \) -o \( z"$1" = z"-m" -a z"$3" = z"-d" \) ]; then
rlm@1 30 locdirs=""
rlm@1 31 notify=0
rlm@1 32 havedir=0
rlm@1 33 for((i=$#; $i>0; ))
rlm@1 34 do
rlm@1 35 a="$1"
rlm@1 36 shift 1; i=$(($i-1))
rlm@1 37 case "$a" in
rlm@1 38 -o|-g|--owner|--group) notify=1
rlm@1 39 shift 1; i=$(($i-1))
rlm@1 40 set -- "$@"
rlm@1 41 ;;
rlm@1 42 $localedir/*) if [ ! -d "$a" ]; then
rlm@1 43 locdirs="$locdirs ""`expr $a : "$localedir/\(.*\)"`"
rlm@1 44 set -- "$@" "$a"
rlm@1 45 havedir=1
rlm@1 46 else
rlm@1 47 notify=1
rlm@1 48 set -- "$@"
rlm@1 49 fi
rlm@1 50 ;;
rlm@1 51 */*|/sbin) if [ ! -d "$a" ]; then
rlm@1 52 set -- "$@" "$a"
rlm@1 53 havedir=1
rlm@1 54 else
rlm@1 55 notify=1
rlm@1 56 set -- "$@"
rlm@1 57 fi
rlm@1 58 ;;
rlm@1 59 *) set -- "$@" "$a" ;;
rlm@1 60 esac
rlm@1 61 done
rlm@1 62
rlm@1 63 test $notify -eq 1 -o z"$locdirs" != z && \
rlm@1 64 echo 1>&2 '***' install "$cmdline"
rlm@1 65
rlm@1 66 test $havedir -eq 0 && exit 0
rlm@1 67
rlm@1 68 $DAISY_CHAIN "$@" || exit $?
rlm@1 69
rlm@1 70 test z"$locdirs" != z &&
rlm@1 71 for dir in $locdirs ; do
rlm@1 72 cumuldir=""
rlm@1 73 for d in `echo $locdirs | sed 's#/# #g' -` ; do
rlm@1 74 cumuldir=$cumuldir$d/
rlm@1 75 if [ -d $localedir/$cumuldir ]; then
rlm@1 76 chgrp install $localedir/$cumuldir
rlm@1 77 chmod g+w,o+t $localedir/$cumuldir
rlm@1 78 fi
rlm@1 79 done
rlm@1 80 done
rlm@1 81
rlm@1 82 else #if "$1" != "-d" ,i.e. we do not create directories *****************
rlm@1 83 notify=0
rlm@1 84 for((i=$# ; $i>0; ))
rlm@1 85 do
rlm@1 86 a="$1"
rlm@1 87 shift 1; i=$(($i-1))
rlm@1 88 case "$a" in
rlm@1 89 -m) set -- "$@" "$a"
rlm@1 90 a="$1"
rlm@1 91 shift 1; i=$(($i-1))
rlm@1 92 case "$a" in
rlm@1 93 4755) notify=1 ; set -- "$@" "755" ;;
rlm@1 94 4775) notify=1 ; set -- "$@" "755" ;;
rlm@1 95 4711) notify=1 ; set -- "$@" "711" ;;
rlm@1 96 *) set -- "$@" "$a" ;;
rlm@1 97 esac
rlm@1 98 ;;
rlm@1 99 -m4755) notify=1 ; set -- "$@" "-m755" ;;
rlm@1 100 -m4775) notify=1 ; set -- "$@" "-m755" ;;
rlm@1 101 -m4711) notify=1 ; set -- "$@" "-m711" ;;
rlm@1 102 -o|-g|--owner|--group) notify=1
rlm@1 103 shift 1; i=$(($i-1))
rlm@1 104 set -- "$@"
rlm@1 105 ;;
rlm@1 106 */man/man?/*)
rlm@1 107 if [ -e "$a" -a ! -O "$a" ]; then
rlm@1 108 if [ `find "$a" -printf \%u` = $manpagesowner ]; then
rlm@1 109 notify=1
rlm@1 110 set -- "$@" not_installed
rlm@1 111 else
rlm@1 112 set -- "$@" "$a"
rlm@1 113 fi
rlm@1 114 else
rlm@1 115 set -- "$@" "$a"
rlm@1 116 fi
rlm@1 117 ;;
rlm@1 118 *) set -- "$@" "$a" ;;
rlm@1 119 esac
rlm@1 120 done
rlm@1 121
rlm@1 122 test $notify -eq 1 && echo 1>&2 '***' install "$cmdline"
rlm@1 123
rlm@1 124 $DAISY_CHAIN "$@" || exit $?
rlm@1 125 fi
rlm@1 126
rlm@1 127 exit 0