Skip to content

Commit

Permalink
Use grub-efi-*-signed corresponding to current arch
Browse files Browse the repository at this point in the history
Signed-off-by: Christophe Bedard <[email protected]>
  • Loading branch information
christophebedard-apexai committed Aug 22, 2024
1 parent 862854b commit 00454d6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 63 deletions.
63 changes: 35 additions & 28 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7660,7 +7660,8 @@ function runLinux() {
yield addAptRepo(ubuntuCodename, use_ros2_testing);
if ("noble" !== ubuntuCodename) {
// Temporary fix to avoid error mount: /var/lib/grub/esp: special device (...) does not exist.
yield utils.exec("sudo", ["apt-mark", "hold", "grub-efi-amd64-signed"]);
const arch = yield utils.getArch();
yield utils.exec("sudo", ["apt-mark", "hold", `grub-efi-${arch}-signed`]);
yield utils.exec("sudo", ["apt-get", "upgrade", "-y"]);
}
// Install development-related packages and some common dependencies
Expand Down Expand Up @@ -7933,6 +7934,7 @@ exports.validateDistro = validateDistro;
exports.determineDistribCodename = determineDistribCodename;
exports.determineDistrib = determineDistrib;
exports.determineDistribVer = determineDistribVer;
exports.getArch = getArch;
const actions_exec = __importStar(__nccwpck_require__(1514));
const core = __importStar(__nccwpck_require__(2186));
/**
Expand Down Expand Up @@ -7975,6 +7977,25 @@ function validateDistro(requiredRosDistributionsList) {
}
return true;
}
/**
* Get the output of a given command.
*
* @param command the command, which must output something
* @returns the string output
*/
function getCommandOutput(command) {
return __awaiter(this, void 0, void 0, function* () {
let output = "";
const options = {};
options.listeners = {
stdout: (data) => {
output += data.toString();
},
};
yield exec("bash", ["-c", command], options);
return output;
});
}
/**
* Determines the Ubuntu distribution codename.
*
Expand All @@ -7985,15 +8006,7 @@ function validateDistro(requiredRosDistributionsList) {
*/
function determineDistribCodename() {
return __awaiter(this, void 0, void 0, function* () {
let distribCodename = "";
const options = {};
options.listeners = {
stdout: (data) => {
distribCodename += data.toString();
},
};
yield exec("bash", ["-c", 'source /etc/lsb-release ; echo -n "$DISTRIB_CODENAME"'], options);
return distribCodename;
return getCommandOutput('source /etc/lsb-release ; echo -n "$DISTRIB_CODENAME"');
});
}
/**
Expand All @@ -8003,15 +8016,7 @@ function determineDistribCodename() {
*/
function determineDistrib() {
return __awaiter(this, void 0, void 0, function* () {
let distrib = "";
const options = {};
options.listeners = {
stdout: (data) => {
distrib += data.toString();
},
};
yield exec("bash", ["-c", 'source /etc/os-release ; echo -n "$ID"'], options);
return distrib;
return getCommandOutput('source /etc/os-release ; echo -n "$ID"');
});
}
/**
Expand All @@ -8021,15 +8026,17 @@ function determineDistrib() {
*/
function determineDistribVer() {
return __awaiter(this, void 0, void 0, function* () {
let distrib = "";
const options = {};
options.listeners = {
stdout: (data) => {
distrib += data.toString();
},
};
yield exec("bash", ["-c", 'source /etc/os-release ; echo -n "$VERSION_ID"'], options);
return distrib;
return getCommandOutput('source /etc/os-release ; echo -n "$VERSION_ID"');
});
}
/**
* Get the machine architecture according to dpkg.
*
* @returns the architecture according to dpkg
*/
function getArch() {
return __awaiter(this, void 0, void 0, function* () {
return getCommandOutput("dpkg --print-architecture");
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/setup-ros-ubuntu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ export async function runLinux(): Promise<void> {

if ("noble" !== ubuntuCodename) {
// Temporary fix to avoid error mount: /var/lib/grub/esp: special device (...) does not exist.
await utils.exec("sudo", ["apt-mark", "hold", "grub-efi-amd64-signed"]);
const arch = await utils.getArch();
await utils.exec("sudo", ["apt-mark", "hold", `grub-efi-${arch}-signed`]);
await utils.exec("sudo", ["apt-get", "upgrade", "-y"]);
}

Expand Down
65 changes: 31 additions & 34 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ export function validateDistro(
return true;
}

/**
* Get the output of a given command.
*
* @param command the command, which must output something
* @returns the string output
*/
async function getCommandOutput(command: string): Promise<string> {
let output = "";
const options: im.ExecOptions = {};
options.listeners = {
stdout: (data: Buffer) => {
output += data.toString();
},
};
await exec("bash", ["-c", command], options);
return output;
}

/**
* Determines the Ubuntu distribution codename.
*
Expand All @@ -65,19 +83,9 @@ export function validateDistro(
* @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 getCommandOutput(
'source /etc/lsb-release ; echo -n "$DISTRIB_CODENAME"',
);
return distribCodename;
}

/**
Expand All @@ -86,15 +94,7 @@ export async function determineDistribCodename(): Promise<string> {
* @returns Promise<string> Linux distribution (e.g. "ubuntu")
*/
export async function determineDistrib(): Promise<string> {
let distrib = "";
const options: im.ExecOptions = {};
options.listeners = {
stdout: (data: Buffer) => {
distrib += data.toString();
},
};
await exec("bash", ["-c", 'source /etc/os-release ; echo -n "$ID"'], options);
return distrib;
return getCommandOutput('source /etc/os-release ; echo -n "$ID"');
}

/**
Expand All @@ -103,17 +103,14 @@ export async function determineDistrib(): Promise<string> {
* @returns Promise<string> Linux distribution version (e.g. "24.04")
*/
export async function determineDistribVer(): Promise<string> {
let distrib = "";
const options: im.ExecOptions = {};
options.listeners = {
stdout: (data: Buffer) => {
distrib += data.toString();
},
};
await exec(
"bash",
["-c", 'source /etc/os-release ; echo -n "$VERSION_ID"'],
options,
);
return distrib;
return getCommandOutput('source /etc/os-release ; echo -n "$VERSION_ID"');
}

/**
* Get the machine architecture according to dpkg.
*
* @returns the architecture according to dpkg
*/
export async function getArch(): Promise<string> {
return getCommandOutput("dpkg --print-architecture");
}

0 comments on commit 00454d6

Please sign in to comment.