commit:     e9c0b253faef56c66801b34fd8e642edfcb36272
Author:     Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 13 10:53:51 2016 +0000
Commit:     Andrew Savchenko <bircoph <AT> gentoo <DOT> org>
CommitDate: Mon Jun 13 10:53:51 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e9c0b253

app-mobilephone/sobexsrv: fixes and cleanups

- Fix bug 522748: openobex >= 1.6 removed unicode <-> ascii
  conversion tools, so implement fallback using iconv -i.
- Port ebuild to EAPI 6.
- Fix multiple "make: jobserver unavailable issues".
- Properly support python script (add eclass, deps, shebang
  fixing), install sample script.

Package-Manager: portage-2.3.0_rc1
Signed-off-by: Andrew Savchenko <bircoph <AT> gentoo.org>

 .../sobexsrv/files/sobexsrv-1.0.1-openobex16.patch | 49 +++++++++++
 app-mobilephone/sobexsrv/sobexsrv-1.0.1-r1.ebuild  | 94 ++++++++++++++++++++++
 2 files changed, 143 insertions(+)

diff --git a/app-mobilephone/sobexsrv/files/sobexsrv-1.0.1-openobex16.patch 
b/app-mobilephone/sobexsrv/files/sobexsrv-1.0.1-openobex16.patch
new file mode 100644
index 0000000..57fff87
--- /dev/null
+++ b/app-mobilephone/sobexsrv/files/sobexsrv-1.0.1-openobex16.patch
@@ -0,0 +1,49 @@
+--- sobexsrv-1.0.1/src/obexsrv.c.orig  2016-06-13 01:59:28.000000000 +0300
++++ sobexsrv-1.0.1/src/obexsrv.c       2016-06-13 12:20:15.501101147 +0300
+@@ -32,6 +32,10 @@
+ #include <langinfo.h>
+ #include <assert.h>
+ 
++#if ((OPENOBEX_VERSION_MAJOR==1) && (OPENOBEX_VERSION_MINOR>=6))
++#include <string.h>
++#endif
++
+ #include "obexsrv.h"
+ #include "util.h"
+ #include "sdp.h"
+@@ -46,7 +50,8 @@
+ 
+ void UnicodeToChar(uint8_t *c, const uint8_t *uc, int size)
+ {
+-      iconv_t dsc = iconv_open(nl_langinfo(CODESET),"UTF16BE");
++      char *lang = nl_langinfo(CODESET);
++      iconv_t dsc = iconv_open(lang,"UTF16BE");
+       size_t isiz,osiz;
+       char *ip = (char*)uc;
+       char *op = (char*)c;
+@@ -54,7 +59,25 @@
+ 
+       if (iconv(dsc,&ip,&isiz,&op,&osiz) == -1) {
+               debug_printf("iconv: error %s\n", strerror(errno));
++#if ((OPENOBEX_VERSION_MAJOR==1) && (OPENOBEX_VERSION_MINOR>=6))
++              // try to convert ignoring errors
++              iconv_close(dsc);
++              debug_printf("iconv: characters that cannot be converted will 
be discarded\n");
++
++              // append "//IGNORE"
++              const char *const suf = "//IGNORE";
++              size_t len = strlen(lang);
++              char *cd = malloc(len + 9);
++              memcpy(cd, lang, len);
++              memcpy(cd+len, suf, 8);
++              cd[len+8] = '\0';
++
++              dsc = iconv_open(cd,"UTF16BE");
++              iconv(dsc,&ip,&isiz,&op,&osiz);
++              free(cd);
++#else
+               OBEX_UnicodeToChar(c,uc,size);
++#endif
+       }
+       iconv_close(dsc);
+ }

diff --git a/app-mobilephone/sobexsrv/sobexsrv-1.0.1-r1.ebuild 
b/app-mobilephone/sobexsrv/sobexsrv-1.0.1-r1.ebuild
new file mode 100644
index 0000000..a09b770
--- /dev/null
+++ b/app-mobilephone/sobexsrv/sobexsrv-1.0.1-r1.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+PYTHON_COMPAT=( python2_7 )
+
+inherit python-single-r1 toolchain-funcs user
+
+MY_P="${P/_pre/pre}"
+
+DESCRIPTION="Scripting/Secure OBEX Server (for BlueZ Linux)"
+SRC_URI="http://www.mulliner.org/bluetooth/${MY_P}.tar.gz
+                https://dev.gentoo.org/~joker/${P}-fix64.patch";
+HOMEPAGE="http://www.mulliner.org/bluetooth/sobexsrv.php";
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS="~amd64 ~ppc ~x86"
+IUSE="gtk"
+
+DEPEND="
+       dev-libs/openobex
+       net-wireless/bluez
+       gtk? ( ${PYTHON_DEPS} )"
+RDEPEND="${DEPEND}
+       gtk? (
+               ${PYTHON_DEPS}
+               >=dev-python/pygtk-2.2
+       )"
+REQUIRED_USE="
+       gtk? ( ${PYTHON_REQUIRED_USE} )"
+
+S="${WORKDIR}/${MY_P}"
+
+PATCHES=(
+       "${DISTDIR}/${P}"-fix64.patch
+       "${FILESDIR}/${P}"-openobex16.patch
+)
+
+pkg_setup() {
+       use gtk && python-single-r1_pkg_setup
+
+       enewgroup sobexsrv
+       enewuser sobexsrv -1 -1 /var/spool/sobexsrv sobexsrv
+}
+
+src_prepare() {
+       default
+
+       sed -e 's:/usr/man/man8:/usr/share/man/man8:' \
+               -e 's/install: all/install:/' \
+           -i Makefile || die
+
+       sed -e 's/^CFLAGS =/CFLAGS +=/' \
+           -e 's/^CC =/CC ?=/' \
+           -e 's/$(CC) $(CFLAGS)/$(CC) $(LDFLAGS) $(CFLAGS)/' \
+           -i src/Makefile || die
+}
+
+src_compile() {
+       tc-export CC
+       emake -C src
+}
+
+src_install() {
+       default
+       dodoc AUTHOR CONFIG SECURITY THANKS
+
+       if use gtk; then
+               python_doscript "${D}/usr/bin/sobexsrv_handler"
+               newdoc "${S}/scripts/test" sobexsrv_handler.sample_script
+       else
+               rm "${D}/usr/bin/sobexsrv_handler" || die
+       fi
+
+       newinitd "${FILESDIR}/init.d_sobexsrv" sobexsrv
+       newconfd "${FILESDIR}/conf.d_sobexsrv" sobexsrv
+
+       keepdir /var/spool/sobexsrv
+       fowners sobexsrv:sobexsrv /var/spool/sobexsrv
+}
+
+pkg_postinst() {
+       elog
+       elog "/usr/bin/sobexsrv is *NOT* installed set-uid root by"
+       elog "default. suid is required for the chroot option (-R)."
+       elog
+       elog "Execute the following commands to enable suid:"
+       elog
+       elog "chown root:sobexsrv /usr/bin/sobexsrv"
+       elog "chmod 4710 /usr/bin/sobexsrv"
+       elog
+}

Reply via email to