From owner-freebsd-chat Thu Feb 18 5:53:40 1999 Delivered-To: freebsd-chat@freebsd.org Received: from scotty.masternet.it (scotty.masternet.it [194.184.65.2]) by hub.freebsd.org (Postfix) with ESMTP id 9708511050 for ; Thu, 18 Feb 1999 05:53:34 -0800 (PST) (envelope-from gmarco@scotty.masternet.it) Received: from suzy (modem20.masternet.it [194.184.65.30]) by scotty.masternet.it (8.8.8/8.8.8) with SMTP id OAA25364; Thu, 18 Feb 1999 14:53:07 +0100 (CET) (envelope-from gmarco@scotty.masternet.it) Message-Id: <4.1.19990218150033.009713b0@194.184.65.4> X-Sender: gmarco@scotty.masternet.it X-Mailer: QUALCOMM Windows Eudora Pro Version 4.1 Date: Thu, 18 Feb 1999 15:01:33 +0100 To: gcross@netspace.net.au From: Gianmarco Giovannelli Subject: Re: Port upgrade check/report tool Cc: chat@freebsd.org In-Reply-To: <199902181150.WAA13777@whirlwind.netspace.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org At 22.47 18/02/99 +1100, you wrote: >I haven't found a tool that will look at the current ports index file, >then look at the ports installed on my system and tell me which ports >are now out-of-date and need upgrading. > >So, I have written a Python program that will do just that. > I have this one... #!/bin/sh # # File: update-packages # # Checks for new packages in the supplied INDEX file to update your installation # # Usage: update-packages INDEX # record_update ( ) { to_be_installed=`sed -e "$1p" -n ${temp}.pkg_list` echo "${i}|${to_be_installed}" >>${temp}.work_list } # # Standard variables # progname=`basename $0` temp=/tmp/${progname}.$$ pkg_dir=/var/db/pkg # default=unknown for i in `ls ${pkg_dir}` do if [ -d ${pkg_dir}/${i} ] then name=`expr "${i}" : "\(.*\)-.*"` version=`expr "${i}" : ".*-\(.*\)"` desc=`grep "^${name}-" $1` if [ $? -eq 0 ] then count=0 echo "${desc}" | while read pkg_desc do pkg_name=`echo "${pkg_desc}" | cut -f 1 -d "|"` new_version=`expr "${pkg_name}" : "${name}-\(.*\)"` if expr ${new_version} \> ${version} >/dev/null then if [ ${count} -eq 0 ] then echo "" echo "Package name : ${name}" echo "Installed version : ${version}" echo -n "Available version(s): " else echo -n " " fi count=$((${count}+1)) echo "${count}) ${new_version}" echo ${count} >${temp}.count echo ${pkg_desc} >>${temp}.pkg_list fi done # # I loose the contents of "count" here, so recover from file # if [ -f ${temp}.count ] then count=`cat ${temp}.count` rm ${temp}.count fi if [ ${count} -ne 0 ] then case ${default} in unknown) if [ ${count} -gt 1 ] then read -p "Do you want to install any of these packages (1-${count}/No/All/nOne/Quit) ? " reply else read -p "Do you want to install this package (Yes/No/All/nOne/Quit) ? " reply if [ "$reply" = "y" -o "$reply" = "Y" ] then reply=1 fi fi reply=`echo ${reply} | tr "[:upper:]" "[:lower:]"` case ${reply} in q|quit) rm ${temp}.pkg_list exit 1 ;; ""|n|no) ;; a|all) record_update 1 default=all ;; o|none) rm ${temp}.pkg_list break ;; [0-9]*) if [ ${reply} -ge 1 -a ${reply} -le ${count} ] then record_update ${reply} fi ;; esac ;; all) record_update 1 ;; esac rm ${temp}.pkg_list fi else echo "" echo "${progname}: warning: ${name} not found in index file" fi fi done echo "Here we are..." cat ${temp}.work_list rm ${temp}.work_list Best Regards, Gianmarco Giovannelli , "Unix expert since yesterday" http://www.giovannelli.it/~gmarco http://www2.masternet.it To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message