|
1 | 1 | #!/bin/bash |
2 | 2 |
|
| 3 | +# script control variables |
| 4 | + |
| 5 | +libname="" # leave this blank for auto-detection |
| 6 | +vlibwarn="yes" |
| 7 | + |
| 8 | +debdir="$(pwd)" |
| 9 | +rootdir="$(dirname $debdir)" |
| 10 | +libdir="$rootdir/library" |
| 11 | + |
3 | 12 | mainlog="CHANGELOG" |
4 | 13 | debianlog="debian/changelog" |
5 | | -pypilog="../library/CHANGELOG.txt" |
| 14 | +pypilog="$libdir/CHANGELOG.txt" |
| 15 | + |
| 16 | +# function define |
| 17 | + |
| 18 | +success() { |
| 19 | + echo "$(tput setaf 2)$1$(tput sgr0)" |
| 20 | +} |
| 21 | + |
| 22 | +inform() { |
| 23 | + echo "$(tput setaf 6)$1$(tput sgr0)" |
| 24 | +} |
| 25 | + |
| 26 | +warning() { |
| 27 | + echo "$(tput setaf 1)$1$(tput sgr0)" |
| 28 | +} |
| 29 | + |
| 30 | +newline() { |
| 31 | + echo "" |
| 32 | +} |
6 | 33 |
|
7 | 34 | # generate debian changelog |
8 | 35 |
|
9 | 36 | cat $mainlog > $debianlog |
| 37 | +inform "seeded debian changelog" |
10 | 38 |
|
11 | 39 | # generate pypi changelog |
12 | 40 |
|
13 | 41 | sed -e "/--/d" -e "s/ \*/\*/" \ |
14 | 42 | -e "s/.*\([0-9].[0-9].[0-9]\).*/\1/" \ |
15 | 43 | -e '/[0-9].[0-9].[0-9]/ a\ |
16 | | - -----' $mainlog | cat -s > $pypilog |
| 44 | +-----' $mainlog | cat -s > $pypilog |
| 45 | + |
| 46 | +version=$(head -n 1 $pypilog) |
| 47 | +inform "pypi changelog generated" |
| 48 | + |
| 49 | +# touch up version in setup.py file |
| 50 | + |
| 51 | +if [ -n $(grep version "$libdir/setup.py" &> /dev/null) ]; then |
| 52 | + inform "touched up version in setup.py" |
| 53 | + sed -i "s/[0-9].[0-9].[0-9]/$version/" "$libdir/setup.py" |
| 54 | +else |
| 55 | + warning "couldn't touch up version in setup, no match found" |
| 56 | +fi |
| 57 | + |
| 58 | +# touch up version in lib |
| 59 | + |
| 60 | +if [ -z "$libname" ]; then |
| 61 | + cd "$libdir" |
| 62 | + libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev) |
| 63 | + libname=$(echo "$libname" | tr "[A-Z]" "[a-z]") && cd "$debdir" |
| 64 | +fi |
| 65 | + |
| 66 | +if grep -e "__version__" "$libdir/$libname.py" &> /dev/null; then |
| 67 | + sed -i "s/__version__ = '[0-9].[0-9].[0-9]/__version__ = '$version/" "$libdir/$libname.py" |
| 68 | + inform "touched up version in $(basename $libdir/$libname.py)" |
| 69 | +elif grep -e "__version__" "$libdir/$libname/__init__.py" &> /dev/null; then |
| 70 | + sed -i "s/__version__ = '[0-9].[0-9].[0-9]/__version__ = '$version/" "$libdir/$libname/__init__.py" |
| 71 | + inform "touched up version in $(basename $libdir/$libname/__init__.py)" |
| 72 | +elif [ "$vlibwarn" == "yes" ]; then |
| 73 | + warning "couldn't touch up __version__ in lib, no match found" |
| 74 | +fi |
17 | 75 |
|
18 | 76 | exit 0 |
0 commit comments