ports/83530: Add 'quicksearch' parameter to ports search engine
Lars Engels
lars.engels at 0x20.net
Fri Jul 15 23:10:02 UTC 2005
>Number: 83530
>Category: ports
>Synopsis: Add 'quicksearch' parameter to ports search engine
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 15 23:10:00 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Lars Engels
>Release: FreeBSD 5.4-STABLE i386
>Organization:
>Environment:
System: FreeBSD 5.4-STABLE #0: Mon Jul 11 23:05:28 CEST 2005
lars at krusty.bsd-geek.de:/usr/obj/usr/src/sys/BART
>Description:
The diff file contains changes to /usr/ports/Mk/bsd.port.subdir.mk which adds the target quicksearch to the ports makefiles.
make quicksearch takes only [x]key and [xname] as a search criteria and only shows the port, path and info section of the matching ports.
The same output can be generated by using display=name,path,info but quicksearch is easier to use.
>How-To-Repeat:
>Fix:
--- bsd.port.subdir.mk.diff begins here ---
*** bsd.port.subdir.mk Sat Jul 16 00:48:17 2005
--- bsd.port.subdir.mk.new Sat Jul 16 00:47:34 2005
***************
*** 430,432 ****
--- 430,506 ----
printf("%s:\t%s\n", names[i], $$i); \
print(""); \
}' ${PORTSDIR}/${INDEXFILE}
+
+ quicksearch: ${PORTSDIR}/${INDEXFILE}
+ @here=${.CURDIR}; \
+ cd ${PORTSDIR}; \
+ if [ -z "$$key" -a -z "$$xkey" -a \
+ -z "$$name" -a -z "$$xname" -a \
+ -z "$$path" -a -z "$$xpath" -a \
+ -z "$$info" -a -z "$$xinfo" ]; \
+ then \
+ echo "The quicksearch target requires a keyword parameter or name parameter,"; \
+ echo "e.g.: \"make search key=somekeyword\""; \
+ echo "or \"make search name=somekeyword\""; \
+ exit; \
+ fi; \
+ awk -F\| -v there="$$here/" -v top="$$(pwd -P)" \
+ -v key="$$key" -v xkey="$$xkey" \
+ -v name="$$name" -v xname="$$xname" \
+ -v path="$$path" -v xpath="$$xpath" \
+ -v info="$$info" -v xinfo="$$xinfo" \
+ -v icase="$${icase:-${PORTSEARCH_IGNORECASE}}" \
+ -v keylim="$${keylim:-${PORTSEARCH_KEYLIM}}" \
+ -v xkeylim="$${xkeylim:-${PORTSEARCH_XKEYLIM}}" \
+ -v display="$${display:-${PORTSEARCH_DISPLAY_FIELDS}}" \
+ 'BEGIN { \
+ if (substr(there, 1, length(top)) == top) \
+ there = "${PORTSDIR}" substr(there, 1 + length(top)); \
+ therelen = length(there); \
+ keylen = length(key); keylim = keylim && keylen; \
+ if (!keylim && keylen) \
+ parms[0] = (icase ? tolower(key) : key); \
+ xkeylen = length(xkey); xkeylim = xkeylim && xkeylen; \
+ if (!xkeylim && xkeylen) \
+ xparms[0] = (icase ? tolower(xkey) : xkey); \
+ if (icase) { \
+ if (length(name)) parms[1] = tolower(name); if (length(xname)) xparms[1] = tolower(xname); \
+ if (length(path)) parms[2] = tolower(path); if (length(xpath)) xparms[2] = tolower(xpath); \
+ if (length(info)) parms[4] = tolower(info); if (length(xinfo)) xparms[4] = tolower(xinfo); \
+ } else { \
+ if (length(name)) parms[1] = name; if (length(xname)) xparms[1] = xname; \
+ if (length(path)) parms[2] = path; if (length(xpath)) xparms[2] = xpath; \
+ if (length(info)) parms[4] = info; if (length(xinfo)) xparms[4] = xinfo; \
+ } \
+ fields["name"] = 1; names[1] = "Port"; \
+ fields["path"] = 2; names[2] = "Path"; \
+ fields["info"] = 4; names[4] = "Info"; \
+ split(display, d, /,[ \t]*/); \
+ for (i in d) { \
+ disp[fields[d[i]]] = 1; \
+ } \
+ } \
+ { \
+ if (substr($$2, 1, therelen) != there) \
+ next; \
+ for (i in parms) \
+ if ((icase ? tolower($$i) : $$i) !~ parms[i]) \
+ next; \
+ for (i in xparms) \
+ if ((icase ? tolower($$i) : $$i) ~ xparms[i]) \
+ next; \
+ found = 0; \
+ for (i = 1; i < 11; i++) \
+ if (i in disp) { \
+ if (xkeylim && (icase ? tolower($$i) : $$i) ~ xkey) \
+ next; \
+ if (!found && keylim && (icase ? tolower($$i) : $$i) ~ key) \
+ found = 1; \
+ } \
+ if (keylim && !found) \
+ next; \
+ for (i = 1; i < 11; i++) \
+ if (i in disp) \
+ printf("%s:\t%s\n", names[i], $$i); \
+ print(""); \
+ }' ${PORTSDIR}/${INDEXFILE}
--- bsd.port.subdir.mk.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list