Skip to content

Commit

Permalink
add Ubuntu Jammy (#474)
Browse files Browse the repository at this point in the history
Signed-off-by: Kenji Brameld <kenjibrameld@gmail.com>
  • Loading branch information
ijnek authored Mar 4, 2022
1 parent cedd5a2 commit 19d11b7
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 61 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
docker_image:
- "ubuntu:bionic"
- "ubuntu:focal"
- "ubuntu:jammy"
container:
image: ${{ matrix.docker_image }}
steps:
Expand Down
69 changes: 41 additions & 28 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6019,6 +6019,27 @@ function validateDistro(requiredRosDistributionsList) {
}
return true;
}
/**
* Determines the Ubuntu distribution codename.
*
* This function directly source /etc/lsb-release instead of invoking
* lsb-release as the package may not be installed.
*
* @returns Promise<string> Ubuntu distribution codename (e.g. "focal")
*/
function determineDistribCodename() {
return __awaiter(this, void 0, void 0, function* () {
let distribCodename = "";
const options = {};
options.listeners = {
stdout: (data) => {
distribCodename += data.toString();
},
};
yield utils_exec("bash", ["-c", 'source /etc/lsb-release ; echo -n "$DISTRIB_CODENAME"'], options);
return distribCodename;
});
}

;// CONCATENATED MODULE: ./src/package_manager/apt.ts
var apt_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
Expand Down Expand Up @@ -6051,7 +6072,6 @@ const aptDependencies = [
"lcov",
"libc++-dev",
"libc++abi-dev",
"python",
"python3-catkin-pkg-modules",
"python3-pip",
"python3-vcstool",
Expand All @@ -6067,11 +6087,20 @@ const distributionSpecificAptDependencies = {
// python3-rosdep is conflicting with ros-melodic-desktop-full,
// and should not be used here. See ros-tooling/setup-ros#74
"python-rosdep",
// python required for sourcing setup.sh
"python",
],
focal: [
// python-rosdep does not exist on Focal, so python3-rosdep is used.
// The issue with ros-melodic-desktop-full is also non-applicable.
"python3-rosdep",
// python required for sourcing setup.sh
"python",
],
jammy: [
// python-rosdep does not exist on Jammy, so python3-rosdep is used.
// The issue with ros-melodic-desktop-full is also non-applicable.
"python3-rosdep",
],
};
/**
Expand All @@ -6092,27 +6121,6 @@ function runAptGetInstall(packages) {
return utils_exec("sudo", aptCommandLine.concat(packages));
});
}
/**
* Determines the Ubuntu distribution codename.
*
* This function directly source /etc/lsb-release instead of invoking
* lsb-release as the package may not be installed.
*
* @returns Promise<string> Ubuntu distribution codename (e.g. "focal")
*/
function determineDistribCodename() {
return apt_awaiter(this, void 0, void 0, function* () {
let distribCodename = "";
const options = {};
options.listeners = {
stdout: (data) => {
distribCodename += data.toString();
},
};
yield utils_exec("bash", ["-c", 'source /etc/lsb-release ; echo -n "$DISTRIB_CODENAME"'], options);
return distribCodename;
});
}
/**
* Run ROS 2 APT dependencies.
*
Expand Down Expand Up @@ -6297,6 +6305,8 @@ WE+F5FaIKwb72PL4rLi4
=i0tj
-----END PGP PUBLIC KEY BLOCK-----
`;
// List of linux distributions that need http://packages.ros.org/ros/ubuntu APT repo
const distrosRequiringRosUbuntu = ["bionic", "focal"];
/**
* Install ROS 2 on a Linux worker.
*/
Expand Down Expand Up @@ -6343,15 +6353,18 @@ function runLinux() {
const keyFilePath = external_path_.join(workspace, "ros.key");
external_fs_default().writeFileSync(keyFilePath, openRoboticsAptPublicGpgKey);
yield utils_exec("sudo", ["apt-key", "add", keyFilePath]);
const distribCodename = yield determineDistribCodename();
if (distrosRequiringRosUbuntu.includes(distribCodename)) {
yield utils_exec("sudo", [
"bash",
"-c",
`echo "deb http://packages.ros.org/ros/ubuntu ${distribCodename} main" > /etc/apt/sources.list.d/ros-latest.list`,
]);
}
yield utils_exec("sudo", [
"bash",
"-c",
`echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list`,
]);
yield utils_exec("sudo", [
"bash",
"-c",
`echo "deb http://packages.ros.org/ros2${use_ros2_testing ? "-testing" : ""}/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros2-latest.list`,
`echo "deb http://packages.ros.org/ros2${use_ros2_testing ? "-testing" : ""}/ubuntu ${distribCodename} main" > /etc/apt/sources.list.d/ros2-latest.list`,
]);
yield utils_exec("sudo", ["apt-get", "update"]);
// Install rosdep and vcs, as well as FastRTPS dependencies, OpenSplice, and
Expand Down
37 changes: 10 additions & 27 deletions src/package_manager/apt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as im from "@actions/exec/lib/interfaces";
import * as utils from "../utils";

const CONNEXT_APT_PACKAGE_NAME = "rti-connext-dds-5.3.1"; // RTI Connext
Expand All @@ -23,7 +22,6 @@ const aptDependencies: string[] = [
"lcov",
"libc++-dev",
"libc++abi-dev",
"python", // required for sourcing setup.sh
"python3-catkin-pkg-modules",
"python3-pip",
"python3-vcstool",
Expand All @@ -41,11 +39,20 @@ const distributionSpecificAptDependencies = {
// python3-rosdep is conflicting with ros-melodic-desktop-full,
// and should not be used here. See ros-tooling/setup-ros#74
"python-rosdep",
// python required for sourcing setup.sh
"python",
],
focal: [
// python-rosdep does not exist on Focal, so python3-rosdep is used.
// The issue with ros-melodic-desktop-full is also non-applicable.
"python3-rosdep",
// python required for sourcing setup.sh
"python",
],
jammy: [
// python-rosdep does not exist on Jammy, so python3-rosdep is used.
// The issue with ros-melodic-desktop-full is also non-applicable.
"python3-rosdep",
],
};

Expand All @@ -66,30 +73,6 @@ export async function runAptGetInstall(packages: string[]): Promise<number> {
return utils.exec("sudo", aptCommandLine.concat(packages));
}

/**
* Determines the Ubuntu distribution codename.
*
* This function directly source /etc/lsb-release instead of invoking
* lsb-release as the package may not be installed.
*
* @returns Promise<string> Ubuntu distribution codename (e.g. "focal")
*/
async function determineDistribCodename(): Promise<string> {
let distribCodename = "";
const options: im.ExecOptions = {};
options.listeners = {
stdout: (data: Buffer) => {
distribCodename += data.toString();
},
};
await utils.exec(
"bash",
["-c", 'source /etc/lsb-release ; echo -n "$DISTRIB_CODENAME"'],
options
);
return distribCodename;
}

/**
* Run ROS 2 APT dependencies.
*
Expand All @@ -101,7 +84,7 @@ export async function installAptDependencies(
let aptPackages: string[] = installConnext
? aptDependencies.concat(CONNEXT_APT_PACKAGE_NAME)
: aptDependencies;
const distribCodename = await determineDistribCodename();
const distribCodename = await utils.determineDistribCodename();
const additionalAptPackages =
distributionSpecificAptDependencies[distribCodename] || [];
aptPackages = aptPackages.concat(additionalAptPackages);
Expand Down
18 changes: 12 additions & 6 deletions src/setup-ros-linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ WE+F5FaIKwb72PL4rLi4
-----END PGP PUBLIC KEY BLOCK-----
`;

// List of linux distributions that need http://packages.ros.org/ros/ubuntu APT repo
const distrosRequiringRosUbuntu = ["bionic", "focal"];

/**
* Install ROS 2 on a Linux worker.
*/
Expand Down Expand Up @@ -101,17 +104,20 @@ export async function runLinux() {
fs.writeFileSync(keyFilePath, openRoboticsAptPublicGpgKey);
await utils.exec("sudo", ["apt-key", "add", keyFilePath]);

await utils.exec("sudo", [
"bash",
"-c",
`echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list`,
]);
const distribCodename = await utils.determineDistribCodename();
if (distrosRequiringRosUbuntu.includes(distribCodename)) {
await utils.exec("sudo", [
"bash",
"-c",
`echo "deb http://packages.ros.org/ros/ubuntu ${distribCodename} main" > /etc/apt/sources.list.d/ros-latest.list`,
]);
}
await utils.exec("sudo", [
"bash",
"-c",
`echo "deb http://packages.ros.org/ros2${
use_ros2_testing ? "-testing" : ""
}/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros2-latest.list`,
}/ubuntu ${distribCodename} main" > /etc/apt/sources.list.d/ros2-latest.list`,
]);

await utils.exec("sudo", ["apt-get", "update"]);
Expand Down
24 changes: 24 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,27 @@ export function validateDistro(

return true;
}

/**
* Determines the Ubuntu distribution codename.
*
* This function directly source /etc/lsb-release instead of invoking
* lsb-release as the package may not be installed.
*
* @returns Promise<string> Ubuntu distribution codename (e.g. "focal")
*/
export async function determineDistribCodename(): Promise<string> {
let distribCodename = "";
const options: im.ExecOptions = {};
options.listeners = {
stdout: (data: Buffer) => {
distribCodename += data.toString();
},
};
await exec(
"bash",
["-c", 'source /etc/lsb-release ; echo -n "$DISTRIB_CODENAME"'],
options
);
return distribCodename;
}

0 comments on commit 19d11b7

Please sign in to comment.