Home | History | Annotate | Download | only in libcups
      1 #!/bin/bash
      2 
      3 if [ -z "$1" ]; then
      4    echo "Please provide the source repo"
      5    exit -1
      6 else
      7    SRC_REPO=$1
      8 fi
      9 
     10 TARGET_DIR=$(realpath $(dirname "$0"))
     11 echo "== Updating $TARGET_DIR from $SRC_REPO =="
     12 
     13 echo
     14 echo "== get current rev =="
     15 cd $TARGET_DIR
     16 
     17 CURRENT_REV=$(cat libcups_version)
     18 echo "Current rev is $CURRENT_REV"
     19 
     20 echo
     21 echo "== create tmp dir =="
     22 TMP_DIR=$(mktemp -d)
     23 echo "Created temporary dir $TMP_DIR"
     24 
     25 echo
     26 echo "== clone repo =="
     27 cd $TMP_DIR
     28 
     29 git clone $SRC_REPO .
     30 
     31 echo
     32 echo "== find new stable rev =="
     33 NEW_REV=$(git tag -l | grep -v "release" | grep -v "b" | grep -v "rc" | sort | tail -n1)
     34 echo "Stable rev is $NEW_REV"
     35 
     36 if [ "$CURRENT_REV" == "$NEW_REV" ] ; then
     37     echo
     38     echo ">>> Rev $CURRENT_REV is already the newest stable rev"
     39 else
     40     echo
     41     echo "== create diff in between rev $CURRENT_REV and rev $NEW_REV =="
     42     TMP_DIFF=$(mktemp)
     43     git diff $CURRENT_REV $NEW_REV -- cups/ filter/ LICENSE.txt > $TMP_DIFF
     44     echo "Diff in $TMP_DIFF"
     45 
     46     echo
     47     echo "== Apply diff =="
     48     cd $TARGET_DIR
     49 
     50     patch -p1 < $TMP_DIFF
     51     if [ $? -ne 0 ] ; then
     52        exit 1
     53     fi
     54 
     55     # update version numbers in config.h
     56     sed -i -e "s/^\(#.*CUPS_SVERSION\).*/\1 \"CUPS $NEW_REV\"/g" config.h
     57     sed -i -e "s:^\(#.*CUPS_MINIMAL\).*:\1 \"CUPS/${NEW_REV#v}\":g" config.h
     58 
     59     echo
     60     echo ">>> Updated license"
     61 
     62     cp LICENSE.txt NOTICE
     63 
     64     echo $NEW_REV > libcups_version
     65     git add -A
     66     git commit -m "Update libcups to $NEW_REV"
     67 
     68     echo
     69     echo ">>> Updated libcups from $CURRENT_REV to $NEW_REV"
     70 fi
     71 
     72 echo
     73 echo "== Cleaning up =="
     74 rm -f $TMP_DIFF
     75 rm -rf $TMP_DIR
     76