From 11c3a2d86a22a68c404ec711bd7b859ad123c784 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Fri, 19 Sep 2008 07:58:09 +0000 Subject: [PATCH] Support both libnl 1.0-pre6 and 1.1. Disable vip6-autod if the configure script didn't detect a usable libnl. Remove util-vserver-pl.spec.in, sync the version with configure.ac. --- Makefile.am | 9 ++-- configure.ac | 14 ++++-- src/vip6-autod.c | 14 +++++- util-vserver-pl.spec | 10 +++-- util-vserver-pl.spec.in | 96 ----------------------------------------- 5 files changed, 33 insertions(+), 110 deletions(-) delete mode 100644 util-vserver-pl.spec.in diff --git a/Makefile.am b/Makefile.am index 950d489..9ff5b2f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -43,13 +43,14 @@ sbin_SCRIPTS = python/bwlimit \ scripts/vuseradd \ scripts/vuserdel -#sbin_PROGRAMS = src/vip6-autod \ -# src/vsh sbin_PROGRAMS = src/vsh - -#sysv_SCRIPTS = sysv/vip6-autod sysv_SCRIPTS = +if ENSC_HAVE_LIBNL +sbin_PROGRAMS += src/vip6-autod +sysv_SCRIPTS += sysv/vip6-autod +endif + crondir = $(sysconfdir)/cron.d logrotatedir = $(sysconfdir)/logrotate.d diff --git a/configure.ac b/configure.ac index 2dec4a4..6af3ce3 100644 --- a/configure.ac +++ b/configure.ac @@ -24,7 +24,7 @@ dnl distribution terms that you use for the rest of that program. dnl AC_PREREQ(2.57) -AC_INIT(util-vserver-pl, 0.1, support@planet-lab.org) +AC_INIT(util-vserver-pl, 0.3.1, support@planet-lab.org) AC_CONFIG_SRCDIR([python/vserverimpl.c]) AC_CONFIG_HEADER([config.h]) @@ -35,6 +35,7 @@ AC_CANONICAL_BUILD AC_CANONICAL_HOST # Checks for programs. +AC_LANG(C) AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S @@ -105,8 +106,13 @@ if test x"$ensc_have_libnl" = xyes; then fi if test x"$ensc_have_libnl" = xyes; then - AC_CHECK_LIB(nl, nl_handle_alloc_cb, [ : ], - [ ensc_have_libnl=no ]) + AC_CHECK_LIB(nl, nl_handle_alloc_cb, [ + AC_DEFINE(HAVE_LIBNL_1_1, [], + [Define this to use the libnl 1.1 API])], + [AC_CHECK_LIB(nl, nlmsg_get_src, + [AC_DEFINE(HAVE_LIBNL_1_0, [], + [Define this to use the libnl 1.0-pre6 API])], + [ensc_have_libnl=no])]) fi if test x"$ensc_have_libnl" != xyes; then @@ -187,5 +193,5 @@ AC_SUBST(sysvdir) AC_DEFINE(_FILE_OFFSET_BITS, [64], [Use 64bit interface for filesystem operations]) -AC_CONFIG_FILES([util-vserver-pl.spec Makefile]) +AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/src/vip6-autod.c b/src/vip6-autod.c index 75055c1..ab03cf5 100644 --- a/src/vip6-autod.c +++ b/src/vip6-autod.c @@ -29,7 +29,11 @@ #include #include -#include +#if defined(HAVE_LIBNL_1_1) +# include +#elif defined(HAVE_LIBNL_1_0) +# define rtnl_addr_put rtnl_addr_free +#endif #include #include @@ -596,16 +600,22 @@ int main(int argc, char *argv[]) openlog("vip6-autod", LOG_PERROR, LOG_DAEMON); +#if defined(HAVE_LIBNL_1_1) cbs = nl_cb_alloc(NL_CB_VERBOSE); if (!cbs) { syslog(LOG_CRIT, "nl_cb_alloc: %s", strerror(errno)); exit(1); } +#elif defined(HAVE_LIBNL_1_0) + handle = nl_handle_alloc_nondefault(NL_CB_VERBOSE); + cbs = nl_handle_get_cb(handle); +#endif nl_cb_set(cbs, NL_CB_VALID, NL_CB_CUSTOM, handle_valid_msg, &map); nl_cb_set(cbs, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, handle_no_op, NULL); nl_cb_err(cbs, NL_CB_CUSTOM, handle_error_msg, &map); - +#ifdef HAVE_LIBNL_1_1 handle = nl_handle_alloc_cb(cbs); +#endif nl_disable_sequence_check(handle); nl_join_groups(handle, RTMGRP_IPV6_PREFIX|RTMGRP_IPV6_IFADDR); diff --git a/util-vserver-pl.spec b/util-vserver-pl.spec index 25c1377..e6bd226 100644 --- a/util-vserver-pl.spec +++ b/util-vserver-pl.spec @@ -4,8 +4,8 @@ %define url $URL$ %define name util-vserver-pl -%define version 0.3 -%define taglevel 13 +%define version 0.3.1 +%define taglevel 1 %define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}} @@ -28,6 +28,8 @@ URL: %(echo %{url} | cut -d ' ' -f 2) Requires: util-vserver util-vserver-core util-vserver-build util-vserver-sysv Provides: util-vserver-python = %{version}-%{release} Obsoletes: util-vserver-py32 resman +BuildRequires: libnl libnl-devel +BuildRequires: python python-devel BuildRequires: util-vserver-core util-vserver-devel BuildRequires: autoconf automake libtool @@ -96,8 +98,8 @@ rm -fr %{buildroot} /bin/vsh %{_mandir}/man8/vsh.8* -#%{_sbindir}/vip6-autod -#%{_sysconfdir}/init.d/vip6-autod +%{_sbindir}/vip6-autod +%{_sysconfdir}/init.d/vip6-autod %changelog * Wed Sep 17 2008 Faiyaz Ahmed - util-vserver-pl-0.3-13 diff --git a/util-vserver-pl.spec.in b/util-vserver-pl.spec.in deleted file mode 100644 index 9b72cbd..0000000 --- a/util-vserver-pl.spec.in +++ /dev/null @@ -1,96 +0,0 @@ -%define name util-vserver-pl -%define version @VERSION@ -%define release 1%{?pldistro:.%{pldistro}}%{?date:.%{date}} - -%define python_sitearch %( python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)" ) - -Summary: PlanetLab extensions to util-vserver -Name: %{name} -Version: %{version} -Release: %{release} -License: GPL -Group: System Environment/Base -Source0: %{name}-%{version}.tar.bz2 -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root -Requires: util-vserver util-vserver-core util-vserver-build util-vserver-sysv -Provides: util-vserver-python = %{version}-%{release} -Obsoletes: util-vserver-py32 resman -BuildRequires: util-vserver-core util-vserver-devel -BuildRequires: autoconf automake libtool - -%description -This package contains all PlanetLab extensions to util-vserver. - -%prep -%setup -q -autoreconf -fi - - -%build -%configure -make - - -%install -rm -fr %{buildroot} -make DESTDIR=%{buildroot} install - -mkdir %{buildroot}/bin -ln -s ..%{_sbindir}/vsh %{buildroot}/bin/vsh - -rm -f %{buildroot}%{python_sitearch}/vserverimpl.a -rm -f %{buildroot}%{python_sitearch}/vserverimpl.la - -# Generate file list for python package -find "%{buildroot}" -name '*.py' | { while read FILE; do - f="${FILE#%{buildroot}}" - echo "${f}" - # need to touch these files, as they are not produced on FC4 or below - touch ${FILE}c - touch ${FILE}o - echo %%ghost "${f}c" - echo %%ghost "${f}o" -done } > %name-python.list - - -%post -# add /bin/vsh to list of secure shells -if [ ! -f /etc/shells ] || ! grep -q '^/bin/vsh$' /etc/shells ; then - echo /bin/vsh >> /etc/shells -fi - - -%postun -# 0 = erase, 1 = upgrade -if [ "$1" = 0 ] ; then - perl -i -n -e 'next if /^\/bin\/vsh$/; print' /etc/shells -fi - - -%clean -rm -fr %{buildroot} - - -%files -f %name-python.list -%defattr(-,root,root,-) -%{_sbindir}/bwlimit -%{_sbindir}/disklimit -%{_sbindir}/vuseradd -%{_sbindir}/vuserdel -%{python_sitearch}/vserverimpl.so - -%{_sbindir}/vsh -/bin/vsh -%{_mandir}/man8/vsh.8* - -%{_sbindir}/vip6-autod -%{_sysconfdir}/init.d/vip6-autod - -%{_sbindir}/vcached -%{_sysconfdir}/cron.d/vcached.cron -%{_sysconfdir}/logrotate.d/vcached.logrotate - - -%changelog -* Fri Nov 30 2007 Daniel Hokka Zakrisson - 0.1-1 -- Initial release -- 2.43.0