.\"-
-.\" Copyright (c) 2007-08 The DragonFly Project. All rights reserved.
+.\" Copyright (c) 2007-09 The DragonFly Project. All rights reserved.
.\"
.\" This code is derived from software contributed to The DragonFly Project
.\" by Matthias Schmidt <matthias@dragonflybsd.org>, University of Marburg.
.\"
.\" $DragonFly: src/usr.bin/pkg_search/pkg_search.1,v 1.11 2008/09/04 10:33:50 matthias Exp $
.\"
-.Dd August 29, 2008
+.Dd February 8, 2009
.Dt PKG_SEARCH 1
.Os
.Sh NAME
.Nm
.Fl s
.Ar package
+.Nm
+.Fl d
.Sh DESCRIPTION
.Nm
queries the
.Pp
The options are as follows:
.Bl -tag -width indent
+.It Fl d
+Download the
+.Xr pkg_summary 5
+file.
+It gets overwritten if it is already installed.
.It Fl k
Also query the Info and WWW field.
.It Fl s
#!/bin/sh
#
-# Copyright (c) 2007-08 The DragonFly Project. All rights reserved.
+# Copyright (c) 2007-09 The DragonFly Project. All rights reserved.
#
# This code is derived from software contributed to The DragonFly Project
# by Matthias Schmidt <matthias@dragonflybsd.org>, University of Marburg.
PKGSRCBOX2=http://pkgbox.dragonflybsd.org/packages/DragonFly-2.2/stable/
INDEXFILE=INDEX
-if [ ! -f ${PKGSUM} -a ! -e ${PORTSDIR}/${INDEXFILE} ]; then
- echo "No pkgsrc(7) tree found. Fetching pkg_summary(5) file."
+# Download the pkg_summary file
+download_summary()
+{
+ echo "Fetching pkg_summary(5) file."
FETCHPATH=${PKGSRCBOX1}/All/pkg_summary.bz2
- mkdir -p ${PORTSDIR}
fetch -o ${PKGSUM}.bz2 ${FETCHPATH}
if [ $? -ne 0 ]; then
FETCHPATH=${PKGSRCBOX2}/All/pkg_summary.bz2
fi
bunzip2 < ${PKGSUM}.bz2 > ${PKGSUM}
rm -f ${PKGSUM}.bz2
- NO_INDEX=1
-fi
-if [ -e ${PKGSUM} -a ! -e ${PORTSDIR}/${INDEXFILE} ]; then
- NO_INDEX=1
-fi
+}
# Perform simple search in pkg_summary
bin_simple_search()
{
echo "usage: `basename $0` [-kv] package"
echo " `basename $0` -s package"
+ echo " `basename $0` -d"
exit 1
}
-args=`getopt ksv $*`
+if [ ! -f ${PKGSUM} -a ! -e ${PORTSDIR}/${INDEXFILE} ]; then
+ echo "No pkgsrc(7) tree found."
+ mkdir -p ${PORTSDIR}
+ download_summary
+ NO_INDEX=1
+fi
+if [ -e ${PKGSUM} -a ! -e ${PORTSDIR}/${INDEXFILE} ]; then
+ NO_INDEX=1
+fi
+
+args=`getopt dksv $*`
SFLAG=0
KFLAG=0
VFLAG=0
+DFLAG=0
set -- $args
for i; do
case "$i" in
+ -d)
+ DFLAG=1; shift;;
-k)
KFLAG=1; shift;;
-s)
esac
done
-if [ -z ${1} ]; then
+if [ ${DFLAG} -eq 0 -a -z ${1} ]; then
usage
fi
+if [ ${DFLAG} -eq 1 ]; then
+ download_summary
+ exit $?
+fi
+
if [ ${VFLAG} -eq 0 -a ${NO_INDEX} -eq 1 ]; then
bin_simple_search $1
elif [ ${VFLAG} -eq 1 -a ${NO_INDEX} -eq 1 ]; then