diff --git a/python-colorzero/git/PKGBUILD b/python-colorzero/git/PKGBUILD new file mode 100644 index 00000000..785cc7e2 --- /dev/null +++ b/python-colorzero/git/PKGBUILD @@ -0,0 +1,36 @@ +# Maintainer: Christopher Arndt +# Contributor: Giampaolo Mancini + +_name=python-colorzero +_name2=${_name##python-} +pkgname=$_name-git +pkgver=46.963f1a0 +pkgrel=1 +pkgdesc='Another color manipulation library for Python' +arch=('any') +url="https://github.com/waveform80/${_name2}" +license=('BSD') +depends=('python') +makedepends=('git' 'python-setuptools') +provides=("${_name}") +conflicts=("${_name}") +source=("git://github.com/waveform80/${_name2}.git") +sha256sums=('SKIP') + +pkgver() { + cd "${srcdir}/${_name2}" + echo "$(git rev-list --count HEAD).$(git rev-parse --short HEAD)" +} + +build() { + cd "${srcdir}/${_name2}" + python setup.py build +} + +package() { + cd "${srcdir}/${_name2}" + python setup.py install --root="${pkgdir}/" --optimize=1 + install -Dm644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}" +} + +# vim:set ts=2 sw=2 et: diff --git a/python-gpiozero/default/PKGBUILD b/python-gpiozero/default/PKGBUILD new file mode 100644 index 00000000..d27ceafa --- /dev/null +++ b/python-gpiozero/default/PKGBUILD @@ -0,0 +1,31 @@ +# Maintainer: Christopher Arndt +# Contributor: Giampaolo Mancini + +pkgname=python-gpiozero +pkgver=1.4.1 +pkgrel=1 +pkgdesc='A simple interface to GPIO devices with Raspberry Pi' +arch=('any') +url="https://github.com/RPi-Distro/${pkgname}" +license=('BSD') +optdepends=( + 'python-spidev: for SPI access' + 'python-rpi.gpio: for Raspberry Pi GPIO pin access via RPi.GPIO library' +) +depends=('python-setuptools') +source=("${pkgname}-${pkgver}.tar.gz::https://github.com/RPi-Distro/${pkgname}/archive/v${pkgver}.tar.gz") +sha256sums=('d2d7ef04487ac5271c0ff565877ce7a5c376fc05d01bff183c98aa00635af099') + + +build() { + cd "${srcdir}/${pkgname}-${pkgver}" + python setup.py build +} + +package() { + cd "${srcdir}/${pkgname}-${pkgver}" + python setup.py install --root="${pkgdir}/" --optimize=1 + install -Dm644 LICENCE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}" +} + +# vim:set ts=2 sw=2 et: diff --git a/python-gpiozero/git/PKGBUILD b/python-gpiozero/git/PKGBUILD new file mode 100644 index 00000000..cfd5f6d8 --- /dev/null +++ b/python-gpiozero/git/PKGBUILD @@ -0,0 +1,39 @@ +# Maintainer: Christopher Arndt +# Contributor: Giampaolo Mancini + +_name=python-gpiozero +pkgname=$_name-git +pkgver=940.4aa1c16 +pkgrel=1 +pkgdesc='A simple interface to GPIO devices with Raspberry Pi' +arch=('any') +url="https://github.com/RPi-Distro/${_name}" +license=('BSD') +optdepends=( + 'python-spidev: for SPI access' + 'python-rpi.gpio: for Raspberry Pi GPIO pin access via RPi.GPIO library' +) +depends=() +makedepends=('git' 'python-setuptools') +provides=("${_name}") +conflicts=("${_name}") +source=("git://github.com/RPi-Distro/${_name}.git") +sha256sums=('SKIP') + +pkgver() { + cd "${srcdir}/${_name}" + echo "$(git rev-list --count HEAD).$(git rev-parse --short HEAD)" +} + +build() { + cd "${srcdir}/${_name}" + python setup.py build +} + +package() { + cd "${srcdir}/${_name}" + python setup.py install --root="${pkgdir}/" --optimize=1 + install -Dm644 LICENCE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}" +} + +# vim:set ts=2 sw=2 et: diff --git a/python-raspberry-gpio/default/PKGBUILD b/python-raspberry-gpio/default/PKGBUILD new file mode 100644 index 00000000..62a245bd --- /dev/null +++ b/python-raspberry-gpio/default/PKGBUILD @@ -0,0 +1,21 @@ +# Maintainer: Devaev Maxim +# Contributor: Michael Serpieri + + +pkgname="python-raspberry-gpio" +pkgver="0.6.3" +pkgrel="1" +pkgdesc="Python library for GPIO access on a Raspberry Pi" +arch=("armv6h" "armv7h" "aarch64") +url="http://sourceforge.net/projects/raspberry-gpio-python/" +license=("MIT") +depends=("python") +makedepends=("python-distribute") +source=("https://files.pythonhosted.org/packages/source/R/RPi.GPIO/RPi.GPIO-$pkgver.tar.gz") +md5sums=("e4abe1cfb5eacebe53078032256eb837") + + +package() { + cd $srcdir/RPi.GPIO-$pkgver + python setup.py install --prefix=/usr --root="$pkgdir/" --optimize=1 +} diff --git a/python-rpi.gpio/default/PKGBUILD b/python-rpi.gpio/default/PKGBUILD new file mode 100644 index 00000000..bd9e9ce4 --- /dev/null +++ b/python-rpi.gpio/default/PKGBUILD @@ -0,0 +1,35 @@ +pkgname=python-rpi.gpio +pkgver=0.6.3 +pkgrel=3 +pkgdesc="A module to control Raspberry Pi GPIO channels" +url="http://sourceforge.net/projects/raspberry-gpio-python/" +arch=('i686' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64') +license=('MIT') +depends=('python') +makedepends=('python-setuptools') +source=("https://pypi.python.org/packages/e2/58/6e1b775606da6439fa3fd1550e7f714ac62aa75e162eed29dbec684ecb3e/RPi.GPIO-0.6.3.tar.gz" + read-pin-base.patch + cpuinfo-from-devicetree.patch) +sha256sums=('a5fc0eb5e401963b6c0a03650da6b42c4005f02d962b81241d96c98d0a578516' + '72539b6246f8f6b1c792052c5d7078e3d171f0a7a3a01d81b59431fed7058fda' + '436825c6601e9ba873092d0be3d76693570e610479523abd3e9b821ff42ea83c') + +prepare () { + cd "${srcdir}/RPi.GPIO-${pkgver}" + + # https://sourceforge.net/p/raspberry-gpio-python/tickets/149/ + patch -p1 -i "${srcdir}/cpuinfo-from-devicetree.patch" + + # https://sourceforge.net/p/raspberry-gpio-python/tickets/150/ + patch -p1 -i "${srcdir}/read-pin-base.patch" +} + +build() { + cd "${srcdir}/RPi.GPIO-${pkgver}" + python setup.py build +} + +package() { + cd "${srcdir}/RPi.GPIO-${pkgver}" + python setup.py install --root=${pkgdir} --optimize=1 --skip-build +} diff --git a/python-rpi.gpio/default/cpuinfo-from-devicetree.patch b/python-rpi.gpio/default/cpuinfo-from-devicetree.patch new file mode 100644 index 00000000..0aeaaa8b --- /dev/null +++ b/python-rpi.gpio/default/cpuinfo-from-devicetree.patch @@ -0,0 +1,84 @@ +diff -r c53985209d09 source/cpuinfo.c +--- a/source/cpuinfo.c Sun Oct 30 22:41:09 2016 +0000 ++++ b/source/cpuinfo.c Wed Feb 22 17:15:44 2017 +0100 +@@ -34,6 +34,8 @@ + char *rev; + int found = 0; + int len; ++ char *line; ++ size_t linelen = 128; + + if ((fp = fopen("/proc/cpuinfo", "r")) == NULL) + return -1; +@@ -51,8 +53,70 @@ + } + fclose(fp); + +- if (!found) ++ if (!found) { ++ // We may have data from the device-tree ++ if ((fp = fopen("/proc/device-tree/compatible", "r")) != NULL) { ++ line = calloc(linelen, sizeof(char)); ++ ++ while (getdelim(&line, &linelen, '\0', fp) != -1) { ++ // Look for the board model ++ if (strstr(line, "raspberrypi,model-a")) { ++ info->type = "Model A"; ++ info->p1_revision = 2; ++ info->ram = "256M"; ++ } else if (strstr(line, "raspberrypi,model-b")) { ++ info->type = "Model B"; ++ info->p1_revision = 2; ++ info->ram = "256M"; ++ } else if (strstr(line, "raspberrypi,model-a-plus")) { ++ info->type = "Model A+"; ++ info->p1_revision = 3; ++ info->ram = "Unknown"; ++ } else if (strstr(line, "raspberrypi,model-b-plus")) { ++ info->type = "Model B+"; ++ info->p1_revision = 3; ++ info->ram = "512M"; ++ } else if (strstr(line, "raspberrypi,2-model-b")) { ++ info->type = "Pi 2 Model B"; ++ info->p1_revision = 3; ++ info->ram = "1G"; ++ } else if (strstr(line, "raspberrypi,compute-module")) { ++ info->type = "Compute"; ++ info->p1_revision = 0; ++ info->ram = "512M"; ++ } else if (strstr(line, "raspberrypi,3-model-b")) { ++ info->type = "Pi 3 Model B"; ++ info->p1_revision = 3; ++ info->ram = "1G"; ++ } else if (strstr(line, "raspberrypi,model-zero")) { ++ info->type = "Zero"; ++ info->p1_revision = 3; ++ info->ram = "512M"; ++ } else if (strstr(line, "raspberrypi,model-b-rev2")) { ++ info->type = "Model B"; ++ info->p1_revision = 2; ++ info->ram = "Unknown"; ++ } ++ ++ // Look for CPU part ++ if (strstr(line, "brcm,bcm2835")) { ++ info->processor = "BCM2835"; ++ } else if (strstr(line, "brcm,bcm2836")) { ++ info->processor = "BCM2836"; ++ } else if (strstr(line, "brcm,bcm2837")) { ++ info->processor = "BCM2837"; ++ } ++ } ++ free(line); ++ ++ info->manufacturer = "Unknown"; ++ fclose(fp); ++ ++ return 0; ++ } ++ + return -1; ++ } + + if ((len = strlen(revision)) == 0) + return -1; diff --git a/python-rpi.gpio/default/read-pin-base.patch b/python-rpi.gpio/default/read-pin-base.patch new file mode 100644 index 00000000..0e527c97 --- /dev/null +++ b/python-rpi.gpio/default/read-pin-base.patch @@ -0,0 +1,138 @@ +diff -r c53985209d09 source/event_gpio.c +--- a/source/event_gpio.c Sun Oct 30 22:41:09 2016 +0000 ++++ b/source/event_gpio.c Thu Feb 23 18:22:28 2017 +0100 +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -62,17 +63,64 @@ + int thread_running = 0; + int epfd_thread = -1; + int epfd_blocking = -1; ++int pin_base = -1; + + /************* /sys/class/gpio functions ************/ ++void gpio_find_chip_base() ++{ ++ DIR *gpio_dir; ++ struct dirent *child; ++ char label_path[128]; ++ char label[128]; ++ int fd; ++ ++ /* No need to search for it twice */ ++ if (pin_base >= 0) ++ return; ++ ++ if ((gpio_dir = opendir("/sys/class/gpio")) == NULL) { ++ pin_base = 0; ++ return; ++ } ++ ++ while ((child = readdir(gpio_dir)) != NULL) { ++ if (!strstr(child->d_name, "gpiochip")) ++ continue; ++ ++ if (snprintf(label_path, sizeof(label_path), ++ "/sys/class/gpio/%s/label", child->d_name) < 0) { ++ pin_base = 0; ++ return; ++ } ++ ++ if ((fd = open(label_path, O_RDONLY)) < 0) { ++ pin_base = 0; ++ return; ++ } ++ ++ if (read(fd, label, sizeof(label)) > 0 && ++ strstr(label, "pinctrl-bcm2835")) { ++ pin_base = atoi(child->d_name + 8); ++ break; ++ } ++ close(fd); ++ } ++ ++ if (pin_base < 0) ++ pin_base = 0; ++} ++ + int gpio_export(unsigned int gpio) + { + int fd, len; +- char str_gpio[3]; ++ char str_gpio[64]; + + if ((fd = open("/sys/class/gpio/export", O_WRONLY)) < 0) + return -1; + +- len = snprintf(str_gpio, sizeof(str_gpio), "%d", gpio); ++ gpio_find_chip_base(); ++ ++ len = snprintf(str_gpio, sizeof(str_gpio), "%d", pin_base + gpio); + write(fd, str_gpio, len); + close(fd); + +@@ -82,12 +130,14 @@ + int gpio_unexport(unsigned int gpio) + { + int fd, len; +- char str_gpio[3]; ++ char str_gpio[64]; + + if ((fd = open("/sys/class/gpio/unexport", O_WRONLY)) < 0) + return -1; + +- len = snprintf(str_gpio, sizeof(str_gpio), "%d", gpio); ++ gpio_find_chip_base(); ++ ++ len = snprintf(str_gpio, sizeof(str_gpio), "%d", pin_base + gpio); + write(fd, str_gpio, len); + close(fd); + +@@ -99,9 +149,11 @@ + int retry; + struct timespec delay; + int fd; +- char filename[33]; ++ char filename[64]; + +- snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/direction", gpio); ++ gpio_find_chip_base(); ++ ++ snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/direction", pin_base + gpio); + + // retry waiting for udev to set correct file permissions + delay.tv_sec = 0; +@@ -126,9 +178,11 @@ + int gpio_set_edge(unsigned int gpio, unsigned int edge) + { + int fd; +- char filename[28]; ++ char filename[64]; + +- snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/edge", gpio); ++ gpio_find_chip_base(); ++ ++ snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/edge", pin_base + gpio); + + if ((fd = open(filename, O_WRONLY)) < 0) + return -1; +@@ -141,10 +195,12 @@ + int open_value_file(unsigned int gpio) + { + int fd; +- char filename[29]; ++ char filename[64]; ++ ++ gpio_find_chip_base(); + + // create file descriptor of value file +- snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/value", gpio); ++ snprintf(filename, sizeof(filename), "/sys/class/gpio/gpio%d/value", pin_base + gpio); + if ((fd = open(filename, O_RDONLY | O_NONBLOCK)) < 0) + return -1; + return fd; diff --git a/python-spidev/default/PKGBUILD b/python-spidev/default/PKGBUILD new file mode 100644 index 00000000..92610170 --- /dev/null +++ b/python-spidev/default/PKGBUILD @@ -0,0 +1,23 @@ +# Maintainer: Radek Podgorny + +pkgname=python-spidev +_name=spidev +pkgver=3.2 +pkgrel=2 +pkgdesc="Python bindings for Linux SPI access through spidev" +arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64') +url="https://github.com/doceme/py-spidev" +license=('GPL') +depends=('python') +source=('https://pypi.python.org/packages/source/s/spidev/spidev-3.2.tar.gz') +md5sums=('f601676f1bb48b9aa3b3897f95216365') + +build() { + cd "$srcdir/$_name-$pkgver" + python setup.py build +} + +package() { + cd "$srcdir/$_name-$pkgver" + python setup.py install --root="$pkgdir/" --optimize=1 +}