-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from RogueM/commit
using sys.exit + __version__ in lib
- Loading branch information
Showing
7 changed files
with
238 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import math | ||
from itertools import tee | ||
from time import sleep | ||
from sys import exit | ||
|
||
try: | ||
import numpy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
#!/bin/bash | ||
|
||
# script control variables | ||
|
||
reponame="" # leave this blank for auto-detection | ||
libname="" # leave this blank for auto-detection | ||
packagename="" # leave this blank for auto-selection | ||
|
||
debianlog="debian/changelog" | ||
debcontrol="debian/control" | ||
debcopyright="debian/copyright" | ||
debrules="debian/rules" | ||
debreadme="debian/README" | ||
|
||
debdir="$(pwd)" | ||
rootdir="$(dirname $debdir)" | ||
libdir="$rootdir/library" | ||
|
||
FLAG=false | ||
|
||
# function define | ||
|
||
success() { | ||
echo "$(tput setaf 2)$1$(tput sgr0)" | ||
} | ||
|
||
inform() { | ||
echo "$(tput setaf 6)$1$(tput sgr0)" | ||
} | ||
|
||
warning() { | ||
echo "$(tput setaf 1)$1$(tput sgr0)" | ||
} | ||
|
||
newline() { | ||
echo "" | ||
} | ||
|
||
# assessing repo and library variables | ||
|
||
if [ -z "$reponame" ] || [ -z "$libname" ]; then | ||
inform "detecting reponame and libname..." | ||
else | ||
inform "using reponame and libname overrides" | ||
fi | ||
|
||
if [ -z "$reponame" ]; then | ||
if [[ $rootdir == *"python"* ]]; then | ||
repodir="$(dirname $rootdir)" | ||
reponame="$(basename $repodir)" | ||
else | ||
repodir="$rootdir" | ||
reponame="$(basename $repodir)" | ||
fi | ||
reponame=$(echo "$reponame" | tr "[A-Z]" "[a-z]") | ||
fi | ||
|
||
if [ -z "$libname" ]; then | ||
cd "$libdir" | ||
libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev) | ||
libname=$(echo "$libname" | tr "[A-Z]" "[a-z]") && cd "$debdir" | ||
fi | ||
|
||
if [ -z "$packagename" ]; then | ||
packagename="$libname" | ||
fi | ||
|
||
echo "reponame is $reponame and libname is $libname" | ||
echo "output packages will be python-$packagename and python3-$packagename" | ||
|
||
# checking generating changelog file | ||
|
||
./makelog.sh | ||
version=$(head -n 1 "$libdir/CHANGELOG.txt") | ||
echo "building $libname version $version" | ||
|
||
# checking debian/changelog file | ||
|
||
inform "checking debian/changelog file..." | ||
|
||
if ! head -n 1 $debianlog | grep "$libname" &> /dev/null; then | ||
warning "library not mentioned in header!" && FLAG=true | ||
elif head -n 1 $debianlog | grep "UNRELEASED"; then | ||
warning "this changelog is not going to generate a release!" | ||
warning "change distribution to 'stable'" && FLAG=true | ||
fi | ||
|
||
# checking debian/copyright file | ||
|
||
inform "checking debian/copyright file..." | ||
|
||
if ! grep "^Source" $debcopyright | grep "$reponame" &> /dev/null; then | ||
warning "$(grep "^Source" $debcopyright)" && FLAG=true | ||
fi | ||
|
||
if ! grep "^Upstream-Name" $debcopyright | grep "$libname" &> /dev/null; then | ||
warning "$(grep "^Upstream-Name" $debcopyright)" && FLAG=true | ||
fi | ||
|
||
# checking debian/control file | ||
|
||
inform "checking debian/control file..." | ||
|
||
if ! grep "^Source" $debcontrol | grep "$libname" &> /dev/null; then | ||
warning "$(grep "^Source" $debcontrol)" && FLAG=true | ||
fi | ||
|
||
if ! grep "^Homepage" $debcontrol | grep "$reponame" &> /dev/null; then | ||
warning "$(grep "^Homepage" $debcontrol)" && FLAG=true | ||
fi | ||
|
||
if ! grep "^Package: python-$packagename" $debcontrol &> /dev/null; then | ||
warning "$(grep "^Package: python-" $debcontrol)" && FLAG=true | ||
fi | ||
|
||
if ! grep "^Package: python3-$packagename" $debcontrol &> /dev/null; then | ||
warning "$(grep "^Package: python3-" $debcontrol)" && FLAG=true | ||
fi | ||
|
||
if ! grep "^Priority: extra" $debcontrol &> /dev/null; then | ||
warning "$(grep "^Priority" $debcontrol)" && FLAG=true | ||
fi | ||
|
||
|
||
# checking debian/rules file | ||
|
||
inform "checking debian/rules file..." | ||
|
||
if ! grep "debian/python-$packagename" $debrules &> /dev/null; then | ||
warning "$(grep "debian/python-" $debrules)" && FLAG=true | ||
fi | ||
|
||
if ! grep "debian/python3-$packagename" $debrules &> /dev/null; then | ||
warning "$(grep "debian/python3-" $debrules)" && FLAG=true | ||
fi | ||
|
||
# checking debian/README file | ||
|
||
inform "checking debian/readme file..." | ||
|
||
if ! grep -e "$libname" -e "$reponame" $debreadme &> /dev/null; then | ||
warning "README does not seem to mention product, repo or lib!" && FLAG=true | ||
fi | ||
|
||
# summary of checks pre build | ||
|
||
if $FLAG; then | ||
warning "Check all of the above and correct!" && exit 1 | ||
else | ||
inform "we're good to go... bulding!" | ||
fi | ||
|
||
# building deb and final checks | ||
|
||
./makedeb.sh | ||
|
||
inform "running lintian..." | ||
lintian -v $(find -name "python*$version*.deb") | ||
lintian -v $(find -name "python3*$version*.deb") | ||
|
||
inform "checking signatures..." | ||
gpg --verify $(find -name "*$version*changes") | ||
gpg --verify $(find -name "*$version*dsc") | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# script control variables | ||
|
||
libname="" # leave this blank for auto-detection | ||
sibname=() # name of sibling in packages list | ||
versionwarn="yes" # set to anything but 'yes' to turn off warning | ||
|
||
debdir="$(pwd)" | ||
rootdir="$(dirname $debdir)" | ||
libdir="$rootdir/library" | ||
|
||
mainlog="CHANGELOG" | ||
debianlog="debian/changelog" | ||
pypilog="../library/CHANGELOG.txt" | ||
pypilog="$libdir/CHANGELOG.txt" | ||
|
||
# function define | ||
|
||
success() { | ||
echo "$(tput setaf 2)$1$(tput sgr0)" | ||
} | ||
|
||
inform() { | ||
echo "$(tput setaf 6)$1$(tput sgr0)" | ||
} | ||
|
||
warning() { | ||
echo "$(tput setaf 1)$1$(tput sgr0)" | ||
} | ||
|
||
newline() { | ||
echo "" | ||
} | ||
|
||
# generate debian changelog | ||
|
||
cat $mainlog > $debianlog | ||
inform "seeded debian changelog" | ||
|
||
# generate pypi changelog | ||
|
||
sed -e "/--/d" -e "s/ \*/\*/" \ | ||
-e "s/.*\([0-9].[0-9].[0-9]\).*/\1/" \ | ||
-e '/[0-9].[0-9].[0-9]/ a\ | ||
-----' $mainlog | cat -s > $pypilog | ||
-----' $mainlog | cat -s > $pypilog | ||
|
||
version=$(head -n 1 $pypilog) | ||
inform "pypi changelog generated" | ||
|
||
# touch up version in setup.py file | ||
|
||
if [ -n $(grep version "$libdir/setup.py" &> /dev/null) ]; then | ||
inform "touched up version in setup.py" | ||
sed -i "s/'[0-9].[0-9].[0-9]'/'$version'/" "$libdir/setup.py" | ||
else | ||
warning "couldn't touch up version in setup, no match found" | ||
fi | ||
|
||
# touch up version in lib or package siblings | ||
|
||
if [ -z "$libname" ]; then | ||
cd "$libdir" | ||
libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev) | ||
libname=$(echo "$libname" | tr "[A-Z]" "[a-z]") && cd "$debdir" | ||
sibname+=( "$libname" ) | ||
elif [ "$libname" != "package" ]; then | ||
sibname+=( "$libname" ) | ||
fi | ||
|
||
for sibling in ${sibname[@]}; do | ||
if grep -e "__version__" "$libdir/$sibling.py" &> /dev/null; then | ||
sed -i "s/__version__ = '[0-9].[0-9].[0-9]'/__version__ = '$version'/" "$libdir/$sibling.py" | ||
inform "touched up version in $sibling.py" | ||
elif grep -e "__version__" "$libdir/$sibling/__init__.py" &> /dev/null; then | ||
sed -i "s/__version__ = '[0-9].[0-9].[0-9]'/__version__ = '$version'/" "$libdir/$sibling/__init__.py" | ||
inform "touched up version in $sibling/__init__.py" | ||
elif [ "$versionwarn" == "yes" ]; then | ||
warning "couldn't touch up __version__ in $sibling, no match found" | ||
fi | ||
done | ||
|
||
exit 0 |