Add missing files
[bcusdk.git] / bcu / addmissing.sh
blob9952088f91d5fb603a43a90aa7de9650c99ae28b
1 #!/bin/bash
2 # BCU SDK bcu development enviroment - install helper
3 # Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 # searches replacement for missing (or equal) SDK files
20 # parameter: destdir installfilename
22 if [ $# != 2 ]; then
23 echo wrong parameters
24 exit 1
27 F=$2
29 if [ ! -f $F ]; then
31 prefix="`echo $F|sed -e 's/\([A-Za-z0-9]*_\).*/\1/g'`"
32 last="`echo $F|sed -e 's/[A-Za-z0-9]*_\(.*\)/\1/g'`"
34 base="`echo "$last" | sed -e 's/\([0-9A-Fa-f]\{4\}\)[^.]*\([.].*\)/\1\2/g'`"
36 if [ -f "$prefix$base" ]; then
37 echo "using $prefix$base for $F"
39 cp "$prefix$base" "$1/$2" || exit 1
41 else
43 ext="`echo $base | sed -e 's/[0-9A-Fa-f]\{4\}\([.].*\)/\1/g'`"
44 mask="`echo $base | sed -e 's/\([0-9A-Fa-f]\{4\}\)[.].*/\1/g'`"
45 var="`echo $last | sed -e 's/[0-9A-Fa-f]\{4\}\([^.]*\)[.].*/\1/g'`"
47 case "$mask" in
48 0021) mask="0020" ;;
49 *) echo "unknown mask version $mask"
50 exit 1 ;;
51 esac
53 for a in "$mask"; do
55 if [ -f "$prefix$a$var$ext" ]; then
56 echo using "$prefix$a$var$ext for $F"
58 cp "$prefix$a$var$ext" "$1/$2" || exit 1
60 exit 0;
63 if [ -f "$prefix$a$ext" ]; then
64 echo "using $prefix$a$ext for $F"
66 cp "$prefix$a$ext" "$1/$2" || exit 1
68 exit 0;
71 done
73 echo "no file found for $F"
74 exit 1
79 exit 0