[augeas-devel] [PATCH] Put the default dir for lenses into DATADIR (the real fix)

David Lutterkort dlutter at redhat.com
Mon Jul 7 23:09:30 UTC 2008


6 files changed, 98 insertions(+), 11 deletions(-)
Makefile.am              |    2 -
build/aux/move-if-change |   77 ++++++++++++++++++++++++++++++++++++++++++++++
configure.ac             |    7 ----
src/Makefile.am          |   14 ++++++++
src/internal.h           |    6 ++-
tests/Makefile.am        |    3 +


# HG changeset patch
# User David Lutterkort <dlutter at redhat.com>
# Date 1215472067 25200
# Node ID f45ac89119cd2afee7fd55f7bfc5fac29afdb520
# Parent  ef0102907692982da3d05567db1c6049e4c23e68
Put the default dir for lenses into DATADIR (the real fix)

Reworks 527:14602e2757dd in a way that actually works and conforms to the
GNU coding standards.

Most of this fix suggested by Jim Meyering, I only touched it up a little
(and no doubt introduced all the bugs).

diff -r ef0102907692 -r f45ac89119cd Makefile.am
--- a/Makefile.am	Mon Jul 07 10:46:41 2008 -0700
+++ b/Makefile.am	Mon Jul 07 16:07:47 2008 -0700
@@ -8,7 +8,7 @@
 dist_lens_DATA=$(wildcard lenses/*.aug)
 dist_lenstest_DATA=$(wildcard lenses/tests/*.aug)
 
-EXTRA_DIST=augeas.spec
+EXTRA_DIST=augeas.spec build/aux/move-if-change
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = augeas.pc
diff -r ef0102907692 -r f45ac89119cd build/aux/move-if-change
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/aux/move-if-change	Mon Jul 07 16:07:47 2008 -0700
@@ -0,0 +1,77 @@
+#!/bin/sh
+# Like mv $1 $2, but if the files are the same, just delete $1.
+# Status is zero if successful, nonzero otherwise.
+
+VERSION='2007-09-28 23:10'; # UTC
+# The definition above must lie within the first 8 lines in order
+# for the Emacs time-stamp write hook (at end) to update it.
+# If you change this file with Emacs, please let the write hook
+# do its job.  Otherwise, update this string manually.
+
+# Copyright (C) 2002-2007 Free Software Foundation, Inc.
+
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+
+usage="usage: $0 SOURCE DEST"
+
+help="$usage
+  or:  $0 OPTION
+If SOURCE is different than DEST, then move it to DEST; else remove SOURCE.
+
+  --help     display this help and exit
+  --version  output version information and exit
+
+Report bugs to <bug-gnulib at gnu.org>."
+
+version=`expr "$VERSION" : '\([^ ]*\)'`
+version="move-if-change (gnulib) $version
+Copyright (C) 2007 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."
+
+
+for arg
+do
+  case $arg in
+    --help | --hel | --he | --h)
+      exec echo "$help" ;;
+    --version | --versio | --versi | --vers | --ver | --ve | --v)
+      exec echo "$version" ;;
+    --)
+      shift
+      break ;;
+    -*)
+      echo "$0: invalid option: $arg" >&2
+      exit 1 ;;
+    *)
+      break ;;
+  esac
+done
+
+test $# = 2 || { echo "$0: $usage" >&2; exit 1; }
+
+if test -r "$2" && cmp -s -- "$1" "$2"; then
+  rm -f -- "$1"
+else
+  mv -f -- "$1" "$2"
+fi
+
+## Local Variables:
+## eval: (add-hook 'write-file-hooks 'time-stamp)
+## time-stamp-start: "VERSION='"
+## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
+## time-stamp-time-zone: "UTC"
+## time-stamp-end: "'; # UTC"
+## End:
diff -r ef0102907692 -r f45ac89119cd configure.ac
--- a/configure.ac	Mon Jul 07 10:46:41 2008 -0700
+++ b/configure.ac	Mon Jul 07 16:07:47 2008 -0700
@@ -32,13 +32,6 @@
 
 gl_INIT
 
-dnl This is a pretty hackish way to expand all the variable references
-dnl in DATADIR. In the end, we want a full absolute path
-eval aug_lens_dir=$datadir/augeas/lenses
-eval aug_lens_dir=$aug_lens_dir
-AC_DEFINE_UNQUOTED([AUGEAS_LENS_DIR], "$aug_lens_dir",
-                   "The default location for lens definitions")
-
 AC_OUTPUT(Makefile \
           gnulib/lib/Makefile \
           gnulib/tests/Makefile \
diff -r ef0102907692 -r f45ac89119cd src/Makefile.am
--- a/src/Makefile.am	Mon Jul 07 10:46:41 2008 -0700
+++ b/src/Makefile.am	Mon Jul 07 16:07:47 2008 -0700
@@ -7,6 +7,10 @@
 AM_YFLAGS=-d -p spec_
 
 EXTRA_DIST=try augeas_sym.version
+
+BUILT_SOURCES = datadir.h
+
+DISTCLEANFILES = datadir.h
 
 lib_LTLIBRARIES = libfa.la libaugeas.la
 noinst_LTLIBRARIES = liblexer.la
@@ -33,3 +37,13 @@
 
 liblexer_la_SOURCES = lexer.l
 liblexer_la_CFLAGS = $(AM_CFLAGS) -Wno-error
+
+# Generate datadir.h. AUGEAS_LENS_DIR in internal.h depends on
+# the value of DATADIR
+internal.h: datadir.h
+
+.FORCE-datadir.h: Makefile
+	echo '#define DATADIR "$(abspath $(datadir))"' > datadir.h1
+	$(top_srcdir)/build/aux/move-if-change datadir.h1 datadir.h
+
+datadir.h: .FORCE-datadir.h
diff -r ef0102907692 -r f45ac89119cd src/internal.h
--- a/src/internal.h	Mon Jul 07 10:46:41 2008 -0700
+++ b/src/internal.h	Mon Jul 07 16:07:47 2008 -0700
@@ -26,6 +26,7 @@
 #define DEBUG
 
 #include "list.h"
+#include "datadir.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -37,9 +38,10 @@
 
 /*
  * Various parameters about env vars, special tree nodes etc.
- * Some of them should be turned into buildtime configurables
- *
  */
+
+/* The default location for lens definitions */
+#define AUGEAS_LENS_DIR DATADIR "/augeas/lenses"
 
 /* The env var that points to the chroot holding files we may modify.
    Mostly useful for testing */
diff -r ef0102907692 -r f45ac89119cd tests/Makefile.am
--- a/tests/Makefile.am	Mon Jul 07 10:46:41 2008 -0700
+++ b/tests/Makefile.am	Mon Jul 07 16:07:47 2008 -0700
@@ -3,7 +3,8 @@
 GNULIB= ../gnulib/lib/libgnu.la
 GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
 
-AM_CFLAGS = $(AUGEAS_CFLAGS) $(WARN_CFLAGS) $(GNULIB_CFLAGS)
+AM_CFLAGS = $(AUGEAS_CFLAGS) $(WARN_CFLAGS) $(GNULIB_CFLAGS) \
+	-I $(top_builddir)/src
 
 valgrind: fatest
 	libtool --mode=execute valgrind --quiet --leak-check=full ./fatest




More information about the augeas-devel mailing list