一个基本功能具备的验证RPM包并拷贝文件的脚本

也许是因为使用的是试用版本的原因,turbolinux desktop 11里提供的turboplus工具一旦在线升级完rpm包就将其删除,这就使得以后全新安装系统更新新包麻烦多多。google了一通实现了一个基本的shell脚本。
turboplus在线每下载一个RPM包安装完就将其删除,再下载另一个再安装再删除不断重复。所以脚本要实现的就是验证RPM下载时的完整性并将其备份。
#!/bin/bash
#cpupdate.sh
UPDDIR=/dato/tmp/tmp
SUCCESS=0
#sE_NOARGS=65
while true ; do
for rpms in *.rpm ; do
rpm -i –test $rpms # Query whether rpm file can be installed.
if [ “$?” -eq $SUCCESS ]
then
cp -pv $rpms $UPDDIR ;
fi
done
done
参考资料
google keyword :check rpm file
rpm-check.sh
http://cvsview.tldp.org/index.cgi/LDP/guide/docbook/abs-guide/rpm-check.sh#rev1.3
一种非常简单的RPM包完整性验证方法
#!/bin/bash
# rpm-check.sh
# Queries an rpm file for description, listing, and whether it can be installed.
# Saves output to a file.
#
# This script illustrates using a code block.
SUCCESS=0
E_NOARGS=65
if [ -z “$1” ]
then
echo “Usage: `basename $0` rpm-file”
exit $E_NOARGS
fi
{
echo
echo “Archive Description:”
rpm -qpi $1 # Query description.
echo
echo “Archive Listing:”
rpm -qpl $1 # Query listing.
echo
rpm -i –test $1 # Query whether rpm file can be installed.
if [ “$?” -eq $SUCCESS ]
then
echo “$1 can be installed.”
else
echo “$1 cannot be installed.”
fi
echo
} > “$1.test” # Redirects output of everything in block to file.
echo “Results of rpm test in file $1.test”
# See rpm man page for explanation of options.
exit 0
Bourne Shell及shell编程
while true死循环的实现

About: dato


发表评论

邮箱地址不会被公开。 必填项已用*标注