|
楼主 |
发表于 2003-11-28 11:13:47
|
显示全部楼层
updateMirror.pl
这段脚本,看不懂,匹配不好
看看我的结果#!/usr/bin/perl
#
# From mthed@shore.net Fri Aug 6 10:30:05 1999
# Date: Fri, 30 Jul 1999 18:18:29 -0400 (EDT)
# From: Joshua Sarro <mthed@shore.net>
# To: mok@imsb.au.dk
# Cc: pahe+rhcd@daimi.au.dk
# Subject: Burning a RedHat CD mini-HOWTO
#
# Hello,
#
# I have a few comments in case your still maintaining this
# howto. First of all the updateMirror script you have listed doesn't
# seem to work correctly with the new version of the distribution. It
# get's a little stuck up because of some of the kernel files being
# built for different architectures. (For instance in the i386 distro
# there are i386, i586, and i686 versions of the kernel). Included at
# the end of this message is a version of the script i wrote which
# seems to do the trick.
#
# Next off, it also seems that your old updateHdlist has some problems
# when used for an architecture other than the machine you are on. For
# instance a person on an i386 machine couldn't correctly build the
# sparc hdlist. At the end of this file I include the script you wrote
# with the slight modifications I made.
#
# That's about it. If you plan on putting those updates in, let me
# know, otherwise I may venture to try it myself if I have the
# time. Thanks for your time.
use strict;
my $version="6.0";
my $arch=$ARGV[0];
my $basedir="/misc/redhat";
my $redhatdir="$basedir/redhat-$version";
my $rpmdir="$redhatdir/$arch/RedHat/RPMS/";
my $updatedir="$basedir/updates/$version/$arch/";
###########################################################################
# Main Program
if(! $arch) {
print "updateCD usage - updateCD.pl <ARCHITECTURE>\n";
exit();
}
my %update;
my %rpm;
my $regex;
# Open updates directory for listing
opendir(UPDATES,$updatedir) || die("Could not open $updatedir.\n");
while($update{FN}=readdir(UPDATES))
{
if($update{FN} !~ /\.rpm$/)
{
next; # Skip any non-rpm files
}
($update{NAME},$update{VERSION},$update{RELEASE},$update{ARCH})=
get_info("$updatedir$update{FN}"); # Call on get_info to get rpm info
# Open rpm directory for listing
opendir(RPMS,$rpmdir) || die("Could not open $rpmdir.\n");
while($rpm{FN}=readdir(RPMS))
{
$regex="\Q$update{NAME}";
if($rpm{FN} !~ /^$regex/ || $rpm{FN} !~ /\.rpm$/)
{
next; # Skip non-rpm's and unrelated files
}
($rpm{NAME},$rpm{VERSION},$rpm{RELEASE},$rpm{ARCH})=
get_info("$rpmdir$rpm{FN}"); # Call on info to get rpm info
# Make sure file is the same package, but a different version. Erase
# The old file and copy the new one in its place
if($rpm{NAME} eq $update{NAME} && $rpm{ARCH} eq $update{ARCH} &&
"$rpm{VERSION}$rpm{RELEASE}" ne "$update{VERSION}$update{RELEASE}")
{
system("cp $updatedir$update{FN} $rpmdir") &&
die("Could not copy $updatedir$update{FN} -> $rpmdir.\n");
print "cp $updatedir$update{FN} -> $rpmdir\n";
unlink("$rpmdir$rpm{FN}") ||
die("Could not remove $rpmdir$rpm{FN}.\n");
print "rm $rpmdir$rpm{FN}\n";
}
}
closedir(RPMS);
}
closedir(UPDATES);
###########################################################################
# Use an rpm query to find information on an rpm file
sub get_info
{
my($filename)=@_;
my $info;
my @dummy;
$info=`rpm --queryformat \'\%{NAME} \%{VERSION} \%{RELEASE} \%{ARCH}\' -qp $filename`;
@dummy=split(/ /,$info); # Seems if we don't assign to an array, the
# variables aren't passed correctly. So we use
# dummy here.
}
# Local Variables:
# mode: font-lock
# End: |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|