From 1c8caf9fd542da587aa91a0dd7cc79f20925ab12 Mon Sep 17 00:00:00 2001 From: Dave Dykstra <2129743+DrDaveD@users.noreply.github.com> Date: Fri, 24 May 2019 10:38:24 -0500 Subject: [PATCH 1/2] skip install parts that require root when non-root --- util/install_helper.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/util/install_helper.sh b/util/install_helper.sh index 688b2450..061b16b0 100755 --- a/util/install_helper.sh +++ b/util/install_helper.sh @@ -22,16 +22,17 @@ else DESTDIR="${DESTDIR%/}" fi -chown root:root "${DESTDIR}${bindir}/fusermount3" -chmod u+s "${DESTDIR}${bindir}/fusermount3" - install -D -m 644 "${MESON_SOURCE_ROOT}/util/fuse.conf" \ "${DESTDIR}${sysconfdir}/fuse.conf" +if [ `id -u` = 0 ]; then + chown root:root "${DESTDIR}${bindir}/fusermount3" + chmod u+s "${DESTDIR}${bindir}/fusermount3" -if test ! -e "${DESTDIR}/dev/fuse"; then - mkdir -p "${DESTDIR}/dev" - mknod "${DESTDIR}/dev/fuse" -m 0666 c 10 229 + if test ! -e "${DESTDIR}/dev/fuse"; then + mkdir -p "${DESTDIR}/dev" + mknod "${DESTDIR}/dev/fuse" -m 0666 c 10 229 + fi fi install -D -m 644 "${MESON_SOURCE_ROOT}/util/udev.rules" \ From 67ec3873e0eaddb5ebafed0f9f81f29e944e91ee Mon Sep 17 00:00:00 2001 From: Dave Dykstra <2129743+DrDaveD@users.noreply.github.com> Date: Wed, 3 Jul 2019 13:32:12 -0500 Subject: [PATCH 2/2] add no-root configure option --- meson_options.txt | 8 ++++++-- util/install_helper.sh | 3 ++- util/meson.build | 10 +++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index c08e38e4..c88b32d8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,7 +5,11 @@ option('udevrulesdir', type : 'string', value : '', description: 'Where to install udev rules (if empty, query pkg-config(1))') option('utils', type : 'boolean', value : true, - description: 'Wheter or not to build and install helper programs') + description: 'Whether or not to build and install helper programs') option('examples', type : 'boolean', value : true, - description: 'Wheter or not to build example programs') \ No newline at end of file + description: 'Whether or not to build example programs') + +option('no-root', type : 'boolean', value : false, + description: 'Install files without root permissions') + diff --git a/util/install_helper.sh b/util/install_helper.sh index 061b16b0..30f6227b 100755 --- a/util/install_helper.sh +++ b/util/install_helper.sh @@ -9,6 +9,7 @@ set -e sysconfdir="$1" bindir="$2" udevrulesdir="$3" +useroot="$4" # Both sysconfdir and bindir are absolute paths (since they are joined # with --prefix in meson.build), but need to be interpreted relative @@ -25,7 +26,7 @@ fi install -D -m 644 "${MESON_SOURCE_ROOT}/util/fuse.conf" \ "${DESTDIR}${sysconfdir}/fuse.conf" -if [ `id -u` = 0 ]; then +if $useroot; then chown root:root "${DESTDIR}${bindir}/fusermount3" chmod u+s "${DESTDIR}${bindir}/fusermount3" diff --git a/util/meson.build b/util/meson.build index aa0e734a..d273ca8e 100644 --- a/util/meson.build +++ b/util/meson.build @@ -20,9 +20,17 @@ if udevrulesdir == '' udevrulesdir = join_paths(udev.get_pkgconfig_variable('udevdir'), 'rules.d') endif +noroot = get_option('no-root') +if noroot + useroot = 'false' +else + useroot = 'true' +endif + meson.add_install_script('install_helper.sh', join_paths(get_option('prefix'), get_option('sysconfdir')), join_paths(get_option('prefix'), get_option('bindir')), - udevrulesdir) + udevrulesdir, + useroot)