diff --git a/library/README.txt b/library/README.txt index e69de29..d2fb250 100644 --- a/library/README.txt +++ b/library/README.txt @@ -0,0 +1,2 @@ +Learn more: https://shop.pimoroni.com/products/rainbow-hat-for-android-things + diff --git a/library/rainbowhat/buzzer.py b/library/rainbowhat/buzzer.py index 5be685b..59d6768 100644 --- a/library/rainbowhat/buzzer.py +++ b/library/rainbowhat/buzzer.py @@ -49,11 +49,11 @@ def note(frequency, duration=1.0): _timeout.start() def midi_note(note_number, duration=1.0): - """Play a single note by midi note number. + """Play a single note by MIDI note number. - Converts a midi note number into a frequency and plays it. A5 is 69. + Converts a MIDI note number into a frequency and plays it. A5 is 69. - :param note_number: Midi note number of note + :param note_number: MIDI note number of note :param duration: Optional duration in seconds, use None to sustain note """ diff --git a/packaging/debian/README b/packaging/debian/README index e184304..59e3174 100644 --- a/packaging/debian/README +++ b/packaging/debian/README @@ -1,6 +1,6 @@ README -Rainbow HAT is fun and flexible with plenty of scope for interesting projects. +Rainbow HAT is ideal for exploring protocols and devices on the Raspberry Pi. It features displays, sensors, sound, and LEDs - plenty of scope for interesting projects! -Learn more: https://shop.pimoroni.com/products/rainbow-hat -For examples run: `curl -sS get.pimoroni.com/rainbowhat | bash` +Learn more: https://shop.pimoroni.com/products/rainbow-hat-for-android-things +For examples run: `curl -sS https://get.pimoroni.com/rainbowhat | bash` diff --git a/packaging/debian/control b/packaging/debian/control index ccdbc6a..0ebe1da 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -11,8 +11,8 @@ X-Python3-Version: >= 3.4 Package: python-rainbowhat Architecture: all Section: python -Depends: ${misc:Depends}, ${python:Depends} -Suggests: +Depends: ${misc:Depends}, ${python:Depends}, python-rpi.gpio, python-smbus +Suggests: python-numpy Description: python library designed to control Rainbow HAT Ideal for exploring protocols and devices on the Raspberry Pi. . @@ -21,8 +21,8 @@ Description: python library designed to control Rainbow HAT Package: python3-rainbowhat Architecture: all Section: python -Depends: ${misc:Depends}, ${python3:Depends} -Suggests: +Depends: ${misc:Depends}, ${python3:Depends}, python3-rpi.gpio, python3-smbus +Suggests: python3-numpy Description: python library designed to control Rainbow HAT Ideal for explorer protocols and devices on the Raspberry Pi. . diff --git a/packaging/makeall.sh b/packaging/makeall.sh index b524052..a1b4596 100755 --- a/packaging/makeall.sh +++ b/packaging/makeall.sh @@ -4,6 +4,10 @@ reponame="" # leave this blank for auto-detection libname="" # leave this blank for auto-detection +packagename="" # leave this blank for auto-selection + +rpigpio="yes" # set to 'no' to turn off warning +smbus="yes" # set to 'no' to turn off warning debianlog="debian/changelog" debcontrol="debian/control" @@ -51,15 +55,21 @@ if [ -z "$reponame" ]; then 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) - cd "$debdir" + 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 @@ -82,11 +92,11 @@ fi inform "checking debian/copyright file..." -if ! grep "^Source" $debcopyright | grep "$libname" $debcopyright &> /dev/null; then +if ! grep "^Source" $debcopyright | grep "$reponame" &> /dev/null; then warning "$(grep "^Source" $debcopyright)" && FLAG=true fi -if ! grep "^Upstream-Name" $debcopyright | grep "$libname" $debcopyright &> /dev/null; then +if ! grep "^Upstream-Name" $debcopyright | grep "$libname" &> /dev/null; then warning "$(grep "^Upstream-Name" $debcopyright)" && FLAG=true fi @@ -94,19 +104,19 @@ fi inform "checking debian/control file..." -if ! grep "^Source" $debcontrol | grep "$libname" $debcontrol &> /dev/null; then +if ! grep "^Source" $debcontrol | grep "$libname" &> /dev/null; then warning "$(grep "^Source" $debcontrol)" && FLAG=true fi -if ! grep "^Homepage" $debcontrol | grep "$reponame" $debcontrol &> /dev/null; then +if ! grep "^Homepage" $debcontrol | grep "$reponame" &> /dev/null; then warning "$(grep "^Homepage" $debcontrol)" && FLAG=true fi -if ! grep "^Package: python-$libname" $debcontrol &> /dev/null; then +if ! grep "^Package: python-$packagename" $debcontrol &> /dev/null; then warning "$(grep "^Package: python-" $debcontrol)" && FLAG=true fi -if ! grep "^Package: python3-$libname" $debcontrol &> /dev/null; then +if ! grep "^Package: python3-$packagename" $debcontrol &> /dev/null; then warning "$(grep "^Package: python3-" $debcontrol)" && FLAG=true fi @@ -114,16 +124,23 @@ if ! grep "^Priority: extra" $debcontrol &> /dev/null; then warning "$(grep "^Priority" $debcontrol)" && FLAG=true fi +if [ $rpigpio == "yes" ] && ! grep "rpi.gpio" $debcontrol &> /dev/null; then + warning "if this library does not depend on rpi.gpio change 'rpigpio' variable!" && FLAG=true +fi + +if [ $smbus == "yes" ] && ! grep "smbus" $debcontrol &> /dev/null; then + warning "if this library does not depend on smbus change the 'smbus' variable!" && FLAG=true +fi # checking debian/rules file inform "checking debian/rules file..." -if ! grep "debian/python-$libname" $debrules &> /dev/null; then +if ! grep "debian/python-$packagename" $debrules &> /dev/null; then warning "$(grep "debian/python-" $debrules)" && FLAG=true fi -if ! grep "debian/python3-$libname" $debrules &> /dev/null; then +if ! grep "debian/python3-$packagename" $debrules &> /dev/null; then warning "$(grep "debian/python3-" $debrules)" && FLAG=true fi diff --git a/packaging/makelog.sh b/packaging/makelog.sh index ec63074..1055987 100755 --- a/packaging/makelog.sh +++ b/packaging/makelog.sh @@ -1,12 +1,41 @@ #!/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 @@ -15,4 +44,39 @@ sed -e "/--/d" -e "s/ \*/\*/" \ -e '/[0-9].[0-9].[0-9]/ a\ -----' $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