def test_missing_deps_msg(self): """Test the missing dependencies list""" self.set_lang_env() self.assertEqual(gen_missing_deps_msg([]), 'No missing dependencies.\n') ret = gen_missing_deps_msg(['python3', 'cmake']) expect = 'Missing Dependencies:\n'\ '=====================\n'\ ' * [ ] cmake\n'\ ' * [ ] python3\n' self.assertEqual(ret, expect)
def main(): overlay = None preserve_existing = True parser = get_parser('Deploy ROS packages into Gentoo Linux') args = parser.parse_args(sys.argv[1:]) pr_comment = args.pr_comment skip_keys = args.skip_keys or [] selected_targets = None if not args.dry_run: if 'SUPERFLORE_GITHUB_TOKEN' not in os.environ: raise NoGitHubAuthToken() if args.pr_only: if args.dry_run: parser.error('Invalid args! cannot dry-run and file PR') if not args.output_repository_path: parser.error('Invalid args! no repository specified') try: prev_overlay = RepoInstance(args.output_repository_path, False) msg, title = load_pr() prev_overlay.pull_request(msg, title=title) clean_up() sys.exit(0) except Exception as e: err('Failed to file PR!') err('reason: {0}'.format(e)) sys.exit(1) elif args.all: warn('"All" mode detected... This may take a while!') preserve_existing = False elif args.ros_distro: warn('"{0}" distro detected...'.format(args.ros_distro)) selected_targets = [args.ros_distro] preserve_existing = False elif args.only: parser.error('Invalid args! --only requires specifying --ros-distro') if not selected_targets: selected_targets = get_distros_by_status('active') repo_org = 'ros' repo_name = 'ros-overlay' if args.upstream_repo: repo_org, repo_name = url_to_repo_org(args.upstream_repo) with TempfileManager(args.output_repository_path) as _repo: if not args.output_repository_path: # give our group write permissions to the temp dir os.chmod(_repo, 17407) # clone if args.output_repository_path is None overlay = RosOverlay( _repo, not args.output_repository_path, org=repo_org, repo=repo_name, from_branch=args.upstream_branch, new_branch=(not args.no_branch), ) if not preserve_existing and not args.only: pr_comment = pr_comment or ( 'Superflore ebuild generator began regeneration of all' ' packages from ROS distro %s from ROS-Overlay commit %s.' % (selected_targets, overlay.repo.get_last_hash())) elif not args.only: pr_comment = pr_comment or ( 'Superflore ebuild generator ran update from ROS-Overlay ' + 'commit %s.' % (overlay.repo.get_last_hash())) # generate installers total_installers = dict() total_broken = set() total_changes = dict() if args.only: pr_comment = pr_comment or ( 'Superflore ebuild generator began regeneration of ' + 'package(s) %s from commit %s.' % (args.only, overlay.repo.get_last_hash())) missing_depends = set() to_commit = set() will_file_pr = False for pkg in args.only: if pkg in skip_keys: warn("Package '%s' is in skip-keys list, skipping..." % pkg) continue info("Regenerating package '%s'..." % pkg) try: ebuild, deps, version = regenerate_pkg( overlay, pkg, get_distro(args.ros_distro), preserve_existing) if not ebuild: for dep in deps: missing_depends.add(dep) except KeyError: err("No package to satisfy key '%s'" % pkg) continue if ebuild: to_commit.add(pkg) will_file_pr = True # if no packages succeeded, exit with error if not will_file_pr: err("No packages generated successfully, exiting.") sys.exit(1) # Commit changes and file pull request regen_dict = dict() regen_dict[args.ros_distro] = to_commit overlay.regenerate_manifests(regen_dict) overlay.commit_changes(args.ros_distro) if args.dry_run: save_pr(overlay, args.only, missing_deps=gen_missing_deps_msg(missing_depends), comment=pr_comment) sys.exit(0) delta = "Regenerated: '%s'\n" % args.only file_pr(overlay, delta, gen_missing_deps_msg(missing_depends), pr_comment) ok('Successfully synchronized repositories!') sys.exit(0) for distro in selected_targets: distro_installers, distro_broken, distro_changes =\ generate_installers( get_distro(distro), overlay=overlay, gen_pkg_func=regenerate_pkg, preserve_existing=preserve_existing, skip_keys=skip_keys, ) for key in distro_broken.keys(): for pkg in distro_broken[key]: total_broken.add(pkg) total_changes[distro] = distro_changes total_installers[distro] = distro_installers num_changes = 0 for distro_name in total_changes: num_changes += len(total_changes[distro_name]) if num_changes == 0: info('ROS distro is up to date.') info('Exiting...') clean_up() sys.exit(0) # remove duplicates delta = gen_delta_msg(total_changes) missing_deps = gen_missing_deps_msg(total_broken) # Commit changes and file pull request overlay.regenerate_manifests(total_installers) overlay.commit_changes('all' if args.all else args.ros_distro) if args.dry_run: info('Running in dry mode, not filing PR') save_pr(overlay, delta, missing_deps=missing_deps, comment=pr_comment) sys.exit(0) file_pr(overlay, delta, missing_deps, comment=pr_comment) clean_up() ok('Successfully synchronized repositories!')
def main(): overlay = None preserve_existing = True parser = get_parser('Deploy ROS packages into Gentoo Linux') args = parser.parse_args(sys.argv[1:]) pr_comment = args.pr_comment selected_targets = None if args.all: warn('"All" mode detected... This may take a while!') preserve_existing = False elif args.ros_distro: selected_targets = [args.ros_distro] set_index_for_distro(args.ros_distro) preserve_existing = False elif args.dry_run and args.pr_only: parser.error('Invalid args! cannot dry-run and file PR') elif args.pr_only and not args.output_repository_path: parser.error('Invalid args! no repository specified') elif args.pr_only: try: prev_overlay = RepoInstance(args.output_repository_path, False) msg, title = load_pr() prev_overlay.pull_request(msg, title) clean_up() sys.exit(0) except Exception as e: err('Failed to file PR!') err('reason: {0}'.format(e)) sys.exit(1) if not selected_targets: selected_targets = active_distros + ros2_distros repo_org = 'ros' repo_name = 'ros-overlay' if args.upstream_repo: repo_org, repo_name = url_to_repo_org(args.upstream_repo) with TempfileManager(args.output_repository_path) as _repo: if not args.output_repository_path: # give our group write permissions to the temp dir os.chmod(_repo, 17407) # clone if args.output_repository_path is None overlay = RosOverlay( _repo, not args.output_repository_path, org=repo_org, repo=repo_name ) if not preserve_existing and not args.only: pr_comment = pr_comment or ( 'Superflore ebuild generator began regeneration of all' ' packages from ROS distro %s from ROS-Overlay commit %s.' % ( selected_targets, overlay.repo.get_last_hash() ) ) elif not args.only: pr_comment = pr_comment or ( 'Superflore ebuild generator ran update from ROS-Overlay ' + 'commit %s.' % (overlay.repo.get_last_hash()) ) # generate installers total_installers = dict() total_broken = set() total_changes = dict() if args.only: pr_comment = pr_comment or ( 'Superflore ebuild generator began regeneration of ' + 'package(s) %s from commit %s.' % ( args.only, overlay.repo.get_last_hash() ) ) for pkg in args.only: info("Regenerating package '%s'..." % pkg) try: regenerate_pkg( overlay, pkg, get_distro(args.ros_distro), preserve_existing ) except KeyError: err("No package to satisfy key '%s'" % pkg) sys.exit(1) # Commit changes and file pull request regen_dict = dict() regen_dict[args.ros_distro] = args.only overlay.regenerate_manifests(regen_dict) overlay.commit_changes(args.ros_distro) if args.dry_run: save_pr( overlay, args.only, missing_deps=None, comment=pr_comment ) sys.exit(0) delta = "Regenerated: '%s'\n" % args.only file_pr(overlay, delta, '', pr_comment) ok('Successfully synchronized repositories!') sys.exit(0) for distro in selected_targets: set_index_for_distro(distro) distro_installers, distro_broken, distro_changes =\ generate_installers( distro_name=distro, overlay=overlay, gen_pkg_func=regenerate_pkg, preserve_existing=preserve_existing ) for key in distro_broken.keys(): for pkg in distro_broken[key]: total_broken.add(pkg) total_changes[distro] = distro_changes total_installers[distro] = distro_installers num_changes = 0 for distro_name in total_changes: num_changes += len(total_changes[distro_name]) if num_changes == 0: info('ROS distro is up to date.') info('Exiting...') clean_up() sys.exit(0) # remove duplicates delta = gen_delta_msg(total_changes) missing_deps = gen_missing_deps_msg(total_broken) # Commit changes and file pull request overlay.regenerate_manifests(total_installers) overlay.commit_changes(args.ros_distro) if args.dry_run: info('Running in dry mode, not filing PR') save_pr( overlay, delta, missing_deps=missing_deps, comment=pr_comment ) sys.exit(0) file_pr(overlay, delta, missing_deps, comment=pr_comment) clean_up() ok('Successfully synchronized repositories!')
def main(): overlay = None preserve_existing = True parser = get_parser('Deploy ROS packages into Yocto Linux') parser.add_argument( '--tar-archive-dir', help='location to store archived packages', type=str ) args = parser.parse_args(sys.argv[1:]) pr_comment = args.pr_comment selected_targets = None if args.all: warn('"All" mode detected... this may take a while!') preserve_existing = False elif args.ros_distro: warn('"{0}" distro detected...'.format(args.ros_distro)) selected_targets = [args.ros_distro] preserve_existing = False elif args.dry_run and args.pr_only: parser.error('Invalid args! cannot dry-run and file PR') elif args.pr_only and not args.output_repository_path: parser.error('Invalid args! no repository specified') elif args.pr_only: try: prev_overlay = RepoInstance(args.output_repository_path, False) msg, title = load_pr() prev_overlay.pull_request(msg, title) clean_up() sys.exit(0) except Exception as e: err('Failed to file PR!') err('reason: {0}'.format(e)) sys.exit(1) if not selected_targets: selected_targets = ros1_distros + ros2_distros repo_org = 'lgsvl' repo_name = 'meta-ros2' if args.upstream_repo: repo_org, repo_name = url_to_repo_org(args.upstream_repo) # open cached tar file if it exists with TempfileManager(args.output_repository_path) as _repo: if not args.output_repository_path: # give our group write permissions to the temp dir os.chmod(_repo, 17407) # clone if args.output-repository_path is None overlay = RosMeta( _repo, not args.output_repository_path, org=repo_org, repo=repo_name ) if not args.only: pr_comment = pr_comment or ( 'Superflore yocto generator began regeneration of all ' 'packages form ROS distribution(s) %s on Meta-ROS from ' 'commit %s.' % ( selected_targets, overlay.repo.get_last_hash() ) ) else: pr_comment = pr_comment or ( 'Superflore yocto generator began regeneration of package(s)' ' %s from ROS distro %s from Meta-ROS from commit %s.' % ( args.only, args.ros_distro, overlay.repo.get_last_hash() ) ) # generate installers total_installers = dict() total_broken = set() total_changes = dict() if args.tar_archive_dir: sha256_filename = '%s/sha256_cache.pickle' % args.tar_archive_dir md5_filename = '%s/md5_cache.pickle' % args.tar_archive_dir else: sha256_filename = None md5_filename = None with TempfileManager(args.tar_archive_dir) as tar_dir,\ CacheManager(sha256_filename) as sha256_cache,\ CacheManager(md5_filename) as md5_cache: # noqa if args.only: for pkg in args.only: info("Regenerating package '%s'..." % pkg) try: regenerate_installer( overlay, pkg, get_distro(args.ros_distro), preserve_existing, tar_dir, md5_cache, sha256_cache ) except KeyError: err("No package to satisfy key '%s'" % pkg) sys.exit(1) # Commit changes and file pull request regen_dict = dict() regen_dict[args.ros_distro] = args.only overlay.commit_changes(args.ros_distro) if args.dry_run: save_pr(overlay, args.only, None, pr_comment) sys.exit(0) delta = "Regenerated: '%s'\n" % args.only file_pr(overlay, delta, '', pr_comment, distro=args.ros_distro) ok('Successfully synchronized repositories!') sys.exit(0) for distro in selected_targets: distro_installers, distro_broken, distro_changes =\ generate_installers( distro, overlay, regenerate_installer, preserve_existing, tar_dir, md5_cache, sha256_cache ) for key in distro_broken.keys(): for pkg in distro_broken[key]: total_broken.add(pkg) total_changes[distro] = distro_changes total_installers[distro] = distro_installers num_changes = 0 for distro_name in total_changes: num_changes += len(total_changes[distro_name]) if num_changes == 0: info('ROS distro is up to date.') info('Exiting...') clean_up() sys.exit(0) # remove duplicates delta = gen_delta_msg(total_changes) missing_deps = gen_missing_deps_msg(total_broken) # Commit changes and file pull request overlay.commit_changes(args.ros_distro) if args.dry_run: info('Running in dry mode, not filing PR') save_pr(overlay, delta, missing_deps, pr_comment) clean_up() sys.exit(0) file_pr(overlay, delta, missing_deps, pr_comment) clean_up() ok('Successfully synchronized repositories!')