From b0ec74b2a2a9f8fb01e56000ee450714da702395 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 8 Feb 2009 14:01:44 +0100 Subject: [PATCH] Add new option to pkg_search -d will download the pkg_summary(5) file for you. If it is already installed, it get's overwritten. This is useful for users using only binary packages. After a release -d will give you the new list of packages available for that release. --- usr.bin/pkg_search/pkg_search.1 | 11 +++++++-- usr.bin/pkg_search/pkg_search.sh | 38 +++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/usr.bin/pkg_search/pkg_search.1 b/usr.bin/pkg_search/pkg_search.1 index 9f8ee59eda..ac0b44dde5 100644 --- a/usr.bin/pkg_search/pkg_search.1 +++ b/usr.bin/pkg_search/pkg_search.1 @@ -1,5 +1,5 @@ .\"- -.\" 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 , University of Marburg. @@ -32,7 +32,7 @@ .\" .\" $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 @@ -45,6 +45,8 @@ .Nm .Fl s .Ar package +.Nm +.Fl d .Sh DESCRIPTION .Nm queries the @@ -62,6 +64,11 @@ This file contains information about each package in a binary repository. .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 diff --git a/usr.bin/pkg_search/pkg_search.sh b/usr.bin/pkg_search/pkg_search.sh index 7aefd4d728..e30b715fc7 100644 --- a/usr.bin/pkg_search/pkg_search.sh +++ b/usr.bin/pkg_search/pkg_search.sh @@ -1,6 +1,6 @@ #!/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 , University of Marburg. @@ -42,10 +42,11 @@ PKGSRCBOX1=http://pkgbox.dragonflybsd.org/packages/${UNAME}-${VERSION}/stable/ 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 @@ -57,11 +58,7 @@ if [ ! -f ${PKGSUM} -a ! -e ${PORTSDIR}/${INDEXFILE} ]; then 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() @@ -161,18 +158,32 @@ usage() { 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) @@ -184,10 +195,15 @@ for i; do 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 -- 2.41.0