DragonFly users List (threaded) for 2007-12
DragonFly BSD
DragonFly users List (threaded) for 2007-12
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Fetch pkgsrc index with pkg_search


From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Dec 2007 12:26:25 -0800 (PST)

:Thanks, I wasn't aware of this file.  The file is not very parser
:friendly, compared with the INDEX file :)
:
:I could use it as a workaround:  If no pkgsrc tree is found, check for
:the pkg_summary file and download it if necessary.  Then pkg_search
:could perform a only basic search.  Maybe it should output the path to
:the server to install the binary package?
:
:Check the attached path against HEAD.  I also updated my email address
::)
:
:Regards,
:
:	Matthias

    There were some ordering issues with the PKGSUM assignment in that
    patch.  I made some modifications and got it to work, but your
    patch also removed the FreeBSD case so you'd have to put that back
    in and fixup PORTSDIR and PKGSUM for FreeBSD and other OSs.

    There might also be issues with the Makefile we put in /usr which
    has the ability to fetch the pkgsrc tree.

						-Matt

Index: pkg_search.sh
===================================================================
RCS file: /cvs/src/usr.bin/pkg_search/pkg_search.sh,v
retrieving revision 1.1
diff -u -p -r1.1 pkg_search.sh
--- pkg_search.sh	4 Dec 2007 18:24:18 -0000	1.1
+++ pkg_search.sh	11 Dec 2007 20:20:34 -0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (c) 2006 Matthias Schmidt <schmidtm @ mathematik . uni-marburg.de>
+# Copyright (c) 2006-07 Matthias Schmidt <schmidtm@mathematik.uni-marburg.de>
 #
 # All rights reserved.
 #
@@ -27,13 +27,36 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSI
 #
 # $DragonFly: src/usr.bin/pkg_search/pkg_search.sh,v 1.1 2007/12/04 18:24:18 dillon Exp $
 
-if [ `uname -s` = "FreeBSD" ]; then
-	PORTSDIR=/usr/ports
-	id=`uname -r | cut -d '.' -f 1`
-	INDEXFILE=INDEX-$id
-elif [ `uname -s` = "DragonFly" ] || [ `uname -s` = "NetBSD" ]; then
+UNAME=`uname -s`
+VERSION=`uname -r | cut -d '.' -f 1,2`
+SIMPLE=0
+
+if [ $UNAME = "DragonFly" ]; then
 	PORTSDIR=/usr/pkgsrc
+	PKGSUM=${PORTSDIR}/pkg_summary
+	PKGSRCBOX1=http://pkgbox.dragonflybsd.org/packages/${UNAME}-${VERSION}/i386/
+	PKGSRCBOX2=http://pkgbox.dragonflybsd.org/packages/DragonFly-1.10.1/i386/
 	INDEXFILE=INDEX
+	if [ ! -f ${PKGSUM} ]; then
+		echo "No pkgsrc(7) tree found.  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
+			fetch -o ${PKGSUM}.bz2 ${FETCHPATH}
+		fi
+		if [ $? -ne 0 ]; then
+			echo "Unable to fetch pkg_summary"
+			exit 1
+		fi
+		bunzip2 < ${PKGSUM}.bz2 > ${PKGSUM}
+		rm -f ${PKGSUM}.bz2
+		SIMPLE=1
+	fi
+	if [ -e ${PKGSUM} -a ! -e ${PORTSDIR}/${INDEXFILE} ]; then
+		SIMPLE=1
+	fi
 fi
 
 if [ -z $1 ]; then 
@@ -41,13 +64,13 @@         echo "Usage: $0 [ -i | -k ] <nam
         exit 1  
 fi
 
-if [ ! -d $PORTSDIR ]; then 
-        echo "No Ports Tree Found!  Please install."
-        exit 1  
-fi
 
 case "$1" in
 	-i)
+		if [ ${SIMPLE} -eq 1 ]; then
+			grep "PKGNAME=$2" ${PKGSUM} | cut -d '=' -f 2
+			exit 1
+		fi
 		awk -F\| -v name="$2" \
 	    '{\
 		    if ($1 ~ name) { \
@@ -57,6 +80,10 @@ 		    }
 	    }' ${PORTSDIR}/${INDEXFILE}
 	;;
 	-k)
+		if [ ${SIMPLE} -eq 1 ]; then
+			grep "PKGNAME=$2" ${PKGSUM} | cut -d '=' -f 2
+			exit 1
+		fi
 		awk -F\| -v name="$2" \
 	    '{\
 		    if ($1 ~ name || $4 ~ name || $10 ~ name) { \
@@ -67,6 +94,11 @@ 	    }' ${PORTSDIR}/${INDEXFILE}
 
 	;;
 	*)
+		if [ ${SIMPLE} -eq 1 ]; then
+			grep "PKGNAME=$1" ${PKGSUM} | cut -d '=' -f 2
+			exit 1
+		fi
+
 		awk -F\| -v name="$1" \
 	    '{\
 		    if ($1 ~ name) { \



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]