From f6a5110e20e01625927b88b1736b006c242c0bf9 Mon Sep 17 00:00:00 2001 From: q66 Date: Tue, 22 Oct 2024 22:04:00 +0200 Subject: [PATCH] locate: respect libexec setting in the build --- import-src.sh | 10 ++- include/meson.build | 2 + patches/src.freebsd.patch | 85 +++++++++++++++---- .../locate/{concatdb.sh => concatdb.sh.in} | 2 +- src.freebsd/findutils/locate/locate/locate.1 | 4 +- .../findutils/locate/locate/locate.updatedb.8 | 4 +- .../findutils/locate/locate/meson.build | 24 ++++-- .../{mklocatedb.sh => mklocatedb.sh.in} | 2 +- .../locate/{updatedb.sh => updatedb.sh.in} | 2 +- src.freebsd/findutils/locate/meson.build | 8 +- .../locate/{updatedb.sh => updatedb.sh.in} | 2 +- src.freebsd/miscutils/whereis/pathnames.h | 4 +- src.freebsd/miscutils/whereis/whereis.1 | 3 +- 13 files changed, 109 insertions(+), 43 deletions(-) rename src.freebsd/findutils/locate/locate/{concatdb.sh => concatdb.sh.in} (97%) rename src.freebsd/findutils/locate/locate/{mklocatedb.sh => mklocatedb.sh.in} (98%) rename src.freebsd/findutils/locate/locate/{updatedb.sh => updatedb.sh.in} (98%) rename src.freebsd/findutils/locate/{updatedb.sh => updatedb.sh.in} (85%) diff --git a/import-src.sh b/import-src.sh index 03c3d444..28528896 100755 --- a/import-src.sh +++ b/import-src.sh @@ -354,10 +354,18 @@ rm -rf ${CWD}/src.orig/telnet/telnetd rm -rf ${CWD}/src.freebsd/telnet/telnetd # remove our own scripts before patching -rm -f ${CWD}/src.freebsd/findutils/locate/updatedb.sh +rm -f ${CWD}/src.freebsd/findutils/locate/updatedb.sh.in rm -f ${CWD}/src.freebsd/nvi/*.sh rm -f ${CWD}/src.freebsd/libfetch/*.sh +# make the locate scripts possible to process +for sc in ${CWD}/src.orig/findutils/locate/locate/*.sh; do + mv "$sc" "$sc.in" +done +for sc in ${CWD}/src.freebsd/findutils/locate/locate/*.sh; do + mv "$sc" "$sc.in" +done + # remove rpmatch header which is our own and applied by patch rm -f ${CWD}/src.freebsd/include/rpmatch.h diff --git a/include/meson.build b/include/meson.build index e5eb89c7..48680701 100644 --- a/include/meson.build +++ b/include/meson.build @@ -3,6 +3,8 @@ confd = configuration_data() confd.set('PROJECT_NAME', '"' + meson.project_name() + '"') confd.set('PROJECT_VERSION', '"' + meson.project_version() + '"') +confd.set_quoted('LIBEXECDIR', join_paths(get_option('prefix'), get_option('libexecdir'))) + confd.set('HAVE_STRTOQ', cc.has_function('strtoq')) confd.set('HAVE_STRLCPY', cc.has_function('strlcpy')) confd.set('HAVE_STRLCAT', cc.has_function('strlcat')) diff --git a/patches/src.freebsd.patch b/patches/src.freebsd.patch index cf05f85b..1c137ae0 100644 --- a/patches/src.freebsd.patch +++ b/patches/src.freebsd.patch @@ -10348,6 +10348,17 @@ /* skip empty lines */ if (*path == '\n') +--- src.orig/findutils/locate/locate/concatdb.sh.in ++++ src.freebsd/findutils/locate/locate/concatdb.sh.in +@@ -38,7 +38,7 @@ + set -o pipefail + + # The directory containing locate subprograms +-: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR ++: ${LIBEXECDIR:=@LIBEXECDIR@}; export LIBEXECDIR + + PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH + : ${TMPDIR:=/var/tmp}; export TMPDIR; --- src.orig/findutils/locate/locate/fastfind.c +++ src.freebsd/findutils/locate/locate/fastfind.c @@ -152,7 +152,7 @@ @@ -10427,10 +10438,11 @@ .El .Sh FILES -.Bl -tag -width /etc/periodic/weekly/310.locate -compact -+.Bl -tag -width /usr/libexec/locate.updatedb -compact ++.Bl -tag -width /var/db/locate.database -compact .It Pa /var/db/locate.database locate database - .It Pa /usr/libexec/locate.updatedb +-.It Pa /usr/libexec/locate.updatedb ++.It Pa locate-updatedb Script to update the locate database -.It Pa /etc/periodic/weekly/310.locate -Script that starts the database rebuild @@ -10489,9 +10501,17 @@ +#FILESYSTEMS="ext2 ext3 ext4 xfs vfat exfat ntfs ntfs3 f2fs zfs btrfs reiserfs reiser4 jfs" --- src.orig/findutils/locate/locate/locate.updatedb.8 +++ src.freebsd/findutils/locate/locate/locate.updatedb.8 -@@ -41,9 +41,6 @@ +@@ -34,16 +34,11 @@ + .Sh NAME + .Nm locate.updatedb + .Nd update locate database +-.Sh SYNOPSIS +-.Nm /usr/libexec/locate.updatedb + .Sh DESCRIPTION + The .Nm - utility updates the database used by +-utility updates the database used by ++utility, located in the configured libexec directory, updates the database used by .Xr locate 1 . -It is typically run once a week by the -.Pa /etc/periodic/weekly/310.locate @@ -10499,7 +10519,7 @@ .Pp The contents of the newly built database can be controlled by the .Pa /etc/locate.rc -@@ -61,8 +58,7 @@ +@@ -61,8 +56,7 @@ the configuration file .El .Sh SEE ALSO @@ -10509,8 +10529,28 @@ .Rs .%A Woods, James A. .%D 1983 ---- src.orig/findutils/locate/locate/updatedb.sh -+++ src.freebsd/findutils/locate/locate/updatedb.sh +--- src.orig/findutils/locate/locate/mklocatedb.sh.in ++++ src.freebsd/findutils/locate/locate/mklocatedb.sh.in +@@ -36,7 +36,7 @@ + set -o pipefail + + # The directory containing locate subprograms +-: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR ++: ${LIBEXECDIR:=@LIBEXECDIR@}; export LIBEXECDIR + : ${TMPDIR:=/var/tmp}; export TMPDIR + + PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH +--- src.orig/findutils/locate/locate/updatedb.sh.in ++++ src.freebsd/findutils/locate/locate/updatedb.sh.in +@@ -40,7 +40,7 @@ + fi + + # The directory containing locate subprograms +-: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR ++: ${LIBEXECDIR:=@LIBEXECDIR@}; export LIBEXECDIR + : ${TMPDIR:=/tmp}; export TMPDIR + if ! TMPDIR=`mktemp -d $TMPDIR/locateXXXXXXXXXX`; then + exit 1 @@ -52,11 +52,10 @@ : ${mklocatedb:=locate.mklocatedb} # make locate database program : ${FCODES:=/var/db/locate.database} # the database @@ -10545,8 +10585,8 @@ } } ---- src.orig/findutils/locate/updatedb.sh -+++ src.freebsd/findutils/locate/updatedb.sh +--- src.orig/findutils/locate/updatedb.sh.in ++++ src.freebsd/findutils/locate/updatedb.sh.in @@ -0,0 +1,24 @@ +#!/bin/sh +# @@ -10568,7 +10608,7 @@ +chmod 644 "$locdb" || rc=3 + +cd / -+echo /usr/libexec/locate.updatedb | nice -n 5 su -m nobody || rc=3 ++printf "%s/locate.updatedb\n" @LIBEXECDIR@ | nice -n 5 su -m nobody || rc=3 +chmod 444 $locdb || rc=3 + +exit $rc @@ -13012,15 +13052,22 @@ } --- src.orig/miscutils/whereis/pathnames.h +++ src.freebsd/miscutils/whereis/pathnames.h -@@ -29,6 +29,7 @@ - #define PATH_LIBEXEC "/usr/libexec" +@@ -25,10 +25,13 @@ + * POSSIBILITY OF SUCH DAMAGE. + */ + ++#include "config-compat.h" ++ + /* Where to look for libexec */ +-#define PATH_LIBEXEC "/usr/libexec" ++#define PATH_LIBEXEC LIBEXECDIR /* Where to look for sources. */ +#if 0 #define PATH_SOURCES \ "/usr/src/bin:/usr/src/usr.bin:/usr/src/sbin:" \ "/usr/src/usr.sbin:/usr/src/libexec:" \ -@@ -39,12 +40,15 @@ +@@ -39,12 +42,15 @@ "/usr/src/secure/sbin:/usr/src/secure/usr.sbin:" \ "/usr/src/secure/libexec:/usr/src/crypto:" \ "/usr/src/games" @@ -13039,7 +13086,7 @@ #define MANWHEREISCMD "man -S1:8:6 -w %s 2>/dev/null" --- src.orig/miscutils/whereis/whereis.1 +++ src.freebsd/miscutils/whereis/whereis.1 -@@ -58,11 +58,7 @@ +@@ -58,22 +58,15 @@ .Ql ,v from a source code control system. .Pp @@ -13048,11 +13095,13 @@ -utility for the -.Dq user.cs_path -string, with +-.Pa /usr/libexec +-and the current user's +The default path searched is the standard utilities path, with - .Pa /usr/libexec - and the current user's ++the configured libexec directory and the current user's .Ev $PATH -@@ -71,9 +67,7 @@ + appended. + Manual pages are searched by default along the .Ev $MANPATH . Program sources are located in a list of known standard places, including all the subdirectories of @@ -13063,7 +13112,7 @@ .Pp The following options are available: .Bl -tag -width indent -@@ -151,8 +145,7 @@ +@@ -151,8 +144,7 @@ .Xr find 1 , .Xr locate 1 , .Xr man 1 , diff --git a/src.freebsd/findutils/locate/locate/concatdb.sh b/src.freebsd/findutils/locate/locate/concatdb.sh.in similarity index 97% rename from src.freebsd/findutils/locate/locate/concatdb.sh rename to src.freebsd/findutils/locate/locate/concatdb.sh.in index 9693017e..c6e434b8 100644 --- a/src.freebsd/findutils/locate/locate/concatdb.sh +++ b/src.freebsd/findutils/locate/locate/concatdb.sh.in @@ -38,7 +38,7 @@ set -e set -o pipefail # The directory containing locate subprograms -: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR +: ${LIBEXECDIR:=@LIBEXECDIR@}; export LIBEXECDIR PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH : ${TMPDIR:=/var/tmp}; export TMPDIR; diff --git a/src.freebsd/findutils/locate/locate/locate.1 b/src.freebsd/findutils/locate/locate/locate.1 index a08d4884..f5764460 100644 --- a/src.freebsd/findutils/locate/locate/locate.1 +++ b/src.freebsd/findutils/locate/locate/locate.1 @@ -187,10 +187,10 @@ path to the locate database if set and not empty, ignored if the option was specified. .El .Sh FILES -.Bl -tag -width /usr/libexec/locate.updatedb -compact +.Bl -tag -width /var/db/locate.database -compact .It Pa /var/db/locate.database locate database -.It Pa /usr/libexec/locate.updatedb +.It Pa locate-updatedb Script to update the locate database .El .Sh SEE ALSO diff --git a/src.freebsd/findutils/locate/locate/locate.updatedb.8 b/src.freebsd/findutils/locate/locate/locate.updatedb.8 index 32e5405e..cd461536 100644 --- a/src.freebsd/findutils/locate/locate/locate.updatedb.8 +++ b/src.freebsd/findutils/locate/locate/locate.updatedb.8 @@ -34,12 +34,10 @@ .Sh NAME .Nm locate.updatedb .Nd update locate database -.Sh SYNOPSIS -.Nm /usr/libexec/locate.updatedb .Sh DESCRIPTION The .Nm -utility updates the database used by +utility, located in the configured libexec directory, updates the database used by .Xr locate 1 . .Pp The contents of the newly built database can be controlled by the diff --git a/src.freebsd/findutils/locate/locate/meson.build b/src.freebsd/findutils/locate/locate/meson.build index 87a7d4cb..0dffadfe 100644 --- a/src.freebsd/findutils/locate/locate/meson.build +++ b/src.freebsd/findutils/locate/locate/meson.build @@ -13,23 +13,29 @@ install_symlink( 'updatedb.8', pointing_to: 'locate.updatedb.8', install_dir: man8dir ) -install_data( - 'updatedb.sh', - rename: 'locate.updatedb', +configure_file( + input: 'updatedb.sh.in', + output: 'locate.updatedb', + configuration: confd, + format: 'cmake@', install_dir: get_option('libexecdir'), install_mode: 'rwxr-xr-x' ) -install_data( - 'mklocatedb.sh', - rename: 'locate.mklocatedb', +configure_file( + input: 'mklocatedb.sh.in', + output: 'locate.mklocatedb', + configuration: confd, + format: 'cmake@', install_dir: get_option('libexecdir'), install_mode: 'rwxr-xr-x' ) -install_data( - 'concatdb.sh', - rename: 'locate.concatdb', +configure_file( + input: 'concatdb.sh.in', + output: 'locate.concatdb', + configuration: confd, + format: 'cmake@', install_dir: get_option('libexecdir'), install_mode: 'rwxr-xr-x' ) diff --git a/src.freebsd/findutils/locate/locate/mklocatedb.sh b/src.freebsd/findutils/locate/locate/mklocatedb.sh.in similarity index 98% rename from src.freebsd/findutils/locate/locate/mklocatedb.sh rename to src.freebsd/findutils/locate/locate/mklocatedb.sh.in index 40727fdd..98220288 100644 --- a/src.freebsd/findutils/locate/locate/mklocatedb.sh +++ b/src.freebsd/findutils/locate/locate/mklocatedb.sh.in @@ -36,7 +36,7 @@ set -e set -o pipefail # The directory containing locate subprograms -: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR +: ${LIBEXECDIR:=@LIBEXECDIR@}; export LIBEXECDIR : ${TMPDIR:=/var/tmp}; export TMPDIR PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH diff --git a/src.freebsd/findutils/locate/locate/updatedb.sh b/src.freebsd/findutils/locate/locate/updatedb.sh.in similarity index 98% rename from src.freebsd/findutils/locate/locate/updatedb.sh rename to src.freebsd/findutils/locate/locate/updatedb.sh.in index 4ca23cd8..22c3fc4e 100644 --- a/src.freebsd/findutils/locate/locate/updatedb.sh +++ b/src.freebsd/findutils/locate/locate/updatedb.sh.in @@ -40,7 +40,7 @@ if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then fi # The directory containing locate subprograms -: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR +: ${LIBEXECDIR:=@LIBEXECDIR@}; export LIBEXECDIR : ${TMPDIR:=/tmp}; export TMPDIR if ! TMPDIR=`mktemp -d $TMPDIR/locateXXXXXXXXXX`; then exit 1 diff --git a/src.freebsd/findutils/locate/meson.build b/src.freebsd/findutils/locate/meson.build index b16ed52a..47e05488 100644 --- a/src.freebsd/findutils/locate/meson.build +++ b/src.freebsd/findutils/locate/meson.build @@ -2,9 +2,11 @@ subdir('bigram') subdir('code') subdir('locate') -install_data( - 'updatedb.sh', - rename: 'locate-updatedb', +configure_file( + input: 'updatedb.sh.in', + output: 'locate-updatedb', + configuration: confd, + format: 'cmake@', install_dir: get_option('bindir'), install_mode: 'rwxr-xr-x' ) diff --git a/src.freebsd/findutils/locate/updatedb.sh b/src.freebsd/findutils/locate/updatedb.sh.in similarity index 85% rename from src.freebsd/findutils/locate/updatedb.sh rename to src.freebsd/findutils/locate/updatedb.sh.in index d77491d5..348781a4 100644 --- a/src.freebsd/findutils/locate/updatedb.sh +++ b/src.freebsd/findutils/locate/updatedb.sh.in @@ -18,7 +18,7 @@ chown nobody "$locdb" || rc=3 chmod 644 "$locdb" || rc=3 cd / -echo /usr/libexec/locate.updatedb | nice -n 5 su -m nobody || rc=3 +printf "%s/locate.updatedb\n" @LIBEXECDIR@ | nice -n 5 su -m nobody || rc=3 chmod 444 $locdb || rc=3 exit $rc diff --git a/src.freebsd/miscutils/whereis/pathnames.h b/src.freebsd/miscutils/whereis/pathnames.h index 27984fc2..7d2fe1fc 100644 --- a/src.freebsd/miscutils/whereis/pathnames.h +++ b/src.freebsd/miscutils/whereis/pathnames.h @@ -25,8 +25,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "config-compat.h" + /* Where to look for libexec */ -#define PATH_LIBEXEC "/usr/libexec" +#define PATH_LIBEXEC LIBEXECDIR /* Where to look for sources. */ #if 0 diff --git a/src.freebsd/miscutils/whereis/whereis.1 b/src.freebsd/miscutils/whereis/whereis.1 index 3a79db69..b52b3516 100644 --- a/src.freebsd/miscutils/whereis/whereis.1 +++ b/src.freebsd/miscutils/whereis/whereis.1 @@ -59,8 +59,7 @@ or trailing from a source code control system. .Pp The default path searched is the standard utilities path, with -.Pa /usr/libexec -and the current user's +the configured libexec directory and the current user's .Ev $PATH appended. Manual pages are searched by default along the