• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3if [ -z "$1" ]; then
4   echo "Please provide the source repo"
5   exit -1
6else
7   SRC_REPO=$1
8fi
9
10TARGET_DIR=$(realpath $(dirname "$0"))
11echo "== Updating $TARGET_DIR from $SRC_REPO =="
12
13echo
14echo "== get current rev =="
15cd $TARGET_DIR
16
17CURRENT_REV=$(cat libcups_version)
18echo "Current rev is $CURRENT_REV"
19
20echo
21echo "== create tmp dir =="
22TMP_DIR=$(mktemp -d)
23echo "Created temporary dir $TMP_DIR"
24
25echo
26echo "== clone repo =="
27cd $TMP_DIR
28
29git clone $SRC_REPO .
30
31echo
32echo "== find new stable rev =="
33NEW_REV=$(git tag -l | grep -v "release" | grep -v "b" | grep -v "rc" | sort | tail -n1)
34echo "Stable rev is $NEW_REV"
35
36if [ "$CURRENT_REV" == "$NEW_REV" ] ; then
37    echo
38    echo ">>> Rev $CURRENT_REV is already the newest stable rev"
39else
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"
70fi
71
72echo
73echo "== Cleaning up =="
74rm -f $TMP_DIFF
75rm -rf $TMP_DIR
76