Don't try to yum list if locked

This commit is contained in:
Jamie Cameron
2009-10-14 15:18:58 -07:00
parent b59d3d1bf4
commit abdf7e6c46

View File

@ -60,7 +60,9 @@ else {
sub list_available
{
local ($nocache) = @_;
if ($nocache || &cache_expired($available_cache_file)) {
local $expired = &cache_expired($available_cache_file);
if ($nocache || $expired == 2 ||
$expired == 1 && !&check_available_lock()) {
# Get from update system
local @rv;
local @avail = &packages_available();
@ -88,6 +90,16 @@ else {
}
}
# check_available_lock()
# Returns 1 if the package update system is currently locked
sub check_available_lock
{
if ($software::update_system eq "yum") {
return &check_pid_file("/var/run/yum.pid");
}
return 0;
}
# filter_duplicates(&packages)
# Given a list of package structures, orders them by name and version number,
# and removes dupes with the same name
@ -100,16 +112,19 @@ local %done;
return grep { !$done{$_->{'name'},$_->{'system'}}++ } @rv;
}
sub cache_expired
# cache_expired(file)
# Checks if some cache has expired. Returns 0 if OK, 1 if expired, 2 if
# totally missing.
sub cache_expired
{
local ($file) = @_;
local @st = stat($file);
if (!@st || !$config{'cache_time'} ||
time()-$st[9] > $config{'cache_time'}*60*60) {
return 1;
}
return 0;
}
return 2 if (!@st);
if (!$config{'cache_time'} || time()-$st[9] > $config{'cache_time'}*60*60) {
return 1;
}
return 0;
}
sub write_cache_file
{