[augeas-devel] Augeas on OSX

Rizwan Kassim rizwank at geekymedia.com
Fri May 23 04:19:33 UTC 2008


>> It's not a tough
>> task, just some script changes and some sussing out of different OSX
>> library methods that I'm not familiar with. Right now I'm hung up on
>> errors requiring argz.h, will try to look at those later this week.
>
> Yeah, I have a few glibc'isms throughout the code; is argz the only one
> that's biting you ? Does OS X's C library e.g. support open_memstream ?

Afaik, yes. The initial issues seem to be things that are GNU
extensions that BSD/OSX don't like. Support for "strndup" for
instance.

(Ideally, i'd like to get this working out of the box, without
resorting to using Fink/MacPorts to make them 'compatible'. Those
packages can provide the libraries as needed, but might as well make
the trunk work on OSX directly =).

Fixed the strndup issue with some code from the gentoo project. It
appears to be safe to use, license wise.
(http://bugs.gentoo.org/show_bug.cgi?id=105858)

diff -r 38c46290bfc5 configure.ac
--- a/configure.ac	Thu May 22 13:18:50 2008 -0700
+++ b/configure.ac	Thu May 22 21:18:48 2008 -0700
@@ -16,6 +16,8 @@

 AUGEAS_CHECK_READLINE

+AC_CHECK_FUNCS(strndup)
+
 AC_OUTPUT(Makefile
           src/Makefile
           man/Makefile
diff -r 38c46290bfc5 src/augeas.c
--- a/src/augeas.c	Thu May 22 13:18:50 2008 -0700
+++ b/src/augeas.c	Thu May 22 21:18:48 2008 -0700
@@ -28,6 +28,7 @@

 #include <fnmatch.h>
 #include <argz.h>
+#include "strutils.h"

 /* We always have a toplevel entry for P_ROOT */
 #define P_ROOT   "augeas"
diff -r 38c46290bfc5 src/fa.h
--- a/src/fa.h	Thu May 22 13:18:50 2008 -0700
+++ b/src/fa.h	Thu May 22 21:18:48 2008 -0700
@@ -184,6 +184,9 @@
 int fa_as_regexp(fa_t fa, char **regexp);
 #endif

+#ifndef REG_NOERROR
+#define REG_NOERROR 0
+#endif

 /*
  * Local variables:
diff -r 38c46290bfc5 src/strutils.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/strutils.c	Thu May 22 21:18:48 2008 -0700
@@ -0,0 +1,29 @@
+/*
+   Copyright (C) 2005 Gentoo Foundation
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/* string utilities that may be missing on various platforms */
+
+#include "strutils.h"
+
+#ifndef HAVE_STRNDUP
+char* strndup(const char* s, size_t n) {
+	char* ret = malloc(n + 1);
+	if (ret == NULL) return(ret);
+	ret[n] = '\0';
+	return(memcpy(ret, s, n));
+}
+#endif
diff -r 38c46290bfc5 src/strutils.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/strutils.h	Thu May 22 21:18:48 2008 -0700
@@ -0,0 +1,31 @@
+/*
+   Copyright (C) 2005 Gentoo Foundation
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/* string utilities that may be missing on various platforms */
+
+#ifndef _HEADER_STRUTIL
+#define _HEADER_STRUTIL 1
+
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
+
+#ifndef HAVE_STRNDUP
+char* strndup(const char* s, size_t n);
+#endif
+
+#endif

>
> For some of these, it might be good to just pull in gnulib (as long as
> the corresponding module is LGPL)
>
>> I do have a patch to autogen.sh
>
> Cool .. I committed that.
>
> David
>
>
>



-- 
Rizwan Kassim
Software and Systems Engineer, uWink Interactive Bistro
http://www.geekymedia.com

If there is any great secret of success in life, it lies in the
ability to put yourself in the other's place and to see things from
his point of view -- as well as your own.
-- Henry Ford




More information about the augeas-devel mailing list