def keep_ad_tools(self): """Mark Active Directory tools to be kept for now The decision in plugininstall (after the copy starts) will tell us if the user has selected or not AD integration, and so, which tools to remove.""" install_misc.record_installed(['adcli', 'realmd', 'sssd'])
def select_ecryptfs(self): """Is ecryptfs in use by an existing user? If so, keep it installed. This duplicates code from user-setup, but necessarily so; when user-setup-ask runs in ubiquity, /target is not yet mounted, but we need to make this decision before generating the file copy blacklist so user-setup-apply would be too late.""" home = self.target_file("home") if os.path.isdir(home): for homedir in os.listdir(home): if os.path.isdir(os.path.join(home, homedir, ".ecryptfs")): syslog.syslog("ecryptfs already in use in %s" % os.path.join(home, homedir)) install_misc.record_installed(["ecryptfs-utils"]) break
def select_ecryptfs(self): """Is ecryptfs in use by an existing user? If so, keep it installed. This duplicates code from user-setup, but necessarily so; when user-setup-ask runs in ubiquity, /target is not yet mounted, but we need to make this decision before generating the file copy blacklist so user-setup-apply would be too late.""" home = self.target_file('home') if os.path.isdir(home): for homedir in os.listdir(home): if os.path.isdir(os.path.join(home, homedir, '.ecryptfs')): syslog.syslog('ecryptfs already in use in %s' % os.path.join(home, homedir)) install_misc.record_installed(['ecryptfs-utils']) break
def generate_blacklist(self): manifest_remove = os.path.join(self.casper_path, 'filesystem.manifest-remove') manifest_desktop = os.path.join(self.casper_path, 'filesystem.manifest-desktop') manifest = os.path.join(self.casper_path, 'filesystem.manifest') if os.path.exists(manifest_remove) and os.path.exists(manifest): difference = set() with open(manifest_remove) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] difference.add(pkg.split()[0]) live_packages = set() with open(manifest) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] live_packages.add(pkg.split()[0]) desktop_packages = live_packages - difference elif os.path.exists(manifest_desktop) and os.path.exists(manifest): desktop_packages = set() with open(manifest_desktop) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] desktop_packages.add(pkg.split()[0]) live_packages = set() with open(manifest) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] live_packages.add(pkg.split()[0]) difference = live_packages - desktop_packages else: difference = set() cache = Cache() use_restricted = True try: if self.db.get('apt-setup/restricted') == 'false': use_restricted = False except debconf.DebconfError: pass if not use_restricted: for pkg in cache.keys(): if (cache[pkg].is_installed and cache[pkg].section.startswith('restricted/')): difference.add(pkg) # Keep packages we explicitly installed. keep = install_misc.query_recorded_installed() arch, subarch = install_misc.archdetect() # Less than ideal. Since we cannot know which bootloader we'll need # at file copy time, we should figure out why grub still fails when # apt-install-direct is present during configure_bootloader (code # removed). if arch in ('amd64', 'i386'): if subarch == 'efi': keep.add('grub-efi') keep.add('grub-efi-amd64') keep.add('grub-efi-amd64-signed') keep.add('shim-signed') keep.add('mokutil') keep.add('fwupdate-signed') install_misc.record_installed(['fwupdate-signed']) try: altmeta = self.db.get('base-installer/kernel/altmeta') if altmeta: altmeta = '-%s' % altmeta except debconf.DebconfError: altmeta = '' keep.add('linux-signed-generic%s' % altmeta) else: keep.add('grub') keep.add('grub-pc') elif (arch in ('armel', 'armhf') and subarch in ('omap', 'omap4', 'mx5')): keep.add('flash-kernel') keep.add('u-boot-tools') elif arch == 'powerpc': keep.add('yaboot') keep.add('hfsutils') # Even adding ubiquity as a depends to oem-config-{gtk,kde} doesn't # appear to force ubiquity and libdebian-installer4 to copy all of # their files, so this does the trick. try: if self.db.get('oem-config/enable') == 'true': keep.add('ubiquity') except (debconf.DebconfError, IOError): pass difference -= install_misc.expand_dependencies_simple( cache, keep, difference) # Consider only packages that don't have a prerm, and which can # therefore have their files removed without any preliminary work. difference = { x for x in difference if not os.path.exists('/var/lib/dpkg/info/%s.prerm' % x) } confirmed_remove = set() with cache.actiongroup(): for pkg in sorted(difference): if pkg in confirmed_remove: continue would_remove = install_misc.get_remove_list(cache, [pkg], recursive=True) if would_remove <= difference: confirmed_remove |= would_remove # Leave these marked for removal in the apt cache to # speed up further calculations. else: for removedpkg in would_remove: cachedpkg = install_misc.get_cache_pkg( cache, removedpkg) cachedpkg.mark_keep() difference = confirmed_remove if len(difference) == 0: del cache self.blacklist = {} return cmd = ['dpkg', '-L'] cmd.extend(difference) subp = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) res = subp.communicate()[0].splitlines() u = {} for x in res: u[x] = 1 self.blacklist = u
def generate_blacklist(self): manifest_remove = os.path.join(self.casper_path, 'filesystem.manifest-remove') manifest_desktop = os.path.join(self.casper_path, 'filesystem.manifest-desktop') manifest = os.path.join(self.casper_path, 'filesystem.manifest') if os.path.exists(manifest_remove) and os.path.exists(manifest): difference = set() with open(manifest_remove) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] difference.add(pkg.split()[0]) live_packages = set() with open(manifest) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] live_packages.add(pkg.split()[0]) desktop_packages = live_packages - difference elif os.path.exists(manifest_desktop) and os.path.exists(manifest): desktop_packages = set() with open(manifest_desktop) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] desktop_packages.add(pkg.split()[0]) live_packages = set() with open(manifest) as manifest_file: for line in manifest_file: if line.strip() != '' and not line.startswith('#'): pkg = line.split(':')[0] live_packages.add(pkg.split()[0]) difference = live_packages - desktop_packages else: difference = set() cache = Cache() use_restricted = True try: if self.db.get('apt-setup/restricted') == 'false': use_restricted = False except debconf.DebconfError: pass if not use_restricted: for pkg in cache.keys(): if (cache[pkg].is_installed and cache[pkg].section.startswith('restricted/')): difference.add(pkg) # Keep packages we explicitly installed. keep = install_misc.query_recorded_installed() arch, subarch = install_misc.archdetect() # Less than ideal. Since we cannot know which bootloader we'll need # at file copy time, we should figure out why grub still fails when # apt-install-direct is present during configure_bootloader (code # removed). if arch in ('amd64', 'i386'): if subarch == 'efi': keep.add('grub-efi') keep.add('grub-efi-amd64') keep.add('grub-efi-amd64-signed') keep.add('shim-signed') keep.add('mokutil') keep.add('fwupdate-signed') install_misc.record_installed(['fwupdate-signed']) try: altmeta = self.db.get( 'base-installer/kernel/altmeta') if altmeta: altmeta = '-%s' % altmeta except debconf.DebconfError: altmeta = '' keep.add('linux-signed-generic%s' % altmeta) else: keep.add('grub') keep.add('grub-pc') elif (arch in ('armel', 'armhf') and subarch in ('omap', 'omap4', 'mx5')): keep.add('flash-kernel') keep.add('u-boot-tools') elif arch == 'powerpc': keep.add('yaboot') keep.add('hfsutils') # Even adding ubiquity as a depends to oem-config-{gtk,kde} doesn't # appear to force ubiquity and libdebian-installer4 to copy all of # their files, so this does the trick. try: if self.db.get('oem-config/enable') == 'true': keep.add('ubiquity') except (debconf.DebconfError, IOError): pass difference -= install_misc.expand_dependencies_simple( cache, keep, difference) # Consider only packages that don't have a prerm, and which can # therefore have their files removed without any preliminary work. difference = { x for x in difference if not os.path.exists('/var/lib/dpkg/info/%s.prerm' % x)} confirmed_remove = set() with cache.actiongroup(): for pkg in sorted(difference): if pkg in confirmed_remove: continue would_remove = install_misc.get_remove_list( cache, [pkg], recursive=True) if would_remove <= difference: confirmed_remove |= would_remove # Leave these marked for removal in the apt cache to # speed up further calculations. else: for removedpkg in would_remove: cachedpkg = install_misc.get_cache_pkg( cache, removedpkg) cachedpkg.mark_keep() difference = confirmed_remove if len(difference) == 0: del cache self.blacklist = {} return cmd = ['dpkg', '-L'] cmd.extend(difference) subp = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) res = subp.communicate()[0].splitlines() u = {} for x in res: u[x] = 1 self.blacklist = u