Give libalpm native support for both libdownload and libfetch

This should remove the need for any additional patching to run on platforms
that have libfetch available but not libdownload. It isn't the prettiest,
but we have kept our libdownload impact down to just a few files, so it can
be easily done.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2008-04-19 12:36:18 -05:00
parent 64e1dd64a4
commit 7a873a8f12
3 changed files with 41 additions and 7 deletions

View File

@ -145,20 +145,23 @@ AC_CHECK_LIB([archive], [archive_read_data], ,
AC_MSG_ERROR([libarchive is needed to compile pacman!]))
# Enable or disable usage of libdownload/libfetch
# - this is a nested check- first see if we need a library, if we do then
# check for libdownload first, then fallback to libfetch, then die
AC_MSG_CHECKING(whether to link with download library)
if test "x$internaldownload" = "xyes" ; then
AC_MSG_RESULT(yes)
AC_DEFINE([INTERNAL_DOWNLOAD], , [Use internal download library])
# Check for libdownload if it was actually requested
# Check for a download library if it was actually requested
AC_CHECK_LIB([download], [downloadParseURL], ,
AC_MSG_ERROR([libdownload is needed to compile pacman!]))
AC_CHECK_LIB([fetch], [fetchParseURL], ,
AC_MSG_ERROR([libdownload or libfetch are needed to compile with internal download support])) )
else
AC_MSG_RESULT(no)
fi
AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes")
# Checks for header files.
AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/statvfs.h sys/time.h syslog.h wchar.h])
AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE

View File

@ -24,8 +24,25 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
#if defined(INTERNAL_DOWNLOAD)
#include <download.h> /* libdownload */
#include <limits.h>
/* the following two are needed on BSD for libfetch */
#if defined(HAVE_SYS_SYSLIMITS_H)
#include <sys/syslimits.h> /* PATH_MAX */
#endif
#if defined(HAVE_SYS_PARAM_H)
#include <sys/param.h> /* MAXHOSTNAMELEN */
#endif
#if defined(HAVE_LIBDOWNLOAD)
#include <download.h>
#elif defined(HAVE_LIBFETCH)
#include <fetch.h>
#define downloadFreeURL fetchFreeURL
#define downloadLastErrCode fetchLastErrCode
#define downloadLastErrString fetchLastErrString
#define downloadParseURL fetchParseURL
#define downloadTimeout fetchTimeout
#define downloadXGet fetchXGet
#endif
/* libalpm */

View File

@ -19,8 +19,22 @@
#include "config.h"
#if defined(INTERNAL_DOWNLOAD)
/* TODO: needed for the libfetch stuff, unfortunately- we should kill it */
#include <stdio.h>
#include <limits.h>
/* the following two are needed on BSD for libfetch */
#if defined(HAVE_SYS_SYSLIMITS_H)
#include <sys/syslimits.h> /* PATH_MAX */
#endif
#if defined(HAVE_SYS_PARAM_H)
#include <sys/param.h> /* MAXHOSTNAMELEN */
#endif
#if defined(HAVE_LIBDOWNLOAD)
#include <download.h> /* downloadLastErrString */
#elif defined(HAVE_LIBFETCH)
#include <fetch.h> /* fetchLastErrString */
#define downloadLastErrString fetchLastErrString
#endif
/* libalpm */
@ -145,7 +159,7 @@ const char SYMEXPORT *alpm_strerror(int err)
return downloadLastErrString;
#else
/* obviously shouldn't get here... */
return _("libdownload error");
return _("download library error");
#endif
case PM_ERR_EXTERNAL_DOWNLOAD:
return _("error invoking external downloader");