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

Collapse All | Expand All

(-)b/sysutils/plocate/Makefile (+42 lines)
Added Link Here
1
PORTNAME=	plocate
2
PORTVERSION=	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=${PREFIX}/var/db
18
19
CFLAGS+=	-I${FILESDIR}
20
21
SUB_FILES=	315.plocate
22
23
GROUPS=		plocate
24
25
post-patch:
26
	@${REINPLACE_CMD} -e 's|#include <linux/stat.h>||' ${WRKSRC}/io_uring_engine.h
27
	@${REINPLACE_CMD} -e 's|#include <stdint.h>|#include <cinttypes>|' ${WRKSRC}/updatedb.cpp
28
	@${REINPLACE_CMD} -e "s|-DUPDATEDB_CONF=\"|-DUPDATEDB_CONF= \"' + get_option('prefix') + '|" ${WRKSRC}/meson.build
29
	@${REINPLACE_CMD} -e "s|conf_data.set('updatedb_conf', |conf_data.set('updatedb_conf',get_option('prefix')+|" ${WRKSRC}/meson.build
30
	@${REINPLACE_CMD} -e '/executable(.plocate-build./,+3d;/plocate-build.8/d' ${WRKSRC}/meson.build
31
	@${REINPLACE_CMD} -e "s|'complete_pread.cpp']|'complete_pread.cpp', '${FILESDIR}/mntent_compat.c++']|" ${WRKSRC}/meson.build
32
	@${REINPLACE_CMD} -e 's|program_invocation_name|"plocate"|' ${WRKSRC}/conf.cpp
33
34
post-install:
35
	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily
36
	${INSTALL_SCRIPT} ${WRKDIR}/315.plocate \
37
		${STAGEDIR}${PREFIX}/etc/periodic/daily
38
	${INSTALL_DATA} ${FILESDIR}/updatedb.conf.sample \
39
		${STAGEDIR}${PREFIX}/etc
40
	${MKDIR} ${STAGEDIR}${PREFIX}/var/db/plocate
41
42
.include <bsd.port.mk>
(-)b/sysutils/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/sysutils/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=%%PREFIX%%/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/sysutils/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/sysutils/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/sysutils/plocate/files/updatedb.conf.sample (+1 lines)
Added Link Here
1
PRUNEFS = "devfs fdescfs nullfs procfs linsysfs"
(-)b/sysutils/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/sysutils/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