{ use POSIX qw(strftime); use File::Slurp; my $curdate = strftime '%Y%m%d', localtime; my $curVers = 7; my $curVersEOL = 20240630; #get CentOS release we are my $SUBVER = read_file('/etc/centos-release'); $SUBVER =~ s/^CentOS Linux release ([0-9\.]+).*?$/$1/; chomp $SUBVER; # we ignore the force value if for a previous release; idealy should be deleted from another fragment against configuration db delete $yum{eolversion} if ( ( defined $yum{eolversion} && (substr($yum{eolversion},0,1)<$curVers) ) || ( "$curdate" < "$curVersEOL") ); $SUBVER = $yum{eolversion} || $SUBVER ; # we need to remove that from migrated server for my $name ( qw(base updates centosplus extras fasttrack centos-sclo-rh centos-sclo-centos) ) { my $repo = $DB->get($name) or next; my $baseurl = $repo->prop('BaseURL') or next; my $mirrorlist = $repo->prop('MirrorList') or next; if ( $baseurl =~ /^http:\/\/vault\.centos\.org\/([0-9])/ ) { # we want to reset this unless vers 7 next if ($1 == $curVers && "$curdate" >= "$curVersEOL"); $repo->delete_prop('MirrorList'); $repo->delete_prop('BaseURL'); unlink "/var/cache/yum/$name/$_" foreach qw(repomd.xml mirrorlist.txt); } else { # no match for a numerical, we probably want to reset that as well $repo->delete_prop('MirrorList'); $repo->delete_prop('BaseURL'); unlink "/var/cache/yum/$name/$_" foreach qw(repomd.xml mirrorlist.txt); } } # return unless we have a release version return unless $SUBVER ne ""; my $curdate = strftime '%Y%m%d', localtime; # return unless EOL is reached return unless ( "$curdate" >= "$curVersEOL"); for my $name ( qw(base updates centosplus extras fasttrack centos-sclo-rh centos-sclo-centos) ) { my $repo = $DB->get($name) or next; my $rname = ( $name eq 'base' )? 'os' :$name; my $sclo = ""; $sclo = "rh/" if $name eq "centos-sclo-rh"; $sclo = "sclo/" if $name eq "centos-sclo-centos"; # setprop BaseURL "http://vault.centos.org/$SUBVER/$rname/\$basearch/" $repo->set_prop('BaseURL', "http://vault.centos.org/$SUBVER/$rname/\$basearch/$sclo"); # delprop MirrorList $repo->set_prop('MirrorList', "disabled"); } }