1 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 """A module for the Installer base class.""" 6 7 import cr 8 9 10 class Installer(cr.Action, cr.Plugin.Type): 11 """Base class for implementing installers. 12 13 Installer implementations must implement the Uninstall and Install methods. 14 If the location into which targets are built is find for running them, then 15 they do not actually have to do anything. 16 """ 17 18 SELECTOR_ARG = '--installer' 19 SELECTOR = 'CR_INSTALLER' 20 SELECTOR_HELP = 'Sets the installer to use.' 21 22 @cr.Plugin.activemethod 23 def Uninstall(self, targets, arguments): 24 """Removes a target from it's installed location.""" 25 26 raise NotImplementedError('Must be overridden.') 27 28 @cr.Plugin.activemethod 29 def Install(self, targets, arguments): 30 """Installs a target somewhere so that it is ready to run.""" 31 raise NotImplementedError('Must be overridden.') 32 33 @cr.Plugin.activemethod 34 def Reinstall(self, targets, arguments): 35 """Force a target to install even if already installed. 36 37 Default implementation is to do an Uninstall Install sequence. 38 Do not call the base version if you implement a more efficient one. 39 """ 40 self.Uninstall(targets, []) 41 self.Install(targets, arguments) 42 43 44 class SkipInstaller(Installer): 45 """An Installer the user chooses to bypass the install step of a command.""" 46 47 @property 48 def priority(self): 49 return super(SkipInstaller, self).priority - 1 50 51 def Uninstall(self, targets, arguments): 52 pass 53 54 def Install(self, targets, arguments): 55 pass 56