def test_get_multiarch_package(self, mock_apt): project_options = snapcraft.ProjectOptions(use_geoip=False) ubuntu = repo.Ubuntu(self.tempdir, project_options=project_options) ubuntu.get(['fake-package:arch']) mock_apt.assert_has_calls([ call.apt_pkg.config.set('Dir::Cache::Archives', os.path.join(self.tempdir, 'download')), call.apt_pkg.config.set('Apt::Install-Recommends', 'False'), call.apt_pkg.config.find_file('Dir::Etc::Trusted'), call.apt_pkg.config.set('Dir::Etc::Trusted', ANY), call.apt_pkg.config.find_file('Dir::Etc::TrustedParts'), call.apt_pkg.config.set('Dir::Etc::TrustedParts', ANY), call.apt_pkg.config.clear('APT::Update::Post-Invoke-Success'), call.progress.text.AcquireProgress(), call.Cache(memonly=True, rootdir=ANY), call.Cache().update(fetch_progress=ANY, sources_list=ANY), call.Cache(memonly=True, rootdir=self.tempdir), call.Cache().open(), ]) mock_apt.assert_has_calls([ call.Cache().fetch_archives(progress=ANY), ]) # __getitem__ is tricky self.assertThat(mock_apt.Cache().__getitem__.call_args_list, Contains(call('fake-package:arch')))
def _setup_dependencies(self, rosdep, catkin): # Parse the Catkin packages to pull out their system dependencies system_dependencies = _find_system_dependencies( self.catkin_packages, rosdep, catkin) # If the package requires roscore, resolve it into a system dependency # as well. if self.options.include_roscore: roscore_dependency = rosdep.resolve_dependency('ros_core') if roscore_dependency: system_dependencies |= set(roscore_dependency) else: raise RuntimeError( 'Unable to determine system dependency for roscore') # Pull down and install any system dependencies that were discovered if system_dependencies: ubuntudir = os.path.join(self.partdir, 'ubuntu') os.makedirs(ubuntudir, exist_ok=True) logger.info('Preparing to fetch package dependencies...') ubuntu = repo.Ubuntu(ubuntudir, sources=self.PLUGIN_STAGE_SOURCES, project_options=self.project) logger.info('Fetching package dependencies...') try: ubuntu.get(system_dependencies) except repo.errors.PackageNotFoundError as e: raise RuntimeError( 'Failed to fetch system dependencies: {}'.format( e.message)) logger.info('Installing package dependencies...') ubuntu.unpack(self.installdir)
def setup(self): os.makedirs(self._wstool_install_path, exist_ok=True) # wstool isn't a dependency of the project, so we'll unpack it # somewhere else, and use it from there. logger.info('Preparing to fetch wstool...') ubuntu = repo.Ubuntu(self._wstool_path, sources=self._ubuntu_sources, project_options=self._project) logger.info('Fetching wstool...') ubuntu.get(['python-wstool']) logger.info('Installing wstool...') ubuntu.unpack(self._wstool_install_path) logger.info('Initializing workspace (if necessary)...') try: self._run([ 'init', self._ros_package_path, '-j{}'.format(self._project.parallel_build_count) ]) except subprocess.CalledProcessError as e: output = e.output.decode('utf8').strip() if 'already is a workspace' not in output: raise RuntimeError( 'Error initializing workspace:\n{}'.format(output))
def test_get_package(self, mock_apt_pkg): project_options = snapcraft.ProjectOptions(use_geoip=False) ubuntu = repo.Ubuntu(self.tempdir, project_options=project_options) ubuntu.get(['fake-package']) mock_apt_pkg.assert_has_calls([ call.config.set('Apt::Install-Recommends', 'False'), call.config.find_file('Dir::Etc::Trusted'), call.config.set('Dir::Etc::Trusted', ANY), call.config.find_file('Dir::Etc::TrustedParts'), call.config.set('Dir::Etc::TrustedParts', ANY), call.config.clear('APT::Update::Post-Invoke-Success'), ]) self.mock_cache.assert_has_calls([ call(memonly=True, rootdir=ANY), call().update(fetch_progress=ANY, sources_list=ANY), call().open(), ]) # __getitem__ is tricky self.assertThat( self.mock_cache.return_value.__getitem__.call_args_list, Contains(call('fake-package'))) self.mock_package.assert_has_calls( [call.candidate.fetch_binary(ANY, progress=ANY)]) # Verify that the package was actually fetched and copied into the # requested location. self.assertThat( os.path.join(self.tempdir, 'download', 'fake-package.deb'), FileExists())
def pull(self): """Copy source into build directory and fetch dependencies. Catkin packages can specify their system dependencies in their package.xml. In order to support that, the Catkin packages are interrogated for their dependencies here. Since `stage-packages` are already installed by the time this function is run, the dependencies from the package.xml are pulled down explicitly. """ super().pull() # Make sure the package path exists before continuing if not os.path.exists(self._ros_package_path): raise FileNotFoundError('Unable to find package path: "{}"'.format( self._ros_package_path)) # Use rosdep for dependency detection and resolution rosdep = _Rosdep(self.options.rosdistro, self._ros_package_path, self._rosdep_path, self.PLUGIN_STAGE_SOURCES, self.project) rosdep.setup() # Parse the Catkin packages to pull out their system dependencies system_dependencies = _find_system_dependencies( self.catkin_packages, rosdep) # If the package requires roscore, resolve it into a system dependency # as well. if self.options.include_roscore: roscore_dependency = rosdep.resolve_dependency('ros_core') if roscore_dependency: system_dependencies |= set(roscore_dependency) else: raise RuntimeError( 'Unable to determine system dependency for roscore') # Pull down and install any system dependencies that were discovered if system_dependencies: ubuntudir = os.path.join(self.partdir, 'ubuntu') os.makedirs(ubuntudir, exist_ok=True) logger.info('Preparing to fetch package dependencies...') ubuntu = repo.Ubuntu(ubuntudir, self.project, sources=self.PLUGIN_STAGE_SOURCES, project_options=self.project) logger.info('Fetching package dependencies...') try: ubuntu.get(system_dependencies) except repo.PackageNotFoundError as e: raise RuntimeError( 'Failed to fetch system dependencies: {}'.format( e.message)) logger.info('Installing package dependencies...') ubuntu.unpack(self.installdir)
def _install_tools(self): logger.info('Preparing to fetch vcstool...') ubuntu = repo.Ubuntu(self._bootstrap_path, sources=self._ubuntu_sources, project_options=self._project) logger.info('Fetching vcstool...') ubuntu.get(['python3-vcstool']) logger.info('Installing vcstool...') ubuntu.unpack(self._tool_dir)
def setup(self): os.makedirs(self._catkin_install_path, exist_ok=True) # With the introduction of an underlay, we no longer know where Catkin # is. Let's just fetch/unpack our own, and use it. logger.info("Preparing to fetch catkin...") ubuntu = repo.Ubuntu(self._catkin_path) logger.info("Fetching catkin...") ubuntu.get(["ros-{}-catkin".format(self._ros_distro)]) logger.info("Installing catkin...") ubuntu.unpack(self._catkin_install_path)
def _setup_stage_packages(self): ubuntu = repo.Ubuntu(self.ubuntudir, sources=self.code.PLUGIN_STAGE_SOURCES) ubuntu.get(self.code.stage_packages) ubuntu.unpack(self.installdir) snap_files, snap_dirs = self.migratable_fileset_for('stage') _migrate_files(snap_files, snap_dirs, self.code.installdir, self.stagedir, missing_ok=True)
def setup(self): os.makedirs(self._catkin_install_path, exist_ok=True) # With the introduction of an underlay, we no longer know where Catkin # is. Let's just fetch/unpack our own, and use it. logger.info('Preparing to fetch catkin...') ubuntu = repo.Ubuntu(self._catkin_path, sources=self._ubuntu_sources, project_options=self._project) logger.info('Fetching catkin...') ubuntu.get(['ros-{}-catkin'.format(self._ros_distro)]) logger.info('Installing catkin...') ubuntu.unpack(self._catkin_install_path)
def _setup_apt_dependencies(self, apt_dependencies): if apt_dependencies: ubuntudir = os.path.join(self.partdir, "ubuntu") os.makedirs(ubuntudir, exist_ok=True) logger.info("Preparing to fetch apt dependencies...") ubuntu = repo.Ubuntu(ubuntudir) logger.info("Fetching apt dependencies...") try: ubuntu.get(apt_dependencies) except repo.errors.PackageNotFoundError as e: raise CatkinAptDependencyFetchError(e.message) logger.info("Installing apt dependencies...") ubuntu.unpack(self.installdir)
def setup(self): os.makedirs(self._compilers_install_path, exist_ok=True) # Since we support building older ROS distros we need to make sure we # use the corresponding compiler versions, so they can't be # build-packages. We'll just download them to another place and use # them from there. logger.info('Preparing to fetch compilers...') ubuntu = repo.Ubuntu(self._compilers_path, sources=self._ubuntu_sources, project_options=self._project) logger.info('Fetching compilers...') ubuntu.get(['gcc', 'g++']) logger.info('Installing compilers...') ubuntu.unpack(self._compilers_install_path)
def _setup_apt_dependencies(self, apt_dependencies): if apt_dependencies: ubuntudir = os.path.join(self.partdir, 'ubuntu') os.makedirs(ubuntudir, exist_ok=True) logger.info('Preparing to fetch apt dependencies...') ubuntu = repo.Ubuntu(ubuntudir, sources=self.PLUGIN_STAGE_SOURCES, project_options=self.project) logger.info('Fetching apt dependencies...') try: ubuntu.get(apt_dependencies) except repo.errors.PackageNotFoundError as e: raise RuntimeError( 'Failed to fetch apt dependencies: {}'.format(e.message)) logger.info('Installing apt dependencies...') ubuntu.unpack(self.installdir)
def _setup_apt_dependencies(self, apt_dependencies): if apt_dependencies: ubuntudir = os.path.join(self.partdir, "ubuntu") os.makedirs(ubuntudir, exist_ok=True) logger.info("Preparing to fetch apt dependencies...") ubuntu = repo.Ubuntu( ubuntudir, sources=self.PLUGIN_STAGE_SOURCES, keyrings=self.PLUGIN_STAGE_KEYRINGS, project_options=self.project, ) logger.info("Fetching apt dependencies...") try: ubuntu.get(apt_dependencies) except repo.errors.PackageNotFoundError as e: raise ColconAptDependencyFetchError(e.message) logger.info("Installing apt dependencies...") ubuntu.unpack(self.installdir)
def setup(self): # Make sure we can run multiple times without error, while leaving the # capability to re-initialize, by making sure we clear the sources. if os.path.exists(self._rosdep_sources_path): shutil.rmtree(self._rosdep_sources_path) os.makedirs(self._rosdep_sources_path) os.makedirs(self._rosdep_install_path, exist_ok=True) os.makedirs(self._rosdep_cache_path, exist_ok=True) # rosdep isn't necessarily a dependency of the project, and we don't # want to bloat the .snap more than necessary. So we'll unpack it # somewhere else, and use it from there. logger.info('Preparing to fetch rosdep...') ubuntu = repo.Ubuntu(self._rosdep_path, sources=self._ubuntu_sources, project_options=self._project) logger.info('Fetching rosdep...') ubuntu.get(['python-rosdep']) logger.info('Installing rosdep...') ubuntu.unpack(self._rosdep_install_path) logger.info('Initializing rosdep database...') try: self._run(['init']) except subprocess.CalledProcessError as e: output = e.output.decode('utf8').strip() raise RuntimeError( 'Error initializing rosdep database:\n{}'.format(output)) logger.info('Updating rosdep database...') try: self._run(['update']) except subprocess.CalledProcessError as e: output = e.output.decode('utf8').strip() raise RuntimeError( 'Error updating rosdep database:\n{}'.format(output))
def pull(self): """Copy source into build directory and fetch dependencies. Catkin packages can specify their system dependencies in their package.xml. In order to support that, the Catkin packages are interrogated for their dependencies here. Since `stage-packages` are already installed by the time this function is run, the dependencies from the package.xml are pulled down explicitly. """ super().pull() # Make sure the package path exists before continuing if not os.path.exists(self._ros_package_path): raise FileNotFoundError( 'Unable to find package path: "{}"'.format( self._ros_package_path)) # Parse the Catkin packages to pull out their system dependencies system_dependencies = _find_system_dependencies( self.catkin_packages, self.options.rosdistro, self._ros_package_path, os.path.join(self.partdir, 'rosdep'), self.PLUGIN_STAGE_SOURCES) # Pull down and install any system dependencies that were discovered if system_dependencies: ubuntudir = os.path.join(self.partdir, 'ubuntu') os.makedirs(ubuntudir, exist_ok=True) logger.info('Preparing to fetch package dependencies...') ubuntu = repo.Ubuntu(ubuntudir, sources=self.PLUGIN_STAGE_SOURCES) logger.info('Fetching package dependencies...') ubuntu.get(system_dependencies) logger.info('Installing package dependencies...') ubuntu.unpack(self.installdir)
def _setup_stage_packages(self): if self.code.stage_packages: ubuntu = repo.Ubuntu(self.ubuntudir, sources=self.code.PLUGIN_STAGE_SOURCES) ubuntu.get(self.code.stage_packages) ubuntu.unpack(self.code.installdir)