Enhance ROS2 repository setup by improving key handling and updating installation commands
This commit is contained in:
@@ -80,25 +80,28 @@ def _setup_locale(write: Write) -> None:
|
|||||||
|
|
||||||
def _add_ros2_repo(write: Write) -> None:
|
def _add_ros2_repo(write: Write) -> None:
|
||||||
write("[cyan][*][/cyan] Adding ROS2 apt repository...")
|
write("[cyan][*][/cyan] Adding ROS2 apt repository...")
|
||||||
_run_quiet(["sudo", "apt-get", "update", "-qq"])
|
|
||||||
|
# Best-effort update before installing prereqs (ignore errors from broken repos)
|
||||||
|
subprocess.run(["sudo", "apt-get", "update", "-qq"], capture_output=True)
|
||||||
|
|
||||||
_run_logged(
|
_run_logged(
|
||||||
["sudo", "apt-get", "install", "-y", "--no-install-recommends",
|
["sudo", "apt-get", "install", "-y", "--no-install-recommends",
|
||||||
"software-properties-common", "curl"],
|
"software-properties-common", "curl", "gnupg"],
|
||||||
write, _APT_ENV,
|
write, _APT_ENV,
|
||||||
)
|
)
|
||||||
_run_quiet(["sudo", "add-apt-repository", "-y", "universe"])
|
_run_quiet(["sudo", "add-apt-repository", "-y", "universe"])
|
||||||
|
|
||||||
if not _ROS_KEYRING.exists():
|
# Always re-download and dearmor the key to fix any previous bad install
|
||||||
write("[cyan][*][/cyan] Downloading ROS2 signing key...")
|
write("[cyan][*][/cyan] Downloading ROS2 signing key...")
|
||||||
with tempfile.NamedTemporaryFile(delete=False, suffix=".gpg") as tmp:
|
with tempfile.NamedTemporaryFile(delete=False, suffix=".key") as tmp:
|
||||||
tmp_path = tmp.name
|
tmp_path = tmp.name
|
||||||
try:
|
try:
|
||||||
urllib.request.urlretrieve(_ROS_KEY_URL, tmp_path)
|
urllib.request.urlretrieve(_ROS_KEY_URL, tmp_path)
|
||||||
_run_quiet(["sudo", "cp", tmp_path, str(_ROS_KEYRING)])
|
_run_quiet(["sudo", "gpg", "--dearmor", "--yes", "-o", str(_ROS_KEYRING), tmp_path])
|
||||||
finally:
|
finally:
|
||||||
os.unlink(tmp_path)
|
os.unlink(tmp_path)
|
||||||
|
write("[green][ok][/green] Signing key installed")
|
||||||
|
|
||||||
if not _ROS_SOURCES.exists():
|
|
||||||
arch = subprocess.check_output(["dpkg", "--print-architecture"], text=True).strip()
|
arch = subprocess.check_output(["dpkg", "--print-architecture"], text=True).strip()
|
||||||
codename = subprocess.check_output(
|
codename = subprocess.check_output(
|
||||||
["bash", "-c", ". /etc/os-release && echo $UBUNTU_CODENAME"], text=True
|
["bash", "-c", ". /etc/os-release && echo $UBUNTU_CODENAME"], text=True
|
||||||
@@ -114,18 +117,19 @@ def _add_ros2_repo(write: Write) -> None:
|
|||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
raise RuntimeError(f"Failed to write {_ROS_SOURCES}")
|
raise RuntimeError(f"Failed to write {_ROS_SOURCES}")
|
||||||
|
|
||||||
_run_quiet(["sudo", "apt-get", "update", "-qq"])
|
write("[cyan][*][/cyan] Updating apt cache...")
|
||||||
|
_run_logged(["sudo", "apt-get", "update", "-q"], write, _APT_ENV)
|
||||||
write("[green][ok][/green] ROS2 repository ready")
|
write("[green][ok][/green] ROS2 repository ready")
|
||||||
|
|
||||||
|
|
||||||
def _install_ros2_jazzy(write: Write) -> None:
|
def _install_ros2_jazzy(write: Write) -> None:
|
||||||
write("[cyan][*][/cyan] Installing ros-jazzy-ros-base and ros-dev-tools...")
|
write("[cyan][*][/cyan] Installing ros-jazzy-desktop and ros-dev-tools...")
|
||||||
_run_logged(
|
_run_logged(
|
||||||
["sudo", "apt-get", "install", "-y", "--no-install-recommends",
|
["sudo", "apt-get", "install", "-y",
|
||||||
"ros-jazzy-ros-base", "ros-dev-tools"],
|
"ros-jazzy-desktop", "ros-dev-tools"],
|
||||||
write, _APT_ENV,
|
write, _APT_ENV,
|
||||||
)
|
)
|
||||||
write("[green][ok][/green] ROS2 Jazzy installed")
|
write("[green][ok][/green] ROS2 Jazzy Desktop installed")
|
||||||
|
|
||||||
|
|
||||||
def _install_colcon(write: Write) -> None:
|
def _install_colcon(write: Write) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user