Skip to content

Commit

Permalink
config: do not hardcode paths outside of $prefix
Browse files Browse the repository at this point in the history
This fixes behavior of the build system when a prefix other than `/usr`
is provided.

Specifically, this change makes it possible to build ZFS utils with
`--prefix=` set to a user-writable directory (such as `$HOME/...`)
and successfully run `make install` without superuser privileges.

Signed-off-by: Ivan Shapovalov <[email protected]>
  • Loading branch information
intelfx committed Jan 28, 2025
1 parent 3420571 commit 406fa95
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions config/mount-helper.m4
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
AC_DEFUN([ZFS_AC_CONFIG_USER_MOUNT_HELPER], [
AC_ARG_WITH(mounthelperdir,
AS_HELP_STRING([--with-mounthelperdir=DIR],
[install mount.zfs in dir [[/sbin]]]),
mounthelperdir=$withval,mounthelperdir=/sbin)
[install mount.zfs in dir [[$sbindir]]]),
mounthelperdir=$withval,mounthelperdir=$sbindir)
AC_SUBST(mounthelperdir)
])
4 changes: 2 additions & 2 deletions config/user-dracut.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_DRACUT], [
[dracutdir=check])
AS_IF([test "x$dracutdir" = xcheck], [
path1=/usr/share/dracut
path2=/usr/lib/dracut
path1=$prefix/share/dracut
path2=$prefix/lib/dracut
default=$path2
AS_IF([test -d "$path1"], [dracutdir="$path1"], [
Expand Down
16 changes: 8 additions & 8 deletions config/user-systemd.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_SYSTEMD], [
AC_ARG_WITH(systemdunitdir,
AS_HELP_STRING([--with-systemdunitdir=DIR],
[install systemd unit files in dir [[/usr/lib/systemd/system]]]),
systemdunitdir=$withval,systemdunitdir=/usr/lib/systemd/system)
[install systemd unit files in dir [[$libdir/systemd/system]]]),
systemdunitdir=$withval,systemdunitdir=$libdir/systemd/system)
AC_ARG_WITH(systemdpresetdir,
AS_HELP_STRING([--with-systemdpresetdir=DIR],
[install systemd preset files in dir [[/usr/lib/systemd/system-preset]]]),
systemdpresetdir=$withval,systemdpresetdir=/usr/lib/systemd/system-preset)
[install systemd preset files in dir [[$libdir/systemd/system-preset]]]),
systemdpresetdir=$withval,systemdpresetdir=$libdir/systemd/system-preset)
AC_ARG_WITH(systemdmodulesloaddir,
AS_HELP_STRING([--with-systemdmodulesloaddir=DIR],
[install systemd module load files into dir [[/usr/lib/modules-load.d]]]),
systemdmodulesloaddir=$withval,systemdmodulesloaddir=/usr/lib/modules-load.d)
[install systemd module load files into dir [[$libdir/modules-load.d]]]),
systemdmodulesloaddir=$withval,systemdmodulesloaddir=$libdir/modules-load.d)
AC_ARG_WITH(systemdgeneratordir,
AS_HELP_STRING([--with-systemdgeneratordir=DIR],
[install systemd generators in dir [[/usr/lib/systemd/system-generators]]]),
systemdgeneratordir=$withval,systemdgeneratordir=/usr/lib/systemd/system-generators)
[install systemd generators in dir [[$libdir/systemd/system-generators]]]),
systemdgeneratordir=$withval,systemdgeneratordir=$libdir/systemd/system-generators)
AS_IF([test "x$enable_systemd" = xcheck], [
AS_IF([systemctl --version >/dev/null 2>&1],
Expand Down
12 changes: 7 additions & 5 deletions config/user-udev.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ AC_DEFUN([ZFS_AC_CONFIG_USER_UDEV], [
AS_IF([test "x$udevdir" = xcheck], [
path1=/lib/udev
path2=/usr/lib/udev
path2=$prefix/lib/udev
default=$path2
AS_IF([test -d "$path1"], [udevdir="$path1"], [
AS_IF([test -d "$path2"], [udevdir="$path2"],
[udevdir="$default"])
])
AS_IF([test "$prefix" = "/usr"], [
AS_IF([test -d "$path1"], [udevdir="$path1"], [
AS_IF([test -d "$path2"], [udevdir="$path2"],
[udevdir="$default"])
])
], [udevdir="$default"])
])
AC_ARG_WITH(udevruledir,
Expand Down
12 changes: 6 additions & 6 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -601,24 +601,24 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
AC_MSG_CHECKING([default init config directory])
case "$VENDOR" in
alpine|artix|gentoo)
initconfdir=/etc/conf.d
initconfdir=$sysconfdir/conf.d
;;
fedora|openeuler|redhat|sles|toss)
initconfdir=/etc/sysconfig
initconfdir=$sysconfdir/sysconfig
;;
freebsd)
initconfdir=$sysconfdir/rc.conf.d
;;
*)
# debian|ubuntu
initconfdir=/etc/default
initconfdir=$sysconfdir/default
;;
esac
AC_MSG_RESULT([$initconfdir])
AC_SUBST(initconfdir)
AC_MSG_CHECKING([whether initramfs-tools is available])
if test -d /usr/share/initramfs-tools ; then
if test -d $datarootdir/initramfs-tools ; then
RPM_DEFINE_INITRAMFS='--define "_initramfs 1"'
AC_MSG_RESULT([yes])
else
Expand All @@ -630,13 +630,13 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
AC_MSG_CHECKING([default bash completion directory])
case "$VENDOR" in
alpine|arch|artix|debian|gentoo|ubuntu)
bashcompletiondir=/usr/share/bash-completion/completions
bashcompletiondir=$datarootdir/bash-completion/completions
;;
freebsd)
bashcompletiondir=$sysconfdir/bash_completion.d
;;
*)
bashcompletiondir=/etc/bash_completion.d
bashcompletiondir=$sysconfdir/bash_completion.d
;;
esac
AC_MSG_RESULT([$bashcompletiondir])
Expand Down
2 changes: 1 addition & 1 deletion contrib/initramfs/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
i_tdir = /usr/share/initramfs-tools
i_tdir = $(datarootdir)/initramfs-tools
dist_i_t_SCRIPTS = \
%D%/zfsunlock

Expand Down

0 comments on commit 406fa95

Please sign in to comment.