Software Installer panel - move dnf monitoring to /var/cache/dnf.status

This commit is contained in:
Brian Read 2024-08-22 12:17:32 +01:00
parent 6a5a756438
commit 1087a8a5a2
2 changed files with 26 additions and 4 deletions

View File

@ -23,6 +23,8 @@ use File::Basename;
our $cdb = esmith::ConfigDB->open || die "Couldn't open config db"; our $cdb = esmith::ConfigDB->open || die "Couldn't open config db";
my $dnf_status_file = '/var/cache/dnf/dnf.status';
#use File::stat; #use File::stat;
our %dbs; our %dbs;
@ -52,7 +54,8 @@ sub main {
$yum_datas{'trt'} = 'STAT'; $yum_datas{'trt'} = 'STAT';
if ( -e "/var/run/yum.pid" ) {
if ( $c->is_dnf_running()) {
$yum_datas{'trt'} = 'LOGF'; $yum_datas{'trt'} = 'LOGF';
$dest = 'yumlogfile'; $dest = 'yumlogfile';
} elsif ($cdb->get_prop('dnf', 'LogFile')) { } elsif ($cdb->get_prop('dnf', 'LogFile')) {
@ -83,7 +86,7 @@ sub do_display {
$yum_datas{'trt'} = $trt; $yum_datas{'trt'} = $trt;
# force $trt if current logfile # force $trt if current logfile
if ( -e "/var/run/yum.pid" ) { if ( $c->is_dnf_running() ) {
$trt = 'LOGF'; $trt = 'LOGF';
} elsif ($cdb->get_prop('dnf', 'LogFile')) { } elsif ($cdb->get_prop('dnf', 'LogFile')) {
$trt = 'PSTU'; $trt = 'PSTU';
@ -106,7 +109,7 @@ sub do_display {
} }
if ( $trt eq 'LOGF' ) { if ( $trt eq 'LOGF' ) {
if (-e "/var/run/yum.pid") { if ($c->is_dnf_running()) {
$dest = 'yumlogfile'; $dest = 'yumlogfile';
} }
} }
@ -221,7 +224,7 @@ sub do_update {
if ( $trt eq 'LOGF' ) { if ( $trt eq 'LOGF' ) {
$dest = 'yumlogfile'; $dest = 'yumlogfile';
if ( ! -e "/var/run/yum.pid") { if ( ! $c->is_dnf_running()) {
$yum_datas{trt} = 'SUC'; $yum_datas{trt} = 'SUC';
$result = $c->l('yum_SUCCESS'); $result = $c->l('yum_SUCCESS');
} }
@ -247,6 +250,24 @@ sub do_update {
}; };
sub get_dnf_status {
#interrogate status file created and maintained by smeserver.py plugin for dnf.
my ($c) = @_;
my $file_name = $dnf_status_file;
my $content = "resolved";
if ( -e "$file_name") {
open my $fh, '<', $file_name or die "Can't open file: $!";
$content = <$fh>;
close $fh;
}
return $content;
}
sub is_dnf_running {
my ($c) = @_;
my $dnf_status = $c->get_dnf_status();
return $dnf_status ne "resolved" && $dnf_status ne "config" && $dnf_status ne "sack";
}
sub is_empty { sub is_empty {

View File

@ -110,6 +110,7 @@ true
%changelog %changelog
* Wed Aug 21 2024 Brian Read <brianr@koozali.org> 11.0.0-16.sme * Wed Aug 21 2024 Brian Read <brianr@koozali.org> 11.0.0-16.sme
- Typo uc DNF changed to lc dnf in Yum.pm [SME: 127245] - Typo uc DNF changed to lc dnf in Yum.pm [SME: 127245]
- Monitor dnf running using dnf status file
* Wed Aug 21 2024 Brian Read <brianr@koozali.org> 11.0.0-15.sme * Wed Aug 21 2024 Brian Read <brianr@koozali.org> 11.0.0-15.sme
- Migrate SM2 Software installer panel from use of yum to dnf [SME: 12718] - Migrate SM2 Software installer panel from use of yum to dnf [SME: 12718]