Skip to content

Commit

Permalink
Improved guard rails around NodeJS 20 Updates (#1604)
Browse files Browse the repository at this point in the history
## ♻️ Current situation

*Describe the current situation. Explain current problems, if there are
any. Be as descriptive as possible (e.g., including examples or code
snippets).*

## 💡 Proposed solution

*Describe the proposed solution and changes. How does it affect the
project? How does it affect the internal structure (e.g.,
refactorings)?*

## ⚙️ Release Notes

*Provide a summary of the changes or features from a user's point of
view. If there are breaking changes, provide migration guides using code
examples of the affected features.*

## ➕ Additional Information
*If applicable, provide additional context in this section.*

### Testing

*Which tests were added? Which existing tests were adapted/changed?
Which situations are covered, and what edge cases are missing?*

### Reviewer Nudging

*Where should the reviewer start? what is a good entry point?*
  • Loading branch information
NorthernMan54 committed Oct 28, 2023
1 parent 5d66ec6 commit 7186f1f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to homebridge-config-ui-x will be documented in this file.

## 4.51.2 (2023-10-27)

### Bug Fixes

- Improved guard rails around the NodeJS 20 update for environments that can not support NodeJS 20 (#1604)
- Include commentary in the release notes about the possiblity of needing to run `sudo hb-service rebuild` after updating, and how to determine if your system is compatible with NodeJS 20.

## 4.51.1 (2023-10-25)

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebridge-config-ui-x",
"displayName": "Homebridge UI",
"version": "4.51.1",
"version": "4.51.2",
"description": "A web based management, configuration and control platform for Homebridge.",
"license": "MIT",
"author": "oznu <dev@oz.nu>",
Expand Down Expand Up @@ -153,4 +153,4 @@
"smart home",
"hb-service"
]
}
}
42 changes: 26 additions & 16 deletions src/bin/platforms/linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,25 @@ export class LinuxInstaller extends BasePlatform {
}
}

private async glibcVersionCheck(target: string) {
const glibcVersion = parseFloat(child_process.execSync('getconf GNU_LIBC_VERSION 2>/dev/null').toString().split('glibc')[1].trim());
if (glibcVersion < 2.23) {
this.hbService.logger('Your version of Linux does not meet the GLIBC version requirements to use this tool to upgrade Node.js. ' +
`Wanted: >=2.23. Installed: ${glibcVersion}`, 'fail');
process.exit(1);
}
if (semver.gte(target, '18.0.0') && glibcVersion < 2.28) {
this.hbService.logger('Your version of Linux does not meet the GLIBC version requirements to use this tool to upgrade Node.js. ' +
`Wanted: >=2.28. Installed: ${glibcVersion}`, 'fail');
process.exit(1);
}
if (semver.gte(target, '20.0.0') && glibcVersion < 2.29) {
this.hbService.logger('Your version of Linux does not meet the GLIBC version requirements to use this tool to upgrade Node.js. ' +
`Wanted: >=2.29. Installed: ${glibcVersion}`, 'fail');
process.exit(1);
}
}

/**
* Update Node.js from the tarball archives
*/
Expand All @@ -325,22 +344,7 @@ export class LinuxInstaller extends BasePlatform {
process.exit(1);
}
} else {
const glibcVersion = parseFloat(child_process.execSync('getconf GNU_LIBC_VERSION 2>/dev/null').toString().split('glibc')[1].trim());
if (glibcVersion < 2.23) {
this.hbService.logger('Your version of Linux does not meet the GLIBC version requirements to use this tool to upgrade Node.js. ' +
`Wanted: >=2.23. Installed: ${glibcVersion}`, 'fail');
process.exit(1);
}
if (semver.gte(job.target, '18.0.0') && glibcVersion < 2.28) {
this.hbService.logger('Your version of Linux does not meet the GLIBC version requirements to use this tool to upgrade Node.js. ' +
`Wanted: >=2.28. Installed: ${glibcVersion}`, 'fail');
process.exit(1);
}
if (semver.gte(job.target, '20.0.0') && glibcVersion < 2.29) {
this.hbService.logger('Your version of Linux does not meet the GLIBC version requirements to use this tool to upgrade Node.js. ' +
`Wanted: >=2.29. Installed: ${glibcVersion}`, 'fail');
process.exit(1);
}
await this.glibcVersionCheck(job.target);
}
} catch (e) {
const osInfo = await si.osInfo();
Expand Down Expand Up @@ -415,13 +419,19 @@ export class LinuxInstaller extends BasePlatform {
this.hbService.logger('Updating from NodeSource...');

try {

await this.glibcVersionCheck(job.target);
const majorVersion = semver.parse(job.target).major;
// update apt (and accept release info changes)
child_process.execSync('apt-get update --allow-releaseinfo-change && sudo apt-get install -y ca-certificates curl gnupg', {
stdio: 'inherit',
});

// Update certificates
child_process.execSync('mkdir -p /etc/apt/keyrings', {
stdio: 'inherit',
});

child_process.execSync('curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/nodes', {
stdio: 'inherit',
});
Expand Down

0 comments on commit 7186f1f

Please sign in to comment.