Skip to content

Commit

Permalink
Read debian virtual packages from apt cache
Browse files Browse the repository at this point in the history
These virtual packages are supported by the rosdep tool, so should be
acceptable for use here as well.
  • Loading branch information
cottsay committed Mar 8, 2024
1 parent bf2bd68 commit 50b23b4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ros_buildfarm/debian_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,17 @@ def get_debian_repo_index(debian_repository_baseurl, target, cache_dir):

package_versions[debian_pkg_name] = PlatformPackageDescriptor(version, source_name)

prefix = 'Provides: '
provides = [line[len(prefix):] for line in lines if line.startswith(prefix)]
provides = [provide.strip() for line in provides for provide in line.split(',')]

for provide in provides:
provide_version = None
if ' ' in provide:
provide, provide_spec = provide.split(' ', 1)
if provide_spec.startswith('(=') and provide_spec.endswith(')'):
provide_version = provide_spec[2:-1].strip()

package_versions[provide] = PlatformPackageDescriptor(provide_version, source_name)

return package_versions
Binary file not shown.
33 changes: 33 additions & 0 deletions test/test_debian_repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2024 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.

import os

from ros_buildfarm.common import PlatformPackageDescriptor
from ros_buildfarm.common import Target
from ros_buildfarm.debian_repo import get_debian_repo_index

mock_index_path = os.path.join(os.path.dirname(__file__), 'mock_debian_index')

def test_parse_debian_repo_index(tmpdir):
mock_index_url = 'file://' + mock_index_path
target = Target('ubuntu', 'noble', 'amd64')
index = get_debian_repo_index(mock_index_url, target, str(tmpdir))

expected = PlatformPackageDescriptor('6.4+20240113-1ubuntu1', 'ncurses')
assert expected == index.get('libncurses-dev')
assert expected == index.get('libncurses5-dev')

expected = PlatformPackageDescriptor(None, 'ncurses')
assert expected == index.get('ncurses-dev')

0 comments on commit 50b23b4

Please sign in to comment.