From owner-freebsd-questions Sat Dec 1 14:44:34 2001 Delivered-To: freebsd-questions@freebsd.org Received: from ns-exch05.jccc.net (ns-exch05.jccc.net [198.248.56.5]) by hub.freebsd.org (Postfix) with ESMTP id 896C037B434 for ; Sat, 1 Dec 2001 14:43:47 -0800 (PST) Received: by ns-exch05 with Internet Mail Service (5.5.2653.19) id ; Sat, 1 Dec 2001 16:43:33 -0600 Message-ID: From: Noah Dunker To: "'freebsd-questions@freebsd.org'" Subject: A little Script I put together Date: Sat, 1 Dec 2001 16:43:32 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG A coworker and I put this together some time ago. We use it mostly on our FreeBSD Laptops. There are a few minor security issues in that this script just blindly accepts packages off the FreeBSD FTP Server (or whatever server/path you choose for $pkg_source. I Figured I'd share. You type a package name, say, xmame, you type: ./pkg_inst.sh xmame And it will download a new package list from freebsd.org, search through it for the full filename of xmame, and feed the whole ftp path to pkg_add, which will download it, and if it has dependencies, pkg_add will download them, too. Kind of like using the ports system, but you don't have to wait. :) /var/pkgindex gets checked every time you run, but it will download a fresh copy if the current /var/pkgindex is more than 24 Hours old. Basically, this just searches the ftp site for the whole version number, so that you don't have to manually trudge out there with ncfpt2 or some such. We decided to use normal shell tools instead of perl. I can't remember why now. :) Enjoy! Props go out to w0lfman68 for not only his incessant prodding of me to make a tool like this, but sitting down and helping me add features and cleaning it up. :) Noah Dunker Systems Analyst/Technician Johnson County Community College #!/bin/sh # # pkg_inst.sh # evil package installer hack # for freebsd # # Usage: pkg_inst.sh # requires lynx # # source of packages pkg_source="ftp.freebsd.org/pub/FreeBSD/ports/packages/All/" # name of pkgindex pkg_index="/var/pkgindex" if [ $1 ] # check for package name arg then # did we get the name of a package.tgz if [ `echo $1 | grep -e "-[0-9]" | wc -c` -gt 3 ] then # set pkgname to 1st arg pkgname=$1 # find a match in the pkg_index else # do we have a current copy of pkg_index if [ `find $pkg_index -mtime 1| wc -c` -gt 3 ] then echo "Found current pkgindex" # set pkgname to name of newest package version in pkgindex pkgname=`cat $pkg_index |cut -b32- |grep "^$1-[0-9]" |cut -f1 -d " " | tail -1` else # go get a new list of packages echo "Getting fresh pkgindex from freebsd.org" lynx -dump -nolist ftp://$pkg_source >/var/pkgindex # set pkgname to name of newest package version in pkgindex pkgname=`cat $pkg_index |cut -b32- |grep "^$1-[0-9]" |cut -f1 -d " " | tail -1` fi fi # if we have the package name install it if [ `echo $pkgname |wc -c` -gt 3 ] then echo "installing package $pkgname" pkg_add ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/All/$pkgname else # no match found echo "Sorry no match for $1" fi else # you did not supply the argument echo "Usage: install.sh " fi # end of script To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message