File: dumps

package info (click to toggle)
libdate-manip-perl 6.76-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,228 kB
  • sloc: perl: 246,208; sh: 54; makefile: 11
file content (43 lines) | stat: -rwxr-xr-x 1,078 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh

if [ ! -d "tzdata/dump" ]; then
   echo "Dump files removed."
   exit
fi

for file in `cd tzdata/dump; echo *` ;do
   tz=`head -1 tzdata/dump/$file | awk '{print $1}'`
   echo "##########################################################"
   echo "### $tz"

   # Create the new dump.  Ignore lines with the year 0001 and 9999.

   perl -I./lib examples/dm_zdump -v $tz | egrep -v '0001|9999' > z.dump.new
   ln=`wc -l z.dump.new | awk '{print $1}'`

   # Copy the old dump.  Ignore the 2 first and 2 last lines.

   tail --lines=+3 tzdata/dump/$file | head --lines=-2 > z.dump.old
   lo=`wc -l z.dump.old | awk '{print $1}'`

   if [ "$ln" = "0" ]; then
      echo "***"
      echo "*** ERROR ***"
      echo "***"

   elif [ $lo -gt $ln ]; then
      mv z.dump.old z.dump.old.1
      head --lines=$ln z.dump.old.1 > z.dump.old
      rm -f z.dump.old.1

   elif [ $ln -gt $lo ]; then
      mv z.dump.new z.dump.new.1
      head --lines=$lo z.dump.new.1 > z.dump.new
      rm -f z.dump.new.1
   fi

   diff -c z.dump.old z.dump.new
   rm -f z.dump.old z.dump.new

done