def main(): """ main method """ # commandline setup and config (options, args) = do_commandline() config = DistUpgradeConfig(".") logdir = setup_logging(options, config) from DistUpgradeVersion import VERSION logging.info("release-upgrader version '%s' started" % VERSION) # create view and app objects view = setup_view(options, config, logdir) # gnu screen support if (view.needs_screen and not "RELEASE_UPGRADER_NO_SCREEN" in os.environ and not options.disable_gnu_screen): run_new_gnu_screen_window_or_reattach() app = DistUpgradeController(view, options, datadir=options.datadir) atexit.register(app._enableAptCronJob) # partial upgrade only if options.partial: if not app.doPartialUpgrade(): sys.exit(1) sys.exit(0) # save system state (only if not doing just a partial upgrade) save_system_state(logdir) # full upgrade, return error code for success/failure if app.run(): return 0 return 1
def __init__(self, datadir=None, logdir=None): DistUpgradeView.__init__(self) self.config = DistUpgradeConfig(".") self._fetchProgress = NonInteractiveFetchProgress() self._installProgress = NonInteractiveInstallProgress(logdir) self._opProgress = apt.progress.base.OpProgress() sys.__excepthook__ = self.excepthook
def __init__(self, logdir): InstallProgress.__init__(self) logging.debug("setting up environ for non-interactive use") if not os.environ.has_key("DEBIAN_FRONTEND"): os.environ["DEBIAN_FRONTEND"] = "noninteractive" os.environ["APT_LISTCHANGES_FRONTEND"] = "none" os.environ["RELEASE_UPRADER_NO_APPORT"] = "1" self.config = DistUpgradeConfig(".") self.logdir = logdir self.install_run_number = 0 try: if self.config.getWithDefault("NonInteractive","ForceOverwrite", False): apt_pkg.config.set("DPkg::Options::","--force-overwrite") except (NoSectionError, NoOptionError): pass # more debug #apt_pkg.Config.Set("Debug::pkgOrderList","true") #apt_pkg.Config.Set("Debug::pkgDPkgPM","true") # default to 2400 sec timeout self.timeout = 2400 try: self.timeout = self.config.getint("NonInteractive","TerminalTimeout") except Exception: pass
parser.add_option("--with-network", dest="withNetwork", action="store_true") parser.add_option("--without-network", dest="withNetwork", action="store_false") (options, args) = parser.parse_args() if not os.path.exists("/var/log/dist-upgrade"): os.mkdir("/var/log/dist-upgrade") logging.basicConfig(level=logging.DEBUG, filename="/var/log/dist-upgrade/main.log", format='%(asctime)s %(levelname)s %(message)s', filemode='w') config = DistUpgradeConfig(".") requested_view = config.get("View", "View") try: view_modul = __import__(requested_view) view_class = getattr(view_modul, requested_view) view = view_class() except (ImportError, AttributeError): logging.error("can't import view '%s'" % requested_view) print "can't find %s" % requested_view sys.exit(1) app = DistUpgradeControler(view, options) app.run() # testcode to see if the bullets look nice in the dialog #for i in range(4):