forked from ros-infrastructure/superflore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
--only PKG
option (ros-infrastructure#76)
* Creating an option to only regenerate a specified package. * Regeneration of a single package is now working. Next is refactoring. * Add unused installer list from regenerate function. * Unify printing functions * Forgot one of the print calls, and moved a variable accidently. * Added util print functions to run.py. * Make the exception handling for make_dir more strict. * Linting after rebase. * Removing duplicated logic from gen_packages function * Moved generate installers function to its own file, outside of the gentoo directory. * Remove all gentoo specific logic from gen_packages, and add logic to handle missing dependencies. * Fixed issue with unresolved dependencies not being reported. * Modify regenerate package logic to only regenerate manifests for packages with changes. * Fix regen logic for a single package. * Addresses comments by @tfoote. * Added nargs='+' to the '--only' option so that multiple packages can be selected.
- Loading branch information
Showing
6 changed files
with
297 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Copyright 2017 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from rosinstall_generator.distro import get_distro | ||
from rosinstall_generator.distro import get_package_names | ||
|
||
from superflore.utils import err | ||
from superflore.utils import get_pkg_version | ||
from superflore.utils import info | ||
from superflore.utils import ok | ||
from superflore.utils import warn | ||
|
||
|
||
def generate_installers( | ||
distro_name, # ros distro name | ||
overlay, # repo instance | ||
gen_pkg_func, # function to call for generating | ||
preserve_existing=True # don't regenerate if installer exists | ||
): | ||
distro = get_distro(distro_name) | ||
pkg_names = get_package_names(distro) | ||
total = float(len(pkg_names[0])) | ||
borkd_pkgs = dict() | ||
changes = [] | ||
installers = [] | ||
bad_installers = [] | ||
succeeded = 0 | ||
failed = 0 | ||
|
||
info("Generating installers for distro '%s'" % distro_name) | ||
for i, pkg in enumerate(sorted(pkg_names[0])): | ||
version = get_pkg_version(distro, pkg) | ||
percent = '%.1f' % (100 * (float(i) / total)) | ||
try: | ||
current, bad_deps = gen_pkg_func( | ||
overlay, pkg, distro, preserve_existing | ||
) | ||
if not current and bad_deps: | ||
# we are missing dependencies | ||
failed_msg = "{0}%: Failed to generate".format(percent) | ||
failed_msg += " installer for package '%s'!" % pkg | ||
err(failed_msg) | ||
borkd_pkgs[pkg] = bad_deps | ||
failed = failed + 1 | ||
continue | ||
elif not current and preserve_existing: | ||
# don't replace the installer | ||
succeeded = succeeded + 1 | ||
continue | ||
success_msg = 'Successfully generated installer for package' | ||
ok('{0}%: {1} \'{2}\'.'.format(percent, success_msg, pkg)) | ||
succeeded = succeeded + 1 | ||
changes.append('*{0} --> {1}*'.format(pkg, version)) | ||
installers.append(pkg) | ||
except KeyError: | ||
failed_msg = 'Failed to generate installer' | ||
err("{0}%: {1} for package {2}!".format(percent, failed_msg, pkg)) | ||
bad_installers.append(pkg) | ||
failed = failed + 1 | ||
results = 'Generated {0} / {1}'.format(succeeded, failed + succeeded) | ||
results += ' for distro {0}'.format(distro_name) | ||
info("------ {0} ------\n".format(results)) | ||
|
||
if len(borkd_pkgs) > 0: | ||
warn("Unresolved:") | ||
for broken in borkd_pkgs.keys(): | ||
warn("{}:".format(broken)) | ||
warn(" {}".format(borkd_pkgs[broken])) | ||
|
||
return installers, borkd_pkgs, changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.