Skip to content

Commit

Permalink
bitbake: rename distro to rosdistro
Browse files Browse the repository at this point in the history
* e.g. get_ros_version expects just a string (as in distro.name) not whole RosDistro class
  this is a bit confusing, because in many places we use the same distro variable
  as this string, rename it to make it more clear
  • Loading branch information
shr-project committed Dec 3, 2020
1 parent d30b889 commit 17c2e11
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
56 changes: 28 additions & 28 deletions superflore/generators/bitbake/gen_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@


def regenerate_pkg(
overlay, pkg, distro, preserve_existing, srcrev_cache,
overlay, pkg, rosdistro, preserve_existing, srcrev_cache,
skip_keys
):
pkg_names = get_package_names(distro)[0]
pkg_names = get_package_names(rosdistro)[0]
if pkg not in pkg_names:
yoctoRecipe.not_generated_recipes.add(pkg)
raise RuntimeError("Unknown package '%s' available packages"
"in selected distro: %s" %
(pkg, get_package_names(distro)))
(pkg, get_package_names(rosdistro)))
try:
version = get_pkg_version(distro, pkg, is_oe=True)
version = get_pkg_version(rosdistro, pkg, is_oe=True)
except KeyError as ke:
yoctoRecipe.not_generated_recipes.add(pkg)
raise ke
repo_dir = overlay.repo.repo_dir
component_name = yoctoRecipe.convert_to_oe_name(
distro.release_packages[pkg].repository_name)
rosdistro.release_packages[pkg].repository_name)
recipe = yoctoRecipe.convert_to_oe_name(pkg)
# check for an existing recipe which was removed by clean_ros_recipe_dirs
prefix = 'meta-ros{0}-{1}/generated-recipes/*/{2}_*.bb'.format(
yoctoRecipe._get_ros_version(distro.name),
distro.name,
yoctoRecipe._get_ros_version(rosdistro.name),
rosdistro.name,
recipe
)
existing = overlay.repo.git.status('--porcelain', '--', prefix)
Expand All @@ -64,16 +64,16 @@ def regenerate_pkg(
warn('More than 1 recipe was output by "git status --porcelain '
'meta-ros{0}-{1}/generated-recipes/*/{2}_*.bb": "{3}"'
.format(
yoctoRecipe._get_ros_version(distro.name),
distro.name,
yoctoRecipe._get_ros_version(rosdistro.name),
rosdistro.name,
recipe,
existing))
if existing.split()[0] != 'D':
err('Unexpected output from "git status --porcelain '
'meta-ros{0}-{1}/generated-recipes/*/{2}_*.bb": "{3}"'
.format(
yoctoRecipe._get_ros_version(distro.name),
distro.name,
yoctoRecipe._get_ros_version(rosdistro.name),
rosdistro.name,
recipe,
existing))

Expand All @@ -89,8 +89,8 @@ def regenerate_pkg(
'--porcelain '
'meta-ros{0}-{1}/generated-recipes/*/{2}_*.bb": "{3}"'
.format(
yoctoRecipe._get_ros_version(distro.name),
distro.name,
yoctoRecipe._get_ros_version(rosdistro.name),
rosdistro.name,
recipe,
existing))
existing = existing[0]
Expand All @@ -106,7 +106,7 @@ def regenerate_pkg(
previous_version = existing[idx_version:].rstrip('.bb')
try:
current = oe_recipe(
distro, pkg, srcrev_cache, skip_keys
rosdistro, pkg, srcrev_cache, skip_keys
)
except InvalidPackage as e:
err('Invalid package: ' + str(e))
Expand All @@ -129,8 +129,8 @@ def regenerate_pkg(
make_dir(
"{0}/meta-ros{1}-{2}/generated-recipes/{3}".format(
repo_dir,
yoctoRecipe._get_ros_version(distro.name),
distro.name,
yoctoRecipe._get_ros_version(rosdistro.name),
rosdistro.name,
component_name
)
)
Expand All @@ -139,8 +139,8 @@ def regenerate_pkg(
recipe_file_name = '{0}/meta-ros{1}-{2}/generated-recipes/{3}/' \
'{4}_{5}.bb'.format(
repo_dir,
yoctoRecipe._get_ros_version(distro.name),
distro.name,
yoctoRecipe._get_ros_version(rosdistro.name),
rosdistro.name,
component_name,
recipe,
version
Expand All @@ -159,14 +159,14 @@ def regenerate_pkg(


def _gen_recipe_for_package(
distro, pkg_name, pkg, repo, ros_pkg,
rosdistro, pkg_name, pkg, repo, ros_pkg,
pkg_rosinstall, srcrev_cache, skip_keys
):
pkg_names = get_package_names(distro)
pkg_names = get_package_names(rosdistro)
pkg_dep_walker = DependencyWalker(
distro,
rosdistro,
evaluate_condition_context=yoctoRecipe._get_condition_context(
distro.name))
rosdistro.name))
pkg_buildtool_deps = pkg_dep_walker.get_depends(pkg_name, "buildtool")
pkg_build_deps = pkg_dep_walker.get_depends(pkg_name, "build")
pkg_build_export_deps = pkg_dep_walker.get_depends(
Expand All @@ -179,7 +179,7 @@ def _gen_recipe_for_package(

# parse through package xml
err_msg = 'Failed to fetch metadata for package {}'.format(pkg_name)
pkg_xml = retry_on_exception(ros_pkg.get_package_xml, distro.name,
pkg_xml = retry_on_exception(ros_pkg.get_package_xml, rosdistro.name,
retry_msg='Could not get package xml!',
error_msg=err_msg)

Expand All @@ -188,7 +188,7 @@ def _gen_recipe_for_package(
len(ros_pkg.repository.package_names),
pkg_name,
pkg_xml,
distro,
rosdistro,
src_uri,
srcrev_cache,
skip_keys,
Expand Down Expand Up @@ -222,18 +222,18 @@ def _gen_recipe_for_package(

class oe_recipe(object):
def __init__(
self, distro, pkg_name, srcrev_cache, skip_keys
self, rosdistro, pkg_name, srcrev_cache, skip_keys
):
pkg = distro.release_packages[pkg_name]
repo = distro.repositories[pkg.repository_name].release_repository
pkg = rosdistro.release_packages[pkg_name]
repo = rosdistro.repositories[pkg.repository_name].release_repository
ros_pkg = RosPackage(pkg_name, repo)

pkg_rosinstall = _generate_rosinstall(
pkg_name, repo.url, get_release_tag(repo, pkg_name), True
)

self.recipe = _gen_recipe_for_package(
distro, pkg_name, pkg, repo, ros_pkg, pkg_rosinstall,
rosdistro, pkg_name, pkg, repo, ros_pkg, pkg_rosinstall,
srcrev_cache, skip_keys
)

Expand Down
10 changes: 5 additions & 5 deletions superflore/generators/bitbake/yocto_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class yoctoRecipe(object):
max_component_name = 0

def __init__(
self, component_name, num_pkgs, pkg_name, pkg_xml, distro, src_uri,
self, component_name, num_pkgs, pkg_name, pkg_xml, rosdistro, src_uri,
srcrev_cache, skip_keys
):
self.component = component_name
Expand All @@ -71,15 +71,15 @@ def __init__(
self.oe_component = yoctoRecipe.convert_to_oe_name(component_name)
self.num_pkgs = num_pkgs
self.name = pkg_name
self.distro = distro.name
self.version = get_pkg_version(distro, pkg_name, is_oe=True)
self.distro = rosdistro.name
self.version = get_pkg_version(rosdistro, pkg_name, is_oe=True)
self.src_uri = src_uri
self.pkg_xml = pkg_xml
self.author = None
if self.pkg_xml:
pkg_fields = PackageMetadata(
pkg_xml,
yoctoRecipe._get_condition_context(distro.name))
yoctoRecipe._get_condition_context(rosdistro.name))
maintainer_name = pkg_fields.upstream_name
maintainer_email = pkg_fields.upstream_email
author_name = pkg_fields.author_name
Expand All @@ -97,7 +97,7 @@ def __init__(
self.license = None
self.homepage = None
self.build_type = 'catkin' if \
yoctoRecipe._get_ros_version(distro.name) == 1 \
yoctoRecipe._get_ros_version(rosdistro.name) == 1 \
else 'ament_cmake'
self.maintainer = "OSRF"
self.depends = set()
Expand Down

0 comments on commit 17c2e11

Please sign in to comment.