Skip to content

Commit

Permalink
locate: respect libexec setting in the build
Browse files Browse the repository at this point in the history
  • Loading branch information
q66 committed Oct 22, 2024
1 parent 6804177 commit f6a5110
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 43 deletions.
10 changes: 9 additions & 1 deletion import-src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions include/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
85 changes: 67 additions & 18 deletions patches/src.freebsd.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -10489,17 +10501,25 @@
+#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
-script.
.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
Expand All @@ -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
Expand Down Expand Up @@ -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
+#
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src.freebsd/findutils/locate/locate/locate.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src.freebsd/findutils/locate/locate/locate.updatedb.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions src.freebsd/findutils/locate/locate/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src.freebsd/findutils/locate/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion src.freebsd/miscutils/whereis/pathnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src.freebsd/miscutils/whereis/whereis.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f6a5110

Please sign in to comment.