=== modified file 'debian/changelog' --- debian/changelog 2010-04-01 06:27:42 +0000 +++ debian/changelog 2010-04-01 10:40:31 +0000 @@ -1,3 +1,11 @@ +ubiquity (2.2.13) UNRELEASED; urgency=low + + * In oem-config, support removing packages that were not part of the + base install and are not needed in the final system by preseeding + oem-config/remove_extras to true (LP: #315644, LP: #553184). + + -- Evan Dandrea Thu, 01 Apr 2010 11:35:54 +0100 + ubiquity (2.2.12) lucid; urgency=low [ Evan Dandrea ] === modified file 'debian/oem-config.templates' --- debian/oem-config.templates 2010-02-17 08:58:10 +0000 +++ debian/oem-config.templates 2010-04-01 08:56:52 +0000 @@ -38,3 +38,10 @@ Description: for internal use; can be preseeded Install language support packages for the locale that has been selected by the user + +Template: oem-config/remove_extras +Type: boolean +Default: false +Description: for internal use; can be preseeded + Remove packages that were not part of the base install and are not needed + by the final system. === modified file 'scripts/install.py' --- scripts/install.py 2010-03-31 19:04:13 +0000 +++ scripts/install.py 2010-04-01 09:02:29 +0000 @@ -409,7 +409,11 @@ self.next_region(size=4) self.db.progress('INFO', 'ubiquity/install/removing') - self.remove_extras() + if 'UBIQUITY_OEM_USER_CONFIG' in os.environ: + if self.db.get('oem-config/remove_extras') == 'true': + self.remove_oem_extras() + else: + self.remove_extras() try: self.copy_network_config() @@ -2181,9 +2185,6 @@ """Try to remove packages that are needed on the live CD but not on the installed system.""" - if 'UBIQUITY_OEM_USER_CONFIG' in os.environ: - return - # Looking through files for packages to remove is pretty quick, so # don't bother with a progress bar for that. @@ -2252,6 +2253,46 @@ (regular, recursive) = install_misc.query_recorded_removed() self.do_remove(regular) self.do_remove(recursive, recursive=True) + + if self.db.get('oem-config/remove_extras') == 'true': + installed = (desktop_packages | keep - regular - recursive) + p = os.path.join(self.target, '/var/lib/ubiquity/installed-packages') + with open(p, 'w') as fp: + for line in installed: + print >>fp, line + + def remove_oem_extras(self): + '''Try to remove packages that were not part of the base install and + are not needed by the final system. + + This is roughly the set of packages installed by ubiquity + packages we + explicitly installed in oem-config (langpacks, for example) - + everything else.''' + + manifest = '/var/lib/ubiquity/installed-packages' + if not os.path.exists(manifest): + return + + keep = set() + with open(manifest) as manifest_file: + for line in manifest_file: + if line.strip() != '' and not line.startswith('#'): + keep.add(line.split()[0]) + # Lets not rip out the ground beneath our feet. + keep.add('ubiquity') + keep.add('oem-config') + + cache = Cache() + remove = set([pkg for pkg in cache.keys() if cache[pkg].isInstalled]) + # Keep packages we explicitly installed. + keep |= install_misc.query_recorded_installed() + remove -= self.expand_dependencies_simple(cache, keep, remove) + del cache + + install_misc.record_removed(remove) + (regular, recursive) = install_misc.query_recorded_removed() + self.do_remove(regular) + self.do_remove(recursive, recursive=True) def copy_tree(self, source, target, uid, gid): # Mostly stolen from copy_all.