def testBlacklistedPackagesAllowed(self): """Test that we can find blacklisted packages with |allow_blacklisted|.""" package_name = 'chromeos-base/blacklisted_package' self._CreatePackage(package_name, blacklisted=True) portage_util.BuildEBuildDictionary(self.overlays, False, [package_name], allow_blacklisted=True) self._assertFoundPackages([package_name])
def testUnknownPackage(self): """Test that _FindUprevCandidates is only called if the CP matches.""" self._CreatePackage('chromeos-base/package_name') portage_util.BuildEBuildDictionary(self.overlays, False, ['chromeos-base/other_package']) self.assertFalse(self.uprev_candidate_mock.called) self._assertFoundPackages([])
def testBlacklistedPackagesIgnoredByDefault(self): """Test that blacklisted packages are ignored by default.""" package_name = 'chromeos-base/blacklisted_package' self._CreatePackage(package_name, blacklisted=True) portage_util.BuildEBuildDictionary(self.overlays, False, [package_name]) self._assertFoundPackages([])
def testWantedPackage(self): """Test that we can find a specific package.""" package_name = 'chromeos-base/mypackage' self._CreatePackage(package_name) portage_util.BuildEBuildDictionary(self.overlays, False, [package_name]) self._assertFoundPackages([package_name])
def main(argv): parser = GetParser() options = parser.parse_args(argv) options.Freeze() if options.command == 'commit': if not options.packages and not options.all: parser.error('Please specify at least one package (--packages)') if options.force and options.all: parser.error('Cannot use --force with --all. You must specify a list of ' 'packages you want to force uprev.') if not os.path.isdir(options.srcroot): parser.error('srcroot is not a valid path: %s' % options.srcroot) portage_util.EBuild.VERBOSE = options.verbose package_list = None if options.packages: package_list = options.packages.split(':') if options.overlays: overlays = {} for path in options.overlays.split(':'): if not os.path.isdir(path): cros_build_lib.Die('Cannot find overlay: %s' % path) overlays[path] = [] else: logging.warning('Missing --overlays argument') overlays = { '%s/private-overlays/chromeos-overlay' % options.srcroot: [], '%s/third_party/chromiumos-overlay' % options.srcroot: [], } manifest = git.ManifestCheckout.Cached(options.srcroot) if options.command == 'commit': portage_util.BuildEBuildDictionary(overlays, options.all, package_list, allow_blacklisted=options.force) # Contains the array of packages we actually revved. revved_packages = [] new_package_atoms = [] for overlay in overlays: ebuilds = overlays[overlay] if not os.path.isdir(overlay): logging.warning('Skipping %s' % overlay) continue # Note we intentionally work from the non push tracking branch; # everything built thus far has been against it (meaning, http mirrors), # thus we should honor that. During the actual push, the code switches # to the correct urls, and does an appropriate rebasing. tracking_branch = git.GetTrackingBranchViaManifest( overlay, manifest=manifest).ref if options.command == 'push': PushChange(constants.STABLE_EBUILD_BRANCH, tracking_branch, options.dryrun, cwd=overlay, staging_branch=options.staging_branch) elif options.command == 'commit': existing_commit = git.GetGitRepoRevision(overlay) work_branch = GitBranch(constants.STABLE_EBUILD_BRANCH, tracking_branch, cwd=overlay) work_branch.CreateBranch() if not work_branch.Exists(): cros_build_lib.Die('Unable to create stabilizing branch in %s' % overlay) # In the case of uprevving overlays that have patches applied to them, # include the patched changes in the stabilizing branch. git.RunGit(overlay, ['rebase', existing_commit]) messages = [] for ebuild in ebuilds: if options.verbose: logging.info('Working on %s, info %s', ebuild.package, ebuild.cros_workon_vars) try: new_package = ebuild.RevWorkOnEBuild(options.srcroot, manifest) if new_package: revved_packages.append(ebuild.package) new_package_atoms.append('=%s' % new_package) messages.append(_GIT_COMMIT_MESSAGE % ebuild.package) except (OSError, IOError): logging.warning( 'Cannot rev %s\n' 'Note you will have to go into %s ' 'and reset the git repo yourself.' % (ebuild.package, overlay)) raise if messages: portage_util.EBuild.CommitChange('\n\n'.join(messages), overlay) if options.command == 'commit': chroot_path = os.path.join(options.srcroot, constants.DEFAULT_CHROOT_DIR) if os.path.exists(chroot_path): CleanStalePackages(options.srcroot, options.boards.split(':'), new_package_atoms) if options.drop_file: osutils.WriteFile(options.drop_file, ' '.join(revved_packages))
def testAnyPackage(self): """Test that we return all packages available if use_all is set.""" package_name = 'chromeos-base/package_name' self._CreatePackage(package_name) portage_util.BuildEBuildDictionary(self.overlays, True, []) self._assertFoundPackages([package_name])
def testUnwantedPackage(self): """Test that we find only the packages we want.""" portage_util.BuildEBuildDictionary(self.overlays, False, []) self._assertFoundPackages([])