FreeBSD Bugzilla – Attachment 241313 Details for
Bug 270657
[NEW PORT] sysutils/plocate - locate that can find all files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
new port patch
0001-NEW-PORT-sysutils-plocate-locate-that-can-find-all-f.patch (text/plain), 12.22 KB, created by
sec
on 2023-04-05 16:38:58 UTC
(
hide
)
Description:
new port patch
Filename:
MIME Type:
Creator:
sec
Created:
2023-04-05 16:38:58 UTC
Size:
12.22 KB
patch
obsolete
>From 83aa03ccca42d6b74d598535f0bc7fb68584f08f Mon Sep 17 00:00:00 2001 >From: Stefan `Sec` Zehl <sec@42.org> >Date: Wed, 5 Apr 2023 18:32:12 +0200 >Subject: [PATCH] [NEW PORT] sysutils/plocate locate that can find all files > >--- > sysutils/plocate/Makefile | 42 +++++ > sysutils/plocate/distinfo | 3 + > sysutils/plocate/files/315.plocate.in | 32 ++++ > sysutils/plocate/files/mntent.h | 62 +++++++ > sysutils/plocate/files/mntent_compat.c++ | 177 ++++++++++++++++++++ > sysutils/plocate/files/updatedb.conf.sample | 1 + > sysutils/plocate/pkg-descr | 5 + > sysutils/plocate/pkg-plist | 8 + > 8 files changed, 330 insertions(+) > create mode 100644 sysutils/plocate/Makefile > create mode 100644 sysutils/plocate/distinfo > create mode 100644 sysutils/plocate/files/315.plocate.in > create mode 100644 sysutils/plocate/files/mntent.h > create mode 100644 sysutils/plocate/files/mntent_compat.c++ > create mode 100644 sysutils/plocate/files/updatedb.conf.sample > create mode 100644 sysutils/plocate/pkg-descr > create mode 100644 sysutils/plocate/pkg-plist > >diff --git a/sysutils/plocate/Makefile b/sysutils/plocate/Makefile >new file mode 100644 >index 0000000..4ecee55 >--- /dev/null >+++ b/sysutils/plocate/Makefile >@@ -0,0 +1,42 @@ >+PORTNAME= plocate >+PORTVERSION= 1.1.18 >+CATEGORIES= sysutils >+MASTER_SITES= https://plocate.sesse.net/download/ >+ >+MAINTAINER= sec@42.org >+COMMENT= Fast & privacy-respecting locate utility >+WWW= https://plocate.sesse.net/ >+ >+LICENSE= GPLv2 >+LICENSE_FILE= ${WRKSRC}/COPYING >+ >+BUILD_DEPENDS= meson:devel/meson >+LIB_DEPENDS= libzstd.so:archivers/zstd >+ >+USES= meson >+MESON_ARGS= --sharedstatedir=${PREFIX}/var/db >+ >+CFLAGS+= -I${FILESDIR} >+ >+SUB_FILES= 315.plocate >+ >+GROUPS= plocate >+ >+post-patch: >+ @${REINPLACE_CMD} -e 's|#include <linux/stat.h>||' ${WRKSRC}/io_uring_engine.h >+ @${REINPLACE_CMD} -e 's|#include <stdint.h>|#include <cinttypes>|' ${WRKSRC}/updatedb.cpp >+ @${REINPLACE_CMD} -e "s|-DUPDATEDB_CONF=\"|-DUPDATEDB_CONF= \"' + get_option('prefix') + '|" ${WRKSRC}/meson.build >+ @${REINPLACE_CMD} -e "s|conf_data.set('updatedb_conf', |conf_data.set('updatedb_conf',get_option('prefix')+|" ${WRKSRC}/meson.build >+ @${REINPLACE_CMD} -e '/executable(.plocate-build./,+3d;/plocate-build.8/d' ${WRKSRC}/meson.build >+ @${REINPLACE_CMD} -e "s|'complete_pread.cpp']|'complete_pread.cpp', '${FILESDIR}/mntent_compat.c++']|" ${WRKSRC}/meson.build >+ @${REINPLACE_CMD} -e 's|program_invocation_name|"plocate"|' ${WRKSRC}/conf.cpp >+ >+post-install: >+ @${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily >+ ${INSTALL_SCRIPT} ${WRKDIR}/315.plocate \ >+ ${STAGEDIR}${PREFIX}/etc/periodic/daily >+ ${INSTALL_DATA} ${FILESDIR}/updatedb.conf.sample \ >+ ${STAGEDIR}${PREFIX}/etc >+ ${MKDIR} ${STAGEDIR}${PREFIX}/var/db/plocate >+ >+.include <bsd.port.mk> >diff --git a/sysutils/plocate/distinfo b/sysutils/plocate/distinfo >new file mode 100644 >index 0000000..9e8a1ad >--- /dev/null >+++ b/sysutils/plocate/distinfo >@@ -0,0 +1,3 @@ >+TIMESTAMP = 1680026625 >+SHA256 (plocate-1.1.18.tar.gz) = 939657050b70719b01ce04fc1c8b64270062a0d53da2c72eafbe036a1964e12c >+SIZE (plocate-1.1.18.tar.gz) = 73906 >diff --git a/sysutils/plocate/files/315.plocate.in b/sysutils/plocate/files/315.plocate.in >new file mode 100644 >index 0000000..4220a49 >--- /dev/null >+++ b/sysutils/plocate/files/315.plocate.in >@@ -0,0 +1,32 @@ >+#!/bin/sh - >+# >+# $FreeBSD$ >+# >+ >+# If there is a global system configuration file, suck it in. >+# >+if [ -r /etc/defaults/periodic.conf ] >+then >+ . /etc/defaults/periodic.conf >+ source_periodic_confs >+fi >+ >+case "$daily_plocate_enable" in >+ [Yy][Ee][Ss]) >+ echo "" >+ echo "Rebuilding plocate database:" >+ >+ SBINDIR=%%PREFIX%%/sbin >+ LOCATEGROUP=plocate >+ DBFILE=%%PREFIX%%/var/db/plocate/plocate.db >+ >+ touch $DBFILE && rc=0 || rc=3 >+ >+ cd / >+ nice -n 5 $SBINDIR/updatedb >+ ;; >+ >+ *) rc=0;; >+esac >+ >+exit $rc >diff --git a/sysutils/plocate/files/mntent.h b/sysutils/plocate/files/mntent.h >new file mode 100644 >index 0000000..e61cddd >--- /dev/null >+++ b/sysutils/plocate/files/mntent.h >@@ -0,0 +1,62 @@ >+/* >+ * mntent >+ * mntent.h - compatability header for FreeBSD >+ * >+ * Copyright (c) 2001 David Rufino <daverufino@btinternet.com> >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND >+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE >+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE >+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT >+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+ * SUCH DAMAGE. >+ */ >+ >+#if defined(HAVE_MNTENT_H) >+#include <mntent.h> >+#else >+#ifndef _MNTENT_H >+#define _MNTENT_H >+#include <stdio.h> >+ >+#define MOUNTED "dummy" >+ >+#define MNTTYPE_NFS "nfs" >+ >+struct mntent { >+ char *mnt_fsname; >+ char *mnt_dir; >+ char *mnt_type; >+ char *mnt_opts; >+ int mnt_freq; >+ int mnt_passno; >+}; >+ >+#define setmntent(x,y) ((FILE *)0x1) >+#ifdef __cplusplus >+extern "C" { >+#endif >+struct mntent *getmntent __P ((FILE *fp)); >+char *hasmntopt __P ((const struct mntent *mnt, const char *option)); >+#ifdef __cplusplus >+}; // extern "C" >+#endif >+#define endmntent(x) ((int)1) >+ >+#endif /* _MNTENT_H */ >+#endif /* HAVE_MNTENT_H */ >diff --git a/sysutils/plocate/files/mntent_compat.c++ b/sysutils/plocate/files/mntent_compat.c++ >new file mode 100644 >index 0000000..4ca1a55 >--- /dev/null >+++ b/sysutils/plocate/files/mntent_compat.c++ >@@ -0,0 +1,177 @@ >+/* >+ * Copyright (c) 1980, 1989, 1993, 1994 >+ * The Regents of the University of California. All rights reserved. >+ * Copyright (c) 2001 >+ * David Rufino <daverufino@btinternet.com> >+ * Copyright (c) 2006 >+ * Stanislav Sedov <ssedov@mbsd.msk.ru> >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. All advertising materials mentioning features or use of this software >+ * must display the following acknowledgement: >+ * This product includes software developed by the University of >+ * California, Berkeley and its contributors. >+ * 4. Neither the name of the University nor the names of its contributors >+ * may be used to endorse or promote products derived from this software >+ * without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND >+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE >+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE >+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL >+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT >+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+ * SUCH DAMAGE. >+ */ >+ >+/* most of this was ripped from the mount(3) source */ >+ >+//#include "config.h" >+#include "mntent.h" >+#include <stdlib.h> >+#include <string.h> >+#include <sys/param.h> >+#include <sys/ucred.h> >+#include <sys/mount.h> >+ >+static int pos = -1; >+static int mntsize = -1; >+static struct mntent _mntent; >+ >+struct { >+ int m_flag; >+ const char *m_option; >+} mntoptions[] = { >+ { MNT_ASYNC, "async" }, >+ { MNT_NOATIME, "noatime"}, >+ { MNT_NOEXEC, "noexec"}, >+ { MNT_NOSUID, "nosuid"}, >+ { MNT_NOSYMFOLLOW, "nosymfollow"}, >+ { MNT_SYNCHRONOUS, "sync"}, >+ { MNT_UNION, "union"}, >+ { MNT_NOCLUSTERR, "noclusterr"}, >+ { static_cast<int>(MNT_NOCLUSTERW), "noclusterw"}, >+ { MNT_SUIDDIR, "suiddir"}, >+#ifdef MNT_SNAPSHOT >+ { MNT_SNAPSHOT, "snapshot"}, >+#endif >+#ifdef MNT_MULTILABEL >+ { MNT_MULTILABEL, "multilabel"}, >+#endif >+#ifdef MNT_ACLS >+ { MNT_ACLS, "acls"}, >+#endif >+#ifdef MNT_NODEV >+ { MNT_NODEV, "nodev"}, >+#endif >+}; >+ >+#define N_OPTS (sizeof(mntoptions) / sizeof(*mntoptions)) >+ >+ >+extern "C" { >+ >+char * >+hasmntopt (const struct mntent *mnt, const char *option) >+{ >+ char *opt, *optbuf; >+ >+ optbuf = strdup(mnt->mnt_opts); >+ for (opt = optbuf; (opt = strtok(opt, " ")) != NULL; opt = NULL) { >+ if (!strcasecmp(opt, option)) { >+ opt = opt - optbuf + mnt->mnt_opts; >+ free (optbuf); >+ return (opt); >+ } >+ } >+ free (optbuf); >+ return (NULL); >+} >+ >+static char * >+catopt (char *s0, const char *s1) >+{ >+ size_t newlen; >+ char *cp; >+ >+ if (s1 == NULL || *s1 == '\0') >+ return s0; >+ >+ if (s0 != NULL) { >+ newlen = strlen(s0) + strlen(s1) + 1 + 1; >+ if ((cp = (char *)realloc(s0, newlen)) == NULL) >+ return (NULL); >+ >+ (void)strcat(cp, " "); >+ (void)strcat(cp, s1); >+ } else >+ cp = strdup(s1); >+ >+ return (cp); >+} >+ >+ >+static char * >+flags2opts (int flags) >+{ >+ char *res = NULL; >+ int i; >+ >+ res = catopt(res, (flags & MNT_RDONLY) ? "ro" : "rw"); >+ >+ for (i = 0; i < N_OPTS; i++) >+ if (flags & mntoptions[i].m_flag) >+ res = catopt(res, mntoptions[i].m_option); >+ return res; >+} >+ >+static struct mntent * >+statfs_to_mntent (struct statfs *mntbuf) >+{ >+ static char opts_buf[40], *tmp; >+ >+ _mntent.mnt_fsname = mntbuf->f_mntfromname; >+ _mntent.mnt_dir = mntbuf->f_mntonname; >+ _mntent.mnt_type = mntbuf->f_fstypename; >+ tmp = flags2opts (mntbuf->f_flags); >+ if (tmp) { >+ opts_buf[sizeof(opts_buf) - 1] = '\0'; >+ strncpy (opts_buf, tmp, sizeof(opts_buf)-1); >+ free (tmp); >+ } else { >+ *opts_buf = '\0'; >+ } >+ _mntent.mnt_opts = opts_buf; >+ _mntent.mnt_freq = _mntent.mnt_passno = 0; >+ return (&_mntent); >+} >+ >+struct mntent * >+getmntent (FILE *fp) >+{ >+ static struct statfs *mntbuf; >+ >+ if (pos == -1 || mntsize == -1) >+ mntsize = getmntinfo (&mntbuf, MNT_NOWAIT); >+ >+ ++pos; >+ if (pos == mntsize) { >+ pos = mntsize = -1; >+ return (NULL); >+ } >+ >+ return (statfs_to_mntent (&mntbuf[pos])); >+} >+ >+}; // extern "C" >diff --git a/sysutils/plocate/files/updatedb.conf.sample b/sysutils/plocate/files/updatedb.conf.sample >new file mode 100644 >index 0000000..9bbf446 >--- /dev/null >+++ b/sysutils/plocate/files/updatedb.conf.sample >@@ -0,0 +1 @@ >+PRUNEFS = "devfs fdescfs nullfs procfs linsysfs" >diff --git a/sysutils/plocate/pkg-descr b/sysutils/plocate/pkg-descr >new file mode 100644 >index 0000000..04e074d >--- /dev/null >+++ b/sysutils/plocate/pkg-descr >@@ -0,0 +1,5 @@ >+plocate is a locate(1) based on posting lists, completely replacing mlocate >+with a much faster (and smaller) index. It is suitable as a default locate on >+your system. Like mlocate and slocate, the returned file set is >+user-dependent, ie. a user will only see a file if find(1) would list it (all >+directories from the root have +rx permissions). >diff --git a/sysutils/plocate/pkg-plist b/sysutils/plocate/pkg-plist >new file mode 100644 >index 0000000..470bd7e >--- /dev/null >+++ b/sysutils/plocate/pkg-plist >@@ -0,0 +1,8 @@ >+@(,plocate,2755) bin/plocate >+sbin/updatedb >+man/man1/plocate.1.gz >+man/man8/updatedb.8.gz >+man/man5/updatedb.conf.5.gz >+etc/periodic/daily/315.plocate >+@sample etc/updatedb.conf.sample >+@dir var/db/plocate >-- >2.39.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 270657
:
241313
|
241965
|
242160
|
242198