def progress_loop(self):
        """Prepare, copy and configure the system."""
        self.start_debconf()
        dbfilter = partman_commit.PartmanCommit(self)
        if dbfilter.run_command(auto_process=True) != 0:
            print('\nUnable to commit the partition table, exiting.',
                  file=self.console)
            return

        self.start_debconf()
        dbfilter = install.Install(self)
        ret = dbfilter.run_command(auto_process=True)
        if ret == 0:
            dbfilter = plugininstall.Install(self)
            ret = dbfilter.run_command(auto_process=True)
        if ret == 0:
            self.run_success_cmd()
            print('Installation complete.', file=self.console)
            telemetry.get().done(self.db)
            if self.get_reboot():
                misc.execute("reboot")
        if ret != 0:
            if ret == 3:
                # error already handled by Install
                sys.exit(ret)
            elif (os.WIFSIGNALED(ret) and os.WTERMSIG(ret)
                  in (signal.SIGINT, signal.SIGKILL, signal.SIGTERM)):
                sys.exit(ret)
            elif os.path.exists('/var/lib/ubiquity/install.trace'):
                with open('/var/lib/ubiquity/install.trace') as tbfile:
                    realtb = tbfile.read()
                raise RuntimeError("Install failed with exit code %s\n%s" %
                                   (ret, realtb))
Beispiel #2
0
    def run(self):
        """Main entry point."""
        # Is this even needed anymore now that Ubiquity elevates its
        # privileges?
        if os.getuid() != 0:
            print(
                'This installer must be run with administrative '
                'privileges, and cannot continue without them.',
                file=self.console)
            sys.exit(1)

        telemetry.get().set_installer_type('NonInteractive')
        telemetry.get().add_stage(telemetry.START_INSTALL_STAGE_TAG)

        for x in self.pages:
            if issubclass(x.filter_class, Plugin):
                ui = x.ui
            else:
                ui = None
            self.start_debconf()
            self.dbfilter = x.filter_class(self, ui=ui)
            self.dbfilter.start(auto_process=True)
            self.mainloop.run()
            if self.dbfilter_status:
                sys.exit(1)

        self.installing = True
        self.progress_loop()
Beispiel #3
0
    def run(self):
        if os.getuid() != 0:
            print(textwrap.fill(
                'This program must be run with administrative privileges, and '
                'cannot continue without them.'),
                  file=sys.stderr)
            sys.exit(1)

        telemetry.get().set_installer_type('DebConf')
        telemetry.get().set_is_oem(self.oem_config)
        telemetry.get().add_stage(telemetry.START_INSTALL_STAGE_TAG)

        self.pagesindex = 0
        self.pageslen = 0
        self.pages = []
        for mod in self.modules:
            if hasattr(mod.module, 'PageDebconf'):
                mod.ui_class = mod.module.PageDebconf
                mod.controller = Controller(self)
                mod.ui = mod.ui_class(mod.controller)
                title = mod.ui.get('plugin_title')
                if title:
                    mod.title = title
                    self.pageslen += 1
                    self.pages.append(mod)

        while (self.pagesindex >= 0 and self.pagesindex < self.pageslen):
            step = self.pages[self.pagesindex]

            self.db.settitle(step.title)

            if issubclass(self.pages[self.pagesindex].filter_class, Plugin):
                ui = self.pages[self.pagesindex].ui
            else:
                ui = None
            dbfilter = self.pages[self.pagesindex].filter_class(self,
                                                                db=self.db,
                                                                ui=ui)
            ret = dbfilter.run_unfiltered()

            if ret == 10:
                self.pagesindex -= 1
            else:
                self.pagesindex += 1

        # TODO: handle errors
        if self.pagesindex == self.pageslen:
            for install_component in plugininstall, install:
                dbfilter = install_component.Install(self, db=self.db)
                ret = dbfilter.run_unfiltered()
                if ret != 0:
                    self.installing = False
                    if ret == 3:
                        # error already handled by Install
                        sys.exit(ret)
                    elif (os.WIFSIGNALED(ret) and os.WTERMSIG(ret)
                          in (signal.SIGINT, signal.SIGKILL, signal.SIGTERM)):
                        sys.exit(ret)
                    elif os.path.exists('/var/lib/ubiquity/install.trace'):
                        with open('/var/lib/ubiquity/install.trace') as tbfile:
                            realtb = tbfile.read()
                        raise RuntimeError(
                            "Install failed with exit code %s\n%s" %
                            (ret, realtb))
                    else:
                        raise RuntimeError(
                            "Install failed with exit code %s; see "
                            "/var/log/syslog" % ret)

            telemetry.get().done(self.db)
            return 0
        else:
            return 10