View | Details | Raw Unified | Return to bug 270657 | Differences between
and this patch

Collapse All | Expand All

(-)b/plocate/Makefile (+34 lines)
Added Link Here
1
PORTNAME=	plocate
2
DISTVERSION=	1.1.18
3
CATEGORIES=	sysutils
4
MASTER_SITES=	https://plocate.sesse.net/download/
5
6
MAINTAINER=	sec@42.org
7
COMMENT=	Fast & privacy-respecting locate utility
8
WWW=		https://plocate.sesse.net/
9
10
LICENSE=	GPLv2
11
LICENSE_FILE=	${WRKSRC}/COPYING
12
13
BUILD_DEPENDS=	meson:devel/meson
14
LIB_DEPENDS=	libzstd.so:archivers/zstd
15
16
USES=		meson
17
MESON_ARGS=	--sharedstatedir=/var/db
18
19
SUB_FILES=	315.plocate
20
21
GROUPS=		plocate
22
23
post-patch:
24
	${CP} ${FILESDIR}/mntent_compat.c++ ${FILESDIR}/mntent.h ${WRKSRC}
25
26
post-install:
27
	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily
28
	${INSTALL_SCRIPT} ${WRKDIR}/315.plocate \
29
		${STAGEDIR}${PREFIX}/etc/periodic/daily
30
	${INSTALL_DATA} ${FILESDIR}/updatedb.conf.sample \
31
		${STAGEDIR}${PREFIX}/etc
32
	${MKDIR} ${STAGEDIR}/var/db/plocate
33
34
.include <bsd.port.mk>
(-)b/plocate/distinfo (+3 lines)
Added Link Here
1
TIMESTAMP = 1680026625
2
SHA256 (plocate-1.1.18.tar.gz) = 939657050b70719b01ce04fc1c8b64270062a0d53da2c72eafbe036a1964e12c
3
SIZE (plocate-1.1.18.tar.gz) = 73906
(-)b/plocate/files/315.plocate.in (+32 lines)
Added Link Here
1
#!/bin/sh -
2
#
3
# $FreeBSD$
4
#
5
6
# If there is a global system configuration file, suck it in.
7
#
8
if [ -r /etc/defaults/periodic.conf ]
9
then
10
    . /etc/defaults/periodic.conf
11
    source_periodic_confs
12
fi
13
14
case "$daily_plocate_enable" in
15
    [Yy][Ee][Ss])
16
	echo ""
17
	echo "Rebuilding plocate database:"
18
19
	SBINDIR=%%PREFIX%%/sbin
20
	LOCATEGROUP=plocate
21
	DBFILE=/var/db/plocate/plocate.db
22
23
	touch $DBFILE && rc=0 || rc=3
24
25
	cd /
26
	nice -n 5 $SBINDIR/updatedb
27
    ;;
28
29
    *)  rc=0;;
30
esac
31
32
exit $rc
(-)b/plocate/files/mntent.h (+62 lines)
Added Link Here
1
/*
2
 *  mntent
3
 *  mntent.h - compatability header for FreeBSD
4
 *
5
 *  Copyright (c) 2001 David Rufino <daverufino@btinternet.com>
6
 *  All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29
30
#if defined(HAVE_MNTENT_H)
31
#include <mntent.h>
32
#else
33
#ifndef _MNTENT_H
34
#define _MNTENT_H
35
#include <stdio.h>
36
37
#define MOUNTED "dummy"
38
39
#define MNTTYPE_NFS "nfs"
40
41
struct mntent {
42
	char *mnt_fsname;
43
	char *mnt_dir;
44
	char *mnt_type;
45
	char *mnt_opts;
46
	int mnt_freq;
47
	int mnt_passno;
48
};
49
50
#define setmntent(x,y) ((FILE *)0x1)
51
#ifdef __cplusplus
52
extern "C" {
53
#endif
54
struct mntent *getmntent __P ((FILE *fp));
55
char *hasmntopt __P ((const struct mntent *mnt, const char *option));
56
#ifdef __cplusplus
57
}; // extern "C"
58
#endif
59
#define endmntent(x) ((int)1)
60
61
#endif /* _MNTENT_H */
62
#endif /* HAVE_MNTENT_H */
(-)b/plocate/files/mntent_compat.c++ (+177 lines)
Added Link Here
1
/*
2
 * Copyright (c) 1980, 1989, 1993, 1994
3
 *      The Regents of the University of California.  All rights reserved.
4
 * Copyright (c) 2001
5
 *      David Rufino <daverufino@btinternet.com>
6
 * Copyright (c) 2006
7
 *      Stanislav Sedov <ssedov@mbsd.msk.ru>
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 * 3. All advertising materials mentioning features or use of this software
18
 *    must display the following acknowledgement:
19
 *      This product includes software developed by the University of
20
 *      California, Berkeley and its contributors.
21
 * 4. Neither the name of the University nor the names of its contributors
22
 *    may be used to endorse or promote products derived from this software
23
 *    without specific prior written permission.
24
 *
25
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35
 * SUCH DAMAGE.
36
 */
37
38
/* most of this was ripped from the mount(3) source */
39
40
//#include "config.h"
41
#include "mntent.h"
42
#include <stdlib.h>
43
#include <string.h>
44
#include <sys/param.h>
45
#include <sys/ucred.h>
46
#include <sys/mount.h>
47
48
static int pos = -1;
49
static int mntsize = -1;
50
static struct mntent _mntent;
51
52
struct {
53
	int		m_flag;
54
	const char	*m_option;
55
} mntoptions[] = {
56
	{ MNT_ASYNC,		"async" },
57
	{ MNT_NOATIME,		"noatime"},
58
	{ MNT_NOEXEC,		"noexec"},
59
	{ MNT_NOSUID,		"nosuid"},
60
	{ MNT_NOSYMFOLLOW,	"nosymfollow"},
61
	{ MNT_SYNCHRONOUS,	"sync"},
62
	{ MNT_UNION,		"union"},
63
	{ MNT_NOCLUSTERR,	"noclusterr"},
64
	{ static_cast<int>(MNT_NOCLUSTERW),	"noclusterw"},
65
	{ MNT_SUIDDIR,		"suiddir"},
66
#ifdef MNT_SNAPSHOT
67
	{ MNT_SNAPSHOT,		"snapshot"},
68
#endif
69
#ifdef MNT_MULTILABEL
70
	{ MNT_MULTILABEL,	"multilabel"},
71
#endif
72
#ifdef MNT_ACLS
73
	{ MNT_ACLS,		"acls"},
74
#endif
75
#ifdef MNT_NODEV
76
	{ MNT_NODEV,		"nodev"},
77
#endif
78
};
79
80
#define N_OPTS (sizeof(mntoptions) / sizeof(*mntoptions))
81
82
83
extern "C" {
84
85
char *
86
hasmntopt (const struct mntent *mnt, const char *option)
87
{
88
	char *opt, *optbuf;
89
90
	optbuf = strdup(mnt->mnt_opts);
91
	for (opt = optbuf; (opt = strtok(opt, " ")) != NULL; opt = NULL) {
92
		if (!strcasecmp(opt, option)) {
93
			opt = opt - optbuf + mnt->mnt_opts;
94
			free (optbuf);
95
			return (opt);
96
		}
97
	}
98
	free (optbuf);
99
	return (NULL);
100
}
101
102
static char *
103
catopt (char *s0, const char *s1)
104
{
105
	size_t newlen;
106
	char *cp;
107
108
	if (s1 == NULL || *s1 == '\0')
109
		return s0;
110
111
	if (s0 != NULL) {
112
		newlen = strlen(s0) + strlen(s1) + 1 + 1;
113
		if ((cp = (char *)realloc(s0, newlen)) == NULL)
114
			return (NULL);
115
116
		(void)strcat(cp, " ");
117
		(void)strcat(cp, s1);
118
	} else
119
		cp = strdup(s1);
120
121
	return (cp);
122
}
123
124
125
static char *
126
flags2opts (int flags)
127
{
128
	char *res = NULL;
129
	int i;
130
131
	res = catopt(res, (flags & MNT_RDONLY) ? "ro" : "rw");
132
133
	for (i = 0; i < N_OPTS; i++)
134
		if (flags & mntoptions[i].m_flag)
135
			res = catopt(res, mntoptions[i].m_option);
136
	return res;
137
}
138
139
static struct mntent *
140
statfs_to_mntent (struct statfs *mntbuf)
141
{
142
	static char opts_buf[40], *tmp;
143
	
144
	_mntent.mnt_fsname = mntbuf->f_mntfromname;
145
	_mntent.mnt_dir = mntbuf->f_mntonname;
146
	_mntent.mnt_type = mntbuf->f_fstypename;
147
	tmp = flags2opts (mntbuf->f_flags);
148
	if (tmp) {
149
		opts_buf[sizeof(opts_buf) - 1] = '\0';
150
		strncpy (opts_buf, tmp, sizeof(opts_buf)-1);
151
		free (tmp);
152
	} else {
153
		*opts_buf = '\0';
154
	}
155
	_mntent.mnt_opts = opts_buf;	
156
	_mntent.mnt_freq = _mntent.mnt_passno = 0;
157
	return (&_mntent);
158
}
159
160
struct mntent *
161
getmntent (FILE *fp)
162
{
163
	static struct statfs *mntbuf;
164
165
	if (pos == -1 || mntsize == -1)
166
		mntsize = getmntinfo (&mntbuf, MNT_NOWAIT);
167
168
	++pos;
169
	if (pos == mntsize) {
170
		pos = mntsize = -1;
171
		return (NULL);
172
	}
173
174
	return (statfs_to_mntent (&mntbuf[pos]));
175
}
176
177
}; // extern "C"
(-)b/plocate/files/patch-conf.cpp (+11 lines)
Added Link Here
1
--- conf.cpp.orig	2023-05-04 07:34:30 UTC
2
+++ conf.cpp
3
@@ -35,6 +35,8 @@ any later version.
4
 #include <string.h>
5
 #include <unistd.h>
6
 
7
+#define program_invocation_name getprogname()
8
+
9
 using namespace std;
10
 
11
 /* true if locate(1) should check whether files are visible before reporting
(-)b/plocate/files/patch-io__uring__engine.h (+10 lines)
Added Link Here
1
--- io_uring_engine.h.orig	2023-05-04 07:33:59 UTC
2
+++ io_uring_engine.h
3
@@ -7,7 +7,6 @@
4
 #include <string_view>
5
 #include <sys/socket.h>
6
 #include <sys/types.h>
7
-#include <linux/stat.h>
8
 
9
 struct io_uring_sqe;
10
 #ifndef WITHOUT_URING
(-)b/plocate/files/patch-meson.build (+56 lines)
Added Link Here
1
--- meson.build.orig	2023-05-04 07:34:20 UTC
2
+++ meson.build
3
@@ -1,7 +1,7 @@
4
 project('plocate', 'cpp', default_options: ['buildtype=debugoptimized','cpp_std=c++17'], version: '1.1.18')
5
 
6
 add_project_arguments('-DGROUPNAME="' + get_option('locategroup') + '"', language: 'cpp')
7
-add_project_arguments('-DUPDATEDB_CONF="/etc/updatedb.conf"', language: 'cpp')
8
+add_project_arguments('-DUPDATEDB_CONF= "' + get_option('prefix') + '/etc/updatedb.conf"', language: 'cpp')
9
 dbfile = join_paths(get_option('sharedstatedir'), get_option('dbpath'))
10
 add_project_arguments('-DDBFILE="' + dbfile + '"', language: 'cpp')
11
 add_project_arguments('-DPACKAGE_NAME="plocate"', language: 'cpp')
12
@@ -30,16 +30,12 @@ if cxx.compiles(code, name: 'function multiversioning'
13
 	add_project_arguments('-DHAS_FUNCTION_MULTIVERSIONING', language: 'cpp')
14
 endif
15
 
16
-executable('plocate', ['plocate.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'parse_trigrams.cpp', 'serializer.cpp', 'access_rx_cache.cpp', 'needle.cpp', 'complete_pread.cpp'],
17
+executable('plocate', ['plocate.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'parse_trigrams.cpp', 'serializer.cpp', 'access_rx_cache.cpp', 'needle.cpp', 'complete_pread.cpp', 'mntent_compat.c++'],
18
 	dependencies: [uringdep, zstddep, threaddep, atomicdep],
19
 	install: true,
20
 	install_mode: ['rwxr-sr-x', 'root', get_option('locategroup')])
21
-executable('plocate-build', ['plocate-build.cpp', 'database-builder.cpp'],
22
-	dependencies: [zstddep],
23
-	install: true,
24
-	install_dir: get_option('sbindir'))
25
 updatedb_progname = get_option('updatedb_progname')
26
-executable(updatedb_progname, ['updatedb.cpp', 'database-builder.cpp', 'conf.cpp', 'lib.cpp', 'bind-mount.cpp', 'complete_pread.cpp'],
27
+executable(updatedb_progname, ['updatedb.cpp', 'database-builder.cpp', 'conf.cpp', 'lib.cpp', 'bind-mount.cpp', 'complete_pread.cpp', 'mntent_compat.c++'],
28
 	dependencies: [zstddep, threaddep],
29
 	install: true,
30
 	install_dir: get_option('sbindir'))
31
@@ -49,7 +45,7 @@ conf_data.set('PROCESSED_BY_MESON', '1')
32
 conf_data.set('sbindir', join_paths(get_option('prefix'), get_option('sbindir')))
33
 conf_data.set('groupname', get_option('locategroup'))
34
 conf_data.set('dbfile', dbfile)
35
-conf_data.set('updatedb_conf', '/etc/updatedb.conf')
36
+conf_data.set('updatedb_conf',get_option('prefix')+'/etc/updatedb.conf')
37
 conf_data.set('updatedb_progname', updatedb_progname)
38
 update_script = configure_file(input: 'update-plocate.sh',
39
                output: 'update-plocate.sh',
40
@@ -64,7 +60,6 @@ if get_option('install_cron')
41
 		rename: 'plocate')
42
 endif
43
 install_man('plocate.1')
44
-install_man('plocate-build.8')
45
 
46
 updatedb_man = configure_file(input: 'updatedb.8.in',
47
                output: updatedb_progname + '.8',
48
@@ -102,7 +97,7 @@ if run_command('[', '-r', pfordir + '/libic.a', ']', c
49
 	turbopfordep = declare_dependency(
50
 		include_directories: include_directories('TurboPFor-Integer-Compression'),
51
 		dependencies: meson.get_compiler('cpp').find_library('ic', dirs: pfordir))
52
-	executable('bench', ['bench.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'complete_pread.cpp'],
53
+	executable('bench', ['bench.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'complete_pread.cpp', 'mntent_compat.c++'],
54
 		dependencies: [uringdep, turbopfordep],
55
 		build_by_default: false,
56
 		install: false)
(-)b/plocate/files/patch-updatedb.cpp (+11 lines)
Added Link Here
1
--- updatedb.cpp.orig	2023-05-04 07:34:10 UTC
2
+++ updatedb.cpp
3
@@ -44,7 +44,7 @@ any later version.
4
 #include <memory>
5
 #include <mntent.h>
6
 #include <random>
7
-#include <stdint.h>
8
+#include <cinttypes>
9
 #include <stdio.h>
10
 #include <stdlib.h>
11
 #include <string.h>
(-)b/plocate/files/updatedb.conf.sample (+1 lines)
Added Link Here
1
PRUNEFS = "devfs fdescfs nullfs procfs linsysfs"
(-)b/plocate/pkg-descr (+5 lines)
Added Link Here
1
plocate is a locate(1) based on posting lists, completely replacing mlocate
2
with a much faster (and smaller) index. It is suitable as a default locate on
3
your system.  Like mlocate and slocate, the returned file set is
4
user-dependent, ie. a user will only see a file if find(1) would list it (all
5
directories from the root have +rx permissions).
(-)b/plocate/pkg-plist (-1 / +8 lines)
Added Link Here
0
- 
1
@(,plocate,2755) bin/plocate
2
sbin/updatedb
3
man/man1/plocate.1.gz
4
man/man8/updatedb.8.gz
5
man/man5/updatedb.conf.5.gz
6
etc/periodic/daily/315.plocate
7
@sample etc/updatedb.conf.sample
8
@dir /var/db/plocate

Return to bug 270657