diff --git a/package/bluez-osmc/Makefile b/package/bluez-osmc/Makefile new file mode 100644 index 000000000000..9d1953a678ae --- /dev/null +++ b/package/bluez-osmc/Makefile @@ -0,0 +1,23 @@ +all: + @echo "Specify a target:\nmake trans\nmake armv6l\nmake armv7\nmake i386\n" + +trans: + sudo bash build.sh "trans" + +armv6l: + sudo bash build.sh "armv6l" + +armv7: + sudo bash build.sh "armv7" + +i386: + sudo setarch i686 bash build.sh "i386" + +amd64: + sudo bash build.sh "amd64" + +clean: + sudo rm -f *.deb > /dev/null 2>&1 + sudo rm -rf files/usr > /dev/null 2>&1 + sudo rm -rf files/lib > /dev/null 2>&1 + sudo rm -rf files/etc > /dev/null 2>&1 diff --git a/package/bluez-osmc/build.sh b/package/bluez-osmc/build.sh new file mode 100755 index 000000000000..5c8592811a03 --- /dev/null +++ b/package/bluez-osmc/build.sh @@ -0,0 +1,59 @@ +# (c) 2014-2015 Sam Nazarko +# email@samnazarko.co.uk + +#!/bin/bash + +. ../common.sh + +if [ "$1" == "trans" ] +then + echo -e "Building transitional package" + dpkg_build files-trans ${1}-bluez-osmc.deb + exit 0 +fi + +VERSION="5.38" +pull_source "https://www.kernel.org/pub/linux/bluetooth/bluez-${VERSION}.tar.xz" "$(pwd)/src" +if [ $? != 0 ]; then echo -e "Error fetching connman source" && exit 1; fi +# Build in native environment +build_in_env "${1}" $(pwd) "bluez-osmc" +build_return=$? +if [ $build_return == 99 ] +then + echo -e "Building package bluez" + out=$(pwd)/files + make clean + update_sources + handle_dep "autoconf" + handle_dep "automake" + handle_dep "autopoint" + handle_dep "autotools-dev" + handle_dep "gettext" + handle_dep "libbison-dev" + handle_dep "libcap-ng-dev" + handle_dep "libdbus-1-dev" + handle_dep "libdbus-glib-1-dev" + handle_dep "libglib2.0-dev" + handle_dep "libical-dev" + handle_dep "python-dev" + handle_dep "libreadline-dev" + handle_dep "${1}-libsqlite-dev-osmc" + handle_dep "libudev-dev" + handle_dep "pkg-config" + sed '/Package/d' -i files/DEBIAN/control + echo "Package: ${1}-bluez-osmc" >> files/DEBIAN/control + pushd src/bluez-$VERSION + install_patch "../../patches" "all" + ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var + if [ $? != 0 ]; then echo -e "Configure failed!" && umount /proc/ > /dev/null 2>&1 && exit 1; fi + $BUILD + if [ $? != 0 ]; then echo -e "Build failed!" && exit 1; fi + make install DESTDIR=${out} + popd + strip_files "${out}" + fix_arch_ctl "files/DEBIAN/control" + dpkg_build files/ ${1}-bluez-osmc.deb + build_return=$? +fi +teardown_env "${1}" +exit $build_return diff --git a/package/bluez-osmc/files-trans/DEBIAN/control b/package/bluez-osmc/files-trans/DEBIAN/control new file mode 100644 index 000000000000..660566302802 --- /dev/null +++ b/package/bluez-osmc/files-trans/DEBIAN/control @@ -0,0 +1,9 @@ +Package: bluez +Origin: OSMC +Version: 5.23-3 +Section: utils +Essential: No +Priority: optional +Maintainer: Sam G Nazarko +Description: bluez transitional package for OSMC +Architecture: all diff --git a/package/bluez-osmc/files-trans/DEBIAN/debian-binary b/package/bluez-osmc/files-trans/DEBIAN/debian-binary new file mode 100644 index 000000000000..cd5ac039d67e --- /dev/null +++ b/package/bluez-osmc/files-trans/DEBIAN/debian-binary @@ -0,0 +1 @@ +2.0 diff --git a/package/bluez-osmc/files/DEBIAN/control b/package/bluez-osmc/files/DEBIAN/control new file mode 100644 index 000000000000..c15dd5c2bb5a --- /dev/null +++ b/package/bluez-osmc/files/DEBIAN/control @@ -0,0 +1,10 @@ +Origin: OSMC +Version: 5.3.8-1 +Section: utils +Essential: No +Priority: optional +Maintainer: Sam G Nazarko +Description: bluez for OSMC +Depends: dbus, kmod, libdbus-1-3, libglib2.0-0, libreadlne6, libudev1 +Replaces: bluez (<< 5.28.2~) +Breaks: bluez (<< 5.28.2~) diff --git a/package/bluez-osmc/files/DEBIAN/debian-binary b/package/bluez-osmc/files/DEBIAN/debian-binary new file mode 100644 index 000000000000..cd5ac039d67e --- /dev/null +++ b/package/bluez-osmc/files/DEBIAN/debian-binary @@ -0,0 +1 @@ +2.0 diff --git a/package/bluez-osmc/files/DEBIAN/postinst b/package/bluez-osmc/files/DEBIAN/postinst new file mode 100755 index 000000000000..5af2351f12b2 --- /dev/null +++ b/package/bluez-osmc/files/DEBIAN/postinst @@ -0,0 +1,22 @@ +#!/bin/bash + +remove_divert () +{ + if dpkg-divert --listpackage "$2" | grep -q "$DPKG_MAINTSCRIPT_PACKAGE"; then + dpkg-divert --remove --package "$DPKG_MAINTSCRIPT_PACKAGE" --rename --divert "$1" "$2" + EXIT=$?; if [ $EXIT -ne 0 ]; then exit $EXIT; fi + fi +} + +if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then exit 1; fi +if [ "$1" = "configure" ]; then + + # remove only diverts that prior versions of this package added which are no longer needed: + # remove_divert PATH_DIV PATH_ORIG + + systemctl daemon-reload + systemctl enable bluez.service >/dev/null 2>&1 + + if ischroot; then exit 0; fi + systemctl restart bluez.service +fi diff --git a/package/bluez-osmc/files/DEBIAN/postrm b/package/bluez-osmc/files/DEBIAN/postrm new file mode 100755 index 000000000000..c66e81731121 --- /dev/null +++ b/package/bluez-osmc/files/DEBIAN/postrm @@ -0,0 +1,16 @@ +#!/bin/bash + +remove_divert () +{ + if dpkg-divert --listpackage "$2" | grep -q "$DPKG_MAINTSCRIPT_PACKAGE"; then + dpkg-divert --remove --package "$DPKG_MAINTSCRIPT_PACKAGE" --rename --divert "$1" "$2" + EXIT=$?; if [ $EXIT -ne 0 ]; then exit $EXIT; fi + fi +} + +if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then exit 1; fi +#if [ "$1" = "remove" ]; then + + # remove all diverts that this version _and_ all prior versions of the package once added: + # remove_divert PATH_DIV PATH_ORIG +#fi diff --git a/package/bluez-osmc/files/DEBIAN/preinst b/package/bluez-osmc/files/DEBIAN/preinst new file mode 100755 index 000000000000..1c5a0b0507f4 --- /dev/null +++ b/package/bluez-osmc/files/DEBIAN/preinst @@ -0,0 +1,20 @@ +#!/bin/bash + +install_divert () +{ + if ! dpkg-divert --listpackage "$2" | grep -q "$DPKG_MAINTSCRIPT_PACKAGE"; then + dpkg-divert --add --package "$DPKG_MAINTSCRIPT_PACKAGE" --rename --divert "$1" "$2" + EXIT=$?; if [ $EXIT -ne 0 ]; then exit $EXIT; fi + fi +} + +if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then exit 1; fi +if [ "$1" = "upgrade" ]; then touch "/var/run/${DPKG_MAINTSCRIPT_PACKAGE}_upgrade"; else rm -f "/var/run/${DPKG_MAINTSCRIPT_PACKAGE}_upgrade"; fi +if [ "$1" = "install" -o "$1" = "upgrade" ]; then + + # install all diverts needed by this version of the package: + # install_divert PATH_DIV PATH_ORIG + + systemctl stop bluez.service >/dev/null 2>&1 + exit 0 +fi diff --git a/package/bluez-osmc/files/DEBIAN/prerm b/package/bluez-osmc/files/DEBIAN/prerm new file mode 100755 index 000000000000..8aea5877322d --- /dev/null +++ b/package/bluez-osmc/files/DEBIAN/prerm @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ "$1" = "remove" ]; then + systemctl disable bluez.service >/dev/null 2>&1 + systemctl stop bluez.service >/dev/null 2>&1 + exit 0 +fi diff --git a/package/bluez-osmc/patches/all-001-add-bcm43xx-3wire-variant.patch b/package/bluez-osmc/patches/all-001-add-bcm43xx-3wire-variant.patch new file mode 100644 index 000000000000..0d03da48ee59 --- /dev/null +++ b/package/bluez-osmc/patches/all-001-add-bcm43xx-3wire-variant.patch @@ -0,0 +1,27 @@ +From 9e530065e466f423c8f0efbf0ed88aaac52a6f2a Mon Sep 17 00:00:00 2001 +From: Phil Elwell +Date: Tue, 16 Feb 2016 16:40:46 +0000 +Subject: [PATCH 1/4] bcm43xx: Add bcm43xx-3wire variant + +--- + tools/hciattach.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/tools/hciattach.c b/tools/hciattach.c +index 59a76a7..5861d33 100644 +--- a/tools/hciattach.c ++++ b/tools/hciattach.c +@@ -1144,6 +1144,9 @@ struct uart_t uart[] = { + { "bcm43xx", 0x0000, 0x0000, HCI_UART_H4, 115200, 3000000, + FLOW_CTL, DISABLE_PM, NULL, bcm43xx, NULL }, + ++ { "bcm43xx-3wire", 0x0000, 0x0000, HCI_UART_3WIRE, 115200, 3000000, ++ 0, DISABLE_PM, NULL, bcm43xx, NULL }, ++ + { "ath3k", 0x0000, 0x0000, HCI_UART_ATH3K, 115200, 115200, + FLOW_CTL, DISABLE_PM, NULL, ath3k_ps, ath3k_pm }, + +-- +2.1.4 + + diff --git a/package/bluez-osmc/patches/all-002-reset-uart-speed-after-fw-dl.patch b/package/bluez-osmc/patches/all-002-reset-uart-speed-after-fw-dl.patch new file mode 100644 index 000000000000..23e387754116 --- /dev/null +++ b/package/bluez-osmc/patches/all-002-reset-uart-speed-after-fw-dl.patch @@ -0,0 +1,39 @@ +From e22b98809f8f28fd1ab47be247f1549295e430bc Mon Sep 17 00:00:00 2001 +From: Phil Elwell +Date: Tue, 16 Feb 2016 16:39:09 +0000 +Subject: [PATCH 2/4] bcm43xx: The UART speed must be reset after the firmware + download + +--- + tools/hciattach_bcm43xx.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +diff --git a/tools/hciattach_bcm43xx.c b/tools/hciattach_bcm43xx.c +index 81f38cb..0b792e0 100644 +--- a/tools/hciattach_bcm43xx.c ++++ b/tools/hciattach_bcm43xx.c +@@ -366,11 +366,8 @@ int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti, + return -1; + + if (bcm43xx_locate_patch(FIRMWARE_DIR, chip_name, fw_path)) { +- fprintf(stderr, "Patch not found, continue anyway\n"); ++ fprintf(stderr, "Patch not found for %s, continue anyway\n", chip_name); + } else { +- if (bcm43xx_set_speed(fd, ti, speed)) +- return -1; +- + if (bcm43xx_load_firmware(fd, fw_path)) + return -1; + +@@ -380,6 +377,7 @@ int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti, + return -1; + } + ++ sleep(1); + if (bcm43xx_reset(fd)) + return -1; + } +-- +2.1.4 + + diff --git a/package/bluez-osmc/patches/all-003-increase-fw-timeout.patch b/package/bluez-osmc/patches/all-003-increase-fw-timeout.patch new file mode 100644 index 000000000000..b21ee0062a61 --- /dev/null +++ b/package/bluez-osmc/patches/all-003-increase-fw-timeout.patch @@ -0,0 +1,26 @@ +From a628ea602b58a026c35c2795d996c3668b4a0f66 Mon Sep 17 00:00:00 2001 +From: Phil Elwell +Date: Wed, 20 Jan 2016 16:00:37 +0000 +Subject: [PATCH 3/4] Increase firmware load timeout to 30s + +--- + tools/hciattach.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/hciattach.c b/tools/hciattach.c +index 5861d33..4141796 100644 +--- a/tools/hciattach.c ++++ b/tools/hciattach.c +@@ -1293,7 +1293,7 @@ int main(int argc, char *argv[]) + { + struct uart_t *u = NULL; + int detach, printpid, raw, opt, i, n, ld, err; +- int to = 10; ++ int to = 30; + int init_speed = 0; + int send_break = 0; + pid_t pid; +-- +2.1.4 + +