And now for something a bit more fun, yum aliases. This does what you'd expect, it allows you to type: "yum lsuT" to get:
yum list updates --enablerepo=updates-testing ...which I do often enough I want to save my fingers :). I've attached both the .py file and the .conf file. Is this useful enough to go in yum-utils? -- James Antill <[EMAIL PROTECTED]> Red Hat
#!/usr/bin/python
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# by James Antill
from yum.plugins import PluginYumExit, TYPE_INTERACTIVE
import sys
requires_api_version = '2.1'
plugin_type = (TYPE_INTERACTIVE,)
class AliasCommand:
def __init__(self, cmd):
self.cmd = cmd
def getNames(self):
return [self.cmd]
def getUsage(self):
return self.getNames()[0]
# doCheck and doCommand are never called.
def init_hook(conduit):
aliases = {}
conffile = conduit.confString('main', 'conffile',
default='/etc/yum/aliases.conf')
recursive = conduit.confBool('main', 'recursive', default=True)
register = conduit.confBool('main', 'register', default=False)
for line in file(conffile):
args = line.split()
if not args or args[0][0] == '#':
continue
cmd = args.pop(0)
if register:
conduit.registerCommand(AliasCommand(cmd))
aliases[cmd] = args
need_rep = True
while need_rep:
need_rep = False
num = 1 # Skip the yum cmd itself
for arg in sys.argv[1:]:
if arg[0] != '-':
break
num += 1
enum = num + 1
for cmd in aliases:
if sys.argv[num] == cmd:
sys.argv[num:enum] = aliases[cmd]
# Mostly works like the shell, so \ls does no alias lookup on ls
if sys.argv[num][0] == '\\':
sys.argv[num] = sys.argv[num][1:]
else:
need_rep = recursive
break
# These are some example aliases: DEV --enablerepo=development UPT --enablerepo=updates-testing SEC --security ls list lsT UPT ls lsD DEV ls lsi ls installed lsu ls updates lsuT lsT updates lsuD lsD updates lss SEC ls lssT SEC lsT lssD SEC lsD lssu lss updates lssuT lssT updates lssuD lssD updates lsec list-sec lsecT UPT lsec lsecD DEV lsec upT UPT update upD DEV update inT UPT install inD DEV install instT UPT install instD DEV install
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Yum-devel mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
