def _gconftool_exists(): global _cached_gconftool_exists if _cached_gconftool_exists is not None: return _cached_gconftool_exists _cached_gconftool_exists = osextras.find_on_path('gconftool-2') return _cached_gconftool_exists
def _gsettings_exists(): global _cached_gsettings_exists if _cached_gsettings_exists is not None: return _cached_gsettings_exists _cached_gsettings_exists = osextras.find_on_path('gsettings') return _cached_gsettings_exists
def mount_one_image(self, fsfile, mountpoint=None): if os.path.splitext(fsfile)[1] == '.cloop': blockdev_prefix = 'cloop' elif os.path.splitext(fsfile)[1] == '.squashfs': blockdev_prefix = 'loop' if blockdev_prefix == '': raise install_misc.InstallStepError( "No source device found for %s" % fsfile) dev = '' sysloops = sorted([ x for x in os.listdir('/sys/block') if x.startswith(blockdev_prefix) ]) for sysloop in sysloops: try: with open(os.path.join('/sys/block', sysloop, 'size')) as sysloopf: sysloopsize = sysloopf.readline().strip() if sysloopsize == '0': if osextras.find_on_path('udevadm'): udevinfo_cmd = ['udevadm', 'info'] else: udevinfo_cmd = ['udevinfo'] udevinfo_cmd.extend( ['-q', 'name', '-p', os.path.join('/block', sysloop)]) with open('/dev/null') as devnull: udevinfo = subprocess.Popen(udevinfo_cmd, stdout=subprocess.PIPE, stderr=devnull, universal_newlines=True) devbase = udevinfo.communicate()[0] if udevinfo.returncode != 0: devbase = sysloop dev = '/dev/%s' % devbase break except Exception: continue if dev == '': raise install_misc.InstallStepError( "No loop device available for %s" % fsfile) misc.execute('losetup', dev, fsfile) if mountpoint is None: mountpoint = '/var/lib/ubiquity/%s' % sysloop if not os.path.isdir(mountpoint): os.mkdir(mountpoint) if not misc.execute('mount', dev, mountpoint): misc.execute('losetup', '-d', dev) misc.execute('mount', '-o', 'loop', fsfile, mountpoint) dev = 'unused' return (dev, mountpoint)
def mount_one_image(self, fsfile, mountpoint=None): if os.path.splitext(fsfile)[1] == '.cloop': blockdev_prefix = 'cloop' elif os.path.splitext(fsfile)[1] == '.squashfs': blockdev_prefix = 'loop' if blockdev_prefix == '': raise install_misc.InstallStepError( "No source device found for %s" % fsfile) dev = '' sysloops = sorted([x for x in os.listdir('/sys/block') if x.startswith(blockdev_prefix)]) for sysloop in sysloops: try: with open(os.path.join('/sys/block', sysloop, 'size')) as sysloopf: sysloopsize = sysloopf.readline().strip() if sysloopsize == '0': if osextras.find_on_path('udevadm'): udevinfo_cmd = ['udevadm', 'info'] else: udevinfo_cmd = ['udevinfo'] udevinfo_cmd.extend( ['-q', 'name', '-p', os.path.join('/block', sysloop)]) with open('/dev/null') as devnull: udevinfo = subprocess.Popen( udevinfo_cmd, stdout=subprocess.PIPE, stderr=devnull, universal_newlines=True) devbase = udevinfo.communicate()[0] if udevinfo.returncode != 0: devbase = sysloop dev = '/dev/%s' % devbase break except: continue if dev == '': raise install_misc.InstallStepError( "No loop device available for %s" % fsfile) misc.execute('losetup', dev, fsfile) if mountpoint is None: mountpoint = '/var/lib/ubiquity/%s' % sysloop if not os.path.isdir(mountpoint): os.mkdir(mountpoint) if not misc.execute('mount', dev, mountpoint): misc.execute('losetup', '-d', dev) misc.execute('mount', '-o', 'loop', fsfile, mountpoint) dev = 'unused' return (dev, mountpoint)
def mount_one_image(self, fsfile, mountpoint=None): if os.path.splitext(fsfile)[1] == ".cloop": blockdev_prefix = "cloop" elif os.path.splitext(fsfile)[1] == ".squashfs": blockdev_prefix = "loop" if blockdev_prefix == "": raise install_misc.InstallStepError("No source device found for %s" % fsfile) dev = "" sysloops = sorted([x for x in os.listdir("/sys/block") if x.startswith(blockdev_prefix)]) for sysloop in sysloops: try: with open(os.path.join("/sys/block", sysloop, "size")) as sysloopf: sysloopsize = sysloopf.readline().strip() if sysloopsize == "0": if osextras.find_on_path("udevadm"): udevinfo_cmd = ["udevadm", "info"] else: udevinfo_cmd = ["udevinfo"] udevinfo_cmd.extend(["-q", "name", "-p", os.path.join("/block", sysloop)]) with open("/dev/null") as devnull: udevinfo = subprocess.Popen( udevinfo_cmd, stdout=subprocess.PIPE, stderr=devnull, universal_newlines=True ) devbase = udevinfo.communicate()[0] if udevinfo.returncode != 0: devbase = sysloop dev = "/dev/%s" % devbase break except: continue if dev == "": raise install_misc.InstallStepError("No loop device available for %s" % fsfile) misc.execute("losetup", dev, fsfile) if mountpoint is None: mountpoint = "/var/lib/ubiquity/%s" % sysloop if not os.path.isdir(mountpoint): os.mkdir(mountpoint) if not misc.execute("mount", dev, mountpoint): misc.execute("losetup", "-d", dev) misc.execute("mount", "-o", "loop", fsfile, mountpoint) dev = "unused" return (dev, mountpoint)
def set_use_nonfree(self, val): if osextras.find_on_path('ubuntu-drivers'): self.prepare_nonfree_software.setChecked(val) else: self.debug('Could not find ubuntu-drivers on the executable path.') self.set_allow_nonfree(False)
def select_language_packs(self, save=False): try: keep_packages = self.db.get('ubiquity/keep-installed') keep_packages = keep_packages.replace(',', '').split() syslog.syslog('keeping packages due to preseeding: %s' % ' '.join(keep_packages)) record_installed(keep_packages) except debconf.DebconfError: pass langpacks = [] all_langpacks = False try: langpack_db = self.db.get('pkgsel/language-packs') if langpack_db == 'ALL': apt_out = subprocess.Popen( ['apt-cache', '-n', 'search', '^language-pack-[^-][^-]*$'], stdout=subprocess.PIPE).communicate()[0].rstrip().split('\n') langpacks = map(lambda x: x.split('-')[2].strip(), apt_out) all_langpacks = True else: langpacks = langpack_db.replace(',', '').split() except debconf.DebconfError: pass if not langpacks: langpack_set = set() try: langpack_db = self.db.get('localechooser/supported-locales') for locale in langpack_db.replace(',', '').split(): langpack_set.add(locale) except debconf.DebconfError: pass langpack_db = self.db.get('debian-installer/locale') langpack_set.add(langpack_db) langpacks = sorted(langpack_set) no_install = '/var/lib/ubiquity/no-install-langpacks' if os.path.exists(no_install): osextras.unlink_force(no_install) if len(langpacks) == 1 and langpacks[0] in ('C', 'en'): # Touch with open(no_install, 'a'): os.utime(no_install, None) syslog.syslog('keeping language packs for: %s' % ' '.join(langpacks)) try: lppatterns = self.db.get('pkgsel/language-pack-patterns').split() except debconf.DebconfError: return cache = Cache() to_install = [] checker = osextras.find_on_path('check-language-support') for lp_locale in langpacks: lp = locale_to_language_pack(lp_locale) # Basic language packs, required to get localisation working at # all. We install these almost unconditionally; if you want to # get rid of even these, you can preseed pkgsel/language-packs # to the empty string. to_install.append('language-pack-%s' % lp) # Other language packs, typically selected by preseeding. for pattern in lppatterns: to_install.append(pattern.replace('$LL', lp)) # More extensive language support packages. # If pkgsel/language-packs is ALL, then speed things up by # calling check-language-support just once. if not all_langpacks and checker: check_lang = subprocess.Popen( ['check-language-support', '-l', lp_locale.split('.')[0], '--show-installed'], stdout=subprocess.PIPE) to_install.extend(check_lang.communicate()[0].strip().split()) else: to_install.append('language-support-%s' % lp) if checker: # Keep language-support-$LL installed if it happens to be in # the live filesystem, since there's no point spending time # removing it; but don't install it if it isn't in the live # filesystem. toplevel = 'language-support-%s' % lp toplevel_pkg = get_cache_pkg(cache, toplevel) if toplevel_pkg and toplevel_pkg.is_installed: to_install.append(toplevel) if all_langpacks and checker: check_lang = subprocess.Popen( ['check-language-support', '-a', '--show-installed'], stdout=subprocess.PIPE) to_install.extend(check_lang.communicate()[0].strip().split()) # Filter the list of language packs to include only language packs # that exist in the live filesystem's apt cache, so that we can tell # the difference between "no such language pack" and "language pack # not retrievable given apt configuration in /target" later on. to_install = [lp for lp in to_install if get_cache_pkg(cache, lp) is not None] install_new = True try: install_new_key = \ self.db.get('pkgsel/install-language-support') == 'true' if install_new_key != '' and not misc.create_bool(install_new_key): install_new = False except debconf.DebconfError: pass if not install_new: # Keep packages that are on the live filesystem, but don't install # new ones. # TODO cjwatson 2010-03-18: To match pkgsel's semantics, we ought to # be willing to install packages from the package pool on the CD as # well. to_install = [lp for lp in to_install if get_cache_pkg(cache, lp).is_installed] del cache record_installed(to_install) langpacks_file = '/var/lib/ubiquity/langpacks' if os.path.exists(langpacks_file): osextras.unlink_force(langpacks_file) if install_new: if save: if not os.path.exists(os.path.dirname(langpacks_file)): os.makedirs(os.path.dirname(langpacks_file)) with open(langpacks_file, 'w') as langpacks: for pkg in to_install: print >>langpacks, pkg return [] else: return to_install
def select_language_packs(self, save=False): try: keep_packages = self.db.get('ubiquity/keep-installed') keep_packages = keep_packages.replace(',', '').split() syslog.syslog('keeping packages due to preseeding: %s' % ' '.join(keep_packages)) record_installed(keep_packages) except debconf.DebconfError: pass langpacks = [] all_langpacks = False try: langpack_db = self.db.get('pkgsel/language-packs') if langpack_db == 'ALL': apt_subp = subprocess.Popen( ['apt-cache', '-n', 'search', '^language-pack-[^-][^-]*$'], stdout=subprocess.PIPE, universal_newlines=True) apt_out = apt_subp.communicate()[0].rstrip().split('\n') langpacks = [x.split('-')[2].strip() for x in apt_out] all_langpacks = True else: langpacks = langpack_db.replace(',', '').split() except debconf.DebconfError: pass if not langpacks: langpack_set = set() try: langpack_db = self.db.get('localechooser/supported-locales') for locale in langpack_db.replace(',', '').split(): langpack_set.add(locale) except debconf.DebconfError: pass langpack_db = self.db.get('debian-installer/locale') langpack_set.add(langpack_db) langpacks = sorted(langpack_set) no_install = '/var/lib/ubiquity/no-install-langpacks' if os.path.exists(no_install): osextras.unlink_force(no_install) if len(langpacks) == 1 and langpacks[0] in ('C', 'en'): # Touch with open(no_install, 'a'): os.utime(no_install, None) syslog.syslog('keeping language packs for: %s' % ' '.join(langpacks)) try: lppatterns = self.db.get('pkgsel/language-pack-patterns').split() except debconf.DebconfError: return cache = Cache() to_install = [] checker = osextras.find_on_path('check-language-support') for lp_locale in langpacks: lp = locale_to_language_pack(lp_locale) # Basic language packs, required to get localisation working at # all. We install these almost unconditionally; if you want to # get rid of even these, you can preseed pkgsel/language-packs # to the empty string. to_install.append('language-pack-%s' % lp) # Other language packs, typically selected by preseeding. for pattern in lppatterns: to_install.append(pattern.replace('$LL', lp)) # More extensive language support packages. # If pkgsel/language-packs is ALL, then speed things up by # calling check-language-support just once. if not all_langpacks and checker: check_lang = subprocess.Popen([ 'check-language-support', '-l', lp_locale.split('.')[0], '--show-installed' ], stdout=subprocess.PIPE, universal_newlines=True) to_install.extend(check_lang.communicate()[0].strip().split()) else: to_install.append('language-support-%s' % lp) if checker: # Keep language-support-$LL installed if it happens to be in # the live filesystem, since there's no point spending time # removing it; but don't install it if it isn't in the live # filesystem. toplevel = 'language-support-%s' % lp toplevel_pkg = get_cache_pkg(cache, toplevel) if toplevel_pkg and toplevel_pkg.is_installed: to_install.append(toplevel) if all_langpacks and checker: check_lang = subprocess.Popen( ['check-language-support', '-a', '--show-installed'], stdout=subprocess.PIPE, universal_newlines=True) to_install.extend(check_lang.communicate()[0].strip().split()) # Filter the list of language packs to include only language packs # that exist in the live filesystem's apt cache, so that we can tell # the difference between "no such language pack" and "language pack # not retrievable given apt configuration in /target" later on. to_install = [ pkg for pkg in to_install if get_cache_pkg(cache, pkg) is not None ] install_new = True try: install_new_key = \ self.db.get('pkgsel/install-language-support') == 'true' if install_new_key != '' and not misc.create_bool(install_new_key): install_new = False except debconf.DebconfError: pass if not install_new: # Keep packages that are on the live filesystem, but don't install # new ones. # TODO cjwatson 2010-03-18: To match pkgsel's semantics, we # ought to be willing to install packages from the package pool # on the CD as well. to_install = [ pkg for pkg in to_install if get_cache_pkg(cache, pkg).is_installed ] del cache record_installed(to_install) langpacks_file = '/var/lib/ubiquity/langpacks' if os.path.exists(langpacks_file): osextras.unlink_force(langpacks_file) if install_new: if save: if not os.path.exists(os.path.dirname(langpacks_file)): os.makedirs(os.path.dirname(langpacks_file)) with open(langpacks_file, 'w') as langpacks: for pkg in to_install: print(pkg, file=langpacks) return [] else: return to_install
def set_use_nonfree(self, val): if osextras.find_on_path('jockey-text'): self.prepare_nonfree_software.set_active(val) else: self.debug('Could not find jockey-text on the executable path.') self.set_allow_nonfree(False)