From d0c4fc8ee820e487064c7f8b4ba9f695e19052ea Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 14 Oct 2020 23:31:08 +0200 Subject: [PATCH] Add some options for controlling installation and processing of the cron.daily script. --- meson.build | 10 +++++++--- meson_options.txt | 2 ++ update-plocate.sh | 11 ++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 meson_options.txt diff --git a/meson.build b/meson.build index ba12c7b..2e2761a 100644 --- a/meson.build +++ b/meson.build @@ -21,14 +21,18 @@ executable('plocate-build', 'plocate-build.cpp', install_dir: get_option('sbindir')) conf_data = configuration_data() +conf_data.set('PROCESSED_BY_MESON', '1') conf_data.set('sbindir', get_option('prefix') + '/' + get_option('sbindir')) +conf_data.set('locategroup', get_option('locategroup')) update_script = configure_file(input: 'update-plocate.sh', output: 'update-plocate.sh', configuration: conf_data) -install_data(update_script, - install_dir: '/etc/cron.daily', - rename: 'plocate') +if get_option('install_cron') + install_data(update_script, + install_dir: '/etc/cron.daily', + rename: 'plocate') +endif install_man('plocate.1') install_man('plocate-build.8') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..4bc9bd8 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,2 @@ +option('install_cron', type: 'boolean', value: true, description: 'Install update script into /etc/cron.daily') +option('locategroup', type: 'string', value: 'mlocate', description: 'Group that the install script will use for the .db file') diff --git a/update-plocate.sh b/update-plocate.sh index 2c1e2d8..d4bafc3 100755 --- a/update-plocate.sh +++ b/update-plocate.sh @@ -2,9 +2,14 @@ set -e -SBINDIR=@sbindir@ -[ -d $SBINDIR ] || SBINDIR=/usr/local/sbin # Default if not processed by Meson. +if [ @PROCESSED_BY_MESON@ = 1 ]; then + SBINDIR=@sbindir@ + LOCATEGROUP=@locategroup@ +else + SBINDIR=/usr/local/sbin + LOCATEGROUP=mlocate +fi $SBINDIR/plocate-build /var/lib/mlocate/mlocate.db /var/lib/mlocate/plocate.db.new -chgrp mlocate /var/lib/mlocate/plocate.db.new +chgrp $LOCATEGROUP /var/lib/mlocate/plocate.db.new mv /var/lib/mlocate/plocate.db.new /var/lib/mlocate/plocate.db -- 2.39.2