From 8f418e3d923bb14bcd40f72f0404f1f86b870d71 Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Thu, 14 Jan 2021 18:40:51 -0500 Subject: [PATCH] repo: default to target arch for stage package cache (#3416) - Add interface to project to define which arch should be used for staging packages. - Add target_arch parameter to fetch_stage_packages(). - Update apt_cache to support specifying the default architecture for the stage package cache. If running with an existing cache, check if /etc/apt is a symlink (how it was done up until now) and unlink it. Then copy the /etc/apt tree instead of linking it. Finally, add a config file to specify the default target architecture. Write that config file out every time the stage cache is (re)initialized. - Update all usage of fetch_stage_packages() to comply with new interface. Signed-off-by: Chris Patterson --- snapcraft/internal/pluginhandler/__init__.py | 1 + snapcraft/internal/repo/_base.py | 7 +- snapcraft/internal/repo/_deb.py | 11 ++- snapcraft/internal/repo/apt_cache.py | 40 ++++++++-- snapcraft/plugins/v1/_ros/rosdep.py | 5 +- snapcraft/plugins/v1/_ros/wstool.py | 1 + snapcraft/plugins/v1/catkin.py | 3 + snapcraft/plugins/v1/colcon.py | 2 + snapcraft/plugins/v2/_ros.py | 8 +- snapcraft/project/_project.py | 13 ++++ snapcraft/project/_project_options.py | 4 + spread.yaml | 7 ++ .../stage-packages/snap/snapcraft.yaml | 15 ++++ .../cross-compile/stage-packages/task.yaml | 78 +++++++++++++++++++ tests/unit/plugins/v1/ros/test_rosdep.py | 2 + tests/unit/plugins/v1/ros/test_wstool.py | 1 + tests/unit/plugins/v1/test_catkin.py | 6 ++ tests/unit/plugins/v1/test_colcon.py | 14 +++- tests/unit/plugins/v2/test_catkin.py | 4 +- tests/unit/plugins/v2/test_catkin_tools.py | 4 +- tests/unit/plugins/v2/test_colcon.py | 4 +- tests/unit/repo/test_deb.py | 6 +- 22 files changed, 216 insertions(+), 20 deletions(-) create mode 100644 tests/spread/cross-compile/stage-packages/snap/snapcraft.yaml create mode 100644 tests/spread/cross-compile/stage-packages/task.yaml diff --git a/snapcraft/internal/pluginhandler/__init__.py b/snapcraft/internal/pluginhandler/__init__.py index 1875ee3b1b..d1929134cf 100644 --- a/snapcraft/internal/pluginhandler/__init__.py +++ b/snapcraft/internal/pluginhandler/__init__.py @@ -457,6 +457,7 @@ def _fetch_stage_packages(self): package_names=stage_packages, base=self._project._get_build_base(), stage_packages_path=self.stage_packages_path, + target_arch=self._project._get_stage_packages_target_arch(), ) except repo.errors.PackageNotFoundError as e: raise errors.StagePackageDownloadError(self.name, e.message) diff --git a/snapcraft/internal/repo/_base.py b/snapcraft/internal/repo/_base.py index 5c61f5b2b5..89df70a202 100644 --- a/snapcraft/internal/repo/_base.py +++ b/snapcraft/internal/repo/_base.py @@ -167,7 +167,12 @@ def get_installed_packages(cls) -> List[str]: @classmethod def fetch_stage_packages( - cls, *, package_names: List[str], base: str, stage_packages_path: pathlib.Path + cls, + *, + package_names: List[str], + base: str, + stage_packages_path: pathlib.Path, + target_arch: str, ) -> List[str]: """Fetch stage packages to stage_packages_path.""" raise errors.NoNativeBackendError() diff --git a/snapcraft/internal/repo/_deb.py b/snapcraft/internal/repo/_deb.py index 8b27285dc2..690c52a0a9 100644 --- a/snapcraft/internal/repo/_deb.py +++ b/snapcraft/internal/repo/_deb.py @@ -416,14 +416,21 @@ def _install_packages(cls, package_names: List[str]) -> None: @classmethod def fetch_stage_packages( - cls, *, package_names: List[str], base: str, stage_packages_path: pathlib.Path + cls, + *, + package_names: List[str], + base: str, + stage_packages_path: pathlib.Path, + target_arch: str, ) -> List[str]: logger.debug(f"Requested stage-packages: {sorted(package_names)!r}") installed: Set[str] = set() stage_packages_path.mkdir(exist_ok=True) - with AptCache(stage_cache=_STAGE_CACHE_DIR) as apt_cache: + with AptCache( + stage_cache=_STAGE_CACHE_DIR, stage_cache_arch=target_arch + ) as apt_cache: filter_packages = set(get_packages_in_base(base=base)) apt_cache.update() apt_cache.mark_packages(set(package_names)) diff --git a/snapcraft/internal/repo/apt_cache.py b/snapcraft/internal/repo/apt_cache.py index 1e2339a31f..3eeafbb74d 100644 --- a/snapcraft/internal/repo/apt_cache.py +++ b/snapcraft/internal/repo/apt_cache.py @@ -38,13 +38,19 @@ class AptCache(ContextDecorator): """Transient cache for use with stage-packages, or read-only host-mode for build-packages.""" - def __init__(self, *, stage_cache: Optional[Path] = None) -> None: + def __init__( + self, + *, + stage_cache: Optional[Path] = None, + stage_cache_arch: Optional[str] = None, + ) -> None: self.stage_cache = stage_cache + self.stage_cache_arch = stage_cache_arch def __enter__(self) -> "AptCache": if self.stage_cache is not None: self._configure_apt() - self._populate_cache_dir() + self._populate_stage_cache_dir() self.cache = apt.Cache(rootdir=str(self.stage_cache), memonly=True) else: # There appears to be a slowdown when using `rootdir` = '/' with @@ -91,15 +97,35 @@ def _configure_apt(self): self.progress.pulse = lambda owner: True self.progress._width = 0 - def _populate_cache_dir(self) -> None: + def _populate_stage_cache_dir(self) -> None: + """Create/refresh cache configuration. + + (1) Delete old-style symlink cache, if symlink. + (2) Delete current-style (copied) tree. + (3) Copy current host apt configuration. + (4) Configure primary arch to target arch. + (5) Install dpkg into cache directory to support multi-arch. + """ if self.stage_cache is None: return - # Create /etc inside cache root, and symlink apt to host's. + # Copy apt configuration from host. cache_etc_apt_path = Path(self.stage_cache, "etc", "apt") - if not cache_etc_apt_path.exists(): - cache_etc_apt_path.parent.mkdir(parents=True, exist_ok=True) - os.symlink(Path("/etc/apt"), cache_etc_apt_path) + + # Delete potentially outdated cache configuration. + if cache_etc_apt_path.is_symlink(): + cache_etc_apt_path.unlink() + elif cache_etc_apt_path.exists(): + shutil.rmtree(cache_etc_apt_path) + + # Copy current cache configuration. + cache_etc_apt_path.parent.mkdir(parents=True, exist_ok=True) + shutil.copytree("/etc/apt", cache_etc_apt_path) + + # Specify default arch (if specified). + if self.stage_cache_arch is not None: + arch_conf_path = cache_etc_apt_path / "apt.conf.d" / "00default-arch" + arch_conf_path.write_text(f'APT::Architecture "{self.stage_cache_arch}";\n') # dpkg also needs to be in the rootdir in order to support multiarch # (apt calls dpkg --print-foreign-architectures). diff --git a/snapcraft/plugins/v1/_ros/rosdep.py b/snapcraft/plugins/v1/_ros/rosdep.py index d243d079a7..1e3fd9f31a 100644 --- a/snapcraft/plugins/v1/_ros/rosdep.py +++ b/snapcraft/plugins/v1/_ros/rosdep.py @@ -100,7 +100,8 @@ def __init__( ros_package_path, rosdep_path, ubuntu_distro, - base + base, + target_arch, ): self._ros_distro = ros_distro self._ros_version = ros_version @@ -115,6 +116,7 @@ def __init__( self._rosdep_install_path = os.path.join(self._rosdep_path, "install") self._rosdep_sources_path = os.path.join(self._rosdep_path, "sources.list.d") self._rosdep_cache_path = os.path.join(self._rosdep_path, "cache") + self._target_arch = target_arch def setup(self): # Make sure we can run multiple times without error, while leaving the @@ -134,6 +136,7 @@ def setup(self): package_names=["python-rosdep"], stage_packages_path=self._rosdep_stage_packages_path, base=self._base, + target_arch=self._target_arch, ) repo.Ubuntu.unpack_stage_packages( stage_packages_path=self._rosdep_stage_packages_path, diff --git a/snapcraft/plugins/v1/_ros/wstool.py b/snapcraft/plugins/v1/_ros/wstool.py index b319c3c762..37a236fd79 100644 --- a/snapcraft/plugins/v1/_ros/wstool.py +++ b/snapcraft/plugins/v1/_ros/wstool.py @@ -89,6 +89,7 @@ def setup(self) -> None: package_names=["python-wstool"], stage_packages_path=self._wstool_stage_packages_path, base=self._base, + target_arch=self._project._get_stage_packages_target_arch(), ) repo.Ubuntu.unpack_stage_packages( stage_packages_path=self._wstool_stage_packages_path, diff --git a/snapcraft/plugins/v1/catkin.py b/snapcraft/plugins/v1/catkin.py index fd99ecb33e..98dd620ade 100644 --- a/snapcraft/plugins/v1/catkin.py +++ b/snapcraft/plugins/v1/catkin.py @@ -506,6 +506,7 @@ def pull(self): rosdep_path=self._rosdep_path, ubuntu_distro=_BASE_TO_UBUNTU_RELEASE_MAP[self.project._get_build_base()], base=self.project._get_build_base(), + target_arch=self.project._get_stage_packages_target_arch(), ) rosdep.setup() @@ -545,6 +546,7 @@ def _setup_apt_dependencies(self, apt_dependencies): package_names=apt_dependencies, stage_packages_path=self.stage_packages_path, base=self.project._get_build_base(), + target_arch=self.project._get_stage_packages_target_arch(), ) except repo.errors.PackageNotFoundError as e: raise CatkinAptDependencyFetchError(e.message) @@ -988,6 +990,7 @@ def setup(self): package_names=["ros-{}-catkin".format(self._ros_distro)], stage_packages_path=self._catkin_stage_packages_path, base=self._project._get_build_base(), + target_arch=self._project._get_stage_packages_target_arch(), ) repo.Ubuntu.unpack_stage_packages( stage_packages_path=self._catkin_stage_packages_path, diff --git a/snapcraft/plugins/v1/colcon.py b/snapcraft/plugins/v1/colcon.py index cd21a454ac..8b077a7055 100644 --- a/snapcraft/plugins/v1/colcon.py +++ b/snapcraft/plugins/v1/colcon.py @@ -364,6 +364,7 @@ def pull(self): rosdep_path=self._rosdep_path, ubuntu_distro=_BASE_TO_UBUNTU_RELEASE_MAP[self.project._get_build_base()], base=self.project._get_build_base(), + target_arch=self.project._get_stage_packages_target_arch(), ) rosdep.setup() @@ -389,6 +390,7 @@ def _setup_apt_dependencies(self, apt_dependencies): package_names=apt_dependencies, stage_packages_path=self.stage_packages_path, base=self.project._get_build_base(), + target_arch=self.project._get_stage_packages_target_arch(), ) except repo.errors.PackageNotFoundError as e: raise ColconAptDependencyFetchError(e.message) diff --git a/snapcraft/plugins/v2/_ros.py b/snapcraft/plugins/v2/_ros.py index aa469225f8..d7f92efdf6 100644 --- a/snapcraft/plugins/v2/_ros.py +++ b/snapcraft/plugins/v2/_ros.py @@ -116,6 +116,8 @@ def _get_stage_runtime_dependencies_commands(self) -> List[str]: "$SNAPCRAFT_PART_INSTALL", "--ros-distro", "$ROS_DISTRO", + "--target-arch", + "$SNAPCRAFT_TARGET_ARCH", ] ) ] @@ -142,7 +144,10 @@ def plugin_cli(): @click.option("--part-src", envvar="SNAPCRAFT_PART_SRC", required=True) @click.option("--part-install", envvar="SNAPCRAFT_PART_INSTALL", required=True) @click.option("--ros-distro", envvar="ROS_DISTRO", required=True) -def stage_runtime_dependencies(part_src: str, part_install: str, ros_distro: str): +@click.option("--target-arch", envvar="SNAPCRAFT_TARGET_ARCH", required=True) +def stage_runtime_dependencies( + part_src: str, part_install: str, ros_distro: str, target_arch: str +): click.echo("Staging runtime dependencies...") # TODO: support python packages (only apt currently supported) apt_packages: Set[str] = set() @@ -180,6 +185,7 @@ def stage_runtime_dependencies(part_src: str, part_install: str, ros_distro: str package_names=package_names, base="core20", stage_packages_path=stage_packages_path, + target_arch=target_arch, ) click.echo(f"Unpacking stage packages: {package_names!r}") diff --git a/snapcraft/project/_project.py b/snapcraft/project/_project.py index 1a396eb744..c2a7dd0baf 100644 --- a/snapcraft/project/_project.py +++ b/snapcraft/project/_project.py @@ -136,6 +136,19 @@ def _get_global_state_file_path(self) -> str: return state_file_path + def _get_stage_packages_target_arch(self) -> str: + """Get architecture for staging packages. + + Prior to core20, staging packages has broken behavior in that it will + stage native architecture packages by default. + + :return: The appropriate default architecture to stage. + """ + if self._get_build_base() in ["core16", "core18"]: + return self.deb_arch + else: + return self.target_arch + def _get_start_time(self) -> datetime: """Returns the timestamp for when a snapcraft project was loaded.""" return self._start_time diff --git a/snapcraft/project/_project_options.py b/snapcraft/project/_project_options.py index 08e659919e..1e7e5974c5 100644 --- a/snapcraft/project/_project_options.py +++ b/snapcraft/project/_project_options.py @@ -250,6 +250,10 @@ def _get_provider_content_dirs(self) -> Set[str]: """ return set() + def _get_stage_packages_target_arch(self) -> str: + """Stub for 'Project' interface for tests using ProjectOptions().""" + return self.deb_arch + def is_static_base(self, base: str) -> bool: """Return True if a base that is intended to be static is used. diff --git a/spread.yaml b/spread.yaml index f2cc241d8a..da520f66fd 100644 --- a/spread.yaml +++ b/spread.yaml @@ -242,6 +242,13 @@ suites: - ubuntu-16.04* - ubuntu-18.04* + # General, core suite + tests/spread/cross-compile/: + summary: tests of supported cross-compile functionality + systems: + - ubuntu-18.04* + - ubuntu-20.04* + # Use of multipass and lxd build providers tests/spread/build-providers/: summary: tests of snapcraft using build providers diff --git a/tests/spread/cross-compile/stage-packages/snap/snapcraft.yaml b/tests/spread/cross-compile/stage-packages/snap/snapcraft.yaml new file mode 100644 index 0000000000..59df2f78d1 --- /dev/null +++ b/tests/spread/cross-compile/stage-packages/snap/snapcraft.yaml @@ -0,0 +1,15 @@ +name: cross-compile-stage-package-test +base: core20 +version: '0.1' +summary: Test +description: | + Test xcompile stage-packages behavior for core20. + +grade: stable +confinement: strict + +parts: + my-part: + plugin: nil + stage-packages: + - jq diff --git a/tests/spread/cross-compile/stage-packages/task.yaml b/tests/spread/cross-compile/stage-packages/task.yaml new file mode 100644 index 0000000000..8341808427 --- /dev/null +++ b/tests/spread/cross-compile/stage-packages/task.yaml @@ -0,0 +1,78 @@ +summary: Cross-compiliation stage-package test + +systems: + - ubuntu-20.04* + +environment: + SNAP_DIR: . + +prepare: | + #shellcheck source=tests/spread/tools/snapcraft-yaml.sh + . "$TOOLS_DIR/snapcraft-yaml.sh" + set_base "$SNAP_DIR/snap/snapcraft.yaml" + + # For gcc and dpkg-architecture. + apt-get install -y dpkg-dev gcc + apt-mark auto dpkg-dev gcc + + # Add architecture to sources. + codename="$(lsb_release -cs)" + echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports $codename main restricted universe multiverse" > /etc/apt/sources.list.d/armhf.list + + # Save original sources, but specify to host arch only. + host_arch="$(dpkg-architecture | grep DEB_BUILD_ARCH= | cut -f 2 -d =)" + cp /etc/apt/sources.list /etc/apt/sources.list.save + sed -i "s|^deb |deb [arch=$host_arch] |g" /etc/apt/sources.list + + # Add armhf arch and update apt cache. + dpkg --add-architecture armhf + apt-get update + +restore: | + cd "$SNAP_DIR" + + snapcraft clean + rm -f ./*.snap + + # Remove architecture from sources. + mv /etc/apt/sources.list.save /etc/apt/sources.list + rm -f /etc/apt/sources.list.d/armhf.list + rm -f /etc/apt/sources.list.d/main.list + + # Remove arch and update apt cache. + dpkg --remove-architecture armhf + apt-get update + + #shellcheck source=tests/spread/tools/snapcraft-yaml.sh + . "$TOOLS_DIR/snapcraft-yaml.sh" + restore_yaml "snap/snapcraft.yaml" + +execute: | + cd "$SNAP_DIR" + + host_arch="$(dpkg-architecture | grep DEB_BUILD_ARCH= | cut -f 2 -d =)" + host_arch_triplet="$(gcc -dumpmachine)" + + # First build for armhf. + snapcraft --target-arch armhf --enable-experimental-target-arch + + [ -f cross-compile-stage-package-test_0.1_armhf.snap ] + [ -f prime/usr/lib/arm-linux-gnueabihf/libjq.so.1 ] + [ "$(ls prime/usr/lib/)" == "arm-linux-gnueabihf" ] + rm cross-compile-stage-package-test_0.1_armhf.snap + + # Re-spin as native. + snapcraft + + [ -f "cross-compile-stage-package-test_0.1_$host_arch.snap" ] + [ -f "prime/usr/lib/$host_arch_triplet/libjq.so.1" ] + [ "$(ls prime/usr/lib/)" == "$host_arch_triplet" ] + rm "cross-compile-stage-package-test_0.1_$host_arch.snap" + + # Re-build for armhf. + snapcraft --target-arch armhf --enable-experimental-target-arch + + [ -f cross-compile-stage-package-test_0.1_armhf.snap ] + [ -f prime/usr/lib/arm-linux-gnueabihf/libjq.so.1 ] + [ "$(ls prime/usr/lib/)" == "arm-linux-gnueabihf" ] + rm cross-compile-stage-package-test_0.1_armhf.snap diff --git a/tests/unit/plugins/v1/ros/test_rosdep.py b/tests/unit/plugins/v1/ros/test_rosdep.py index 59fdb0aebe..b2609df32d 100644 --- a/tests/unit/plugins/v1/ros/test_rosdep.py +++ b/tests/unit/plugins/v1/ros/test_rosdep.py @@ -38,6 +38,7 @@ def setUp(self): rosdep_path="rosdep_path", ubuntu_distro="xenial", base="core", + target_arch=self.project._get_stage_packages_target_arch(), ) patcher = mock.patch("snapcraft.repo.Ubuntu") @@ -63,6 +64,7 @@ def test_setup(self): stage_packages_path=self.rosdep._rosdep_stage_packages_path, package_names=["python-rosdep"], base="core", + target_arch=self.project._get_stage_packages_target_arch(), ) ] ), diff --git a/tests/unit/plugins/v1/ros/test_wstool.py b/tests/unit/plugins/v1/ros/test_wstool.py index 460a8ae72d..334910e321 100644 --- a/tests/unit/plugins/v1/ros/test_wstool.py +++ b/tests/unit/plugins/v1/ros/test_wstool.py @@ -55,6 +55,7 @@ def test_setup(self): stage_packages_path=self.wstool._wstool_stage_packages_path, package_names=["python-wstool"], base="core", + target_arch=self.project.target_arch, ) ] ), diff --git a/tests/unit/plugins/v1/test_catkin.py b/tests/unit/plugins/v1/test_catkin.py index 75cff1758e..ad67cf165c 100644 --- a/tests/unit/plugins/v1/test_catkin.py +++ b/tests/unit/plugins/v1/test_catkin.py @@ -109,6 +109,7 @@ def assert_rosdep_setup( rosdep_path=rosdep_path, ubuntu_distro=ubuntu_distro, base="core", + target_arch=self.project._get_stage_packages_target_arch(), ), mock.call().setup(), ] @@ -956,6 +957,7 @@ def test_pull_debian_dependencies(self, generate_setup_mock): stage_packages_path=plugin.stage_packages_path, package_names={"bar", "baz", "foo"}, base=plugin.project._get_build_base(), + target_arch=plugin.project._get_stage_packages_target_arch(), ) ] ), @@ -1059,6 +1061,7 @@ def resolve(package_name): stage_packages_path=plugin.stage_packages_path, package_names={"ros-core-dependency"}, base=plugin.project._get_build_base(), + target_arch=plugin.project._get_stage_packages_target_arch(), ) ] ), @@ -1221,6 +1224,7 @@ def test_pull_debian_dependencies(self, generate_setup_mock): stage_packages_path=plugin.stage_packages_path, package_names={"bar", "baz", "foo"}, base=plugin.project._get_build_base(), + target_arch=plugin.project._get_stage_packages_target_arch(), ) ] ), @@ -1324,6 +1328,7 @@ def resolve(package_name): stage_packages_path=plugin.stage_packages_path, package_names={"ros-core-dependency"}, base=self.project._get_build_base(), + target_arch=self.project._get_stage_packages_target_arch(), ) ] ), @@ -2142,6 +2147,7 @@ def test_setup(self): stage_packages_path=self.catkin._catkin_stage_packages_path, package_names=["ros-kinetic-catkin"], base=self.project._get_build_base(), + target_arch=self.project._get_stage_packages_target_arch(), ) ] ), diff --git a/tests/unit/plugins/v1/test_colcon.py b/tests/unit/plugins/v1/test_colcon.py index f9ca3357f7..2c57e23772 100644 --- a/tests/unit/plugins/v1/test_colcon.py +++ b/tests/unit/plugins/v1/test_colcon.py @@ -72,7 +72,14 @@ class props: self.pip_mock.return_value.list.return_value = {} def assert_rosdep_setup( - self, rosdistro, ros_version, package_path, rosdep_path, ubuntu_distro, base + self, + rosdistro, + ros_version, + package_path, + rosdep_path, + ubuntu_distro, + base, + target_arch, ): self.rosdep_mock.assert_has_calls( [ @@ -83,6 +90,7 @@ def assert_rosdep_setup( rosdep_path=rosdep_path, ubuntu_distro=ubuntu_distro, base=base, + target_arch=target_arch, ), mock.call().setup(), ] @@ -913,6 +921,7 @@ def test_pull_debian_dependencies(self): os.path.join(plugin.partdir, "rosdep"), self.ubuntu_distro, plugin.project._get_build_base(), + plugin.project._get_stage_packages_target_arch(), ) # Verify that dependencies were found as expected. TODO: Would really @@ -930,6 +939,7 @@ def test_pull_debian_dependencies(self): stage_packages_path=plugin.stage_packages_path, package_names={"bar", "baz", "foo"}, base=plugin.project._get_build_base(), + target_arch=plugin.project._get_stage_packages_target_arch(), ) ] ), @@ -965,6 +975,7 @@ def test_pull_local_dependencies(self): os.path.join(plugin.partdir, "rosdep"), self.ubuntu_distro, plugin.project._get_build_base(), + plugin.project._get_stage_packages_target_arch(), ) # Verify that dependencies were found as expected. TODO: Would really @@ -995,6 +1006,7 @@ def test_pull_pip_dependencies(self): os.path.join(plugin.partdir, "rosdep"), self.ubuntu_distro, plugin.project._get_build_base(), + plugin.project._get_stage_packages_target_arch(), ) self.assert_pip_setup( diff --git a/tests/unit/plugins/v2/test_catkin.py b/tests/unit/plugins/v2/test_catkin.py index 8594f2e2b5..0b65fbf466 100644 --- a/tests/unit/plugins/v2/test_catkin.py +++ b/tests/unit/plugins/v2/test_catkin.py @@ -99,7 +99,7 @@ class Options: "env -i LANG=C.UTF-8 LC_ALL=C.UTF-8 /test/python3 -I " "/test/_ros.py " "stage-runtime-dependencies --part-src $SNAPCRAFT_PART_SRC --part-install $SNAPCRAFT_PART_INSTALL " - "--ros-distro $ROS_DISTRO", + "--ros-distro $ROS_DISTRO --target-arch $SNAPCRAFT_TARGET_ARCH", ] @@ -149,5 +149,5 @@ class Options: "/test/python3 -I " "/test/_ros.py " "stage-runtime-dependencies --part-src $SNAPCRAFT_PART_SRC --part-install $SNAPCRAFT_PART_INSTALL " - "--ros-distro $ROS_DISTRO", + "--ros-distro $ROS_DISTRO --target-arch $SNAPCRAFT_TARGET_ARCH", ] diff --git a/tests/unit/plugins/v2/test_catkin_tools.py b/tests/unit/plugins/v2/test_catkin_tools.py index 3ff6ee2593..922b91c4d7 100644 --- a/tests/unit/plugins/v2/test_catkin_tools.py +++ b/tests/unit/plugins/v2/test_catkin_tools.py @@ -97,7 +97,7 @@ class Options: "env -i LANG=C.UTF-8 LC_ALL=C.UTF-8 /test/python3 -I " "/test/_ros.py " "stage-runtime-dependencies --part-src $SNAPCRAFT_PART_SRC --part-install $SNAPCRAFT_PART_INSTALL " - "--ros-distro $ROS_DISTRO", + "--ros-distro $ROS_DISTRO --target-arch $SNAPCRAFT_TARGET_ARCH", ] @@ -147,5 +147,5 @@ class Options: "/test/python3 -I " "/test/_ros.py " "stage-runtime-dependencies --part-src $SNAPCRAFT_PART_SRC --part-install $SNAPCRAFT_PART_INSTALL " - "--ros-distro $ROS_DISTRO", + "--ros-distro $ROS_DISTRO --target-arch $SNAPCRAFT_TARGET_ARCH", ] diff --git a/tests/unit/plugins/v2/test_colcon.py b/tests/unit/plugins/v2/test_colcon.py index 8e2b9024e5..f9cace5c27 100644 --- a/tests/unit/plugins/v2/test_colcon.py +++ b/tests/unit/plugins/v2/test_colcon.py @@ -120,7 +120,7 @@ class Options: "env -i LANG=C.UTF-8 LC_ALL=C.UTF-8 /test/python3 -I " "/test/_ros.py " "stage-runtime-dependencies --part-src $SNAPCRAFT_PART_SRC --part-install $SNAPCRAFT_PART_INSTALL " - "--ros-distro $ROS_DISTRO", + "--ros-distro $ROS_DISTRO --target-arch $SNAPCRAFT_TARGET_ARCH", ] @@ -172,5 +172,5 @@ class Options: "http_proxy=http://foo https_proxy=https://bar " "/test/python3 -I /test/_ros.py " "stage-runtime-dependencies --part-src $SNAPCRAFT_PART_SRC --part-install $SNAPCRAFT_PART_INSTALL " - "--ros-distro $ROS_DISTRO", + "--ros-distro $ROS_DISTRO --target-arch $SNAPCRAFT_TARGET_ARCH", ] diff --git a/tests/unit/repo/test_deb.py b/tests/unit/repo/test_deb.py index 084a32aa43..e8d0152b80 100644 --- a/tests/unit/repo/test_deb.py +++ b/tests/unit/repo/test_deb.py @@ -83,11 +83,12 @@ def test_fetch_stage_packages(self): package_names=["fake-package"], stage_packages_path=self.stage_packages_path, base="core", + target_arch="amd64", ) self.fake_apt_cache.assert_has_calls( [ - call(stage_cache=self.stage_cache_path), + call(stage_cache=self.stage_cache_path, stage_cache_arch="amd64"), call().__enter__(), call().__enter__().update(), call().__enter__().mark_packages({"fake-package"}), @@ -114,6 +115,7 @@ def test_fetch_virtual_stage_package(self): package_names=["virtual-fake-package"], stage_packages_path=self.stage_packages_path, base="core", + target_arch="amd64", ) self.assertThat(fetched_packages, Equals(["fake-package=1.0"])) @@ -132,6 +134,7 @@ def test_fetch_stage_package_with_deps(self): package_names=["fake-package"], stage_packages_path=self.stage_packages_path, base="core", + target_arch="amd64", ) self.assertThat( @@ -150,6 +153,7 @@ def test_get_package_fetch_error(self): package_names=["fake-package"], stage_packages_path=Path(self.path), base="core", + target_arch="amd64", ) self.assertThat(str(raised), Equals("Package fetch error: foo"))