Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Some tunes for portable compiling.
Vsevolod Stakhov committed 11 years ago
commit b207305fb69ea32fca27ce01f2d30ce40fcb7d4f
parent 6e8ba8f
5 files changed +56 -26
modified configure.ac
@@ -86,6 +86,8 @@ AC_CHECK_HEADERS_ONCE([sys/types.h])
AC_CHECK_HEADERS_ONCE([sys/stat.h])
AC_CHECK_HEADERS_ONCE([sys/param.h])
AC_CHECK_HEADERS_ONCE([sys/mman.h])
+
AC_CHECK_HEADERS_ONCE([sys/elf_common.h])
+
AC_CHECK_HEADERS_ONCE([link.h])
AC_CHECK_HEADERS_ONCE([stdlib.h])
AC_CHECK_HEADERS_ONCE([stddef.h])
AC_CHECK_HEADERS_ONCE([stdarg.h])
@@ -100,6 +102,7 @@ AC_CHECK_HEADERS_ONCE([libgen.h])
AC_CHECK_HEADERS_ONCE([stdio.h])
AC_CHECK_HEADERS_ONCE([float.h])
AC_CHECK_HEADERS_ONCE([math.h])
+
AC_CHECK_HEADERS_ONCE([osreldate.h])

AC_CHECK_HEADER([regex.h], [
	AC_DEFINE(HAVE_REGEX_H, 1, [Define to 1 if you have the <regex.h> header file.])
@@ -172,17 +175,26 @@ AC_SEARCH_LIBS([jail_getid], [jail], [
	LIBJAIL_LIB="-ljail"
	], [])

-
AC_CHECK_HEADER([gelf.h], [
-
	AC_DEFINE(HAVE_GELF_H, 1, [Define to 1 if you have the <gelf.h> header file.])
-
	AC_CHECK_LIB(elf, gelf_getehdr, [
-
		AC_DEFINE(HAVE_LIBELF, 1, [Define to 1 if you have the 'elf' library (-lelf).])
-
		LIBELF_LIB="-lelf"
-
	])
-
], [
-
	LIBELF_LIB="\$(top_builddir)/external/libelf.la"
-
	LIBELF_BUNDLED="libelf.la"
-
	LIBELF_INCLUDE="-I\$(top_srcdir)/external/libelf"
-
])
+
LIBELF_LIB="\$(top_builddir)/external/libelf.la"
+
LIBELF_BUNDLED="libelf.la"
+
LIBELF_INCLUDE="-I\$(top_srcdir)/external/libelf"
+

+
AC_CHECK_HEADERS([gelf.h libelf.h], [
+
	AC_CHECK_TYPES([Elf_Note], [
+
		AC_DEFINE(HAVE_GELF_H, 1, [Define to 1 if you have the <gelf.h> header file.])
+
		AC_CHECK_LIB(elf, gelf_getehdr, [
+
			AC_DEFINE(HAVE_LIBELF, 1, [Define to 1 if you have the 'elf' library (-lelf).])
+
			LIBELF_LIB="-lelf"
+
			LIBELF_BUNDLED=
+
			LIBELF_INCLUDE=
+
		]) dnl AC_CHECK_LIB
+
	], dnl AC_CHECK_TYPES
+
	[], AC_LANG_SOURCE(
+
	[[
+
#include "gelf.h"
+
#include "libelf.h"
+
	]])
+
	)])

AC_CHECK_HEADER([sys/sbuf.h], [
	AC_DEFINE(HAVE_SYS_SBUF_H, 1, [Define to 1 if you have the <sys/sbuf.h> header file.])
modified libpkg/fetch.c
@@ -1,6 +1,7 @@
/*-
 * Copyright (c) 2012-2013 Baptiste Daroussin <bapt@FreeBSD.org>
 * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
+
 * Copyright (c) 2014 Vsevolod Stakhov <vsevolod@FreeBSD.org>
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
@@ -29,6 +30,7 @@
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/uio.h>
+
#include <sys/time.h>

#include <ctype.h>
#include <fcntl.h>
@@ -139,10 +141,10 @@ ssh_read(void *data, char *buf, int len)
		timeout.tv_sec += fetchTimeout;
	}

-
	deltams = INFTIM;
+
	deltams = -1;
	memset(&pfd, 0, sizeof pfd);
	pfd.fd = repo->sshio.in;
-
	pfd.events = POLLIN | POLLERR;
+
	pfd.events = POLLIN;

	for (;;) {
		rlen = read(pfd.fd, buf, len);
@@ -150,14 +152,13 @@ ssh_read(void *data, char *buf, int len)
			break;
		} else if (rlen == -1) {
			if (errno == EINTR)
-
				break;
-
			if (errno != EAGAIN) {
+
				continue;
+
			else if (errno != EAGAIN) {
				pkg_emit_errno("timeout", "ssh");
				return (-1);
			}
-
			if (errno == EAGAIN) {
+
			else if (errno == EAGAIN)
				break;
-
			}
		}

		if (fetchTimeout > 0) {
@@ -184,12 +185,13 @@ ssh_writev(int fd, struct iovec *iov, int iovcnt)
	struct pollfd pfd;
	ssize_t wlen, total;
	int deltams;
+
	struct msghdr msg;

	memset(&pfd, 0, sizeof pfd);

	if (fetchTimeout) {
		pfd.fd = fd;
-
		pfd.events = POLLOUT | POLLERR;
+
		pfd.events = POLLOUT;
		gettimeofday(&timeout, NULL);
		timeout.tv_sec += fetchTimeout;
	}
@@ -207,19 +209,26 @@ ssh_writev(int fd, struct iovec *iov, int iovcnt)
				delta.tv_usec / 1000;
			errno = 0;
			pfd.revents = 0;
-
			if (poll(&pfd, 1, deltams) < 0) {
+
			while (poll(&pfd, 1, deltams) == -1) {
+
				if (errno == EINTR)
+
					continue;
+

				return (-1);
			}
		}
		errno = 0;
-
		wlen = writev(fd, iov, iovcnt);
+
		memset(&msg, 0, sizeof(msg));
+
		msg.msg_iov = iov;
+
		msg.msg_iovlen = iovcnt;
+

+
		wlen = sendmsg(fd, &msg, 0);
		if (wlen == 0) {
-
			errno = EPIPE;
+
			errno = ECONNRESET;
			return (-1);
		}
-
		if (wlen < 0) {
+
		else if (wlen < 0)
			return (-1);
-
		}
+

		total += wlen;

		while (iovcnt > 0 && wlen >= (ssize_t)iov->iov_len) {
modified libpkg/pkg_config.c
@@ -2,6 +2,7 @@
 * Copyright (c) 2011-2014 Baptiste Daroussin <bapt@FreeBSD.org>
 * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
 * Copyright (c) 2014 Matthew Seaman <matthew@FreeBSD.org>
+
 * Copyright (c) 2014 Vsevolod Stakhov <vsevolod@FreeBSD.org>
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
@@ -26,6 +27,8 @@
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

+
#include "pkg_config.h"
+

#include <assert.h>
#include <sys/socket.h>
#include <sys/utsname.h>
@@ -37,7 +40,9 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
+
#ifdef HAVE_OSRELDATE_H
#include <osreldate.h>
+
#endif
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
@@ -61,7 +66,7 @@
#define TEXT(X)		#X
#define INDEXFILE	"INDEX-" STRINGIFY(OSMAJOR)
#else
-
#define INDEXFILE	INDEX
+
#define INDEXFILE	"INDEX"
#endif

int eventpipe = -1;
modified libpkg/pkg_elf.c
@@ -37,7 +37,7 @@
#include <machine/endian.h>
#endif
#include <sys/types.h>
-
#ifdef HAVE_LIBELF
+
#ifdef HAVE_SYS_ELF_COMMON_H
#include <sys/elf_common.h>
#endif
#include <sys/stat.h>
@@ -49,13 +49,16 @@
#include <fcntl.h>
#include <gelf.h>
#include <libgen.h>
-
#ifdef HAVE_LIBELF
+
#ifdef HAVE_LINK_H
#include <link.h>
#endif
#include <paths.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
+
#ifdef HAVE_LIBELF
+
#include <libelf.h>
+
#endif

#include "pkg.h"
#include "private/pkg.h"
modified libpkg/private/pkg.h
@@ -31,6 +31,7 @@
#define _PKG_PRIVATE_H

#include <sys/param.h>
+
#include <sys/cdefs.h>
#include <sys/sbuf.h>
#include <sys/types.h>