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.1.3 christos raspbian*) 83 1.1.1.3 christos lf=loc/debian 84 1.1.1.3 christos ${V}echo "Looking for <$lf>" >&2 85 1.1.1.3 christos if test -f $lf 86 1.1.1.3 christos then 87 1.1.1.3 christos LF=$lf 88 1.1.1.3 christos fi 89 1.1.1.3 christos ;; 90 1.1 christos redhat* | fedora*) 91 1.1 christos lf=loc/redhat 92 1.1 christos ${V}echo "Looking for <$lf>" >&2 93 1.1 christos if test -f $lf 94 1.1 christos then 95 1.1 christos LF=$lf 96 1.1 christos fi 97 1.1 christos ;; 98 1.1 christos esac 99 1.1 christos ;; 100 1.1 christos esac 101 1.1 christos 102 1.1 christos # This might be a good place to see if uname returns "Linux", 103 1.1 christos # and if so, use a generic file for that. 104 1.1 christos case "$LF" in 105 1.1 christos '') 106 1.1 christos case "`uname`" in 107 1.1 christos Linux) 108 1.1 christos lf=loc/linux 109 1.1 christos ${V}echo "Looking for <$lf>" >&2 110 1.1 christos if test -f $lf 111 1.1 christos then 112 1.1 christos LF=$lf 113 1.1 christos fi 114 1.1 christos ;; 115 1.1 christos esac 116 1.1 christos ;; 117 1.1 christos esac 118 1.1 christos 119 1.1 christos # Finally, 'legacy' 120 1.1 christos case "$LF" in 121 1.1 christos '') 122 1.1 christos lf=loc/legacy 123 1.1 christos ${V}echo "Looking for <$lf>" >&2 124 1.1 christos if test -f $lf 125 1.1 christos then 126 1.1 christos LF=$lf 127 1.1 christos fi 128 1.1 christos ;; 129 1.1 christos esac 130 1.1 christos 131 1.1 christos case "$LF" in 132 1.1 christos '') 133 1.1 christos echo "No loc/XXX file found!" >&2 134 1.1 christos exit 1 135 1.1 christos ;; 136 1.1 christos esac 137 1.1 christos ;; 138 1.1 christos esac 139 1.1 christos 140 1.1 christos ${V}echo "Using <$LF>" >&2 141 1.1 christos echo "GENLOCINFOFILE=$LF" 142 1.1 christos 143 1.1 christos ### 144 1.1 christos 145 1.1 christos rm -f $sdir/genLocInfo.rc? 146 1.1 christos 147 1.1 christos oIFS=$IFS 148 1.1 christos IFS="," 149 1.1 christos 150 1.1 christos while true 151 1.1 christos do 152 1.1 christos if read c d s x 153 1.1 christos then 154 1.1 christos # echo "Got <$c><$d><$s><$x>" >&2 155 1.1 christos case "$c" in 156 1.1 christos \#*) continue ;; 157 1.1 christos esac 158 1.1 christos case "$x" in 159 1.1 christos '') ;; 160 1.1 christos *) echo "Unrecognized input: <$c,$d,$s,$x>" >&2 161 1.1 christos touch $sdir/genLocInfo.rc1 162 1.1 christos continue 163 1.1 christos ;; 164 1.1 christos esac 165 1.1 christos case "$c,$d,$s" in 166 1.1 christos [Mm][Aa][Nn],,) 167 1.1 christos echo "MANTAGFMT=man" 168 1.1 christos continue 169 1.1 christos ;; 170 1.1 christos [Mm][Dd][Oo][Cc],,) 171 1.1 christos echo "MANTAGFMT=mdoc" 172 1.1 christos continue 173 1.1 christos ;; 174 1.1 christos esac 175 1.1 christos 176 1.1 christos case "$c,$d,$s" in 177 1.1.1.2 christos *,bin,*) DB=bin ; DL= ; DS= ; NI= ;; 178 1.1.1.2 christos *,libexec,*) DB= ; DL=libexec ; DS= ; NI= ;; 179 1.1.1.2 christos *,noinst,*) DB= ; DL= ; DS= ; NI=noinst ;; 180 1.1.1.2 christos *,sbin,*) DB= ; DL= ; DS=sbin ; NI= ;; 181 1.1 christos *) echo "Unrecognized input: <$c,$d,$s>" >&2 182 1.1 christos touch $sdir/genLocInfo.rc1 183 1.1 christos continue 184 1.1 christos ;; 185 1.1 christos esac 186 1.1 christos case "$c,$d,$s" in 187 1.1 christos *,*,1) ;; 188 1.1 christos *,*,1m) ;; 189 1.1 christos *,*,1M) ;; 190 1.1 christos *,*,8) ;; 191 1.1 christos *) echo "Unrecognized input: <$c,$d,$s>" >&2 192 1.1 christos touch $sdir/genLocInfo.rc1 193 1.1 christos continue 194 1.1 christos ;; 195 1.1 christos esac 196 1.1 christos 197 1.1 christos # Should be OK, mostly... 198 1.1 christos C=`echo $c | sed -e 'y/abcdefghijklmnopqrstuvwxyz-/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/'` 199 1.1 christos # echo "c: <$c>, C: <$C>, DB: <$DB>, DL: <$DL>, DS: <$DS>" >&2 200 1.1 christos 201 1.1 christos case "$d" in 202 1.1 christos bin) 203 1.1 christos eval ${C}_DB=$c 204 1.1 christos eval ${C}_DL= 205 1.1 christos eval ${C}_DS= 206 1.1.1.2 christos eval ${C}_NI= 207 1.1 christos ;; 208 1.1 christos libexec) 209 1.1 christos eval ${C}_DB= 210 1.1 christos eval ${C}_DL=$c 211 1.1 christos eval ${C}_DS= 212 1.1.1.2 christos eval ${C}_NI= 213 1.1.1.2 christos ;; 214 1.1.1.2 christos noinst) 215 1.1.1.2 christos eval ${C}_DB= 216 1.1.1.2 christos eval ${C}_DL= 217 1.1.1.2 christos eval ${C}_DS= 218 1.1.1.2 christos eval ${C}_NI=$c 219 1.1 christos ;; 220 1.1 christos sbin) 221 1.1 christos eval ${C}_DB= 222 1.1 christos eval ${C}_DL= 223 1.1 christos eval ${C}_DS=$c 224 1.1.1.2 christos eval ${C}_NI= 225 1.1 christos ;; 226 1.1.1.2 christos *) echo "$0: installdir <$d> must be bin, sbin, libexec, or noinst" >&2 227 1.1 christos exit 1 228 1.1 christos ;; 229 1.1 christos esac 230 1.1 christos eval ${C}_MS=$s 231 1.1 christos 232 1.1 christos # echo "<$c> gets installed in <$d> with a <$s> manpage suffix" >&2 233 1.1 christos # echo "${C}_DB is <`eval echo '$'${C}_DB`>" >&2 234 1.1 christos # echo "${C}_DL is <`eval echo '$'${C}_DL`>" >&2 235 1.1 christos # echo "${C}_DS is <`eval echo '$'${C}_DS`>" >&2 236 1.1.1.2 christos # echo "${C}_NI is <`eval echo '$'${C}_NI`>" >&2 237 1.1 christos # echo "${C}_MS is <`eval echo '$'${C}_MS`>" >&2 238 1.1 christos echo "${C}_DB=`eval echo '$'${C}_DB`" 239 1.1 christos echo "${C}_DL=`eval echo '$'${C}_DL`" 240 1.1 christos echo "${C}_DS=`eval echo '$'${C}_DS`" 241 1.1.1.2 christos echo "${C}_NI=`eval echo '$'${C}_NI`" 242 1.1 christos echo "${C}_MS=`eval echo '$'${C}_MS`" 243 1.1 christos 244 1.1 christos touch $sdir/genLocInfo.rc0 245 1.1 christos else 246 1.1 christos break 247 1.1 christos fi 248 1.1 christos done < $LF 249 1.1 christos IFS=$oIFS 250 1.1 christos 251 1.1 christos if test -f $sdir/genLocInfo.rc1 252 1.1 christos then 253 1.1 christos rm $sdir/genLocInfo.rc? 254 1.1 christos exit 1 255 1.1 christos fi 256 1.1 christos 257 1.1 christos if test -f $sdir/genLocInfo.rc0 258 1.1 christos then 259 1.1 christos rm $sdir/genLocInfo.rc? 260 1.1 christos echo 'GENLOCINFO=OK' 261 1.1 christos exit 0 262 1.1 christos fi 263 1.1 christos 264 1.1 christos exit 1 265