summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Ludd <solar@gentoo.org>2005-05-10 12:41:51 +0000
committerNed Ludd <solar@gentoo.org>2005-05-10 12:41:51 +0000
commit0ffe92c824c5537450719c3004179688ad59d1ad (patch)
tree90e98c778bc47f28a291d55875a1012f72fce3e1 /app-portage
parentmake sure to RDEPEND on a socks5 implementation -- dante is the only one I ca... (diff)
downloadgentoo-2-0ffe92c824c5537450719c3004179688ad59d1ad.tar.gz
gentoo-2-0ffe92c824c5537450719c3004179688ad59d1ad.tar.bz2
gentoo-2-0ffe92c824c5537450719c3004179688ad59d1ad.zip
- initial creation of qfile package. A very small and fast c implementation of portage query file tool
(Portage version: 2.0.51.21)
Diffstat (limited to 'app-portage')
-rw-r--r--app-portage/qfile/ChangeLog11
-rw-r--r--app-portage/qfile/Manifest5
-rw-r--r--app-portage/qfile/files/digest-qfile-0.0.10
-rw-r--r--app-portage/qfile/files/qfile.c170
-rw-r--r--app-portage/qfile/metadata.xml9
-rw-r--r--app-portage/qfile/qfile-0.0.1.ebuild29
6 files changed, 224 insertions, 0 deletions
diff --git a/app-portage/qfile/ChangeLog b/app-portage/qfile/ChangeLog
new file mode 100644
index 000000000000..5b52c0a1a266
--- /dev/null
+++ b/app-portage/qfile/ChangeLog
@@ -0,0 +1,11 @@
+# ChangeLog for app-portage/qfile
+# Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/app-portage/qfile/ChangeLog,v 1.1 2005/05/10 12:41:51 solar Exp $
+
+*qfile-0.0.1 (10 May 2005)
+
+ 10 May 2005; <solar@gentoo.org> +metadata.xml, +files/qfile.c,
+ +qfile-0.0.1.ebuild:
+ - initial creation of qfile package. A very small and fast c implementation of
+ portage query file tool
+
diff --git a/app-portage/qfile/Manifest b/app-portage/qfile/Manifest
new file mode 100644
index 000000000000..1d8a5ee2c660
--- /dev/null
+++ b/app-portage/qfile/Manifest
@@ -0,0 +1,5 @@
+MD5 cffbd3ee4f59f2a8812fd0e476d6de9a qfile-0.0.1.ebuild 729
+MD5 c2533cd492bf3cbb1320c8ed3121906c ChangeLog 342
+MD5 01cd2009d0c8237db444e250643f9438 metadata.xml 248
+MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-qfile-0.0.1 0
+MD5 6cf97214567873e16a84a57a8ff40ee8 files/qfile.c 4314
diff --git a/app-portage/qfile/files/digest-qfile-0.0.1 b/app-portage/qfile/files/digest-qfile-0.0.1
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/app-portage/qfile/files/digest-qfile-0.0.1
diff --git a/app-portage/qfile/files/qfile.c b/app-portage/qfile/files/qfile.c
new file mode 100644
index 000000000000..aa37718c45ab
--- /dev/null
+++ b/app-portage/qfile/files/qfile.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2003-2005 Gentoo Foundation
+ * Distributed under the terms of the GNU General Public License v2
+ * $Header: /var/cvsroot/gentoo-x86/app-portage/qfile/files/qfile.c,v 1.1 2005/05/10 12:41:51 solar Exp $
+ *
+ * 2005 Ned Ludd <solar@gentoo.org>
+ *
+ ********************************************************************
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <getopt.h>
+
+/* static const char *rcsid = "$Id: qfile.c,v 1.1 2005/05/10 12:41:51 solar Exp $"; */
+
+int color = 1;
+int exact = 0;
+int found = 0;
+
+void qfile(char *path, char *fname)
+{
+ FILE *fp;
+ DIR *dir;
+ struct dirent *dentry;
+ char *p, *newp;
+ int flen = strlen(fname);
+ int base = 0;
+ char buffer[1024];
+
+ if (chdir(path) != 0 || (dir = opendir(path)) == NULL)
+ return;
+
+ if (!strchr(fname, '/'))
+ base = 1;
+ else
+ base = 0;
+
+ readdir(dir);
+ readdir(dir); /* skip . & .. */
+ while ((dentry = readdir(dir))) {
+ if ((asprintf(&p, "%s/%s/CONTENTS", path, dentry->d_name)) == (-1))
+ continue;
+ if ((fp = fopen(p, "r")) == NULL) {
+ free(p);
+ continue;
+ }
+ free(p);
+ while ((fgets(buffer, sizeof(buffer), fp)) != NULL) {
+ if ((p = strchr(buffer, ' ')) == NULL)
+ continue;
+ *p++;
+ newp = strdup(p);
+ if (!newp)
+ continue;
+ if ((p = strchr(newp, ' ')) != NULL)
+ *p++ = 0;
+ if (strncmp(!base ? newp : basename(newp), fname, flen) != 0
+ || strlen(!base ? newp : basename(newp)) != flen) {
+ free(newp);
+ continue;
+ }
+ /* If the d_name is something like foo-3DVooDoo-0.0-r0 doing non
+ * exact matches would fail to display the name properly.
+ * /var/cvsroot/gentoo-x86/app-dicts/canna-2ch/
+ * /var/cvsroot/gentoo-x86/net-dialup/intel-536ep/
+ * /var/cvsroot/gentoo-x86/net-misc/cisco-vpnclient-3des/
+ * /var/cvsroot/gentoo-x86/sys-cluster/openmosix-3dmon-stats/
+ * /var/cvsroot/gentoo-x86/sys-cluster/openmosix-3dmon/
+ */
+ if (!exact && (p = strchr(dentry->d_name, '-')) != NULL) {
+ ++p;
+ if (*p >= '0' && *p <= '9') {
+ --p;
+ *p = 0;
+ } else {
+ /* tricky tricky.. I wish to advance to the second - */
+ /* and repeat the first p strchr matching */
+ char *q = strdup(p);
+ if (!q) {
+ free(newp);
+ continue;
+ }
+ if ((p = strchr(q, '-')) != NULL) {
+ int l = 0;
+ ++p;
+ if (*p >= '0' && *p <= '9') {
+ --p;
+ *p = 0;
+ ++p;
+ l = strlen(dentry->d_name) - strlen(p) - 1;
+ dentry->d_name[l] = 0;
+ }
+ }
+ free(q);
+ }
+ }
+
+ if (color)
+ printf("\e[0;01m%s/\e[36;01m%s\e[0m (%s)\n", basename(path),
+ dentry->d_name, newp);
+ else
+ printf("%s/%s (%s)\n", basename(path), dentry->d_name, newp);
+
+ free(newp);
+ fclose(fp);
+ closedir(dir);
+ found++;
+ return;
+ }
+ fclose(fp);
+ }
+ closedir(dir);
+ return;
+}
+
+int main(int argc, char **argv)
+{
+ DIR *dir;
+ struct dirent *dentry;
+ int i;
+ char *p, *path = "/var/db/pkg";
+
+ if ((chdir(path) == 0) && ((dir = opendir(path)))) {
+ readdir(dir);
+ readdir(dir); /* skip . & .. */
+ while ((dentry = readdir(dir))) {
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] != '-') {
+ if ((asprintf(&p, "%s/%s", path, dentry->d_name)) != (-1)) {
+ qfile(p, argv[i]);
+ free(p);
+ }
+ } else {
+ if (((strcmp(argv[i], "-nc")) == 0)
+ || ((strcmp(argv[i], "-C")) == 0))
+ color = 0;
+
+ if (((strcmp(argv[i], "-e")) == 0)
+ || ((strcmp(argv[i], "-exact")) == 0))
+ exact = 1;
+ }
+ }
+ }
+ closedir(dir);
+ }
+ exit(found ? EXIT_SUCCESS : EXIT_FAILURE);
+}
diff --git a/app-portage/qfile/metadata.xml b/app-portage/qfile/metadata.xml
new file mode 100644
index 000000000000..567723f81625
--- /dev/null
+++ b/app-portage/qfile/metadata.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>no-herd</herd>
+ <maintainer>
+ <email>solar@gentoo.org</email>
+ <name>Ned Ludd</name>
+ </maintainer>
+</pkgmetadata>
diff --git a/app-portage/qfile/qfile-0.0.1.ebuild b/app-portage/qfile/qfile-0.0.1.ebuild
new file mode 100644
index 000000000000..f938846a2c41
--- /dev/null
+++ b/app-portage/qfile/qfile-0.0.1.ebuild
@@ -0,0 +1,29 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-portage/qfile/qfile-0.0.1.ebuild,v 1.1 2005/05/10 12:41:51 solar Exp $
+
+inherit toolchain-funcs
+
+DESCRIPTION="very small and fast c implementation of portage query file tool"
+HOMEPAGE="http://www.gentoo.org/"
+SRC_URI=""
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
+IUSE=""
+DEPEND="virtual/libc"
+
+S=${WORKDIR}
+
+src_compile() {
+ cd ${S}
+ $(tc-getCC) ${CFLAGS} -o qfile \
+ ${FILESDIR}/qfile.c ${LDFLAGS} || die "compile"
+}
+
+src_install() {
+ dodir /usr/bin
+ exeinto /usr/bin
+ newexe ${S}/qfile ${PN} || die
+}