From owner-freebsd-hackers Sat Sep 25 16:52:45 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from dorifer.heim3.tu-clausthal.de (dorifer.heim3.tu-clausthal.de [139.174.243.252]) by hub.freebsd.org (Postfix) with ESMTP id AE6BD14CEF for ; Sat, 25 Sep 1999 16:52:39 -0700 (PDT) (envelope-from olli@dorifer.heim3.tu-clausthal.de) Received: (from olli@localhost) by dorifer.heim3.tu-clausthal.de (8.8.8/8.8.8) id BAA26437 for freebsd-hackers@FreeBSD.ORG; Sun, 26 Sep 1999 01:52:36 +0200 (CEST) (envelope-from olli) Date: Sun, 26 Sep 1999 01:52:36 +0200 (CEST) From: Oliver Fromme Message-Id: <199909252352.BAA26437@dorifer.heim3.tu-clausthal.de> To: freebsd-hackers@FreeBSD.ORG Subject: Re: A new package fetching utility, pkg_get Organization: Administration Heim 3 Reply-To: freebsd-hackers@FreeBSD.ORG MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: TIN [version 1.2 RZTUC(3) PL2] Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG While we're talking about making package handling easier for newbies, I'd like to present two simple shell scripts that I wrote quite some time ago. Yeah, I know I could send-pr this, but I'm not sure if they're really worth it (if someone thinks they are, then I'll send-pr them). The first one is "pkg_ls" and it simply lists packages that are installed. If no arguments are given, it lists all of them, otherwise the arguments are (abbreviated) package names to list. For example, "pkg_ls lynx" will list your installed lynx package, without you having to know which version it is. You can do this with pkg_info | grep, but remember we're talking about making things easier for newbies. ;-) The second script is called "pkg_rm"; it can be used to delete packages like pkg_delete, but you can use arguments in the same way as for pkg_ls above (i.e. "pkg_rm lynx"). Think of it like pkg_info | grep | pkg_delete. It might more sense to implement these features in pkg_info and pkg_delete, resprectively, but I don't have the time to do that (and these scripts work fine, so I have no incentive to bother with the C sources of pkg_{info,delete}). ------------------ begin file pkg_ls ------------------ #!/bin/sh - PL_EXITCODE=0 Usage() { echo "" echo "Usage: `basename $0` []" >&2 echo "Where is one or more package names which may" >&2 echo "be abbreviated." >&2 echo "" exit 1 } if OPTS=`getopt 'h?' "$@"`; then : else Usage fi set -- $OPTS while :; do case "$1" in --) shift; break;; -*) Usage;; *) break;; esac shift done if [ $# -lt 1 ]; then set -- . fi while [ $# -gt 0 ]; do PKGS=`pkg_info -aI 2>/dev/null | grep "^$1"` if [ -z "$PKGS" ]; then echo "*** No package matching \"$1\" found!" >&2 echo "" PL_EXITCODE=1 else echo "$PKGS" >&2 fi shift done exit $PL_EXITCODE ------------------ end file pkg_ls ------------------ ------------------ begin file pkg_rm ------------------ #!/bin/sh - PR_FLAGS="" PR_EXITCODE=0 Usage() { echo "" echo "Usage: `basename $0` [-fln] " >&2 echo "Where is one or more package names which may" >&2 echo "be abbreviated, as long as they're unique. If multiple" >&2 echo "packages match, they are listed (but none is removed)." >&2 echo " -f Force removal, ignoring dependencies." >&2 echo " -l Only list packages (do not remove)." >&2 echo " -n Print what would be done (do not remove)." >&2 echo "" exit 1 } if OPTS=`getopt 'lnfh?' "$@"`; then : else Usage fi set -- $OPTS while :; do case "$1" in -f) PR_FLAGS="-f";; -n) PR_NOTREALLY=1;; -l) PR_LIST=1;; --) shift; break;; -*) Usage;; *) break;; esac shift done if [ $# -lt 1 ]; then Usage fi while [ $# -gt 0 ]; do PKGS=`pkg_info -aI 2>/dev/null | grep "^$1"` if [ -z "$PKGS" ]; then echo "*** No package matching \"$1\" found!" >&2 echo "" PR_EXITCODE=1 elif [ `echo "$PKGS" | wc -l` -eq 1 ]; then PKG=`echo "$PKGS" | cut -f1 -d" "` if [ "$PR_LIST" = 1 ]; then echo "$PKGS" elif [ "$PR_NOTREALLY" = 1 ]; then echo pkg_delete $PR_FLAGS $PKG else echo "Removing $PKGS ..." pkg_delete $PR_FLAGS $PKG fi else echo "*** Multiple packages match \"$1\":" >&2 echo "$PKGS" >&2 echo "" PR_EXITCODE=1 fi shift done exit $PR_EXITCODE ------------------ end file pkg_rm ------------------ Regards Oliver -- Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany (Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de) "In jedem Stück Kohle wartet ein Diamant auf seine Geburt" (Terry Pratchett) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message