Re: Fetch pkgsrc index with pkg_search

2007-12-12 Thread Matthias Schmidt
He,

* Matthew Dillon wrote:
 
 There were some ordering issues with the PKGSUM assignment in that
 patch.  I made some modifications and got it to work, but your

You're right.  I fine with your patch.

 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.

Yeah, this was intended.  I provide a version for {Free,Net}BSD on my
website.  I thought the DragonFly version doesn't need any information
about other OSs.

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

There could be two possibilities.  I could use the Makefile to fetch a
complete pkgsrc tree instead of the summary file or I could save the
summary file in another location.  If the user installs a pkgsrc tree
later, pkg_search prefers the tree instead of the summary file.
Comments?

Regards,

Matthias

-- 
Dipl.-Inf. Matthias Schmidt [EMAIL PROTECTED]
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


Fetch pkgsrc index with pkg_search

2007-12-11 Thread Matthias Schmidt
Hi guys,

after an upcoming discussion on FreeBSD cvs-src list [1] I modified
pkg_search to create a ports directory and fetch the appropriate INDEX
file from the server if both are not installed.   This enables 
pkg_search to work out-of-the-box and without the need to install 
a complete ports tree (which could be usefull for servers etc).

Fetching the INDEX file was pretty easy because FreeBSD supports the
make fetchindex command fetching the INDEX file from the master
server.  Is there are similar command available for pkgsrc/DragonFly?
According to my search within the mk/ directory there exists no such
command.

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.

Regards,

Matthias

[1] http://lists.freebsd.org/pipermail/cvs-src/2007-December/085011.html

-- 
Dipl.-Inf. Matthias Schmidt [EMAIL PROTECTED]
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


Re: Fetch pkgsrc index with pkg_search

2007-12-11 Thread reed
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.

Here is a small part of a shell script I use:

TAG=2007Q3
OPERATING_SYSTEM=`uname -s`
##OS_VERSION=`uname -r`
OS_VERSION=4.0
PLATFORM=`uname -p` # should I use -m?
PKG_REPO=${OPERATING_SYSTEM}/${PLATFORM}/${OS_VERSION}_${TAG}/All
DOWNLOAD_URL=http://ftp.NetBSD.org/pub/pkgsrc/packages/${PKG_REPO}/;
ftp ${DOWNLOAD_URL}/pkg_summary.gz


Re: Fetch pkgsrc index with pkg_search

2007-12-11 Thread Matthias Schmidt
Hi,

* [EMAIL PROTECTED] 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 [EMAIL PROTECTED]
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.0 +0100
+++ pkg_search/pkg_search.sh2007-12-11 18:15:36.0 +0100
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (c) 2006 Matthias Schmidt schmidtm @ mathematik . uni-marburg.de
+# Copyright (c) 2006-07 Matthias Schmidt [EMAIL PROTECTED]
 #
 # 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) { \


Re: Fetch pkgsrc index with pkg_search

2007-12-11 Thread Matthew Dillon

: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 -   1.1
+++ pkg_search.sh   11 Dec 2007 20:20:34 -
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (c) 2006 Matthias Schmidt schmidtm @ mathematik . uni-marburg.de
+# Copyright (c) 2006-07 Matthias Schmidt [EMAIL PROTECTED]
 #
 # 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) { \