Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of the manifest generation #296

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions superflore/generators/ebuild/ebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Ebuild(object):
This is where any necessary variables will be filled.
"""
def __init__(self):
self.eapi = str(6)
self.eapi = str(8)
self.description = ""
self.homepage = "https://wiki.ros.org"
self.src_uri = None
Expand Down Expand Up @@ -143,7 +143,7 @@ def get_ebuild_text(self, distributor, license_text):
ret += self.get_python_compat(['2_7', '3_5', '3_6'])
elif self.python_3:
# only use 3.5, 3.6 for ROS 2
ret += self.get_python_compat(['3_5', '3_6'])
ret += self.get_python_compat(['3_8','3_9' ,'3_10','3_11'])
else:
# fallback to python 2.7
ret += self.get_python_compat(['2_7'])
Expand Down
38 changes: 33 additions & 5 deletions superflore/generators/ebuild/gen_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,43 @@ def regenerate_pkg(overlay, pkg, distro, preserve_existing=False):
return current, previous_version, pkg


def _package_condition_context(rosdistro_name):
distro_properties = get_distros()[rosdistro_name]
ros_version = None
if distro_properties['distribution_type'] == 'ros2':
ros_version = '2'
elif distro_properties['distribution_type'] == 'ros1':
ros_version = '1'
else:
err("Superflore does not handle the distribution type '{}'".format(
distro_properties['distribution_type']))
raise 'Invalid distribution_type for {}'.format(rosdistro_name)
ros_python_version = None
if distro_properties['python_version'] == 3:
ros_python_version = '3'
elif distro_properties['python_version'] == 2:
ros_python_version = '2'
else:
err("Superflore does not handle the python version '{}'".format(
distro_properties['python_version']))
raise 'Invalid python_version for {}'.format(rosdistro_name)
return {
'ROS_DISTRO': rosdistro_name,
'ROS_VERSION': ros_version,
'ROS_PYTHON_VERSION': ros_python_version}


def _gen_metadata_for_package(
distro, pkg_name, pkg, repo, ros_pkg, pkg_rosinstall
distro, pkg_name, repo, ros_pkg, pkg_rosinstall
):
pkg_metadata_xml = metadata_xml()
try:
pkg_xml = retry_on_exception(ros_pkg.get_package_xml, distro.name)
except Exception:
warn("fetch metadata for package {}".format(pkg_name))
return pkg_metadata_xml
pkg = PackageMetadata(pkg_xml)
package_condition_context = _package_condition_context(distro.name)
pkg = PackageMetadata(pkg_xml, evaluate_condition_context=package_condition_context)
pkg_metadata_xml.upstream_email = pkg.upstream_email
pkg_metadata_xml.upstream_name = pkg.upstream_name
pkg_metadata_xml.longdescription = pkg.longdescription
Expand All @@ -146,7 +173,8 @@ def _gen_ebuild_for_package(
pkg_ebuild.distro = distro.name
pkg_ebuild.src_uri = pkg_rosinstall[0]['tar']['uri']
pkg_names = get_package_names(distro)
pkg_dep_walker = DependencyWalker(distro)
package_condition_context = _package_condition_context(distro.name)
pkg_dep_walker = DependencyWalker(distro, evaluate_condition_context=package_condition_context)

pkg_buildtool_deps = pkg_dep_walker.get_depends(pkg_name, "buildtool")
pkg_build_deps = pkg_dep_walker.get_depends(pkg_name, "build")
Expand Down Expand Up @@ -181,7 +209,7 @@ def _gen_ebuild_for_package(
except Exception:
warn("fetch metadata for package {}".format(pkg_name))
return pkg_ebuild
pkg = PackageMetadata(pkg_xml)
pkg = PackageMetadata(pkg_xml, evaluate_condition_context=package_condition_context)
pkg_ebuild.upstream_license = pkg.upstream_license
pkg_ebuild.description = pkg.description
pkg_ebuild.homepage = pkg.homepage
Expand All @@ -201,7 +229,7 @@ def __init__(self, distro, pkg_name, has_patches=False):

self.metadata_xml =\
_gen_metadata_for_package(distro, pkg_name,
pkg, repo, ros_pkg, pkg_rosinstall)
repo, ros_pkg, pkg_rosinstall)
self.ebuild =\
_gen_ebuild_for_package(distro, pkg_name,
pkg, repo, ros_pkg, pkg_rosinstall)
Expand Down
41 changes: 30 additions & 11 deletions superflore/generators/ebuild/overlay_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def commit_changes(self, distro):
self.repo.git.commit(m='{0}'.format(commit_msg))

def regenerate_manifests(
self, regen_dict, image_owner='allenh1', image_name='ros_gentoo_base'
self,
regen_dict,
image_owner='tomkimsour',
image_name='ros_gentoo_base',
split_limit=1000
):
info(
"Pulling docker image '%s/%s:latest'..." % (
Expand All @@ -76,16 +80,31 @@ def regenerate_manifests(
'/root/.gnupg'
)
dock.map_directory(self.repo.repo_dir, '/tmp/ros-overlay')
for key in regen_dict.keys():
for pkg in regen_dict[key]:
pkg_dir = '/tmp/ros-overlay/ros-{0}/{1}'.format(key, pkg)
dock.add_bash_command('cd {0}'.format(pkg_dir))
dock.add_bash_command('repoman manifest')
try:
dock.run(show_cmd=True)
except docker.errors.ContainerError:
print(dock.log)
raise
for distro in regen_dict.keys():
chunk_list = []
chunk_count = 0
pkg_list = regen_dict[distro]
while len(pkg_list) > 0:
current_chunk = list()
for x in range(split_limit):
if len(pkg_list) > 0:
current_chunk.append(pkg_list.pop())
else:
break
chunk_list.append(current_chunk)
info("Regeneration list consists of '%d' chunks" % len(chunk_list))
info("key_lists: '%s'" % chunk_list)
for chunk in chunk_list:
for pkg in chunk:
pkg_dir = '/tmp/ros-overlay/ros-{0}/{1}'.format(distro, pkg)
dock.add_bash_command('cd {0}'.format(pkg_dir))
dock.add_bash_command('ebuild *.ebuild manifest')
try:
dock.run(show_cmd=True)
dock.clear_commands()
except docker.errors.ContainerError:
print(dock.log)
raise

def pull_request(self, message, overlay=None, title=''):
if not title:
Expand Down