Commit 531291c8 authored by Seth Vidal's avatar Seth Vidal

Merge branch 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum-utils

* 'master' of ssh://login.linux.duke.edu/home/groups/yum/git/yum-utils:
  provide more verbose failure information with higher debug level
  check for yum-updatesd being on the bus in case we're using system activation
  refresh-updatesd: documentation updates
  refresh-updatesd: Remove repos_setup check.
  refresh-updatesd: some tweaks
  fixed issue in debuginfo-install there make it fail with plugins there uses conduit.getPackages() (rhbz #249742)
  chmod +x *.py (make it a little easier to test)
  fixed UnboundLocalError: local variable 'r_e' referenced before assignment in repoquery (convert unicode -> str)
  Make package-cleanup --orphans work as no root (rhbz #253352)
  Fixed yumdownloader --url output to show the right url (rhbz #301981)
  Allow package name globs on the list-sec/info-sec lines
  We need to catch when we install a kmod with a lower VR than a kmod of
  Don't print metadata more than once
parents 80f420a9 e447618c
......@@ -47,6 +47,9 @@ class DebugInfoInstall(YumUtilBase):
parser.print_help()
sys.exit(0)
# Setup yum (Ts, RPM db, Repo & Sack)
self.doUtilYumSetup()
# enable the -debuginfo repos for enabled primary repos
for repo in self.repos.listEnabled():
di = '%s-debuginfo' % repo.id
......
......@@ -34,11 +34,22 @@ from rpmUtils import miscutils, transaction
from optparse import OptionParser
from yum.packages import YumInstalledPackage
from yum import Errors
from yum.misc import getCacheDir
def initYum(opts):
my = yum.YumBase()
my.doConfigSetup(opts.conffile,init_plugins=False)
if opts.orphans:
# make it work as non root user.
if my.conf.uid != 0:
cachedir = getCacheDir()
if cachedir is None:
my.logger.error("Error: Could not make cachedir, exiting")
sys.exit(50)
my.repos.setCacheDir(cachedir)
# Turn of cache
my.conf.cache = 0
my.doRepoSetup()
else:
# Disable all enabled repositories
......
......@@ -26,6 +26,7 @@ from sets import Set
from yum import packages
from yum.constants import TS_INSTALL
from yum.plugins import TYPE_CORE, PluginYumExit
from rpm import RPMPROB_FILTER_OLDPACKAGE
requires_api_version = '2.4'
plugin_type = (TYPE_CORE,)
......@@ -225,6 +226,15 @@ def installAllKmods(c, avaModules, modules, kernels):
if po.kmodName in names:
interesting.append(po)
# If We have stuff in the interesting list its most likely a kmod for
# an older kernel and therefore will have a VR < a VR of a kmod that
# may already be installed. RPM doesn't like installing packages
# older than what's already installed. Tell it to shutup.
# XXX: If we thought hard enough we could do this more exactly.
if len(interesting) > 0:
tsInfo = c.getTsInfo()
tsInfo.probFilterFlags.append(RPMPROB_FILTER_OLDPACKAGE)
table = resolveVersions(interesting + modules)
for kernel in [ getKernelProvides(k)[0] for k in kernels ]:
......
This is refresh-updatesd, a plugin for Yum.
refresh-updatesd tells yum-updatesd to check for updates when yum exits.
This way, if you run 'yum list updates' and yum says there's a new version
of zsh available, puplet will almost instantly update itself to reflect this.
refresh-updatesd tells yum-updatesd to check for updates when yum exits. This
way, if you run 'yum update' and install all available updates, puplet will
almost instantly update itself to reflect this.
The plugin is very dumb, It should probably only send the message in
certain cases.
The plugin is very dumb, It should probably send a message when yum detects
updated packages as well.
# A plugin for yum which notifies yum-updatesd to refresh it's data
# A plugin for yum which notifies yum-updatesd to refresh its data
#
# Written by James Bowes <jbowes@redhat.com>
#
......@@ -12,7 +12,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# version 0.0.3
# version 0.0.5
import dbus
from yum.plugins import TYPE_CORE
......@@ -20,24 +20,29 @@ from yum.plugins import TYPE_CORE
requires_api_version = '2.5'
plugin_type = TYPE_CORE
repos_setup = False
def postreposetup_hook(conduit):
global repos_setup
repos_setup = True
def close_hook(conduit):
if not repos_setup:
return
def posttrans_hook(conduit):
"""
Tell yum-updatesd to refresh its state. Run only after an rpm transaction.
"""
try:
bus = dbus.SystemBus()
except dbus.DBusException:
conduit.error(2, "Unable to connect to dbus")
except dbus.DBusException, e:
conduit.info(2, "Unable to connect to dbus")
conduit.info(6, "%s" %(e,))
return
try:
o = bus.get_object('org.freedesktop.DBus', '/')
if not o.NameHasOwner("edu.duke.linux.yum"):
conduit.info(2, "yum-updatesd not on the bus")
return
except dbus.DBusException, e:
conduit.info(2, "Unable to look at what's on dbus")
conduit.info(6, "%s" %(e,))
return
try:
updatesd_proxy = bus.get_object('edu.duke.linux.yum', '/Updatesd')
updatesd_iface = dbus.Interface(updatesd_proxy, 'edu.duke.linux.yum')
updatesd_iface.CheckNow()
except dbus.DBusException:
conduit.error(2, "Unable to send message to yum-updatesd")
except dbus.DBusException, e:
conduit.info(2, "Unable to send message to yum-updatesd")
conduit.info(6, "%s" %(e,))
......@@ -37,6 +37,7 @@
import yum
import time
import textwrap
import fnmatch
import sys
from yum.plugins import TYPE_INTERACTIVE
from yum.update_md import UpdateMetadata
......@@ -80,8 +81,19 @@ def ysp_should_filter_pkg(opts, pkg, md, used_map):
used_map[ref_type][ref['id']] = True
return ref
return None
if opts.advisory and md['update_id'] in opts.advisory:
def match_sec_cmd(sec_cmds, pkg, md):
for i in sec_cmds:
if fnmatch.fnmatch(pkg.name, i):
return i
if md['update_id'] == i:
return i
return None
rcmd = match_sec_cmd(opts.sec_cmds, pkg, md)
if rcmd:
used_map['cmd'][rcmd] = True
return md
elif opts.advisory and md['update_id'] in opts.advisory:
used_map['id'][md['update_id']] = True
return md
elif opts.cve and has_id(md['references'], "cve", opts.cve):
......@@ -91,7 +103,8 @@ def ysp_should_filter_pkg(opts, pkg, md, used_map):
elif opts.security:
if md['type'] == 'security':
return md
elif not (opts.advisory or opts.cve or opts.bz or opts.security):
elif not (opts.advisory or opts.cve or opts.bz or opts.security or \
opts.sec_cmds):
return md # This is only possible from should_show_pkg
return None
......@@ -116,7 +129,9 @@ def ysp_should_show_pkg(opts, pkg, md, used_map, rname=None):
return ysp_should_filter_pkg(opts, pkg, md, used_map)
def ysp_gen_used_map(opts):
used_map = {'bugzilla' : {}, 'cve' : {}, 'id' : {}}
used_map = {'bugzilla' : {}, 'cve' : {}, 'id' : {}, 'cmd' : {}}
for i in opts.sec_cmds:
used_map['cmd'][i] = False
for i in opts.advisory:
used_map['id'][i] = False
for i in opts.bz:
......@@ -126,6 +141,9 @@ def ysp_gen_used_map(opts):
return used_map
def ysp_chk_used_map(used_map, msg):
for i in used_map['cmd']:
if not used_map['cmd'][i]:
msg('Argument \"%s\" not found applicable for this system' % i)
for i in used_map['id']:
if not used_map['id'][i]:
msg('Advisory \"%s\" not found applicable for this system' % i)
......@@ -159,6 +177,9 @@ class SecurityListCommands:
msg(" %s %-8s %s" % (str(ref['id']), md['type'], pkg))
else:
msg("%s %-8s %s" % (md['update_id'], md['type'], pkg))
def show_pkg_exit(self):
pass
def doCommand(self, base, basecmd, extcmds):
ygh = base.doPackageLists('updates')
......@@ -171,54 +192,69 @@ class SecurityListCommands:
def msg_warn(x):
logger.warn(x)
opts,cmdline = base.plugins.cmdline
opts, cmdline = base.plugins.cmdline
ygh.updates.sort(key=lambda x: x.name)
filt_type = None
show_type = None
if len(extcmds) >= 1:
filt_type = extcmds.pop(0)
if False:
pass
elif filt_type == "bugzillas":
filt_type = "bugzilla"
elif filt_type == "bzs":
filt_type = "bugzilla"
elif filt_type == "bz":
filt_type = "bugzilla"
elif filt_type == "bugzilla":
pass
elif filt_type == "sec":
filt_type = "security"
elif filt_type == "security":
pass
elif filt_type == "cves":
filt_type = "cve"
elif filt_type == "cve":
pass
else:
extcmds = [filt_type] + extcmds
filt_type = None
show_type = filt_type
if filt_type and filt_type == "security":
show_type = None
opts.sec_cmds = extcmds
used_map = ysp_gen_used_map(opts)
if False:
pass
elif len(extcmds) == 1 and (extcmds[0] == "bugzillas" or \
extcmds[0] == "bzs"):
for pkg in ygh.updates:
md = ysp_should_show_pkg(opts, pkg, md_info, used_map,
"bugzilla")
if not md:
continue
self.show_pkg(msg, pkg, md, "bugzilla")
elif len(extcmds) == 1 and extcmds[0] == "cves":
for pkg in ygh.updates:
md = ysp_should_show_pkg(opts, pkg, md_info, used_map, "cve")
if not md:
continue
self.show_pkg(msg, pkg, md, "cve")
elif len(extcmds) == 1 and (extcmds[0] == "security" or \
extcmds[0] == "sec"):
for pkg in ygh.updates:
md = ysp_should_show_pkg(opts, pkg, md_info, used_map,
"security")
if not md:
continue
self.show_pkg(msg, pkg, md)
else:
opts.advisory += extcmds
used_map = ysp_gen_used_map(opts)
for pkg in ygh.updates:
md = ysp_should_show_pkg(opts, pkg, md_info, used_map)
if not md:
continue
self.show_pkg(msg, pkg, md)
for pkg in ygh.updates:
md = ysp_should_show_pkg(opts, pkg, md_info, used_map,
filt_type)
if not md:
continue
self.show_pkg(msg, pkg, md, show_type)
ysp_chk_used_map(used_map, msg)
# else:
# return 1, [str(PluginYumExit('Bad %s commands' % basecmd))]
self.show_pkg_exit()
return 0, [basecmd + ' done']
class SecurityInfoCommands(SecurityListCommands):
show_pkg_info_done = {}
def getNames(self):
return ['info-security', 'info-sec']
def show_pkg(self, msg, pkg, md, disp=None):
if md['update_id'] in self.show_pkg_info_done:
return
self.show_pkg_info_done[md['update_id']] = True
msg(md)
msg('')
def show_pkg_exit(self):
self.show_pkg_info_done = {}
def config_hook(conduit):
'''
Yum Plugin Config Hook:
......@@ -288,7 +324,7 @@ def ysp_check_func_enter(conduit):
opts, args = conduit.getCmdLine()
ndata = not (opts.security or opts.advisory or opts.bz or opts.cve)
ret = None
if len(args) >= 2:
if ((args[0] == "list") and (args[1] == "updates")):
......@@ -337,6 +373,7 @@ def exclude_hook(conduit):
(pkg,pkg.repoid))
conduit.delPackage(pkg)
opts.sec_cmds = []
used_map = ysp_gen_used_map(opts)
# The official API is:
#
......@@ -385,6 +422,7 @@ def preresolve_hook(conduit):
tot = 0
cnt = 0
opts.sec_cmds = []
used_map = ysp_gen_used_map(opts)
tsinfo = conduit.getTsInfo()
tspkgs = tsinfo.getMembers()
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -413,7 +413,7 @@ class YumBaseQuery(yum.YumBase):
# XXX rhbz#246519, for some reason returnPackagesByDep() fails
# to find some root level directories while
# searchPackageProvides() does... use that for now
matches = yum.YumBase.searchPackageProvides(self, [depstring])
matches = yum.YumBase.searchPackageProvides(self, [str(depstring)])
provider = matches.keys()
# provider.extend(yum.YumBase.returnPackagesByDep(self, depstring))
except yum.Errors.YumBaseError, err:
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -138,9 +138,8 @@ Requires: yum-updatesd
%description -n yum-refresh-updatesd
yum-refresh-updatesd tells yum-updatesd to check for updates when yum exits.
This way, if you run 'yum list updates' and yum says there's a new version
of (for example) zsh available, puplet will almost instantly update itself
to reflect this.
This way, if you run 'yum update' and install all available updates, puplet
will almost instantly update itself to reflect this.
%package -n yum-merge-conf
Summary: Yum plugin to merge configuration changes when installing packages
......@@ -335,6 +334,8 @@ fi
%changelog
* Sun Sep 30 2007 James Bowes <jbowes@redhat.com>
- Update the yum-refresh-updatesd description
* Mon Sep 14 2007 Tim Lauridsen <tla@rasmil.dk>
- do not use wildcards for manpages in yum-utils files section to avoid duplicates
......
......@@ -158,7 +158,7 @@ class YumDownloader(YumUtilBase):
repo = self.repos.getRepo(download.repoid)
remote = download.returnSimple('relativepath')
if opts.urls:
url = urljoin(repo.urls[0],remote)
url = urljoin(repo.urls[0]+'/',remote)
self.logger.info('%s' % url)
continue
local = os.path.basename(remote)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment