[yum-cvs] 4 commits - .gitignore plugins/aliases yum-utils.spec
James Antill
james at linux.duke.edu
Thu Dec 20 17:51:09 UTC 2007
.gitignore | 2
plugins/aliases/aliases | 57 +++++++++++++++++
plugins/aliases/aliases.conf | 12 +++
plugins/aliases/aliases.py | 138 +++++++++++++++++++++++++++++++++++++++++++
yum-utils.spec | 24 ++++++-
5 files changed, 230 insertions(+), 3 deletions(-)
New commits:
commit 578e1c7773a63bff1093c8de3677f425d03e160d
Author: James Antill <james at and.org>
Date: Thu Dec 20 12:50:44 2007 -0500
Match foo.py~ for backup files
diff --git a/.gitignore b/.gitignore
index ef229b1..fd0676e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-*.~
+*~
*.bak
*.pyc
*.pyo
commit 1cc413d4cc826c8e638d1e51d6c141197ec66ad2
Author: James Antill <james at and.org>
Date: Thu Dec 20 12:49:53 2007 -0500
Fix typo
diff --git a/yum-utils.spec b/yum-utils.spec
index 4096db9..e80b8e2 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -157,7 +157,7 @@ Group: System Environment/Base
Requires: yum >= 3.0.5
%description -n yum-security
-This plugin adds ther options --security, --cve, --bz and --advisory flags
+This plugin adds the options --security, --cve, --bz and --advisory flags
to yum and the list-security and info-security commands.
The options make it possible to limit list/upgrade of packages to specific
security relevant ones. The commands give you the security information.
commit 29f4a47f80ab0a2f5856b6de56afe8389aa67792
Author: James Antill <james at and.org>
Date: Thu Dec 20 12:49:31 2007 -0500
Add yum-aliases to the specfile
diff --git a/yum-utils.spec b/yum-utils.spec
index 6e99ebd..4096db9 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -194,6 +194,15 @@ Requires: yum >= 3.0
this plugin allows yum to erase specific packages on install/update based on an additional
metadata file in repositories. It is used to simplify distribution upgrade hangups.
+%package -n yum-aliases
+Summary: Yum plugin to enable aliases filters
+Group: System Environment/Base
+Requires: yum >= 3.0.5
+
+%description -n yum-aliases
+This plugin adds the command alias, and parses the aliases config. file to
+enable aliases.
+
%prep
%setup -q
@@ -206,7 +215,7 @@ make -C updateonboot DESTDIR=$RPM_BUILD_ROOT install
# Plugins to install
plugins="changelog fastestmirror fedorakmod protectbase versionlock tsflags kernel-module \
downloadonly allowdowngrade skip-broken priorities refresh-updatesd merge-conf \
- security protect-packages basearchonly upgrade-helper"
+ security protect-packages basearchonly upgrade-helper aliases"
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/yum/pluginconf.d/ $RPM_BUILD_ROOT/usr/lib/yum-plugins/
@@ -215,6 +224,8 @@ for plug in $plugins; do
install -m 644 $plug/*.conf $RPM_BUILD_ROOT/%{_sysconfdir}/yum/pluginconf.d/
install -m 644 $plug/*.py $RPM_BUILD_ROOT/usr/lib/yum-plugins/
done
+install -m 644 aliases/aliases $RPM_BUILD_ROOT/%{_sysconfdir}/yum/aliases.conf
+
%clean
rm -rf $RPM_BUILD_ROOT
@@ -348,8 +359,17 @@ fi
%config(noreplace) %{_sysconfdir}/yum/pluginconf.d/upgrade-helper.conf
/usr/lib/yum-plugins/upgrade-helper.*
+%files -n yum-aliases
+%defattr(-, root, root)
+%config(noreplace) %{_sysconfdir}/yum/pluginconf.d/aliases.conf
+%config(noreplace) %{_sysconfdir}/yum/aliases.conf
+/usr/lib/yum-plugins/aliases.*
+
%changelog
+* Thu Dec 12 2007 James Antill <james at fedoraproject.org>
+- Add yum-aliases plugin
+
* Fri Dec 7 2007 Tim Lauridsen <timlau at fedoraproject.org>
- mark as 1.1.9
* Fri Oct 26 2007 Seth Vidal <skvidal at fedoraproject.org>
commit fb9eeb9087022c044ccdc48e3c892a2e26bd7c18
Author: James Antill <james at and.org>
Date: Thu Dec 20 12:38:01 2007 -0500
Add aliases module
diff --git a/plugins/aliases/aliases b/plugins/aliases/aliases
new file mode 100644
index 0000000..411c524
--- /dev/null
+++ b/plugins/aliases/aliases
@@ -0,0 +1,57 @@
+
+# These are some aliases that a lot of people might find useful, well those
+# who install yum-aliases plugin anyway :). Note that they require alias
+# recursion, which is the default.
+
+DEV --enablerepo=development
+UPT --enablerepo=updates-testing
+SEC --security
+
+SRC --enablerepo=fedora-source --enablerepo=updates-source
+# Note that we/you can move to =X,Y in 3.2.9 onwards.
+DBG --enablerepo=fedora-debuginfo --enablerepo=updates-debuginfo
+ALLSRC --enablerepo=*-source
+ALLDBG --enablerepo=*-debuginfo
+
+up upgrade
+inst install
+
+ls list
+lsi ls installed
+lsu ls updates
+lss
+lsec list-security
+lssu SEC ls updates
+
+force-install --skip-broken --disableexcludes=all install
+force-inst --skip-broken --disableexcludes=all inst
+force-upgrade --skip-broken --disableexcludes=all upgrade
+force-up --skip-broken --disableexcludes=all up
+force-update --skip-broken --disableexcludes=all update
+
+dbg-install DBG install
+dbg-inst DBG inst
+
+# These are some example aliases, which probably aren't worth enabling for
+# everyone. Mostly useful for people who use DEV / UPT a lot.
+
+# lsT UPT ls
+# lsD DEV ls
+#
+# lsuT lsT updates
+# lsuD lsD updates
+#
+# lssT SEC lsT
+# lssD SEC lsD
+#
+# lssuT SEC lsT updates
+# lssuD SEC lsD updates
+#
+# lsecT UPT lsec
+# lsecD DEV lsec
+#
+# upT UPT update
+# upD DEV update
+#
+# instT UPT install
+# instD DEV install
diff --git a/plugins/aliases/aliases.conf b/plugins/aliases/aliases.conf
new file mode 100644
index 0000000..97f8245
--- /dev/null
+++ b/plugins/aliases/aliases.conf
@@ -0,0 +1,12 @@
+[main]
+enabled=1
+
+# conffile - config. file to use
+# <default> = /etc/yum/aliases.conf
+
+# recursive - whether aliases a resolved recursivly
+# <default> = True
+
+# register - register aliases a yum commands (so they are in yum help, TAB
+# complete things might pick them up then too).
+# <default> = False
diff --git a/plugins/aliases/aliases.py b/plugins/aliases/aliases.py
new file mode 100644
index 0000000..6f7a061
--- /dev/null
+++ b/plugins/aliases/aliases.py
@@ -0,0 +1,138 @@
+#!/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
+import time
+import cli
+from i18n import _
+
+requires_api_version = '2.1'
+plugin_type = (TYPE_INTERACTIVE,)
+
+class AliasedCommand:
+ 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, for aliased commands.
+
+
+aliases = None
+conffile = None
+recursive = None
+def parse_aliases(conffile):
+ aliases = {}
+ for line in file(conffile):
+ args = line.split()
+ if len(args) < 2 or args[0][0] == '#':
+ continue
+ cmd = args.pop(0)
+ aliases[cmd] = args
+ return aliases
+
+def resolve_aliases(args, log, skip=0):
+ need_rep = True
+ while need_rep:
+ need_rep = False
+ num = skip
+ for arg in args[skip:]:
+ if arg[0] != '-':
+ break
+ num += 1
+
+ if num >= len(args): # Only options
+ break
+
+ enum = num + 1
+ for cmd in aliases:
+ if cmd == args[num]:
+ log(3, 'ALIAS DONE(%s): %s' % (cmd, str(aliases[cmd])))
+ args[num:enum] = aliases[cmd]
+ # Mostly works like the shell, so \ls does no alias lookup on ls
+ if args[num][0] == '\\':
+ args[num] = args[num][1:]
+ else:
+ need_rep = recursive
+ break
+
+
+class AliasCommand(AliasedCommand):
+ def __init__(self):
+ AliasedCommand.__init__(self, "alias")
+
+ def doCheck(self, base, basecmd, extcmds):
+ if len(extcmds) > 1: # Add a new alias
+ try:
+ open(conffile, "a").close()
+ except:
+ base.logger.critical(_("Can't open aliases file: %s") %
+ conffile)
+ raise cli.CliError
+
+ def doCommand(self, base, basecmd, extcmds):
+ if len(extcmds) > 1: # Add a new alias
+ fo = open(conffile, "a")
+ fo.write(_("\n# Alias added on %s\n%s\n") % (time.ctime(),
+ ' '.join(extcmds)))
+ fo.close()
+ return 0, [basecmd + ' done']
+
+ if len(extcmds) == 1: # Show just a single alias
+ cmd = extcmds[0]
+ if cmd not in aliases:
+ return 1, [_("%s, no match for %s") % (basecmd, cmd)]
+
+ args = [cmd]
+ resolve_aliases(args, lambda x,y: base.verbose_logger.debug(y))
+ print _("Alias %s = %s") % (cmd, " ".join(args))
+ return 0, [basecmd + ' done']
+
+
+ for cmd in sorted(aliases.keys()):
+ args = aliases[cmd][:]
+ resolve_aliases(args, lambda x,y: base.verbose_logger.debug(y))
+ print _("Alias %s = %s") % (cmd, " ".join(args))
+
+ return 0, [basecmd + ' done']
+
+
+def config_hook(conduit):
+ global aliases
+ global conffile
+ global recursive
+
+ conffile = conduit.confString('main', 'conffile',
+ default='/etc/yum/aliases.conf')
+ recursive = conduit.confBool('main', 'recursive', default=True)
+ register = conduit.confBool('main', 'register', default=False)
+
+ conduit.registerCommand(AliasCommand())
+ aliases = parse_aliases(conffile)
+ if register:
+ for cmd in aliases:
+ conduit.registerCommand(AliasedCommand(cmd))
+
+ # Skip the yum cmd itself
+ resolve_aliases(args=sys.argv, skip=1, log=conduit.info)
+
More information about the Yum-cvs-commits
mailing list