Skip to content

Commit 4d432b7

Browse files
committed
Merge branch 'master' of github.com:pimoroni/cap1xxx
2 parents 131cca2 + a12a72b commit 4d432b7

7 files changed

Lines changed: 97 additions & 20 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ library/debian/
1818
packaging/*tar.xz
1919
pip-log.txt
2020
pip-delete-this-directory.txt
21+
.DS_Store
22+

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Cap1xxx
2+
3+
Python library for Microchip Capacitive Touch devices in the Cap1xxx family.

library/CHANGELOG.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
0.1.2
2-
-----
2+
-----
33

44
* Initial commit to Raspbian apt repository
55

66
0.1.1
7-
-----
7+
-----
88

99
* Increased delay in polling loop to avoid CPU hogging
1010

1111
0.0.2
12-
-----
12+
-----
1313

1414
* Many little bugfixes, for an actually working library
1515

library/cap1xxx.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@
88

99
import atexit
1010
import signal
11-
import sys
1211
import threading
1312
import time
13+
from sys import exit, version_info
1414

1515
try:
1616
from smbus import SMBus
1717
except ImportError:
18-
if sys.version_info[0] < 3:
18+
if version_info[0] < 3:
1919
exit("This library requires python-smbus\nInstall with: sudo apt-get install python-smbus")
20-
elif sys.version_info[0] == 3:
20+
elif version_info[0] == 3:
2121
exit("This library requires python3-smbus\nInstall with: sudo apt-get install python3-smbus")
2222

2323
try:
2424
import RPi.GPIO as GPIO
2525
except ImportError:
2626
exit("This library requires the RPi.GPIO module\nInstall with: sudo pip install RPi.GPIO")
2727

28+
__version__ = '0.1.2'
2829

2930
# DEVICE MAP
3031
DEFAULT_ADDR = 0x28

packaging/makeall.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
# script control variables
44

5-
reponame="cap1xxx" # leave this blank for auto-detection
6-
libname="cap1xxx" # leave this blank for auto-detection
5+
reponame="" # leave this blank for auto-detection
6+
libname="" # leave this blank for auto-detection
7+
packagename="" # leave this blank for auto-selection
78

89
debianlog="debian/changelog"
910
debcontrol="debian/control"
@@ -51,15 +52,21 @@ if [ -z "$reponame" ]; then
5152
repodir="$rootdir"
5253
reponame="$(basename $repodir)"
5354
fi
55+
reponame=$(echo "$reponame" | tr "[A-Z]" "[a-z]")
5456
fi
5557

5658
if [ -z "$libname" ]; then
5759
cd "$libdir"
5860
libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev)
59-
cd "$debdir"
61+
libname=$(echo "$libname" | tr "[A-Z]" "[a-z]") && cd "$debdir"
62+
fi
63+
64+
if [ -z "$packagename" ]; then
65+
packagename="$libname"
6066
fi
6167

6268
echo "reponame is $reponame and libname is $libname"
69+
echo "output packages will be python-$packagename and python3-$packagename"
6370

6471
# checking generating changelog file
6572

@@ -82,31 +89,31 @@ fi
8289

8390
inform "checking debian/copyright file..."
8491

85-
if ! grep "^Source" $debcopyright | grep "$libname" $debcopyright &> /dev/null; then
92+
if ! grep "^Source" $debcopyright | grep "$reponame" &> /dev/null; then
8693
warning "$(grep "^Source" $debcopyright)" && FLAG=true
8794
fi
8895

89-
if ! grep "^Upstream-Name" $debcopyright | grep "$libname" $debcopyright &> /dev/null; then
96+
if ! grep "^Upstream-Name" $debcopyright | grep "$libname" &> /dev/null; then
9097
warning "$(grep "^Upstream-Name" $debcopyright)" && FLAG=true
9198
fi
9299

93100
# checking debian/control file
94101

95102
inform "checking debian/control file..."
96103

97-
if ! grep "^Source" $debcontrol | grep "$libname" $debcontrol &> /dev/null; then
104+
if ! grep "^Source" $debcontrol | grep "$libname" &> /dev/null; then
98105
warning "$(grep "^Source" $debcontrol)" && FLAG=true
99106
fi
100107

101-
if ! grep "^Homepage" $debcontrol | grep "$reponame" $debcontrol &> /dev/null; then
108+
if ! grep "^Homepage" $debcontrol | grep "$reponame" &> /dev/null; then
102109
warning "$(grep "^Homepage" $debcontrol)" && FLAG=true
103110
fi
104111

105-
if ! grep "^Package: python-$libname" $debcontrol &> /dev/null; then
112+
if ! grep "^Package: python-$packagename" $debcontrol &> /dev/null; then
106113
warning "$(grep "^Package: python-" $debcontrol)" && FLAG=true
107114
fi
108115

109-
if ! grep "^Package: python3-$libname" $debcontrol &> /dev/null; then
116+
if ! grep "^Package: python3-$packagename" $debcontrol &> /dev/null; then
110117
warning "$(grep "^Package: python3-" $debcontrol)" && FLAG=true
111118
fi
112119

@@ -119,11 +126,11 @@ fi
119126

120127
inform "checking debian/rules file..."
121128

122-
if ! grep "debian/python-$libname" $debrules &> /dev/null; then
129+
if ! grep "debian/python-$packagename" $debrules &> /dev/null; then
123130
warning "$(grep "debian/python-" $debrules)" && FLAG=true
124131
fi
125132

126-
if ! grep "debian/python3-$libname" $debrules &> /dev/null; then
133+
if ! grep "debian/python3-$packagename" $debrules &> /dev/null; then
127134
warning "$(grep "debian/python3-" $debrules)" && FLAG=true
128135
fi
129136

packaging/makedeb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
gettools="yes"
3+
gettools="no"
44
setup="yes"
55
cleanup="yes"
66
pkgfiles=( "build" "changes" "deb" "dsc" "tar.xz" )

packaging/makelog.sh

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,82 @@
11
#!/bin/bash
22

3+
# script control variables
4+
5+
libname="" # leave this blank for auto-detection
6+
sibname=() # name of sibling in packages list
7+
versionwarn="yes" # set to anything but 'yes' to turn off warning
8+
9+
debdir="$(pwd)"
10+
rootdir="$(dirname $debdir)"
11+
libdir="$rootdir/library"
12+
313
mainlog="CHANGELOG"
414
debianlog="debian/changelog"
5-
pypilog="../library/CHANGELOG.txt"
15+
pypilog="$libdir/CHANGELOG.txt"
16+
17+
# function define
18+
19+
success() {
20+
echo "$(tput setaf 2)$1$(tput sgr0)"
21+
}
22+
23+
inform() {
24+
echo "$(tput setaf 6)$1$(tput sgr0)"
25+
}
26+
27+
warning() {
28+
echo "$(tput setaf 1)$1$(tput sgr0)"
29+
}
30+
31+
newline() {
32+
echo ""
33+
}
634

735
# generate debian changelog
836

937
cat $mainlog > $debianlog
38+
inform "seeded debian changelog"
1039

1140
# generate pypi changelog
1241

1342
sed -e "/--/d" -e "s/ \*/\*/" \
1443
-e "s/.*\([0-9].[0-9].[0-9]\).*/\1/" \
1544
-e '/[0-9].[0-9].[0-9]/ a\
16-
-----' $mainlog | cat -s > $pypilog
45+
-----' $mainlog | cat -s > $pypilog
46+
47+
version=$(head -n 1 $pypilog)
48+
inform "pypi changelog generated"
49+
50+
# touch up version in setup.py file
51+
52+
if [ -n $(grep version "$libdir/setup.py" &> /dev/null) ]; then
53+
inform "touched up version in setup.py"
54+
sed -i "s/'[0-9].[0-9].[0-9]'/'$version'/" "$libdir/setup.py"
55+
else
56+
warning "couldn't touch up version in setup, no match found"
57+
fi
58+
59+
# touch up version in lib or package siblings
60+
61+
if [ -z "$libname" ]; then
62+
cd "$libdir"
63+
libname=$(grep "name" setup.py | tr -d "[:space:]" | cut -c 7- | rev | cut -c 3- | rev)
64+
libname=$(echo "$libname" | tr "[A-Z]" "[a-z]") && cd "$debdir"
65+
sibname+=( "$libname" )
66+
elif [ "$libname" != "package" ]; then
67+
sibname+=( "$libname" )
68+
fi
69+
70+
for sibling in ${sibname[@]}; do
71+
if grep -e "__version__" "$libdir/$sibling.py" &> /dev/null; then
72+
sed -i "s/__version__ = '[0-9].[0-9].[0-9]'/__version__ = '$version'/" "$libdir/$sibling.py"
73+
inform "touched up version in $sibling.py"
74+
elif grep -e "__version__" "$libdir/$sibling/__init__.py" &> /dev/null; then
75+
sed -i "s/__version__ = '[0-9].[0-9].[0-9]'/__version__ = '$version'/" "$libdir/$sibling/__init__.py"
76+
inform "touched up version in $sibling/__init__.py"
77+
elif [ "$versionwarn" == "yes" ]; then
78+
warning "couldn't touch up __version__ in $sibling, no match found"
79+
fi
80+
done
1781

1882
exit 0

0 commit comments

Comments
 (0)