Date: Thu, 18 Feb 1999 15:01:33 +0100 From: Gianmarco Giovannelli <gmarco@scotty.masternet.it> To: gcross@netspace.net.au Cc: chat@freebsd.org Subject: Re: Port upgrade check/report tool Message-ID: <4.1.19990218150033.009713b0@194.184.65.4> In-Reply-To: <199902181150.WAA13777@whirlwind.netspace.net.au>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.1.19990218150033.009713b0>
