From ae1ec1b41805d93690b1c56899f20d99ec575d10 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 20 May 2010 13:47:21 +0000 Subject: [PATCH] Add install_system_dirs makefile target. Add configure options for system and locking directories. --- Makefile.in | 8 ++++ WHATS_NEW | 2 + configure | 96 +++++++++++++++++++++++++++++++++++++++++ configure.in | 42 ++++++++++++++++++ doc/example.conf.in | 14 +++--- lib/config/defaults.h | 5 --- lib/misc/configure.h.in | 15 +++++++ make.tmpl.in | 9 ++++ man/Makefile.in | 2 +- man/lvm.8.in | 4 +- man/lvm.conf.5.in | 18 ++++---- man/vgcfgbackup.8.in | 4 +- 12 files changed, 193 insertions(+), 26 deletions(-) diff --git a/Makefile.in b/Makefile.in index cf4629db8..4601ab4fc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -78,6 +78,14 @@ DISTCLEAN_TARGETS += cscope.out check check_cluster check_local: all $(MAKE) -C test $(@) +install_system_dirs: + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_ARCHIVE_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_BACKUP_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_CACHE_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_LOCK_DIR) + $(INSTALL_ROOT_DATA) /dev/null $(DESTDIR)$(DEFAULT_CACHE_DIR)/.cache + LCOV_TRACES = libdm.info lib.info tools.info \ daemons/dmeventd.info daemons/clvmd.info CLEAN_TARGETS += $(LCOV_TRACES) diff --git a/WHATS_NEW b/WHATS_NEW index 9a77216ce..096537cda 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,7 @@ Version 2.02.66 - =============================== + Add install_system_dirs makefile target. + Add configure options for system and locking directories. Generate example.conf so default lvm.conf contents can be configured. Install lvmconf script by default. Remove unnecessary versioned dmeventd plugin symlinks. diff --git a/configure b/configure index 501db5cba..9ff2ab89c 100755 --- a/configure +++ b/configure @@ -689,6 +689,11 @@ DM_COMPAT DMEVENTD DL_LIBS DEVMAPPER +DEFAULT_LOCK_DIR +DEFAULT_CACHE_SUBDIR +DEFAULT_BACKUP_SUBDIR +DEFAULT_ARCHIVE_SUBDIR +DEFAULT_SYS_DIR DEBUG COPTIMISE_FLAG CONFDIR @@ -851,6 +856,11 @@ with_udev_prefix with_udevdir with_dmeventd_pidfile with_dmeventd_path +with_default_system_dir +with_default_archive_subdir +with_default_backup_subdir +with_default_cache_subdir +with_default_locking_dir with_interface ' ac_precious_vars='build_alias @@ -1573,6 +1583,11 @@ Optional Packages: --with-udevdir=DIR udev rules in DIR [UPREFIX/lib/udev/rules.d] --with-dmeventd-pidfile=PATH dmeventd pidfile [/var/run/dmeventd.pid] --with-dmeventd-path=PATH dmeventd path [EPREFIX/sbin/dmeventd] + --with-default-system-dir=DIR Default LVM system directory [/etc/lvm] + --with-default-archive-subdir=SUBDIR Default metadata archive subdir [archive] + --with-default-backup-subdir=SUBDIR Default metadata backup subdir [backup] + --with-default-cache-subdir=SUBDIR Default metadata cache subdir [cache] + --with-default-locking-dir=DIR Default locking directory [/var/lock/lvm] --with-interface=IFACE Choose kernel interface (ioctl) [ioctl] Some influential environment variables: @@ -15484,6 +15499,82 @@ fi fi +################################################################################ + + + +# Check whether --with-default-system-dir was given. +if test "${with_default_system_dir+set}" = set; then + withval=$with_default_system_dir; DEFAULT_SYS_DIR="$withval" +else + DEFAULT_SYS_DIR="/etc/lvm" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_SYS_DIR "$DEFAULT_SYS_DIR" +_ACEOF + + + + + +# Check whether --with-default-archive-subdir was given. +if test "${with_default_archive_subdir+set}" = set; then + withval=$with_default_archive_subdir; DEFAULT_ARCHIVE_SUBDIR="$withval" +else + DEFAULT_ARCHIVE_SUBDIR="archive" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_ARCHIVE_SUBDIR "$DEFAULT_ARCHIVE_SUBDIR" +_ACEOF + + + + + +# Check whether --with-default-backup-subdir was given. +if test "${with_default_backup_subdir+set}" = set; then + withval=$with_default_backup_subdir; DEFAULT_BACKUP_SUBDIR="$withval" +else + DEFAULT_BACKUP_SUBDIR="backup" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_BACKUP_SUBDIR "$DEFAULT_BACKUP_SUBDIR" +_ACEOF + + + + + +# Check whether --with-default-cache-subdir was given. +if test "${with_default_cache_subdir+set}" = set; then + withval=$with_default_cache_subdir; DEFAULT_CACHE_SUBDIR="$withval" +else + DEFAULT_CACHE_SUBDIR="cache" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_CACHE_SUBDIR "$DEFAULT_CACHE_SUBDIR" +_ACEOF + + + + + +# Check whether --with-default-locking-dir was given. +if test "${with_default_locking_dir+set}" = set; then + withval=$with_default_locking_dir; DEFAULT_LOCK_DIR="$withval" +else + DEFAULT_LOCK_DIR="/var/lock/lvm" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_LOCK_DIR "$DEFAULT_LOCK_DIR" +_ACEOF + + ################################################################################ { $as_echo "$as_me:$LINENO: checking for kernel interface choice" >&5 $as_echo_n "checking for kernel interface choice... " >&6; } @@ -15610,6 +15701,11 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'` + + + + + diff --git a/configure.in b/configure.in index 15b050a7d..75ebe6376 100644 --- a/configure.in +++ b/configure.in @@ -1019,6 +1019,43 @@ if test "$BUILD_DMEVENTD" = yes; then [ AC_DEFINE_UNQUOTED(DMEVENTD_PATH,"$dmeventd_prefix/sbin/dmeventd") ]) fi +################################################################################ +dnl -- various defaults +AH_TEMPLATE(DEFAULT_SYS_DIR, [Path to LVM system directory.]) +AC_ARG_WITH(default-system-dir, + [ --with-default-system-dir=DIR Default LVM system directory [[/etc/lvm]] ], + [ DEFAULT_SYS_DIR="$withval" ], + [ DEFAULT_SYS_DIR="/etc/lvm" ]) +AC_DEFINE_UNQUOTED(DEFAULT_SYS_DIR,["$DEFAULT_SYS_DIR"] ) + +AH_TEMPLATE(DEFAULT_ARCHIVE_SUBDIR, [Name of default metadata archive subdirectory.]) +AC_ARG_WITH(default-archive-subdir, + [ --with-default-archive-subdir=SUBDIR Default metadata archive subdir [[archive]] ], + [ DEFAULT_ARCHIVE_SUBDIR="$withval" ], + [ DEFAULT_ARCHIVE_SUBDIR="archive" ]) +AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE_SUBDIR,["$DEFAULT_ARCHIVE_SUBDIR"]) + +AH_TEMPLATE(DEFAULT_BACKUP_SUBDIR, [Name of default metadata backup subdirectory.]) +AC_ARG_WITH(default-backup-subdir, + [ --with-default-backup-subdir=SUBDIR Default metadata backup subdir [[backup]] ], + [ DEFAULT_BACKUP_SUBDIR="$withval" ], + [ DEFAULT_BACKUP_SUBDIR="backup" ]) +AC_DEFINE_UNQUOTED(DEFAULT_BACKUP_SUBDIR,["$DEFAULT_BACKUP_SUBDIR"] ) + +AH_TEMPLATE(DEFAULT_CACHE_SUBDIR, [Name of default metadata backup subdirectory.]) +AC_ARG_WITH(default-cache-subdir, + [ --with-default-cache-subdir=SUBDIR Default metadata cache subdir [[cache]] ], + [ DEFAULT_CACHE_SUBDIR="$withval" ], + [ DEFAULT_CACHE_SUBDIR="cache" ]) +AC_DEFINE_UNQUOTED(DEFAULT_CACHE_SUBDIR,["$DEFAULT_CACHE_SUBDIR"] ) + +AH_TEMPLATE(DEFAULT_LOCK_DIR, [Name of default locking directory.]) +AC_ARG_WITH(default-locking-dir, + [ --with-default-locking-dir=DIR Default locking directory [[/var/lock/lvm]] ], + [ DEFAULT_LOCK_DIR="$withval" ], + [ DEFAULT_LOCK_DIR="/var/lock/lvm" ]) +AC_DEFINE_UNQUOTED(DEFAULT_LOCK_DIR,["$DEFAULT_LOCK_DIR"] ) + ################################################################################ dnl -- which kernel interface to use (ioctl only) AC_MSG_CHECKING(for kernel interface choice) @@ -1075,6 +1112,11 @@ AC_SUBST(CPG_CFLAGS) AC_SUBST(CPG_LIBS) AC_SUBST(CSCOPE_CMD) AC_SUBST(DEBUG) +AC_SUBST(DEFAULT_SYS_DIR) +AC_SUBST(DEFAULT_ARCHIVE_SUBDIR) +AC_SUBST(DEFAULT_BACKUP_SUBDIR) +AC_SUBST(DEFAULT_CACHE_SUBDIR) +AC_SUBST(DEFAULT_LOCK_DIR) AC_SUBST(DEVMAPPER) AC_SUBST(DLM_CFLAGS) AC_SUBST(DLM_LIBS) diff --git a/doc/example.conf.in b/doc/example.conf.in index 3bc86fa3a..531857128 100644 --- a/doc/example.conf.in +++ b/doc/example.conf.in @@ -1,10 +1,10 @@ # This is an example configuration file for the LVM2 system. # It contains the default settings that would be used if there was no -# /etc/lvm/lvm.conf file. +# @DEFAULT_SYS_DIR@/lvm.conf file. # # Refer to 'man lvm.conf' for further information including the file layout. # -# To put this file in a different directory and override /etc/lvm set +# To put this file in a different directory and override @DEFAULT_SYS_DIR@ set # the environment variable LVM_SYSTEM_DIR before running the tools. @@ -66,12 +66,12 @@ devices { # The results of the filtering are cached on disk to avoid # rescanning dud devices (which can take a very long time). - # By default this cache is stored in the /etc/lvm/cache directory + # By default this cache is stored in the @DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@ directory # in a file called '.cache'. # It is safe to delete the contents: the tools regenerate it. # (The old setting 'cache' is still respected if neither of # these new ones is present.) - cache_dir = "/etc/lvm/cache" + cache_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@" cache_file_prefix = "" # You can turn off writing this cache file by setting this to 0. @@ -192,7 +192,7 @@ backup { # Where shall we keep it ? # Remember to back up this directory regularly! - backup_dir = "/etc/lvm/backup" + backup_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_BACKUP_SUBDIR@" # Should we maintain an archive of old metadata configurations. # Use 1 for Yes; 0 for No. @@ -201,7 +201,7 @@ backup { # Where should archived files go ? # Remember to back up this directory regularly! - archive_dir = "/etc/lvm/archive" + archive_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_ARCHIVE_SUBDIR@" # What is the minimum number of archive files you wish to keep ? retain_min = 10 @@ -295,7 +295,7 @@ global { # Local non-LV directory that holds file-based locks while commands are # in progress. A directory like /tmp that may get wiped on reboot is OK. - locking_dir = "/var/lock/lvm" + locking_dir = "@DEFAULT_LOCK_DIR@" # Whenever there are competing read-only and read-write access requests for # a volume group's metadata, instead of always granting the read-only diff --git a/lib/config/defaults.h b/lib/config/defaults.h index 22a085d9c..3c383d0ab 100644 --- a/lib/config/defaults.h +++ b/lib/config/defaults.h @@ -19,15 +19,11 @@ #define DEFAULT_ARCHIVE_ENABLED 1 #define DEFAULT_BACKUP_ENABLED 1 -#define DEFAULT_ARCHIVE_SUBDIR "archive" -#define DEFAULT_BACKUP_SUBDIR "backup" -#define DEFAULT_CACHE_SUBDIR "cache" #define DEFAULT_CACHE_FILE_PREFIX "" #define DEFAULT_ARCHIVE_DAYS 30 #define DEFAULT_ARCHIVE_NUMBER 10 -#define DEFAULT_SYS_DIR "/etc/lvm" #define DEFAULT_DEV_DIR "/dev" #define DEFAULT_PROC_DIR "/proc" #define DEFAULT_SYSFS_SCAN 1 @@ -37,7 +33,6 @@ #define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1 #define DEFAULT_DATA_ALIGNMENT_DETECTION 1 -#define DEFAULT_LOCK_DIR "/var/lock/lvm" #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so" #define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1 #define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1 diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in index 7c203ab3e..5b8fd0635 100644 --- a/lib/misc/configure.h.in +++ b/lib/misc/configure.h.in @@ -17,9 +17,24 @@ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA +/* Name of default metadata archive subdirectory. */ +#undef DEFAULT_ARCHIVE_SUBDIR + +/* Name of default metadata backup subdirectory. */ +#undef DEFAULT_BACKUP_SUBDIR + +/* Name of default metadata backup subdirectory. */ +#undef DEFAULT_CACHE_SUBDIR + +/* Name of default locking directory. */ +#undef DEFAULT_LOCK_DIR + /* Define to 0 to reinstate the pre-2.02.54 handling of unit suffixes. */ #undef DEFAULT_SI_UNIT_CONSISTENCY +/* Path to LVM system directory. */ +#undef DEFAULT_SYS_DIR + /* Define to 1 to enable LVM2 device-mapper interaction. */ #undef DEVMAPPER_SUPPORT diff --git a/make.tmpl.in b/make.tmpl.in index fd7581228..a71b7a726 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -67,6 +67,12 @@ pkgconfigdir = $(usrlibdir)/pkgconfig USRLIB_RELPATH = $(shell echo $(abspath $(usrlibdir) $(libdir)) | \ $(AWK) -f $(top_srcdir)/scripts/relpath.awk) +DEFAULT_SYS_DIR = @DEFAULT_SYS_DIR@ +DEFAULT_ARCHIVE_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_ARCHIVE_SUBDIR@ +DEFAULT_BACKUP_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_BACKUP_SUBDIR@ +DEFAULT_CACHE_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_CACHE_SUBDIR@ +DEFAULT_LOCK_DIR = @DEFAULT_LOCK_DIR@ + # Setup vpath search paths for some suffixes vpath %.c $(srcdir) vpath %.in $(srcdir) @@ -94,6 +100,9 @@ INSTALL_PROGRAM = $(INSTALL) $(M_INSTALL_PROGRAM) $(STRIP) INSTALL_DATA = $(INSTALL) -p $(M_INSTALL_DATA) INSTALL_WDATA = $(INSTALL) -p -m 644 +INSTALL_ROOT_DIR = $(INSTALL) -m 0700 -d +INSTALL_ROOT_DATA = $(INSTALL) -m 0600 + .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security diff --git a/man/Makefile.in b/man/Makefile.in index 9b538410a..eef1982a3 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -67,7 +67,7 @@ $(MAN5) $(MAN8) $(MAN8CLUSTER): Makefile %: %.in @case "$@" in \ */*) ;; \ - *) echo "Creating $@" ; $(SED) -e "s/#VERSION#/$(LVM_VERSION)/" $< > $@ ;; \ + *) echo "Creating $@" ; $(SED) -e "s+#VERSION#+$(LVM_VERSION)+;s+#DEFAULT_SYS_DIR#+$(DEFAULT_SYS_DIR)+;s+#DEFAULT_ARCHIVE_DIR#+$(DEFAULT_ARCHIVE_DIR)+;s+#DEFAULT_BACKUP_DIR#+$(DEFAULT_BACKUP_DIR)+;s+#DEFAULT_CACHE_DIR#+$(DEFAULT_CACHE_DIR)+;s+#DEFAULT_LOCK_DIR#+$(DEFAULT_LOCK_DIR)+" $< > $@ ;; \ esac install_man5: $(MAN5) diff --git a/man/lvm.8.in b/man/lvm.8.in index 1e016f77e..e38ce4f46 100644 --- a/man/lvm.8.in +++ b/man/lvm.8.in @@ -254,7 +254,7 @@ satisfy allocation attempts. \fBLVM_SYSTEM_DIR\fP Directory containing lvm.conf and other LVM system files. -Defaults to "/etc/lvm". +Defaults to "#DEFAULT_SYS_DIR#". .TP \fBHOME\fP Directory containing .lvm_history if the internal readline shell @@ -277,7 +277,7 @@ A LV cannot be called '.' '..' 'snapshot' or 'pvmove'. The LV name may also not .SH DIAGNOSTICS All tools return a status code of zero on success or non-zero on failure. .SH FILES -.I /etc/lvm/lvm.conf +.I #DEFAULT_SYS_DIR#/lvm.conf .br .I $HOME/.lvm_history .SH SEE ALSO diff --git a/man/lvm.conf.5.in b/man/lvm.conf.5.in index 9cc05e8ac..02ebb2a09 100644 --- a/man/lvm.conf.5.in +++ b/man/lvm.conf.5.in @@ -2,7 +2,7 @@ .SH NAME lvm.conf \- Configuration file for LVM2 .SH SYNOPSIS -.B /etc/lvm/lvm.conf +.B #DEFAULT_SYS_DIR#/lvm.conf .SH DESCRIPTION lvm.conf is loaded during the initialisation phase of \fBlvm\fP (8). This file can in turn lead to other files @@ -105,7 +105,7 @@ As an example, to ignore /dev/cdrom you could use: \fBdevices { filter=["r|cdrom|"] }\fP .IP \fBcache_dir\fP \(em Persistent filter cache file directory. -Defaults to "/etc/lvm/cache". +Defaults to "#DEFAULT_CACHE_DIR#". .IP \fBwrite_cache_state\fP \(em Set to 0 to disable the writing out of the persistent filter cache file when \fBlvm\fP exits. @@ -206,12 +206,12 @@ in low memory situations this setting can cause your machine to lock up. .IP \fBarchive_dir\fP \(em Directory used for automatic metadata archives. Backup copies of former metadata for each volume group are archived here. -Defaults to "/etc/lvm/archive". +Defaults to "#DEFAULT_ARCHIVE_DIR#". .IP \fBbackup_dir\fP \(em Directory used for automatic metadata backups. A single backup copy of the current metadata for each volume group is stored here. -Defaults to "/etc/lvm/backup". +Defaults to "#DEFAULT_BACKUP_DIR#". .IP \fBarchive\fP \(em Whether or not tools automatically archive existing metadata into \fBarchive_dir\fP before making changes to it. @@ -420,11 +420,11 @@ important never to edit these metadata files unless you fully understand how things work: to make changes you should always use the tools as normal, or else vgcfgbackup, edit backup, vgcfgrestore. .SH FILES -.I /etc/lvm/lvm.conf -.I /etc/lvm/archive -.I /etc/lvm/backup -.I /etc/lvm/cache/.cache -.I /var/lock/lvm +.I #DEFAULT_SYS_DIR#/lvm.conf +.I #DEFAULT_ARCHIVE_DIR# +.I #DEFAULT_BACKUP_DIR# +.I #DEFAULT_CACHE_DIR#/.cache +.I #DEFAULT_LOCK_DIR# .SH SEE ALSO .BR lvm (8), .BR umask (2), diff --git a/man/vgcfgbackup.8.in b/man/vgcfgbackup.8.in index 6eb25c22b..1a72a015e 100644 --- a/man/vgcfgbackup.8.in +++ b/man/vgcfgbackup.8.in @@ -18,13 +18,13 @@ If you don't name any volume groups on the command line, all of them will be backed up. .sp In a default installation, each volume group gets backed up into a separate -file bearing the name of the volume group in the directory /etc/lvm/backup. +file bearing the name of the volume group in the directory #DEFAULT_BACKUP_DIR#. You can write the backup to an alternative file using -f. In this case if you are backing up more than one volume group the filename is treated as a template, and %s gets replaced by the volume group name. .sp NB. This DOESN'T backup user/system data in logical -volume(s)! Backup /etc/lvm regularly too. +volume(s)! Backup #DEFAULT_SYS_DIR# regularly too. .SH OPTIONS See \fBlvm\fP for common options. .SH SEE ALSO