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: Matthias Schmidt <schmidtm@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Dec 2007 17:19:27 +0100

Hi,

* reed@reedmedia.net wrote:
> On Tue, 11 Dec 2007, Matthias Schmidt wrote:
> 
> > Would it be possible to add the pkgsrc INDEX to an official server?
> > This enables users to use pkg_search on DragonFly without the need to
> > download the whole tree and only install binary packages.
> 
> We have a documented data file -- see pkg_summary(5) manual page.

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

-- 
Dipl.-Inf. Matthias Schmidt <schmidtm@mathematik.uni-marburg.de>
Dept. of Mathematics and Computer Science, Distributed Systems Group
University of Marburg, Hans-Meerwein-Strasse, 35032 Marburg, Germany
Tel: +49.6421.28 21 591, Fax: +49.6421.28 21 573, Office C4347
Binary files pkg_search.orig/.pkg_search.sh.swp and pkg_search/.pkg_search.sh.swp differ
diff -urN pkg_search.orig/pkg_search.sh pkg_search/pkg_search.sh
--- pkg_search.orig/pkg_search.sh	2007-12-11 17:57:44.000000000 +0100
+++ pkg_search/pkg_search.sh	2007-12-11 18:15:36.000000000 +0100
@@ -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,25 @@
 #
 # $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
+PKGSRCBOX=http://chlamydia.fs.ei.tum.de/pub/DragonFly/packages/stable/
+UNAME=`uname -s`
+VERSION=`uname -r | cut -d '.' -f 1,2`
+SIMPLE=0
+PKGSUM=${PORTSDIR}/pkg_summary
+
+if [ $UNAME = "DragonFly" ]; then
 	PORTSDIR=/usr/pkgsrc
 	INDEXFILE=INDEX
+	if [ ! -d ${PORTSDIR} ]; then
+		echo "No pkgsrc(7) tree found.  Fetch pkg_summary(5) file."
+		mkdir -p ${PORTSDIR}
+		fetch -o ${PKGSUM}.bz2 ${PKGSRCBOX}${UNAME}-${VERSION}/All/pkg_summary.bz2
+		bunzip2 < ${PKGSUM}.bz2 > ${PKGSUM}
+		SIMPLE=1
+	fi
+	if [ -e ${PKGSUM} -a ! -e ${PORTSDIR}/${INDEXFILE} ]; then
+		SIMPLE=1
+	fi
 fi
 
 if [ -z $1 ]; then 
@@ -41,13 +53,13 @@
         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 +69,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 +83,11 @@
 
 	;;
 	*)
+		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]