Home | History | Annotate | Line # | Download | only in scripts
genLocInfo revision 1.1
      1  1.1  christos #! /bin/sh
      2  1.1  christos 
      3  1.1  christos args=`getopt d:f:v $*`
      4  1.1  christos set -- $args
      5  1.1  christos 
      6  1.1  christos LF=
      7  1.1  christos V=": "
      8  1.1  christos 
      9  1.1  christos for i
     10  1.1  christos do
     11  1.1  christos     case "$i" in
     12  1.1  christos      -d) sdir="$2" ; shift 2 ;;
     13  1.1  christos      -f) locfile="$2" ; shift 2 ;;
     14  1.1  christos      -v) V= ; shift ;;
     15  1.1  christos      --) shift ; break ;;
     16  1.1  christos     esac
     17  1.1  christos done
     18  1.1  christos 
     19  1.1  christos case "$sdir" in
     20  1.1  christos  '')
     21  1.1  christos     sdir=.
     22  1.1  christos esac
     23  1.1  christos 
     24  1.1  christos case "$locfile" in
     25  1.1  christos  */*)
     26  1.1  christos     LF=$locfile
     27  1.1  christos     ;;
     28  1.1  christos  '')
     29  1.1  christos     ;;
     30  1.1  christos  *)
     31  1.1  christos     lf=loc/$locfile
     32  1.1  christos     if test -f $lf
     33  1.1  christos     then
     34  1.1  christos 	LF=$lf
     35  1.1  christos     fi
     36  1.1  christos     ;;
     37  1.1  christos esac
     38  1.1  christos 
     39  1.1  christos # If we have a file to use (ie, LF is not empty) then look for one.
     40  1.1  christos case "$LF" in
     41  1.1  christos  '')
     42  1.1  christos     PATH=$PATH:libevent/build-aux
     43  1.1  christos     export PATH
     44  1.1  christos     set `scripts/cvo.sh @osname@ @osver@` || exit 1
     45  1.1  christos 
     46  1.1  christos     CVO_OSNAME=$1
     47  1.1  christos     CVO_OSVER=$2
     48  1.1  christos 
     49  1.1  christos     x=$CVO_OSVER
     50  1.1  christos 
     51  1.1  christos     while true
     52  1.1  christos     do
     53  1.1  christos 	case "$x" in
     54  1.1  christos 	 '') break ;;
     55  1.1  christos 	esac
     56  1.1  christos lf=loc/$CVO_OSNAME$x
     57  1.1  christos ${V}echo "Looking for <$lf>" >&2
     58  1.1  christos 	if test -f $lf
     59  1.1  christos 	then
     60  1.1  christos 	    LF=$lf
     61  1.1  christos 	    break
     62  1.1  christos 	fi
     63  1.1  christos 	case "$x" in
     64  1.1  christos 	 *.*) x=`echo $x | sed -e 's/\.[^.]*$//'` ;;
     65  1.1  christos 	 *) x= ;;
     66  1.1  christos 	esac
     67  1.1  christos     done
     68  1.1  christos     case "$LF" in
     69  1.1  christos      '')
     70  1.1  christos 	lf=loc/$CVO_OSNAME
     71  1.1  christos ${V}echo "Looking for <$lf>" >&2
     72  1.1  christos 	if test -f $lf
     73  1.1  christos 	then
     74  1.1  christos 	    LF=$lf
     75  1.1  christos 	fi
     76  1.1  christos 	;;
     77  1.1  christos     esac
     78  1.1  christos     # Handle some "aliases"
     79  1.1  christos     case "$LF" in
     80  1.1  christos      '')
     81  1.1  christos 	case "$CVO_OSNAME" in
     82  1.1  christos 	 redhat* | fedora*)
     83  1.1  christos 	    lf=loc/redhat
     84  1.1  christos ${V}echo "Looking for <$lf>" >&2
     85  1.1  christos 	    if test -f $lf
     86  1.1  christos 	    then
     87  1.1  christos 		LF=$lf
     88  1.1  christos 	    fi
     89  1.1  christos 	    ;;
     90  1.1  christos 	esac
     91  1.1  christos 	;;
     92  1.1  christos     esac
     93  1.1  christos 
     94  1.1  christos     # This might be a good place to see if uname returns "Linux",
     95  1.1  christos     # and if so, use a generic file for that.
     96  1.1  christos     case "$LF" in
     97  1.1  christos      '')
     98  1.1  christos 	case "`uname`" in
     99  1.1  christos 	 Linux)
    100  1.1  christos 	    lf=loc/linux
    101  1.1  christos ${V}echo "Looking for <$lf>" >&2
    102  1.1  christos 	    if test -f $lf
    103  1.1  christos 	    then
    104  1.1  christos 		LF=$lf
    105  1.1  christos 	    fi
    106  1.1  christos 	    ;;
    107  1.1  christos 	esac
    108  1.1  christos 	;;
    109  1.1  christos     esac
    110  1.1  christos 
    111  1.1  christos     # Finally, 'legacy'
    112  1.1  christos     case "$LF" in
    113  1.1  christos      '')
    114  1.1  christos 	lf=loc/legacy
    115  1.1  christos ${V}echo "Looking for <$lf>" >&2
    116  1.1  christos 	if test -f $lf
    117  1.1  christos 	then
    118  1.1  christos 	    LF=$lf
    119  1.1  christos 	fi
    120  1.1  christos 	;;
    121  1.1  christos     esac
    122  1.1  christos 
    123  1.1  christos     case "$LF" in
    124  1.1  christos      '')
    125  1.1  christos 	echo "No loc/XXX file found!" >&2
    126  1.1  christos 	exit 1
    127  1.1  christos 	;;
    128  1.1  christos     esac
    129  1.1  christos     ;;
    130  1.1  christos esac
    131  1.1  christos 
    132  1.1  christos ${V}echo "Using <$LF>" >&2
    133  1.1  christos echo "GENLOCINFOFILE=$LF"
    134  1.1  christos 
    135  1.1  christos ###
    136  1.1  christos 
    137  1.1  christos rm -f $sdir/genLocInfo.rc?
    138  1.1  christos 
    139  1.1  christos oIFS=$IFS
    140  1.1  christos IFS=","
    141  1.1  christos 
    142  1.1  christos while true
    143  1.1  christos do
    144  1.1  christos     if read c d s x
    145  1.1  christos     then
    146  1.1  christos 	# echo "Got <$c><$d><$s><$x>" >&2
    147  1.1  christos 	case "$c" in
    148  1.1  christos 	 \#*) continue ;;
    149  1.1  christos 	esac
    150  1.1  christos 	case "$x" in
    151  1.1  christos 	 '') ;;
    152  1.1  christos 	 *) echo "Unrecognized input: <$c,$d,$s,$x>" >&2
    153  1.1  christos 	    touch $sdir/genLocInfo.rc1
    154  1.1  christos 	    continue
    155  1.1  christos 	    ;;
    156  1.1  christos 	esac
    157  1.1  christos 	case "$c,$d,$s" in
    158  1.1  christos 	 [Mm][Aa][Nn],,)
    159  1.1  christos 	    echo "MANTAGFMT=man"
    160  1.1  christos 	    continue
    161  1.1  christos 	    ;;
    162  1.1  christos 	 [Mm][Dd][Oo][Cc],,)
    163  1.1  christos 	    echo "MANTAGFMT=mdoc"
    164  1.1  christos 	    continue
    165  1.1  christos 	    ;;
    166  1.1  christos 	esac
    167  1.1  christos 
    168  1.1  christos 	case "$c,$d,$s" in
    169  1.1  christos 	 *,bin,*)  DB=bin ; DL= ; DS= ;;
    170  1.1  christos 	 *,libexec,*)  DB= ; DL=libexec ; DS= ;;
    171  1.1  christos 	 *,sbin,*) DB= ; DL= ; DS=sbin ;;
    172  1.1  christos 	 *) echo "Unrecognized input: <$c,$d,$s>" >&2
    173  1.1  christos 	    touch $sdir/genLocInfo.rc1
    174  1.1  christos 	    continue
    175  1.1  christos 	    ;;
    176  1.1  christos 	esac
    177  1.1  christos 	case "$c,$d,$s" in
    178  1.1  christos 	 *,*,1) ;;
    179  1.1  christos 	 *,*,1m) ;;
    180  1.1  christos 	 *,*,1M) ;;
    181  1.1  christos 	 *,*,8) ;;
    182  1.1  christos 	 *) echo "Unrecognized input: <$c,$d,$s>" >&2
    183  1.1  christos 	    touch $sdir/genLocInfo.rc1
    184  1.1  christos 	    continue
    185  1.1  christos 	    ;;
    186  1.1  christos 	esac
    187  1.1  christos 
    188  1.1  christos 	# Should be OK, mostly...
    189  1.1  christos 	C=`echo $c | sed -e 'y/abcdefghijklmnopqrstuvwxyz-/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/'`
    190  1.1  christos 	# echo "c: <$c>, C: <$C>, DB: <$DB>, DL: <$DL>, DS: <$DS>" >&2
    191  1.1  christos 
    192  1.1  christos 	case "$d" in
    193  1.1  christos 	 bin)
    194  1.1  christos 	    eval ${C}_DB=$c
    195  1.1  christos 	    eval ${C}_DL=
    196  1.1  christos 	    eval ${C}_DS=
    197  1.1  christos 	    ;;
    198  1.1  christos 	 libexec)
    199  1.1  christos 	    eval ${C}_DB=
    200  1.1  christos 	    eval ${C}_DL=$c
    201  1.1  christos 	    eval ${C}_DS=
    202  1.1  christos 	    ;;
    203  1.1  christos 	 sbin)
    204  1.1  christos 	    eval ${C}_DB=
    205  1.1  christos 	    eval ${C}_DL=
    206  1.1  christos 	    eval ${C}_DS=$c
    207  1.1  christos 	    ;;
    208  1.1  christos 	 *) echo "$0: installdir <$d> must be bin, sbin, or libexec" >&2
    209  1.1  christos 	    exit 1
    210  1.1  christos 	    ;;
    211  1.1  christos 	esac
    212  1.1  christos 	eval ${C}_MS=$s
    213  1.1  christos 
    214  1.1  christos 	# echo "<$c> gets installed in <$d> with a <$s> manpage suffix" >&2
    215  1.1  christos 	# echo "${C}_DB is <`eval echo '$'${C}_DB`>" >&2
    216  1.1  christos 	# echo "${C}_DL is <`eval echo '$'${C}_DL`>" >&2
    217  1.1  christos 	# echo "${C}_DS is <`eval echo '$'${C}_DS`>" >&2
    218  1.1  christos 	# echo "${C}_MS is <`eval echo '$'${C}_MS`>" >&2
    219  1.1  christos 	echo "${C}_DB=`eval echo '$'${C}_DB`"
    220  1.1  christos 	echo "${C}_DL=`eval echo '$'${C}_DL`"
    221  1.1  christos 	echo "${C}_DS=`eval echo '$'${C}_DS`"
    222  1.1  christos 	echo "${C}_MS=`eval echo '$'${C}_MS`"
    223  1.1  christos 
    224  1.1  christos 	touch $sdir/genLocInfo.rc0
    225  1.1  christos     else
    226  1.1  christos 	break
    227  1.1  christos     fi
    228  1.1  christos done < $LF
    229  1.1  christos IFS=$oIFS
    230  1.1  christos 
    231  1.1  christos if test -f $sdir/genLocInfo.rc1
    232  1.1  christos then
    233  1.1  christos     rm $sdir/genLocInfo.rc?
    234  1.1  christos     exit 1
    235  1.1  christos fi
    236  1.1  christos 
    237  1.1  christos if test -f $sdir/genLocInfo.rc0
    238  1.1  christos then
    239  1.1  christos     rm $sdir/genLocInfo.rc?
    240  1.1  christos     echo 'GENLOCINFO=OK'
    241  1.1  christos     exit 0
    242  1.1  christos fi
    243  1.1  christos 
    244  1.1  christos exit 1
    245