# 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. # Copyright 2008 Red Hat, Inc # written by Seth Vidal """ This plugin prohibits running yum -y update, prompts for additional confirmation on yum update and makes snide remarks on exit. Think of it like a demo for something more useful. """ from yum.plugins import TYPE_CORE, PluginYumExit from yum.constants import * import yum import sys import os warning_msg = """ YOU ARE VARNED UPDATING IS BAD, YOU VILL SUFFER FOR ZISS TREACHERY! Sincerely, The Management """ no_automated_update_msg = """ You cannot run an unattended yum full update. You will now be forcibly escorted from the building! Do not attempt to run ve can ALVAYS FIND YOU! With Love, The Management """ if yum.__version__.startswith('2.4'): from yum.plugins import TYPE_INTERFACE plugin_type = (TYPE_CORE,TYPE_INTERFACE) requires_api_version = '2.1' else: from yum.plugins import TYPE_INTERACTIVE plugin_type = (TYPE_CORE,TYPE_INTERACTIVE) requires_api_version = '2.4' # running from prerepo setup to stop it all before it gets too far # but far enough along so we have all the input the user will give def prereposetup_hook(conduit): if hasattr(conduit._base, 'basecmd') and conduit._base.basecmd == 'update': if not conduit._base.extcmds or '*' in conduit._base.extcmds: conf = conduit.getConf() if conf.assumeyes: print no_automated_update_msg raise PluginYumExit, "No Automated Updates, allowed" else: print warning_msg if not conduit.promptYN('Update and potentially break everything?!'): raise PluginYumExit, "Did not agree, VERBOTTEN!" def close_hook(conduit): print "Have a nice day.... OR ELSE!"