OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [tools/] [update/] [update.in] - Blame information for rev 487

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
#!@KSH@ -p
2
#
3
# $Id: update.in,v 1.2 2001-09-27 12:02:54 chris Exp $
4
#
5
# Either bash or ksh will be ok for this; requires 'test -ot'
6
#  (-p above just says to not parse $ENV file; makes it faster for
7
#   those of us who set $ENV)
8
#
9
# Update RTEMS applications for the API changes from 3.1.0 to 3.2.0
10
#
11
# NOTE
12
#
13
#   This is potentially a very dangerous program.
14
 
15
# progname=`basename $0`
16
progname=${0##*/}        # fast basename hack for ksh, bash
17
 
18
USAGE=\
19
"
20
usage: $progname [ -vs ] [ -b base_directory ] [-p file] [-f] [files...]
21
        -v          -- verbose
22
        -p          -- file with replacement instructions
23
        -s          -- skip prompt for backup verification
24
        -f          -- do files at end of line
25
 
26
base_directory is the root directory of the source code to update.  It
27
defaults to the current directory.
28
 
29
This program updates C, H, and .inl files.
30
"
31
 
32
fatal() {
33
    if [ "$1" ]
34
    then
35
        echo    >&2
36
        echo $* >&2
37
        echo    >&2
38
    fi
39
    echo "$USAGE" 1>&2
40
    exit 1
41
}
42
 
43
#
44
#  KLUDGE to figure out at runtime how to echo a line without a
45
#  newline.
46
#
47
count=`echo "\\c" | wc -c`
48
if [ ${count} -ne 0 ] ; then
49
  EARG="-n"
50
  EOL=""
51
else
52
  EARG=""
53
  EOL="\\c"
54
fi
55
 
56
#
57
#  Function to make sure they do a backup
58
#
59
 
60
WARNING=\
61
"
62
 
63
*******************************************************************************
64
*******************************************************************************
65
*******************************************************************************
66
****                                                                       ****
67
****        WARNING!!!          WARNING!!!           WARNING!!!            ****
68
****                                                                       ****
69
****   ALL SOURCE CODE SHOULD BE BACKED UP BEFORE RUNNING THIS PROGRAM!!   ****
70
****                                                                       ****
71
****        WARNING!!!          WARNING!!!           WARNING!!!            ****
72
****                                                                       ****
73
*******************************************************************************
74
*******************************************************************************
75
*******************************************************************************
76
 
77
"
78
 
79
verify_backup()
80
{
81
  echo "$WARNING"
82
  continue="yes"
83
  while [ $continue = "yes" ]
84
  do
85
echo ${EARG} "Do you wish to update the source tree at this time [y|n]? " ${EOL}
86
    read answer
87
    case $answer in
88
      [yY]*)
89
        continue="no"
90
        ;;
91
      [nN]*)
92
        echo
93
        echo "Exitting at user request"
94
        echo
95
        exit 0
96
        ;;
97
    esac
98
  done
99
}
100
 
101
#
102
#  Default tools to use...
103
#
104
#  NOTE: The GNU versions of both of these are faster.
105
#
106
find_prog=find
107
xargs_prog=xargs
108
 
109
#
110
# process the options
111
#
112
 
113
verbose=""
114
suffix=""
115
mode=""
116
base_directory=.
117
do_files="no"
118
do_prompt="yes"
119
replacement_file="${RTEMS_ROOT}/update-tools/310_to_320_list"
120
 
121
while getopts sfp:b:v OPT
122
do
123
    case "$OPT" in
124
        v)
125
          verbose="yes";;
126
        s)
127
          do_prompt="no";;
128
        b)
129
          base_directory=${OPTARG};;
130
        p)
131
          replacement_file=${OPTARG};;
132
        f)
133
          do_files="yes";;
134
        *)
135
          fatal
136
    esac
137
done
138
 
139
let $((shiftcount = $OPTIND - 1))
140
shift $shiftcount
141
 
142
args=$*
143
 
144
#
145
#  Make sure they have done a backup
146
#
147
 
148
if [ ${do_prompt} = "yes" ]
149
then
150
  verify_backup
151
fi
152
 
153
#
154
# Validate the base directory
155
#
156
 
157
if [ ! -d $base_directory ]
158
then
159
    fatal "${base_directory} does not exist"
160
fi
161
 
162
#
163
# Validate the replacement file
164
#
165
 
166
if [ ! -r $replacement_file ]
167
then
168
    fatal "${replacement_file} does not exist or is not readable"
169
fi
170
 
171
 
172
#
173
#  Verify enough of the RTEMS environment variables are set
174
#
175
 
176
if [ ! -d "${RTEMS_ROOT}" ]
177
then
178
    fatal "RTEMS_ROOT environment variable is not initialized"
179
fi
180
 
181
#
182
# Update the files
183
#
184
 
185
generate_list()
186
{
187
  if [ ${do_files} = "yes" ]
188
  then
189
    for i in $args
190
    do
191
      echo $i
192
    done
193
  else
194
    ${find_prog} ${base_directory} \(  -name "*.[ch]" -o -name "*.inl" \) -print
195
  fi
196
}
197
 
198
generate_list | ${xargs_prog} |
199
  while read line
200
  do
201
    ${RTEMS_ROOT}/update-tools/word-replace -p ${replacement_file} ${line}
202
    if [ $? -ne 0 ]
203
    then
204
      exit 1
205
    fi
206
    for file in ${line}
207
    do
208
      mv ${file}.fixed ${file}
209
    done
210
  done
211
 
212
exit 0
213
 
214
# Local Variables: ***
215
# mode:ksh ***
216
# End: ***

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.