def copy_debconf(): """Copy a few important questions into the installed system.""" if not TARGET: return targetdb = TARGET + '/var/cache/debconf/config.dat' patterns = ['^oem-config/'] oem = False import debconf dccomm = subprocess.Popen(['debconf-communicate', '-fnoninteractive', 'ubiquity'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True, universal_newlines=True) try: dc = debconf.Debconf(read=dccomm.stdout, write=dccomm.stdin) try: if dc.get('oem-config/enable') == 'true': oem = True except debconf.DebconfError: pass finally: dccomm.stdin.close() dccomm.wait() if not oem: patterns.append('^keyboard-configuration/') patterns.append('^console-setup/') for q in patterns: misc.execute_root( 'debconf-copydb', 'configdb', 'targetdb', '-p', q, '--config=Name:targetdb', '--config=Driver:File', '--config=Mode:0644', '--config=Filename:%s' % targetdb)
def __init__(self, distro): BaseFrontend.__init__(self, distro) with misc.raised_privileges(): self.console = open('/dev/console', 'w') if not self.console: self.console = sys.stdout # better than crashing self.installing = False self.progress_position = ubiquity.progressposition.ProgressPosition() self.progress_val = 0 self.progress_info = '' self.mainloop = GObject.MainLoop() self.pages = [] for mod in self.modules: if hasattr(mod.module, 'PageNoninteractive'): mod.controller = ubiquity.frontend.base.Controller(self) mod.ui_class = mod.module.PageNoninteractive mod.ui = mod.ui_class(mod.controller) self.pages.append(mod) i18n.reset_locale(self) if self.oem_config: misc.execute_root('apt-install', 'oem-config-gtk')
def copy_debconf(): """Copy a few important questions into the installed system.""" if not TARGET: return targetdb = TARGET + '/var/cache/debconf/config.dat' patterns = ['^oem-config/'] oem = False import debconf dccomm = subprocess.Popen( ['debconf-communicate', '-fnoninteractive', 'ubiquity'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True, universal_newlines=True) try: dc = debconf.Debconf(read=dccomm.stdout, write=dccomm.stdin) try: if dc.get('oem-config/enable') == 'true': oem = True except debconf.DebconfError: pass finally: dccomm.stdin.close() dccomm.wait() if not oem: patterns.append('^keyboard-configuration/') patterns.append('^console-setup/') for q in patterns: misc.execute_root('debconf-copydb', 'configdb', 'targetdb', '-p', q, '--config=Name:targetdb', '--config=Driver:File', '--config=Mode:0644', '--config=Filename:%s' % targetdb)
def __init__(self, controller, *args, **kwargs): PageBase.__init__(self, *args, **kwargs) self.controller = controller from PyQt5 import uic from PyQt5.QtGui import QPixmap, QIcon self.plugin_widgets = uic.loadUi( '/usr/share/ubiquity/qt/stepUserSetup.ui') self.page = self.plugin_widgets self.username_edited = False self.hostname_edited = False if self.controller.oem_config: self.page.fullname.setText('OEM Configuration (temporary user)') self.page.fullname.setReadOnly(True) self.page.fullname.setEnabled(False) self.page.username.setText('oem') self.page.username.setReadOnly(True) self.page.username.setEnabled(False) self.page.login_pass.hide() self.page.login_auto.hide() self.page.login_encrypt.hide() self.username_edited = True self.hostname_edited = True self.page.hostname.setText('oem%s' % self.suffix) # The UserSetup component takes care of preseeding passwd/user-uid. misc.execute_root('apt-install', 'oem-config-kde') warningIcon = QPixmap( "/usr/share/icons/oxygen/48x48/status/dialog-warning.png") self.page.fullname_error_image.setPixmap(warningIcon) self.page.username_error_image.setPixmap(warningIcon) self.page.password_error_image.setPixmap(warningIcon) self.page.hostname_error_image.setPixmap(warningIcon) self.page.show_password.setIcon(QIcon.fromTheme("password-show-off")) self.clear_errors() self.page.fullname.textChanged[str].connect(self.on_fullname_changed) self.page.username.textChanged[str].connect(self.on_username_changed) self.page.hostname.textChanged[str].connect(self.on_hostname_changed) self.page.show_password.toggled.connect(self.on_show_password) # self.page.password.textChanged[str].connect(self.on_password_changed) # self.page.verified_password.textChanged[str].connect( # self.on_verified_password_changed) self.page.login_pass.clicked[bool].connect(self.on_login_pass_clicked) self.page.login_auto.clicked[bool].connect(self.on_login_auto_clicked) self.page.password_debug_warning_label.setVisible( 'UBIQUITY_DEBUG' in os.environ)
def __init__(self, controller, *args, **kwargs): PageBase.__init__(self, *args, **kwargs) self.controller = controller from PyQt4 import uic from PyQt4.QtGui import QDialog from PyKDE4.kdeui import KIconLoader self.plugin_widgets = uic.loadUi( '/usr/share/ubiquity/qt/stepUserSetup.ui') self.page = self.plugin_widgets self.username_edited = False self.hostname_edited = False if self.controller.oem_config: self.page.fullname.setText('OEM Configuration (temporary user)') self.page.fullname.setReadOnly(True) self.page.fullname.setEnabled(False) self.page.username.setText('oem') self.page.username.setReadOnly(True) self.page.username.setEnabled(False) self.page.login_pass.hide() self.page.login_auto.hide() self.page.login_encrypt.hide() self.username_edited = True #self.hostname_edited = True #if self.laptop: # self.page.hostname.setText('oem-laptop') #else: # self.page.hostname.setText('oem-desktop') # The UserSetup component takes care of preseeding passwd/user-uid. execute_root('apt-install', 'oem-config-kde') iconLoader = KIconLoader() warningIcon = iconLoader.loadIcon("dialog-warning", KIconLoader.Desktop) self.page.fullname_error_image.setPixmap(warningIcon) self.page.username_error_image.setPixmap(warningIcon) self.page.password_error_image.setPixmap(warningIcon) self.page.hostname_error_image.setPixmap(warningIcon) self.clear_errors() self.page.fullname.textChanged[str].connect(self.on_fullname_changed) self.page.username.textChanged[str].connect(self.on_username_changed) self.page.hostname.textChanged[str].connect(self.on_hostname_changed) #self.page.password.textChanged[str].connect(self.on_password_changed) #self.page.verified_password.textChanged[str].connect(self.on_verified_password_changed) self.page.password_debug_warning_label.setVisible( 'UBIQUITY_DEBUG' in os.environ)
def Set_RootPartitionLabel(self): '''find the / mount partition then label it with UBUNTU for further use''' mount_output = magic.fetch_output(['mount']).split('\n') for line in mount_output: item = line.split() if '/' in item: try: from ubiquity import misc misc.execute_root('e2label',item[0],'UBUNTU') except Exception: pass
def __init__(self, controller, *args, **kwargs): PageBase.__init__(self, *args, **kwargs) self.controller = controller from PyQt4 import uic from PyQt4.QtGui import QPixmap self.plugin_widgets = uic.loadUi( '/usr/share/ubiquity/qt/stepUserSetup.ui') self.page = self.plugin_widgets self.username_edited = False self.hostname_edited = False if self.controller.oem_config: self.page.fullname.setText('OEM Configuration (temporary user)') self.page.fullname.setReadOnly(True) self.page.fullname.setEnabled(False) self.page.username.setText('oem') self.page.username.setReadOnly(True) self.page.username.setEnabled(False) self.page.login_pass.hide() self.page.login_auto.hide() self.page.login_encrypt.hide() self.username_edited = True self.hostname_edited = True self.page.hostname.setText('oem%s' % self.suffix) # The UserSetup component takes care of preseeding passwd/user-uid. misc.execute_root('apt-install', 'oem-config-kde') warningIcon = QPixmap( "/usr/share/icons/oxygen/48x48/status/dialog-warning.png") self.page.fullname_error_image.setPixmap(warningIcon) self.page.username_error_image.setPixmap(warningIcon) self.page.password_error_image.setPixmap(warningIcon) self.page.hostname_error_image.setPixmap(warningIcon) self.clear_errors() self.page.fullname.textChanged[str].connect(self.on_fullname_changed) self.page.username.textChanged[str].connect(self.on_username_changed) self.page.hostname.textChanged[str].connect(self.on_hostname_changed) #self.page.password.textChanged[str].connect(self.on_password_changed) #self.page.verified_password.textChanged[str].connect( # self.on_verified_password_changed) self.page.login_pass.clicked[bool].connect(self.on_login_pass_clicked) self.page.login_auto.clicked[bool].connect(self.on_login_auto_clicked) self.page.password_debug_warning_label.setVisible( 'UBIQUITY_DEBUG' in os.environ)
def unmount_target(): if not TARGET: return paths = [] with open('/proc/mounts') as mounts: for line in mounts: path = line.split(' ')[1] if path == TARGET or path.startswith(TARGET + '/'): paths.append(path) paths.sort() paths.reverse() for path in paths: misc.execute_root('umount', path)
def __init__(self, controller, *args, **kwargs): PageBase.__init__(self, *args, **kwargs) self.controller = controller from PyQt4 import uic from PyQt4.QtGui import QDialog from PyKDE4.kdeui import KIconLoader self.plugin_widgets = uic.loadUi('/usr/share/ubiquity/qt/stepUserSetup.ui') self.page = self.plugin_widgets self.username_edited = False self.hostname_edited = False if self.controller.oem_config: self.page.fullname.setText('OEM Configuration (temporary user)') self.page.fullname.setReadOnly(True) self.page.fullname.setEnabled(False) self.page.username.setText('oem') self.page.username.setReadOnly(True) self.page.username.setEnabled(False) self.page.login_pass.hide() self.page.login_auto.hide() self.page.login_encrypt.hide() self.username_edited = True self.hostname_edited = True if self.laptop: self.page.hostname.setText('oem-laptop') else: self.page.hostname.setText('oem-desktop') # The UserSetup component takes care of preseeding passwd/user-uid. execute_root('apt-install', 'oem-config-kde') iconLoader = KIconLoader() warningIcon = iconLoader.loadIcon("dialog-warning", KIconLoader.Desktop) self.page.fullname_error_image.setPixmap(warningIcon) self.page.username_error_image.setPixmap(warningIcon) self.page.password_error_image.setPixmap(warningIcon) self.page.hostname_error_image.setPixmap(warningIcon) self.clear_errors() self.page.fullname.textChanged[str].connect(self.on_fullname_changed) self.page.username.textChanged[str].connect(self.on_username_changed) self.page.hostname.textChanged[str].connect(self.on_hostname_changed) #self.page.password.textChanged[str].connect(self.on_password_changed) #self.page.verified_password.textChanged[str].connect(self.on_verified_password_changed) self.page.password_debug_warning_label.setVisible('UBIQUITY_DEBUG' in os.environ)
def cleanup(self): di_locale = self.db.get('debian-installer/locale') if di_locale not in i18n.get_supported_locales(): di_locale = self.db.get('debian-installer/fallbacklocale') if di_locale != self.frontend.locale: self.frontend.locale = di_locale os.environ['LANG'] = di_locale os.environ['LANGUAGE'] = di_locale try: locale.setlocale(locale.LC_ALL, '') except locale.Error, e: self.debug('locale.setlocale failed: %s (LANG=%s)', e, di_locale) misc.execute_root('fontconfig-voodoo', '--auto', '--force', '--quiet')
def reset_locale(frontend, just_country=False): frontend.start_debconf() di_locale = frontend.db.get('debian-installer/locale') if not di_locale: # TODO cjwatson 2006-07-17: maybe fetch # languagechooser/language-name and set a language based on # that? di_locale = 'en_US.UTF-8' if 'LANG' not in os.environ or di_locale != os.environ['LANG']: os.environ['LANG'] = di_locale os.environ['LANGUAGE'] = di_locale try: locale.setlocale(locale.LC_ALL, '') except locale.Error, e: print >>sys.stderr, 'locale.setlocale failed: %s (LANG=%s)' % \ (e, di_locale) if not just_country: misc.execute_root('fontconfig-voodoo', '--auto', '--force', '--quiet') im_switch.start_im()
def run_success_cmd(self): if self.success_cmd != "": self.debconf_progress_info(self.get_string("ubiquity/install/success_command")) execute_root("sh", "-c", self.success_cmd)
def run_error_cmd(self): if self.error_cmd != "": execute_root("sh", "-c", self.error_cmd)
def run_automation_error_cmd(self): if self.automation_error_cmd != "": execute_root("sh", "-c", self.automation_error_cmd)
def __init__(self, controller, *args, **kwargs): from gi.repository import Gio, Gtk PageBase.__init__(self, *args, **kwargs) self.resolver = Gio.Resolver.get_default() self.controller = controller self.username_changed_id = None self.hostname_changed_id = None self.username_edited = False self.hostname_edited = False self.hostname_timeout_id = 0 builder = Gtk.Builder() self.controller.add_builder(builder) builder.add_from_file(os.path.join(os.environ['UBIQUITY_GLADE'], 'stepUserInfo.ui')) builder.connect_signals(self) self.page = builder.get_object('stepUserInfo') self.username = builder.get_object('username') self.hostname = builder.get_object('hostname') self.fullname = builder.get_object('fullname') self.password = builder.get_object('password') self.verified_password = builder.get_object('verified_password') self.login_auto = builder.get_object('login_auto') self.login_encrypt = builder.get_object('login_encrypt') self.login_pass = builder.get_object('login_pass') self.username_error_label = builder.get_object('username_error_label') self.hostname_error_label = builder.get_object('hostname_error_label') self.password_error_label = builder.get_object('password_error_label') self.login_vbox = builder.get_object('login_vbox') self.username_ok = builder.get_object('username_ok') self.hostname_ok = builder.get_object('hostname_ok') self.fullname_ok = builder.get_object('fullname_ok') self.password_ok = builder.get_object('password_ok') self.password_strength = builder.get_object('password_strength') # Dodgy hack to let us center the contents of the page without it # moving as elements appear and disappear, specifically the full name # okay check icon and the hostname error messages. paddingbox = builder.get_object('paddingbox') def func(box): box.get_parent().child_set_property(box, 'expand', False) box.set_size_request(box.get_allocation().width / 2, -1) paddingbox.connect('realize', func) # Some signals need to be connected by hand so that we have the # handler ids. self.username_changed_id = self.username.connect( 'changed', self.on_username_changed) self.hostname_changed_id = self.hostname.connect( 'changed', self.on_hostname_changed) if self.controller.oem_config: self.fullname.set_text('OEM Configuration (temporary user)') self.fullname.set_editable(False) self.fullname.set_sensitive(False) self.username.set_text('oem') self.username.set_editable(False) self.username.set_sensitive(False) self.username_edited = True self.hostname.set_text('oem%s' % self.suffix) self.hostname_edited = True self.login_vbox.hide() # The UserSetup component takes care of preseeding passwd/user-uid. misc.execute_root('apt-install', 'oem-config-gtk', 'oem-config-slideshow-ubuntu') self.resolver_ok = True self.plugin_widgets = self.page
def run_success_cmd(self): if self.success_cmd != '': self.debconf_progress_info( self.get_string('ubiquity/install/success_command')) execute_root('sh', '-c', self.success_cmd)
def run_automation_error_cmd(self): if self.automation_error_cmd != '': execute_root('sh', '-c', self.automation_error_cmd)
def run_error_cmd(self): if self.error_cmd != '': execute_root('sh', '-c', self.error_cmd)
def do_shutdown(self): misc.execute_root("poweroff")
def do_reboot(self): misc.execute_root("reboot")
def __init__(self, controller, *args, **kwargs): PageBase.__init__(self, *args, **kwargs) self.controller = controller self.username_changed_id = None self.hostname_changed_id = None self.username_edited = False self.hostname_edited = False import gtk from ubiquity.frontend.gtk_components.labelled_entry import LabelledEntry builder = gtk.Builder() self.controller.add_builder(builder) builder.add_from_file('/usr/share/ubiquity/gtk/stepUserInfo.ui') builder.connect_signals(self) self.page = builder.get_object('stepUserInfo') self.username = builder.get_object('username') self.fullname = builder.get_object('fullname') self.password = builder.get_object('password') self.verified_password = builder.get_object('verified_password') self.login_auto = builder.get_object('login_auto') self.login_encrypt = builder.get_object('login_encrypt') self.username_error_reason = builder.get_object( 'username_error_reason') self.username_error_box = builder.get_object('username_error_box') self.password_error_reason = builder.get_object( 'password_error_reason') self.password_error_box = builder.get_object('password_error_box') self.hostname_error_reason = builder.get_object( 'hostname_error_reason') self.hostname_error_box = builder.get_object('hostname_error_box') self.hostname = builder.get_object('hostname') self.login_vbox = builder.get_object('login_vbox') self.scrolledwin = builder.get_object('userinfo_scrolledwindow') self.username_valid_image = builder.get_object('username_valid_image') self.hostname_valid_image = builder.get_object('hostname_valid_image') self.fullname_valid_image = builder.get_object('fullname_valid_image') self.password_valid = builder.get_object('password_valid') # Some signals need to be connected by hand so that we have the # handler ids. self.username_changed_id = self.username.connect( 'changed', self.on_username_changed) self.hostname_changed_id = self.hostname.connect( 'changed', self.on_hostname_changed) if self.controller.oem_config: self.fullname.set_text('OEM Configuration (temporary user)') self.fullname.set_editable(False) self.fullname.set_sensitive(False) self.username.set_text('oem') self.username.set_editable(False) self.username.set_sensitive(False) self.username_edited = True #if self.laptop: # self.hostname.set_text('oem-laptop') #else: # self.hostname.set_text('oem-desktop') #self.hostname_edited = True self.login_vbox.hide() # The UserSetup component takes care of preseeding passwd/user-uid. execute_root('apt-install', 'oem-config-gtk') sh = gtk.gdk.get_default_root_window().get_screen().get_height() # A bit ugly, but better to show the scrollbar on the edge cases than # not show it when needed. if sh <= 600: self.scrolledwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.plugin_widgets = self.page
def __init__(self, controller, *args, **kwargs): PageBase.__init__(self, *args, **kwargs) self.controller = controller self.username_changed_id = None self.hostname_changed_id = None self.username_edited = False self.hostname_edited = False import gtk from ubiquity.frontend.gtk_components.labelled_entry import LabelledEntry builder = gtk.Builder() self.controller.add_builder(builder) builder.add_from_file('/usr/share/ubiquity/gtk/stepUserInfo.ui') builder.connect_signals(self) self.page = builder.get_object('stepUserInfo') self.username = builder.get_object('username') self.fullname = builder.get_object('fullname') self.password = builder.get_object('password') self.verified_password = builder.get_object('verified_password') self.login_auto = builder.get_object('login_auto') self.login_encrypt = builder.get_object('login_encrypt') self.username_error_reason = builder.get_object('username_error_reason') self.username_error_box = builder.get_object('username_error_box') self.password_error_reason = builder.get_object('password_error_reason') self.password_error_box = builder.get_object('password_error_box') self.hostname_error_reason = builder.get_object('hostname_error_reason') self.hostname_error_box = builder.get_object('hostname_error_box') self.hostname = builder.get_object('hostname') self.login_vbox = builder.get_object('login_vbox') self.scrolledwin = builder.get_object('userinfo_scrolledwindow') self.username_valid_image = builder.get_object('username_valid_image') self.hostname_valid_image = builder.get_object('hostname_valid_image') self.fullname_valid_image = builder.get_object('fullname_valid_image') self.password_valid = builder.get_object('password_valid') # Some signals need to be connected by hand so that we have the # handler ids. self.username_changed_id = self.username.connect( 'changed', self.on_username_changed) self.hostname_changed_id = self.hostname.connect( 'changed', self.on_hostname_changed) if self.controller.oem_config: self.fullname.set_text('OEM Configuration (temporary user)') self.fullname.set_editable(False) self.fullname.set_sensitive(False) self.username.set_text('oem') self.username.set_editable(False) self.username.set_sensitive(False) self.username_edited = True if self.laptop: self.hostname.set_text('oem-laptop') else: self.hostname.set_text('oem-desktop') self.hostname_edited = True self.login_vbox.hide() # The UserSetup component takes care of preseeding passwd/user-uid. execute_root('apt-install', 'oem-config-gtk') sh = gtk.gdk.get_default_root_window().get_screen().get_height() # A bit ugly, but better to show the scrollbar on the edge cases than # not show it when needed. if sh <= 600: self.scrolledwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.plugin_widgets = self.page