connman: portability patches from Alpine.

This commit is contained in:
Juan RP 2015-05-31 16:03:15 +02:00
parent fc7248fa85
commit 15bbed5455
3 changed files with 282 additions and 3 deletions

View File

@ -0,0 +1,61 @@
musl does not implement res_ninit
diff --exclude '*.*o' -ru connman-1.24.orig/gweb/gresolv.c connman-1.24/gweb/gresolv.c
--- connman-1.24.orig/gweb/gresolv.c 2014-07-18 20:17:25.000000000 -0300
+++ connman-1.24/gweb/gresolv.c 2014-07-18 20:24:01.874669130 -0300
@@ -874,8 +874,6 @@
resolv->index = index;
resolv->nameserver_list = NULL;
- res_ninit(&resolv->res);
-
return resolv;
}
@@ -915,8 +913,6 @@
flush_nameservers(resolv);
- res_nclose(&resolv->res);
-
g_free(resolv);
}
@@ -1019,24 +1015,19 @@
debug(resolv, "hostname %s", hostname);
if (!resolv->nameserver_list) {
- int i;
-
- for (i = 0; i < resolv->res.nscount; i++) {
- char buf[100];
- int family = resolv->res.nsaddr_list[i].sin_family;
- void *sa_addr = &resolv->res.nsaddr_list[i].sin_addr;
-
- if (family != AF_INET &&
- resolv->res._u._ext.nsaddrs[i]) {
- family = AF_INET6;
- sa_addr = &resolv->res._u._ext.nsaddrs[i]->sin6_addr;
+ FILE *f = fopen("/etc/resolv.conf", "r");
+ if (f) {
+ char line[256], *s;
+ int i;
+ while (fgets(line, sizeof(line), f)) {
+ if (strncmp(line, "nameserver", 10) || !isspace(line[10]))
+ continue;
+ for (s = &line[11]; isspace(s[0]); s++);
+ for (i = 0; s[i] && !isspace(s[i]); i++);
+ s[i] = 0;
+ g_resolv_add_nameserver(resolv, s, 53, 0);
}
-
- if (family != AF_INET && family != AF_INET6)
- continue;
-
- if (inet_ntop(family, sa_addr, buf, sizeof(buf)))
- g_resolv_add_nameserver(resolv, buf, 53, 0);
+ fclose(f);
}
if (!resolv->nameserver_list)

View File

@ -0,0 +1,207 @@
--- ./configure.ac.orig
+++ ./configure.ac
@@ -171,6 +171,8 @@
AM_CONDITIONAL(PPTP, test "${enable_pptp}" != "no")
AM_CONDITIONAL(PPTP_BUILTIN, test "${enable_pptp}" = "builtin")
+AC_CHECK_MEMBERS([struct in6_pktinfo.ipi6_addr], [], [], [[#include <netinet/in.h>]])
+AC_CHECK_HEADERS(execinfo.h)
AC_CHECK_HEADERS(resolv.h, dummy=yes,
AC_MSG_ERROR(resolver header files are required))
AC_CHECK_LIB(resolv, ns_initparse, dummy=yes, [
diff --git a/gdhcp/common.c b/gdhcp/common.c
index e111150..ee4dc43 100644
--- gdhcp/common.c
+++ gdhcp/common.c
@@ -22,6 +22,7 @@
#include <config.h>
#endif
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -31,7 +32,6 @@
#include <string.h>
#include <endian.h>
#include <net/if_arp.h>
-#include <linux/if.h>
#include <netpacket/packet.h>
#include <net/ethernet.h>
#include <arpa/inet.h>
@@ -39,6 +39,8 @@
#include "gdhcp.h"
#include "common.h"
+#include <linux/if.h>
+
static const DHCPOption client_options[] = {
{ OPTION_IP, 0x01 }, /* subnet-mask */
{ OPTION_IP | OPTION_LIST, 0x03 }, /* routers */
diff --git a/src/log.c b/src/log.c
index a693bd0..9054462 100644
--- src/log.c
+++ src/log.c
@@ -30,7 +30,9 @@
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
+#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
+#endif
#include <dlfcn.h>
#include "connman.h"
@@ -112,6 +114,7 @@ void connman_debug(const char *format, ...)
static void print_backtrace(unsigned int offset)
{
+#ifdef HAVE_EXECINFO_H
void *frames[99];
size_t n_ptrs;
unsigned int i;
@@ -210,6 +213,7 @@ static void print_backtrace(unsigned int offset)
close(outfd[1]);
close(infd[0]);
+#endif /* HAVE_EXECINFO_H */
}
static void signal_handler(int signo)
diff --git a/tools/dhcp-test.c b/tools/dhcp-test.c
index c34e10a..eae66fc 100644
--- tools/dhcp-test.c
+++ tools/dhcp-test.c
@@ -33,7 +33,6 @@
#include <arpa/inet.h>
#include <net/route.h>
#include <net/ethernet.h>
-#include <linux/if_arp.h>
#include <gdhcp/gdhcp.h>
--- plugins/wifi.c 2014-06-07 21:46:22.000000000 -0300
+++ plugins/wifi.c 2014-07-18 20:37:16.811343663 -0300
@@ -30,9 +30,8 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
-#include <linux/if_arp.h>
-#include <linux/wireless.h>
#include <net/ethernet.h>
+#include <linux/wireless.h>
#ifndef IFF_LOWER_UP
#define IFF_LOWER_UP 0x10000
--- src/ntp.c 2014-06-07 21:46:22.000000000 -0300
+++ src/ntp.c 2014-07-18 20:38:12.144677543 -0300
@@ -180,7 +180,7 @@
msg.xmttime.fraction = htonl(transmit_timeval.tv_usec * 1000);
len = sendto(fd, &msg, sizeof(msg), MSG_DONTWAIT,
- &addr, sizeof(addr));
+ (struct sockaddr *) &addr, sizeof(addr));
if (len < 0) {
connman_error("Time request for server %s failed (%d/%s)",
server, errno, strerror(errno));
--- src/tethering.c 2014-04-04 15:12:07.000000000 -0300
+++ src/tethering.c 2014-07-18 20:39:12.091344804 -0300
@@ -31,10 +31,8 @@
#include <stdio.h>
#include <sys/ioctl.h>
#include <net/if.h>
-#include <linux/sockios.h>
#include <string.h>
#include <fcntl.h>
-#include <linux/if_tun.h>
#include <netinet/in.h>
#include <linux/if_bridge.h>
--- tools/dnsproxy-test.c 2013-12-05 09:12:12.000000000 -0200
+++ tools/dnsproxy-test.c 2014-07-18 20:36:37.484676606 -0300
@@ -24,6 +24,7 @@
#endif
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
--- tools/private-network-test.c 2013-08-19 19:57:25.000000000 -0300
+++ tools/private-network-test.c 2014-07-18 20:28:42.644671909 -0300
@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/signalfd.h>
#include <unistd.h>
--- tools/tap-test.c 2013-12-05 09:12:12.000000000 -0200
+++ tools/tap-test.c 2014-07-18 20:28:35.351338499 -0300
@@ -29,7 +29,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
--- gweb/gresolv.c 2014-07-18 20:43:40.000000000 -0300
+++ gweb/gresolv.c 2014-07-18 20:44:43.284681413 -0300
@@ -24,6 +24,7 @@
#endif
#include <errno.h>
+#include <stdio.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
--- src/ippool.c 2014-04-04 15:12:07.000000000 -0300
+++ src/ippool.c 2014-07-18 20:44:56.068014872 -0300
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <sys/errno.h>
+#include <errno.h>
#include <sys/socket.h>
#include "connman.h"
--- src/iptables.c 2014-04-04 15:12:07.000000000 -0300
+++ src/iptables.c 2014-07-18 20:44:25.844681240 -0300
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <sys/errno.h>
+#include <errno.h>
#include <sys/socket.h>
#include <xtables.h>
--- gdhcp/common.h.orig
+++ gdhcp/common.h
@@ -18,6 +18,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <netinet/udp.h>
#include <netinet/ip.h>
@@ -170,8 +173,8 @@
[OPTION_U32] = 4,
};
-/* already defined within netinet/in.h if using GNU compiler */
-#ifndef __USE_GNU
+/* already defined within netinet/in.h if using GNU or musl libc */
+#ifndef HAVE_STRUCT_IN6_PKTINFO_IPI6_ADDR
struct in6_pktinfo {
struct in6_addr ipi6_addr; /* src/dst IPv6 address */
unsigned int ipi6_ifindex; /* send/recv interface index */

View File

@ -1,7 +1,7 @@
# Template file for 'connman' # Template file for 'connman'
pkgname=connman pkgname=connman
version=1.29 version=1.29
revision=1 revision=2
lib32disaled=yes lib32disaled=yes
build_options="systemd" build_options="systemd"
build_style=gnu-configure build_style=gnu-configure
@ -9,9 +9,9 @@ configure_args="
--enable-polkit --enable-client --enable-pie --enable-ethernet --enable-polkit --enable-client --enable-pie --enable-ethernet
--enable-wifi --enable-bluetooth --enable-loopback --enable-nmcompat --enable-wifi --enable-bluetooth --enable-loopback --enable-nmcompat
--enable-openvpn --with-openvpn=/usr/bin/openvpn --enable-openconnect --enable-openvpn --with-openvpn=/usr/bin/openvpn --enable-openconnect
--with-openconnect=/usr/sbin/openconnect --disable-tools --disable-wispr --with-openconnect=/usr/sbin/openconnect
$(vopt_if systemd --with-systemdunitdir=/usr/lib/systemd/system)" $(vopt_if systemd --with-systemdunitdir=/usr/lib/systemd/system)"
hostmakedepends="pkg-config wpa_supplicant iptables" hostmakedepends="automake libtool pkg-config wpa_supplicant iptables"
makedepends="libglib-devel dbus-devel iptables-devel gnutls-devel readline-devel" makedepends="libglib-devel dbus-devel iptables-devel gnutls-devel readline-devel"
depends="wpa_supplicant" depends="wpa_supplicant"
short_desc="Open Source CONNection MANager" short_desc="Open Source CONNection MANager"
@ -21,6 +21,17 @@ homepage="http://connman.net/"
distfiles="${KERNEL_SITE}/network/$pkgname/$pkgname-$version.tar.xz" distfiles="${KERNEL_SITE}/network/$pkgname/$pkgname-$version.tar.xz"
checksum=2a5a69693566f7fd59b2e677fa89356ada6d709998aa665caef8707b1e7a8594 checksum=2a5a69693566f7fd59b2e677fa89356ada6d709998aa665caef8707b1e7a8594
pre_configure() {
case "$XBPS_TARGET_MACHINE" in
*-musl)
for f in ${FILESDIR}/musl/*.patch; do
patch -Np1 -i $f
done
;;
*) export CFLAGS+=" -D_GNU_SOURCE";;
esac
autoreconf -fi
}
post_install() { post_install() {
# Install the client connmanctl. # Install the client connmanctl.
vbin client/connmanctl vbin client/connmanctl