From: Matthias Schmidt Date: Sun, 17 Feb 2008 19:35:24 +0000 (+0000) Subject: Add a new option -s. With this option pkg_search(1) will display the description X-Git-Tag: v2.0.1~1090 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/4faa2bb3686f4636f0d6871a6e40df57c3300c4a Add a new option -s. With this option pkg_search(1) will display the description of a package. This is very helpful it you want to know more about a package. % pkg_search -s host-20040812 Host is a very powerful DNS query and testing command-line tool. Major differences with the ancient version of the program with the same name [...] Note: You need the complete pkgsrc tree to use -s. While here: o Whitespace fixes o Remove unused split commands o Bump copyright to 2008. --- diff --git a/usr.bin/pkg_search/pkg_search.1 b/usr.bin/pkg_search/pkg_search.1 index 4eeb511bdc..b06a80adf3 100644 --- a/usr.bin/pkg_search/pkg_search.1 +++ b/usr.bin/pkg_search/pkg_search.1 @@ -1,9 +1,9 @@ .\"- -.\" Copyright (c) 2007 The DragonFly Project. All rights reserved. -.\" +.\" Copyright (c) 2007-08 The DragonFly Project. All rights reserved. +.\" .\" This code is derived from software contributed to The DragonFly Project .\" by Matthias Schmidt , University of Marburg. -.\" +.\" .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -30,9 +30,9 @@ .\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $DragonFly: src/usr.bin/pkg_search/pkg_search.1,v 1.9 2008/02/10 11:01:46 matthias Exp $ +.\" $DragonFly: src/usr.bin/pkg_search/pkg_search.1,v 1.10 2008/02/17 19:35:24 matthias Exp $ .\" -.Dd February 10, 2008 +.Dd February 17, 2008 .Dt PKG_SEARCH 1 .Os .Sh NAME @@ -40,7 +40,7 @@ .Nd print information about a package .Sh SYNOPSIS .Nm -.Op Fl k | v +.Op Fl k | s | v .Ar package .Sh DESCRIPTION .Nm @@ -61,6 +61,8 @@ The options are as follows: .Bl -tag -width indent .It Fl k Also query the Info and WWW field. +.It Fl s +Show the description of a package. .It Fl v Print verbose information (Ports directory, URL, depencies) .El diff --git a/usr.bin/pkg_search/pkg_search.sh b/usr.bin/pkg_search/pkg_search.sh index b24f07e394..8323a1aa2f 100644 --- a/usr.bin/pkg_search/pkg_search.sh +++ b/usr.bin/pkg_search/pkg_search.sh @@ -1,19 +1,19 @@ #!/bin/sh # -# Copyright (c) 2007 The DragonFly Project. All rights reserved. +# Copyright (c) 2007-08 The DragonFly Project. All rights reserved. # # This code is derived from software contributed to The DragonFly Project # by Matthias Schmidt , University of Marburg. # # All rights reserved. # -# Redistribution and use in source and binary forms, with or without +# Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # -# - Redistributions of source code must retain the above copyright notice, +# - Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. -# - Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation +# - 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. # - Neither the name of The DragonFly Project nor the names of its # contributors may be used to endorse or promote products derived @@ -31,7 +31,7 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# $DragonFly: src/usr.bin/pkg_search/pkg_search.sh,v 1.6 2008/02/10 11:01:46 matthias Exp $ +# $DragonFly: src/usr.bin/pkg_search/pkg_search.sh,v 1.7 2008/02/17 19:35:24 matthias Exp $ UNAME=`uname -s` VERSION=`uname -r | cut -d '.' -f 1,2` @@ -88,7 +88,7 @@ bin_ext_search() found = 1; } else found = 0; - + if (found == 1 && $1 == "COMMENT") printf("Desc\t: %-50s\n", $2); if (found == 1 && $1 == "PKGPATH") @@ -104,9 +104,8 @@ index_v_search() if [ ${KFLAG} -eq 0 ]; then awk -F\| -v name="$1" '{ if (tolower($1) ~ name) { - split($2, a, "/"); printf("Name\t: %s-50\nDir\t: %-50s\nDesc\t: %-50s"\ - "\nURL\t: %-50s\nDeps\t: %s\n\n", $1, $2, + "\nURL\t: %-50s\nDeps\t: %s\n\n", $1, $2, $4, $12, $9); } }' ${PORTSDIR}/${INDEXFILE} @@ -114,9 +113,8 @@ index_v_search() awk -F\| -v name="$1" '{ if (tolower($1) ~ name || tolower($4) ~ name || tolower($12) ~ name) { - split($2, a, "/"); printf("Name\t: %s-50\nDir\t: %-50s\nDesc\t: %-50s"\ - "\nURL\t: %-50s\nDeps\t: %s\n\n", $1, $2, + "\nURL\t: %-50s\nDeps\t: %s\n\n", $1, $2, $4, $12, $9); } }' ${PORTSDIR}/${INDEXFILE} @@ -129,7 +127,6 @@ index_search() if [ ${KFLAG} -eq 0 ]; then awk -F\| -v name="$1" '{ if (tolower($1) ~ name) { - split($2, a, "/"); printf("%-20s\t%-25s\n", $1, $4); } }' ${PORTSDIR}/${INDEXFILE} @@ -137,21 +134,38 @@ index_search() awk -F\| -v name="$1" '{ if (tolower($1) ~ name || tolower($4) ~ name || tolower($12) ~ name) { - split($2, a, "/"); printf("%-20s\t%-25s\n", $1, $4); } }' ${PORTSDIR}/${INDEXFILE} fi } +show_description() +{ + PDESC=`awk -F\| -v name="$1" '{ + if (tolower($1) == name) { + split($2, ppath, "/"); + printf("%s\n", $5); + } + }' ${PORTSDIR}/${INDEXFILE}` + if [ -f "${PORTSDIR}/${PDESC}" ]; then + cat "${PORTSDIR}/${PDESC}" + else + echo "Unable to locate package $1. Please provide the exact" + echo "package name as given by pkg_search(1). You need the" + echo "complete pkgsrc(7) tree to perform this operation." + fi +} + usage() { echo "usage: $0 [-k | -v] package" - exit 1 + exit 1 } -args=`getopt kv $*` +args=`getopt ksv $*` +SFLAG=0 KFLAG=0 VFLAG=0 @@ -160,6 +174,8 @@ for i; do case "$i" in -k) KFLAG=1; shift;; + -s) + SFLAG=1; shift;; -v) VFLAG=1; shift;; --) @@ -175,6 +191,8 @@ if [ ${VFLAG} -eq 0 -a ${NO_INDEX} -eq 1 ]; then bin_simple_search $1 elif [ ${VFLAG} -eq 1 -a ${NO_INDEX} -eq 1 ]; then bin_ext_search $1 +elif [ ${SFLAG} -eq 1 -a ${NO_INDEX} -eq 0 ]; then + show_description $1 elif [ ${VFLAG} -eq 0 -a ${NO_INDEX} -eq 0 ]; then index_search $1 elif [ ${VFLAG} -eq 1 -a ${NO_INDEX} -eq 0 ]; then