File: updatedates.sh

package info (click to toggle)
soplex 7.1.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,568 kB
  • sloc: cpp: 76,923; sh: 1,125; python: 672; makefile: 668; awk: 243; ansic: 93; php: 15
file content (109 lines) | stat: -rwxr-xr-x 3,016 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
# This bash script updates all copyrights in the SoPlex files and posted
# those files which contain a copyright which do not have the right format
#
# You just have to run this script. There is nothing to adjust.
# The correct year is detected through the 'date' function
#
# Note that not all files (usually scripts) contain a copyright. A copyright is only
# needed for those files which are part of a SoPlex distribution (see scripts/makedist.sh)
#
# USAGE: ./scripts/updatedates.sh

NEWYEAR=`date +"%Y"`
LASTYEAR=`expr $NEWYEAR - 1`

echo ""
echo "NEWYEAR  = $NEWYEAR"
echo "LASTYEAR = $LASTYEAR"

DIRECTORIES=(check doc src src/soplex tests extra)
EXTENSIONS=(sh awk h c hpp cpp html)
EXTRAFILES=(Makefile make/make.install make/make.detecthost Makefile.nmake)

for DIRECTORY in ${DIRECTORIES[@]}
do
    echo ""
    echo "Updating directory $DIRECTORY.."

    for EXTENSION in ${EXTENSIONS[@]}
    do
        for FILE in $DIRECTORY/*.$EXTENSION
        do
            if test -f $FILE
            then
                # check if the file has a correct old copyright
                COUNT=`grep -c 1997- $FILE`

                if test "$COUNT" != 0
                then
                    # post those files which have a wrong old copyright
                    echo "COPYRIGHT ERROR --------------------> $FILE"
                    grep "1997-" $FILE
                    continue
                fi

      # check if the file has already the new copyright
      COUNT1=`grep -c "1996-$NEWYEAR" $FILE`
      COUNT2=`grep -c "1996-$LASTYEAR" $FILE`

      if test "$COUNT2" != 0
      then
          if test "$COUNT1" == "$COUNT2"
          then
              echo "- $FILE PARTIALLY UP TO DATE, updating completely"
          else
              echo "- $FILE updated"
          fi

          sed -i 's!1996-'$LASTYEAR'!1996-'$NEWYEAR'!g' $FILE
      else
          echo "- $FILE already up to date"
          continue
      fi
            fi
        done
    done
done

echo ""
echo "Updating additional files.."

for FILE in ${EXTRAFILES[@]}
do
    if test -f $FILE
    then
        # check if the file has a correct old copyright
        COUNT=`grep -c 1997- $FILE`

        if test "$COUNT" != 0
        then
            # post those files which have a wrong old copyright
            echo "COPYRIGHT ERROR --------------------> $FILE"
            grep "1997-" $FILE
            continue
        fi

      # check if the file has already the new copyright
      COUNT1=`grep -c "1996-$NEWYEAR" $FILE`
      COUNT2=`grep -c "1996-$LASTYEAR" $FILE`

      if test "$COUNT2" != 0
      then
          if test "$COUNT1" == "$COUNT2"
          then
              echo "- $FILE PARTIALLY UP TO DATE, updating completely"
          else
              echo "- $FILE updated"
          fi

          sed -i 's!1996-'$LASTYEAR'!1996-'$NEWYEAR'!g' $FILE
      else
          echo "- $FILE already up to date"
          continue
      fi
    fi
done

sed -i 's!2002-'$LASTYEAR'!2002-'$NEWYEAR'!g' LICENSE