我有这个 Perl 脚本,它用于根据包版本对包进行排序:
#!/usr/bin/perl -w
#
# Compare versions of all *.rpm files against the
# latest packages installed (if installed)
#
# Usage:
# rpmver.pl
# This script looks for all *.rpm files.
#
use strict;
use RPM2;
my $rpm_db = RPM2->open_rpm_db();
for my $filename (<*.rpm>) {
my $h = RPM2->open_package( $filename );
# Ensure we compare against the newest
# package of the given name.
my ($installed) =
sort { $b <=> $a } $rpm_db->find_by_name($h->name);
if (not $installed) {
printf "Package %s not installed.\n", $h->as_nvre;
} else {
my ($result) = ($h <=> $installed);
if ($result < 0) {
printf "Installed package %s newer than file %s\n",
$installed->as_nvre,
$h->as_nvre;
} else {
printf "File %s newer than installed package %s\n",
$h->as_nvre,
$installed->as_nvre;
}
}
}
我有一个带有 SRPM 的 Linux 存储库。我想将最新的软件包移动到不同的目录中;例如latest_packages
。必须如何修改脚本?