This commit is contained in:
brent s 2019-05-31 16:03:14 -04:00
parent 4ef4a939e8
commit a89a6ec94b
2 changed files with 21 additions and 6 deletions

View File

@ -6,6 +6,8 @@ import sys
from lxml import etree from lxml import etree
import yum import yum


# See <optools>:/storage/backups/borg/tools/restore_yum_pkgs.py to use the XML file this generates.



# Detect RH version. # Detect RH version.
ver_re =re.compile('^(centos.*|red\s?hat.*) ([0-9\.]+) .*$', re.IGNORECASE) ver_re =re.compile('^(centos.*|red\s?hat.*) ([0-9\.]+) .*$', re.IGNORECASE)

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python


import argparse import argparse # yum install python-argparse on CentOS/RHEL 6.x
import os import os
import re import re
import subprocess import subprocess
@ -10,7 +10,7 @@ import warnings
# The yum API is *suuuper* cantankerous and kind of broken, even. # The yum API is *suuuper* cantankerous and kind of broken, even.
# Patches welcome, but for now we just use subprocess. # Patches welcome, but for now we just use subprocess.
import yum import yum
from lxml import etree from lxml import etree # yum install python-lxml




# Detect RH version. # Detect RH version.
@ -92,14 +92,21 @@ class Reinstaller(object):
if self.latest: if self.latest:
pkgs['upgrade'].append(pkgobj.name) pkgs['upgrade'].append(pkgobj.name)
else: else:
pkgs['upgrade'].append(pkgobj.nevra) if distver[0] >= 7:
pkgs['upgrade'].append(pkgobj.nevra)
else:
pkgs['upgrade'].append(pkgobj._ui_nevra())
pkg_found = True pkg_found = True
is_installed = False is_installed = False
break break
if pkglist.installed and not pkg_found: if pkglist.installed and not pkg_found:
for pkgobj in reversed(pkglist.installed): for pkgobj in reversed(pkglist.installed):
if pkgobj.repo.name == reponm: if pkgobj.repo.name == reponm:
warn = ('{0} from {1} is already installed; skipping').format(pkgobj.nevra, if distver[0] >= 7:
nevra = pkgobj.nevra
else:
nevra = pkgobj._ui_nevra()
warn = ('{0} from {1} is already installed; skipping').format(nevra,
repo.attrib['name']) repo.attrib['name'])
warnings.warn(warn) warnings.warn(warn)
pkg_found = True pkg_found = True
@ -116,7 +123,10 @@ class Reinstaller(object):
if self.latest: if self.latest:
pkgs['new'].append(pkgobj.name) pkgs['new'].append(pkgobj.name)
else: else:
pkgs['new'].append(pkgobj.nevra) if distver[0] >= 7:
pkgs['new'].append(pkgobj.nevra)
else:
pkgs['new'].append(pkgobj._ui_nevra())
is_installed = False is_installed = False
pkg_found = True pkg_found = True
break break
@ -129,7 +139,10 @@ class Reinstaller(object):
# self.yb.resolveDeps() # self.yb.resolveDeps()
# self.yb.buildTransaction() # self.yb.buildTransaction()
# self.yb.processTransaction() # self.yb.processTransaction()
pkgs['downgrade'].append(pkgobj.nevra) if distver[0] >= 7:
pkgs['downgrade'].append(pkgobj.nevra)
else:
pkgs['downgrade'].append(pkgobj._ui_nevra())
pkg_found = True pkg_found = True
break break
# # This... seems to always fail. Patches welcome. # # This... seems to always fail. Patches welcome.