"Fossies" - the Fresh Open Source Software Archive

Member "evolution-mapi-3.46.1/cmake/verify-news-file.sh" (2 Dec 2022, 1556 Bytes) of package /linux/misc/evolution-mapi-3.46.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 
    3 # Verifies that the NEWS file's first line contains correct version and date.
    4 # Requires arguments:
    5 #   $1 ... the NEWS file name, preferably with full path
    6 #   $2 ... expected version string, like "1.2.3"
    7 #
    8 # The date is expected in a form of YYYY-MM-DD of the current local time.
    9 # The NEWS line is in form of "PROJECTNAME VERSION DATE".
   10 #
   11 # The test can be skipped entirely when SKIP_NEWS_FILE_TEST=1 is set.
   12 
   13 FILENAME=$1
   14 EXPVERSION=$2
   15 
   16 if [ ! -f "$FILENAME" ]; then
   17     echo "File '$FILENAME' does not exist" 1>&2
   18     exit 1
   19 fi
   20 
   21 if [ -z "$EXPVERSION" ]; then
   22     echo "Expected version argument not given or empty, use format '1.2.3'" 1>&2
   23     exit 1
   24 fi
   25 
   26 NEWSLINE=`head --lines=1 "$FILENAME"`
   27 EXPDATE=`date +%Y-%m-%d`
   28 
   29 NEWSVERSION="${NEWSLINE#* }"
   30 NEWSDATE="${NEWSVERSION#* }"
   31 NEWSVERSION="${NEWSVERSION% *}"
   32 SUCCESS=1
   33 
   34 if [ "$NEWSVERSION" != "$EXPVERSION" ]; then
   35     echo "Read NEWS version '$NEWSVERSION' doesn't match expected version '$EXPVERSION'" 1>&2
   36     SUCCESS=0
   37 fi
   38 
   39 if [ "$NEWSDATE" != "$EXPDATE" ]; then
   40     echo "Read NEWS date '$NEWSDATE' doesn't match expected date '$EXPDATE'" 1>&2
   41     SUCCESS=0
   42 fi
   43 
   44 if [ "$SUCCESS" != "1" ]; then
   45     if [ "$SKIP_NEWS_FILE_TEST" = "1" ]; then
   46         echo "" 1>&2
   47         echo "****************************************************************" 1>&2
   48         echo "*  Failed NEWS file test ignored due to SKIP_NEWS_FILE_TEST=1  *" 1>&2
   49         echo "****************************************************************" 1>&2
   50         echo "" 1>&2
   51         exit 0
   52     else
   53         echo "(This test can be skipped when SKIP_NEWS_FILE_TEST=1 is set.)" 1>&2
   54     fi
   55     exit 1
   56 fi