Use automake to build initramfs scripts and hooks.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #6761
contrib/dracut/02zfsexpandknowledge/Makefile
contrib/dracut/90zfs/Makefile
contrib/initramfs/Makefile
+ contrib/initramfs/hooks/Makefile
+ contrib/initramfs/scripts/Makefile
+ contrib/initramfs/scripts/local-top/Makefile
module/Makefile
module/avl/Makefile
module/nvpair/Makefile
initrd_SCRIPTS = \
conf.d/zfs conf-hooks.d/zfs hooks/zfs scripts/zfs scripts/local-top/zfs
+SUBDIRS = hooks scripts
+
EXTRA_DIST = \
$(top_srcdir)/contrib/initramfs/conf.d/zfs \
$(top_srcdir)/contrib/initramfs/conf-hooks.d/zfs \
- $(top_srcdir)/contrib/initramfs/hooks/zfs \
- $(top_srcdir)/contrib/initramfs/scripts/zfs \
- $(top_srcdir)/contrib/initramfs/scripts/local-top/zfs \
$(top_srcdir)/contrib/initramfs/README.initramfs.markdown
install-initrdSCRIPTS: $(EXTRA_DIST)
--- /dev/null
+hooksdir = $(datarootdir)/initramfs-tools/hooks
+
+hooks_SCRIPTS = \
+ zfs
+
+EXTRA_DIST = \
+ $(top_srcdir)/contrib/initramfs/hooks/zfs.in
+
+$(hooks_SCRIPTS):%:%.in
+ -$(SED) -e 's,@sbindir\@,$(sbindir),g' \
+ -e 's,@sysconfdir\@,$(sysconfdir),g' \
+ -e 's,@udevdir\@,$(udevdir),g' \
+ -e 's,@udevruledir\@,$(udevruledir),g' \
+ $< >'$@'
+
+clean-local::
+ -$(RM) $(hooks_SCRIPTS)
+
+distclean-local::
+ -$(RM) $(hooks_SCRIPTS)
# These prerequisites are provided by the zfsutils package. The zdb utility is
# not strictly required, but it can be useful at the initramfs recovery prompt.
-COPY_EXEC_LIST="/sbin/zdb /sbin/zpool /sbin/zfs /sbin/mount.zfs"
-COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/dirname /lib/udev/vdev_id"
-COPY_FILE_LIST="/etc/hostid /etc/zfs/zpool.cache /etc/default/zfs"
-COPY_FILE_LIST="$COPY_FILE_LIST /etc/zfs/zfs-functions /etc/zfs/vdev_id.conf"
-COPY_FILE_LIST="$COPY_FILE_LIST /lib/udev/rules.d/69-vdev.rules"
+# The mount helper mount.zfs must be installed in /sbin because this path is
+# hardcoded in the mount(8) for security reasons.
+COPY_EXEC_LIST="@sbindir@/zdb @sbindir@/zpool @sbindir@/zfs /sbin/mount.zfs"
+COPY_EXEC_LIST="$COPY_EXEC_LIST @udevdir@/vdev_id"
+COPY_FILE_LIST="/etc/hostid @sysconfdir@/zfs/zpool.cache"
+COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/default/zfs"
+COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/zfs/zfs-functions"
+COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/zfs/vdev_id.conf"
+COPY_FILE_LIST="$COPY_FILE_LIST @udevruledir@/69-vdev.rules"
# These prerequisites are provided by the base system.
COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/dirname /bin/hostname /sbin/blkid"
fi
for ii in zfs zfs.conf spl spl.conf
-do
+do
if [ -f "/etc/modprobe.d/$ii" ]; then
if [ ! -d "$DESTDIR/etc/modprobe.d" ]; then
mkdir -p $DESTDIR/etc/modprobe.d
--- /dev/null
+scriptsdir = $(datarootdir)/initramfs-tools/scripts
+
+scripts_SCRIPTS = \
+ zfs
+
+SUBDIRS = local-top
+
+EXTRA_DIST = \
+ $(top_srcdir)/contrib/initramfs/scripts/zfs.in
+
+$(scripts_SCRIPTS):%:%.in
+ -$(SED) -e 's,@sbindir\@,$(sbindir),g' \
+ -e 's,@sysconfdir\@,$(sysconfdir),g' \
+ $< >'$@'
+
+clean-local::
+ -$(RM) $(scripts_SCRIPTS)
+
+distclean-local::
+ -$(RM) $(scripts_SCRIPTS)
--- /dev/null
+localtopdir = $(datarootdir)/initramfs-tools/scripts/local-top
+
+EXTRA_DIST = zfs
# Paths to what we need - in the initrd, these paths are hardcoded,
# so override the defines in zfs-functions.
-ZFS="/sbin/zfs"
-ZPOOL="/sbin/zpool"
-ZPOOL_CACHE="/etc/zfs/zpool.cache"
+ZFS="@sbindir@/zfs"
+ZPOOL="@sbindir@/zpool"
+ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
export ZFS ZPOOL ZPOOL_CACHE
# This runs any scripts that should run before we start importing
# Separate the full snapshot ('$snap') into it's filesystem and
# snapshot names. Would have been nice with a split() function..
rootfs="${snap%%@*}"
- snapname="${snap##*@}"
+ snapname="${snap##*@}"
ZFS_BOOTFS="${rootfs}_${snapname}"
if ! grep -qiE '(^|[^\\](\\\\)* )(rollback)=(on|yes|1)( |$)' /proc/cmdline