]> git.pld-linux.org Git - packages/amanda.git/blob - amanda-chg-zd-mtx-sh.patch
perl 5.38.0 rebuild
[packages/amanda.git] / amanda-chg-zd-mtx-sh.patch
1 diff -ur amanda-2.6.1p1/changer-src/chg-zd-mtx.sh amanda-2.6.1p1-sh/changer-src/chg-zd-mtx.sh
2 --- amanda-2.6.1p1/changer-src/chg-zd-mtx.sh    2008-12-16 21:46:41.000000000 +0100
3 +++ amanda-2.6.1p1-sh/changer-src/chg-zd-mtx.sh 2009-07-03 21:00:25.379617588 +0200
4 @@ -364,7 +364,7 @@
5  
6  internal_call=0
7  Exit() {
8 -       if [ $internal_call -gt 0 ]; then
9 +       if [ "$internal_call" -gt 0 ]; then
10                 call_type=Return
11         else
12                 call_type=Exit
13 @@ -376,7 +376,7 @@
14         exit_answer="$@"
15         Log $call_type "($code) -> $exit_slot $@"
16         echo "$exit_slot" "$@"
17 -       if [ $call_type = Return ]; then
18 +       if [ "$call_type" = "Return" ]; then
19                 return $code
20         fi
21         amgetconf dbclose.$myname:$DBGFILE > /dev/null 2>&1
22 @@ -393,12 +393,12 @@
23         "$@" > $stdout 2> $stderr
24         exitcode=$?
25         Log `_ 'Exit code: %s' "$exitcode"`
26 -       if [ -s $stdout ]
27 +       if [ -s "$stdout" ]
28         then
29                 LogAppend Stdout:
30                 cat $stdout >> $DBGFILE
31         fi
32 -       if [ -s $stderr ]
33 +       if [ -s "$stderr" ]
34         then
35                 LogAppend Stderr:
36                 cat $stderr >> $DBGFILE
37 @@ -425,13 +425,13 @@
38  mtx_status_valid=0
39  get_mtx_status() {
40         test -n "$DEBUG" && set -x
41 -       if [ $mtx_status_valid -ne 0 ]; then
42 +       if [ "$mtx_status_valid" -ne 0 ]; then
43                 return 0
44         fi
45         rm -f $mtx_status
46         Run $MTX status > $mtx_status 2>&1
47         status=$?
48 -       if [ $status -eq 0 ]; then
49 +       if [ "$status" -eq 0 ]; then
50                 mtx_status_valid=1
51         fi
52  
53 @@ -503,7 +503,7 @@
54         fi
55  
56         #Use the current slot if it's empty and we don't know which slot is loaded'
57 -       if [ $loadedslot -eq -2 ]; then
58 +       if [ "$loadedslot" -eq -2 ]; then
59                 set x `sed -n '
60  {
61      /^.*Storage Element '$currentslot':Empty/ {
62 @@ -526,13 +526,13 @@
63  ' < $mtx_status 2>& 1`
64                 shift                           # get rid of the "x"
65                 loadedslotx=$1
66 -               if [ ! -z $loadedslotx ]; then
67 +               if [ ! -z "$loadedslotx" ]; then
68                         loadedslot=$loadedslotx
69                 fi
70         fi
71  
72         #Use the first empty slot if we don't know which slot is loaded'
73 -       if [ $loadedslot -eq -2 ]; then
74 +       if [ "$loadedslot" -eq -2 ]; then
75                 set x `sed -n '
76  {
77      /^.*Storage Element \([0-9][0-9]*\):Empty/ {
78 @@ -606,27 +606,27 @@
79  }
80  ' < $mtx_status 2>&1 | grep -v "^${cleanslot}\$" | sort -n`
81         slot_list=`echo $slot_list`             # remove the newlines
82 -       if [ $firstslot -lt 0 -o $lastslot -lt 0 ]; then
83 +       if [ "$firstslot" -lt 0 -o "$lastslot" -lt 0 ]; then
84                 last=$lastslot
85                 for slot in $slot_list; do
86 -                       if [ $firstslot -lt 0 ]; then
87 +                       if [ "$firstslot" -lt 0 ]; then
88                                 Log `_ 'SLOTLIST -> firstslot set to %s' "$slot"`
89                                 firstslot=$slot
90                         fi
91 -                       if [ $lastslot -lt 0 ]; then
92 +                       if [ "$lastslot" -lt 0 ]; then
93                                 last=$slot
94                         fi
95                 done
96 -               if [ $lastslot -lt 0 -a $last -ge 0 ]; then
97 +               if [ "$lastslot" -lt 0 -a "$last" -ge 0 ]; then
98                         Log `_ 'SLOTLIST -> lastslot set to %s' "$last"`
99                         lastslot=$last
100                 fi
101 -               if [ $firstslot -lt 0 ]; then
102 +               if [ "$firstslot" -lt 0 ]; then
103                         Exit 2 \
104                              `_ '<none>'` \
105                              `_ 'cannot determine first slot'`
106                         return $?               # in case we are internal
107 -               elif [ $lastslot -lt 0 ]; then
108 +               elif [ "$lastslot" -lt 0 ]; then
109                         Exit 2 \
110                              `_ '<none>'` \
111                              `_ 'cannot determine last slot'`
112 @@ -635,7 +635,7 @@
113         fi
114         amanda_slot_list=
115         for slot in $slot_list; do
116 -               if [ $slot -ge $firstslot -a $slot -le $lastslot ]; then
117 +               if [ "$slot" -ge "$firstslot" -a "$slot" -le "$lastslot" ]; then
118                         amanda_slot_list="$amanda_slot_list $slot"
119                 fi
120         done
121 @@ -671,7 +671,7 @@
122                              `_ 'Line %s malformed in %s: %s %s %s' "$line" "$labelfile" "$lbl" "$bc" "$junk"`
123                         return $?               # in case we are internal
124                 fi
125 -               if [ $lbl = "$lbl_search" -o $bc = "$bc_search" ]; then
126 +               if [ "$lbl" = "$lbl_search" -o "$bc" = "$bc_search" ]; then
127                         if [ $labelfile_entry_found -ne 0 ]; then
128                                 Log       `_ 'ERROR    -> Duplicate entries: %s line %s' "$labelfile" "$line"`
129                                 LogAppend `_ '         -> Remove %s and run "%s %s update"' "$labelfile" "$sbindir/amtape" "$config"`
130 @@ -860,7 +860,7 @@
131          Exit 2 \
132               ` _ '<none>'` \
133               "tapedev $rawtape is not a tape device."
134 -elif [ $tape = "/dev/null" -o `expr "$tape" : 'null:'` -eq 5 ]; then
135 +elif [ "$tape" = "/dev/null" -o "`expr "$tape" : 'null:'`" -eq 5 ]; then
136         Exit 2 \
137              `_ '<none>'` \
138              "tapedev ($tape) may not be the null device"
139 @@ -871,7 +871,7 @@
140         Exit 2 \
141              `_ '<none>'` \
142              "changerdev may not be empty"
143 -elif [ $TAPE = "/dev/null" ]; then
144 +elif [ "$TAPE" = "/dev/null" ]; then
145         Exit 2 \
146              `_ '<none>'` \
147              "changerdev ($TAPE) may not be the null device"
148 @@ -884,19 +884,19 @@
149  #### Set up the various config files.
150  
151  conf_match=`expr "$changerfile" : .\*\.conf\$`
152 -if [ $conf_match -ge 6 ]; then
153 +if [ "$conf_match" -ge 6 ]; then
154         configfile=$changerfile
155         changerfile=`echo $changerfile | sed 's/.conf$//g'`
156  else
157         configfile=$changerfile.conf
158  fi
159  
160 -if [ ! -e $configfile ]; then
161 +if [ ! -e "$configfile" ]; then
162         Exit 2 \
163              `_ '<none>'` \
164              "configuration file \"$configfile\" doesn't exist"
165  fi
166 -if [ ! -f $configfile ]; then
167 +if [ ! -f "$configfile" ]; then
168         Exit 2 \
169              `_ '<none>'` \
170              "configuration file \"$configfile\" is not a file"
171 @@ -907,10 +907,10 @@
172  slotfile=$changerfile-slot
173  labelfile=$changerfile-barcodes
174  slotinfofile=""
175 -[ ! -s $cleanfile ] && echo 0 > $cleanfile
176 -[ ! -s $accessfile ] && echo 0 > $accessfile
177 -[ ! -s $slotfile ] && echo -1 > $slotfile
178 -[ ! -f $labelfile ] && > $labelfile
179 +[ ! -s "$cleanfile" ] && echo 0 > $cleanfile
180 +[ ! -s "$accessfile" ] && echo 0 > $accessfile
181 +[ ! -s "$slotfile" ] && echo -1 > $slotfile
182 +[ ! -f "$labelfile" ] && > $labelfile
183  cleancount=`cat $cleanfile`
184  accesscount=`cat $accessfile`
185  
186 @@ -957,7 +957,7 @@
187  
188  # Get DBGFILE set if it is not already.
189  
190 -if [ $DBGFILE = /dev/null ]; then
191 +if [ "$DBGFILE" = /dev/null ]; then
192         if [ -d "$DBGDIR" ]; then
193                 DBGFILE=$DBGDIR/changer.debug.drive$driveslot
194         else
195 @@ -1037,9 +1037,9 @@
196  
197  Log `_ "Config info:"`
198  for var in $varlist; do
199 -       if [ $var = "OFFLINE_BEFORE_UNLOAD" ]; then
200 +       if [ "$var" = "OFFLINE_BEFORE_UNLOAD" ]; then
201                 continue                        # old name
202 -       elif [ $var = "AUTOCLEAN" ]; then
203 +       elif [ "$var" = "AUTOCLEAN" ]; then
204                 continue                        # old name
205         elif [ $var = "slotinfofile" ]; then
206                 continue                        # not numeric
207 @@ -1062,12 +1062,12 @@
208  
209  # Run the rest of the config file sanity checks.
210  
211 -if [ $firstslot -gt $lastslot ]; then
212 +if [ "$firstslot" -gt "$lastslot" ]; then
213         Exit 2 \
214              `_ '<none>'` \
215              `_ 'firstslot (%s) greater than lastslot (%s) in %s' "$firstslot" "$lastslot" "$configfile"`
216  fi
217 -if [ $autoclean -ne 0 -a $cleanslot -lt 0 ]; then
218 +if [ "$autoclean" -ne 0 -a "$cleanslot" -lt 0 ]; then
219         Exit 2 \
220              `_ '<none>'` \
221              `_ 'autoclean set but cleanslot not valid (%s)' "$cleanslot"`
222 @@ -1077,10 +1077,10 @@
223  
224  currentslot=`cat $slotfile`
225  if IsNumeric "$currentslot" ; then
226 -       if [ $currentslot -lt $firstslot ]; then
227 +       if [ "$currentslot" -lt "$firstslot" ]; then
228                 Log `_ 'SETUP    -> current slot %s less than %s ... resetting to %s' "$currentslot" "$firstslot" "$firstslot"`
229                 currentslot=$firstslot
230 -       elif [ $currentslot -gt $lastslot ]; then
231 +       elif [ "$currentslot" -gt "$lastslot" ]; then
232                 Log `_ 'SETUP    -> current slot %s greater than %s ... resetting to %s' "$currentslot" "$lastslot" "$lastslot"`
233                 currentslot=$lastslot
234         fi
235 @@ -1093,19 +1093,19 @@
236  first_slot_in_list=-1
237  next_slot_after_current=-1
238  for slot in $slot_list; do
239 -       if [ $first_slot_in_list -lt 0 ]; then
240 +       if [ "$first_slot_in_list" -lt 0 ]; then
241                 first_slot_in_list=$slot        # in case $firstslot is missing
242         fi
243 -       if [ $slot -eq $currentslot ]; then
244 +       if [ "$slot" -eq "$currentslot" ]; then
245                 found_current=1
246                 break
247 -       elif [ $slot -gt $currentslot ]; then
248 +       elif [ "$slot" -gt "$currentslot" ]; then
249                 next_slot_after_current=$slot   # $currentslot is missing
250                 break
251         fi
252  done
253 -if [ $found_current -eq 0 ]; then
254 -       if [ $next_slot_after_current -lt 0 ]; then
255 +if [ "$found_current" -eq 0 ]; then
256 +       if [ "$next_slot_after_current" -lt 0 ]; then
257                 new_currentslot=$first_slot_in_list
258         else
259                 new_currentslot=$next_slot_after_current
260 @@ -1124,9 +1124,9 @@
261         test -n "$DEBUG" && set -x
262         Log `_ 'EJECT    -> ejecting tape from %s' "$tape"`
263         get_loaded_info 
264 -       if [ $loadedslot -gt 0 ]; then
265 +       if [ "$loadedslot" -gt 0 ]; then
266                 Log `_ 'EJECT    -> moving tape from drive %s to storage slot %s' "$driveslot" "$loadedslot"`
267 -               if [ $offline_before_unload -ne 0 ]; then
268 +               if [ "$offline_before_unload" -ne 0 ]; then
269                          Run try_eject_device $tape
270                 fi
271                 sleep $unloadpause
272 @@ -1134,7 +1134,7 @@
273                 status=$?
274                 Log `_ '         -> status %s, result "%s"' "$status" "$result"`
275                 mtx_status_valid=0
276 -               if [ $status -ne 0 ]; then
277 +               if [ "$status" -ne 0 ]; then
278                         answer="$result"
279                         code=2
280                 else
281 @@ -1213,7 +1213,7 @@
282         prev_slot=$1
283         shift
284         while [ $# -gt 0 ]; do
285 -               if [ $1 -eq $find_slot ]; then
286 +               if [ "$1" -eq "$find_slot" ]; then
287                         break
288                 fi
289                 prev_slot=$1
290 @@ -1242,15 +1242,15 @@
291         # If the desired slot is already loaded, we are done.  Only update
292         # current slot if this is not the cleaning slot.
293         get_loaded_info
294 -       if [ $loadslot = $loadedslot ]; then
295 -               if [ $loadslot -ne $cleanslot ]; then
296 +       if [ "$loadslot" = "$loadedslot" ]; then
297 +               if [ "$loadslot" -ne "$cleanslot" ]; then
298                         rm -f $slotfile
299                         echo $loadslot > $slotfile
300                 fi
301                 Exit 0 "$loadedslot" "$rawtape"
302                 return $?                       # in case we are internal
303         fi
304 -       if [ $loadedslot -eq -2 ]; then
305 +       if [ "$loadedslot" -eq -2 ]; then
306                 Exit 0 "$loadedslot" "$rawtape"
307                 return $?                       # in case we are internal
308          fi
309 @@ -1258,20 +1258,20 @@
310         # If we are loading the cleaning tape, bump the cleaning count
311         # and reset the access count.  Otherwise, bump the access count
312         # and see if it is time to do a cleaning.
313 -       if [ $loadslot = $cleanslot ]; then
314 +       if [ "$loadslot" = "$cleanslot" ]; then
315                 rm -f $cleanfile $accessfile
316                 expr $cleancount + 1 > $cleanfile
317                 echo 0 > $accessfile
318         else
319                 rm -f $accessfile
320                 expr $accesscount + 1 > $accessfile
321 -               if [ $autoclean -ne 0 -a $accesscount -gt $autocleancount ]
322 +               if [ "$autoclean" -ne 0 -a "$accesscount" -gt "$autocleancount" ]
323                 then
324                         internal_call=`expr $internal_call + 1`
325                         loadslot clean > /dev/null 2>&1
326                         status=$?
327                         internal_call=`expr $internal_call - 1`
328 -                       if [ $status -ne 0 ]; then
329 +                       if [ "$status" -ne 0 ]; then
330                                 Exit $status "$loadslot" "$exit_answer"
331                                 return $?       # in case we are internal
332                         fi
333 @@ -1291,14 +1291,14 @@
334         eject > /dev/null 2>&1
335         status=$?
336         internal_call=`expr $internal_call - 1`
337 -       if [ $status -gt 1 ]; then
338 +       if [ "$status" -gt 1 ]; then
339                 Exit $status "$exit_slot" "$exit_answer"
340                 return $?                       # in case we are internal
341         fi
342  
343         # If we were doing an "advance", we are done.
344 -       if [ $whichslot = advance ]; then
345 -               if [ $loadslot -ne $cleanslot ]; then
346 +       if [ "$whichslot" = "advance" ]; then
347 +               if [ "$loadslot" -ne "$cleanslot" ]; then
348                         rm -f $slotfile
349                         echo $loadslot > $slotfile
350                 fi
351 @@ -1312,7 +1312,7 @@
352         status=$?
353         Log `_ '         -> status %s, result "%s"' "$status" "$result"`
354         mtx_status_valid=0
355 -       if [ $status -ne 0 ]; then
356 +       if [ "$status" -ne 0 ]; then
357                 Exit 2 "$loadslot" "$result"
358                 return $?                       # in case we are internal
359         fi
360 @@ -1322,7 +1322,7 @@
361         # for "long enough" (as determined empirically by the user),
362         # then return success.
363         ###
364 -       if [ $loadslot -eq $cleanslot ]; then
365 +       if [ "$loadslot" -eq "$cleanslot" ]; then
366                 Run sleep $cleancycle
367                 Exit 0 "$loadslot" "$rawtape"
368                 return $?                       # in case we are internal
369 @@ -1334,7 +1334,7 @@
370         waittime=0
371         ready=0
372         sleep $initial_poll_delay
373 -       while [ $waittime -lt $max_drive_wait ]; do
374 +       while [ "$waittime" -lt "$max_drive_wait" ]; do
375                  amdevcheck_status $tape
376                 if [ $? -eq 0 ]; then
377                         ready=1
378 @@ -1343,12 +1343,12 @@
379                 sleep $poll_drive_ready
380                 waittime=`expr $waittime + $poll_drive_ready`
381         done
382 -       if [ $ready -eq 0 ]; then
383 +       if [ "$ready" -eq 0 ]; then
384                 Exit 2 "$loadslot" `_ 'Drive not ready after %s seconds: %s' "$max_drive_wait" "$amdevcheck_message"`
385                 return $?                       # in case we are internal
386         fi
387  
388 -       if [ $loadslot -ne $cleanslot ]; then
389 +       if [ "$loadslot" -ne "$cleanslot" ]; then
390                 rm -f $slotfile
391                 echo $loadslot > $slotfile
392         fi
393 @@ -1379,11 +1379,11 @@
394         # can search based on barcodes.
395         ###
396         reader=
397 -        if [ $havereader -eq 1 ]; then
398 +        if [ "$havereader" -eq 1 ]; then
399                 reader=1
400          fi
401  
402 -       if [ $currentslot -lt $firstslot -o $currentslot -gt $lastslot ]; then
403 +       if [ "$currentslot" -lt "$firstslot" -o "$currentslot" -gt "$lastslot" ]; then
404                 currentslot=$firstslot          # what "current" will get
405         fi
406         numslots=`expr $lastslot - $firstslot + 1`
407 @@ -1404,12 +1404,12 @@
408         fi
409          tapelabel=$1
410          get_loaded_info
411 -       if [ $loadedslot -lt 0 ]; then
412 +       if [ "$loadedslot" -lt 0 ]; then
413                 Exit 1 `_ '<none>'` `_ 'No tape currently loaded'`
414                 return $?                       # in case we are internal
415         fi
416         record_label_in_slot "$tapelabel" "$loadedslot"
417 -       if [ $havereader -eq 0 ]; then
418 +       if [ "$havereader" -eq 0 ]; then
419                 Exit 0 "$loadedslot" "$rawtape" # that's all we needed
420                 return $?                       # in case we are internal
421         fi
422 @@ -1419,7 +1419,7 @@
423         fi
424         Log       `_ 'LABEL    -> Adding label "%s" with barcode "%s" for slot %s into %s' "$tapelabel" "$loadedbarcode" "$loadedslot" "$labelfile"`
425         read_labelfile "$tapelabel" "$loadedbarcode" < $labelfile
426 -       if [ $labelfile_entry_found -ne 0 ]; then
427 +       if [ "$labelfile_entry_found" -ne 0 ]; then
428                 lf_val=
429                 if [ "$labelfile_barcode" != "$loadedbarcode" ]; then
430                         lf_type=label
431 @@ -1465,13 +1465,13 @@
432                 return $?                       # in case we are internal
433         fi
434          tapelabel=$1
435 -       if [ $havereader -eq 0 ]; then
436 +       if [ "$havereader" -eq 0 ]; then
437                 Exit 2 `_ '<none>'` `_ 'Not configured with barcode reader'`
438                 return $?                       # in case we are internal
439         fi
440         Log `_ 'SEARCH   -> Hunting for label "%s"' "$tapelabel"`
441         read_labelfile "$tapelabel" "" < $labelfile
442 -       if [ $labelfile_entry_found -eq 0 ]; then
443 +       if [ "$labelfile_entry_found" -eq 0 ]; then
444                 LogAppend `_ '         -> !!! label "%s" not found in %s !!!' "$tapelabel" "$labelfile"`
445                 LogAppend `_ '         -> Remove %s and run "%s %s update"' "$labelfile" "$sbindir/amtape" "$config"`
446                 Exit 2 \
This page took 0.111969 seconds and 3 git commands to generate.