Move udev rules from /etc/udev to /lib/udev

This change moves the default install location for the zfs udev
rules from /etc/udev/ to /lib/udev/.  The correct convention is
for rules provided by a package to be installed in /lib/udev/.
The /etc/udev/ directory is reserved for custom rules or local
overrides.

Additionally, this patch cleans up some abuse of the bindir install
location by adding a udevdir and udevruledir install directories.
This allows us to revert to the default bin install location.  The
udev install directories can be set with the following new options.

  --with-udevdir=DIR      install udev helpers [EPREFIX/lib/udev]
  --with-udevruledir=DIR  install udev rules [UDEVDIR/rules.d]

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #356
This commit is contained in:
Kyle Fuller 2011-08-05 20:22:58 +01:00 committed by Brian Behlendorf
parent f3ab88d646
commit 12d06bac9b
18 changed files with 45 additions and 30 deletions

View File

@ -3,7 +3,7 @@ include $(top_srcdir)/config/deb.am
include $(top_srcdir)/config/tgz.am include $(top_srcdir)/config/tgz.am
if CONFIG_USER if CONFIG_USER
USER_DIR = dracut etc man scripts lib cmd USER_DIR = dracut udev etc man scripts lib cmd
endif endif
if CONFIG_KERNEL if CONFIG_KERNEL
KERNEL_DIR = module KERNEL_DIR = module

View File

@ -1 +1 @@
dist_bin_SCRIPTS = sas_switch_id dist_udev_SCRIPTS = sas_switch_id

View File

@ -1 +1 @@
dist_bin_SCRIPTS = zpool_id dist_udev_SCRIPTS = zpool_id

View File

@ -4,7 +4,7 @@ DEFAULT_INCLUDES += \
-I$(top_srcdir)/include \ -I$(top_srcdir)/include \
-I$(top_srcdir)/lib/libspl/include -I$(top_srcdir)/lib/libspl/include
bin_PROGRAMS = zvol_id udev_PROGRAMS = zvol_id
zvol_id_SOURCES = \ zvol_id_SOURCES = \
$(top_srcdir)/cmd/zvol_id/zvol_id_main.c $(top_srcdir)/cmd/zvol_id/zvol_id_main.c

14
config/user-udev.m4 Normal file
View File

@ -0,0 +1,14 @@
AC_DEFUN([ZFS_AC_CONFIG_USER_UDEV], [
AC_ARG_WITH(udevdir,
AC_HELP_STRING([--with-udevdir=DIR],
[install udev helpers [[EPREFIX/lib/udev]]]),
udevdir=$withval, udevdir='${exec_prefix}/lib/udev')
AC_ARG_WITH(udevruledir,
AC_HELP_STRING([--with-udevruledir=DIR],
[install udev rules [[UDEVDIR/rules.d]]]),
udevruledir=$withval, udevruledir='${udevdir}/rules.d')
AC_SUBST(udevdir)
AC_SUBST(udevruledir)
])

View File

@ -2,6 +2,7 @@ dnl #
dnl # Default ZFS user configuration dnl # Default ZFS user configuration
dnl # dnl #
AC_DEFUN([ZFS_AC_CONFIG_USER], [ AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_UDEV
ZFS_AC_CONFIG_USER_ARCH ZFS_AC_CONFIG_USER_ARCH
ZFS_AC_CONFIG_USER_IOCTL ZFS_AC_CONFIG_USER_IOCTL
ZFS_AC_CONFIG_USER_ZLIB ZFS_AC_CONFIG_USER_ZLIB

View File

@ -57,9 +57,9 @@ AC_CONFIG_FILES([
Makefile Makefile
dracut/Makefile dracut/Makefile
dracut/90zfs/Makefile dracut/90zfs/Makefile
udev/Makefile
udev/rules.d/Makefile
etc/Makefile etc/Makefile
etc/udev/Makefile
etc/udev/rules.d/Makefile
etc/init.d/Makefile etc/init.d/Makefile
etc/init.d/zfs.arch etc/init.d/zfs.arch
etc/init.d/zfs.gentoo etc/init.d/zfs.gentoo

View File

@ -29,8 +29,8 @@ installkernel() {
install() { install() {
inst_rules "$moddir/90-zfs.rules" inst_rules "$moddir/90-zfs.rules"
inst_rules /etc/udev/rules.d/60-zpool.rules inst_rules /lib/udev/rules.d/60-zpool.rules
inst_rules /etc/udev/rules.d/60-zvol.rules inst_rules /lib/udev/rules.d/60-zvol.rules
inst /etc/zfs/zdev.conf inst /etc/zfs/zdev.conf
inst /etc/zfs/zpool.cache inst /etc/zfs/zpool.cache
inst /etc/hostid inst /etc/hostid

View File

@ -1 +1 @@
SUBDIRS = init.d udev zfs SUBDIRS = init.d zfs

View File

@ -1,15 +0,0 @@
pkgsysconfdir = $(sysconfdir)/udev/rules.d
pkgsysconf_DATA = \
60-zpool.rules \
60-zvol.rules
EXTRA_DIST = \
60-zpool.rules.in \
60-zvol.rules.in
$(pkgsysconf_DATA):
-$(SED) -e 's,@bindir\@,$(bindir),g' '$@.in' >'$@'
distclean-local::
-$(RM) $(pkgsysconf_DATA)

View File

@ -1,8 +1,8 @@
# #
# /etc/udev/rules.d/60-zpool.rules # /lib/udev/rules.d/60-zpool.rules
# #
ENV{DEVTYPE}=="disk", IMPORT{program}="@bindir@/zpool_id -d %p" ENV{DEVTYPE}=="disk", IMPORT{program}="@udevdir@/zpool_id -d %p"
KERNEL=="*[!0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}" KERNEL=="*[!0-9]", ENV{SUBSYSTEM}=="block", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}"
KERNEL=="*[0-9]", ENV{SUBSYSTEM}=="block", ENV{DEVTYPE}=="partition", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}-part%n" KERNEL=="*[0-9]", ENV{SUBSYSTEM}=="block", ENV{DEVTYPE}=="partition", ENV{ID_ZPOOL}=="?*", SYMLINK+="$env{ID_ZPOOL_PATH}-part%n"

View File

@ -3,4 +3,4 @@
# persistent disk links: /dev/zvol/dataset_name # persistent disk links: /dev/zvol/dataset_name
# also creates compatibilty symlink of /dev/dataset_name # also creates compatibilty symlink of /dev/dataset_name
KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add|change" PROGRAM="@bindir@/zvol_id $tempnode" SYMLINK+="zvol/%c %c" KERNEL=="zd*" SUBSYSTEM=="block" ACTION=="add|change" PROGRAM="@udevdir@/zvol_id $tempnode" SYMLINK+="zvol/%c %c"

14
udev/rules.d/Makefile.am Normal file
View File

@ -0,0 +1,14 @@
udevrule_DATA = \
60-zpool.rules \
60-zvol.rules
EXTRA_DIST = \
60-zpool.rules.in \
60-zvol.rules.in
$(udevrule_DATA):
-$(SED) -e 's,@udevdir\@,$(udevdir),g' '$@.in' >'$@'
distclean-local::
-$(RM) $(udevrule_DATA)

View File

@ -3,9 +3,9 @@
%define release @ZFS_META_RELEASE@ %define release @ZFS_META_RELEASE@
%define debug_package %{nil} %define debug_package %{nil}
%define _prefix / %define _prefix /
%define _bindir /lib/udev
%define _libexecdir /usr/libexec %define _libexecdir /usr/libexec
%define _datadir /usr/share %define _datadir /usr/share
%define _udevdir /lib/udev
Summary: ZFS Library and Utils Summary: ZFS Library and Utils
Group: Utilities/System Group: Utilities/System
@ -61,7 +61,7 @@ which are ZFS aware.
%prep %prep
%setup %setup
%build %build
%configure --with-config=user --without-blkid %configure --with-config=user --without-blkid --with-udevdir=%{_udevdir}
make make
%install %install
@ -80,8 +80,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/* %{_libdir}/*
%{_mandir}/man8/* %{_mandir}/man8/*
%{_sysconfdir}/init.d/* %{_sysconfdir}/init.d/*
%{_sysconfdir}/udev/rules.d/*
%{_sysconfdir}/zfs/* %{_sysconfdir}/zfs/*
%{_udevdir}/*
%{_udevdir}/rules.d/*
%files devel %files devel
%defattr(-,root,root) %defattr(-,root,root)