#!/bin/bash # Zoekt een file in de file-list-cache. update de cache indien nodig. # Houdt rekeing met verschillende HOSTitecturen door naar HOST variabelle te kijken. # De standandaard HOSTitectuur is wegens historische redenen 'npl' (i386) # Andere HOSTitecturen bevinden zich op dit moment 1 dir hoger. (dus zelfde plek als npl staat) # Voorbeeld: HOST=powerpc-405-linux-gnu cd `dirname $0`/.. || exit 1 FILE=$1 BASE=`pwd` cd $BASE/npl updatecache() { LIST=`stat -c %Y .tmp/files.$HOST 2>/dev/null` NOW=`date +%s` (( DIFF = NOW - LIST )) if [ ! -e .tmp/files.$HOST ] || [ "$1" == "force" ] || [ $DIFF -gt 60 ]; then #not found, update filelist and try again.. #echo "Rebuilding filelist.." >&2 mkdir .tmp 2>/dev/null find -L $BASE/$HOST | grep -v '\.svn' > .tmp/files.$$ mv .tmp/files.$$ .tmp/files.$HOST || exit 1 fi } findcache() { grep "/$FILE\$" .tmp/files.$HOST 2>/dev/null } if [ "$HOST" == "" ]; then HOST="npl"; fi #1. zoeken in opgegeven HOST findcache $FILE && exit 0 #2. update opgegeven HOST en zoek nog een keer updatecache findcache $FILE && exit 0 #we hebben al in npl gezocht, dus er is niks om terug te vallen: [ "$HOST" == "npl" ] && exit 1 #3. pak default HOST (npl) en probeer nog eens. # Dit is nodig voor bijvoorbeeld crosscompilers voor de destbetreffende HOSTitectuur. # gcc_powerpc valt namelijk onder i386 (npl) en NIET onder powerpc zelf, omdat het een HOSTcompiler is! HOST=npl findcache $FILE && exit 0 updatecache findcache $FILE && exit 0 # not found exit 1