pulsar: 1.104.0 -> 1.105.0
Release note: https://github.com/pulsar-edit/pulsar/releases/tag/v1.105.0 This Pulsar release was made from a Windows computer, the SHA256SUMS.txt file was encoded in UTF-16LE with BOM. Most of the work was enhancing the update script to handle this case. Also implemented the recommendation from SuperSandro2000: https://github.com/NixOS/nixpkgs/pull/226616#discussion_r1170658908
This commit is contained in:
parent
c8f6370f7d
commit
a53041856d
|
@ -23,13 +23,13 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
pname = "pulsar";
|
pname = "pulsar";
|
||||||
version = "1.104.0";
|
version = "1.105.0";
|
||||||
|
|
||||||
sourcesPath = {
|
sourcesPath = {
|
||||||
x86_64-linux.tarname = "Linux.${pname}-${version}.tar.gz";
|
x86_64-linux.tarname = "Linux.${pname}-${version}.tar.gz";
|
||||||
x86_64-linux.hash = "sha256-HEMUQVNPb6qWIXX25N79HwHo7j11MyFiBRsq9otdAL8=";
|
x86_64-linux.hash = "sha256-j2d83m8B6lt1eRAwOOTEq4o+CNe8I+6rkz9qyux55Qw=";
|
||||||
aarch64-linux.tarname = "ARM.Linux.${pname}-${version}-arm64.tar.gz";
|
aarch64-linux.tarname = "ARM.Linux.${pname}-${version}-arm64.tar.gz";
|
||||||
aarch64-linux.hash = "sha256-f+s54XtLLdhTFY9caKTKngJF6zLai0F7ur9v37bwuNE=";
|
aarch64-linux.hash = "sha256-iZVE1R30Tynyn/cAwNIiGrsCMTkWKFUforOkGXSzMsw=";
|
||||||
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
||||||
|
|
||||||
additionalLibs = lib.makeLibraryPath [
|
additionalLibs = lib.makeLibraryPath [
|
||||||
|
@ -119,7 +119,7 @@ stdenv.mkDerivation rec {
|
||||||
# But asar complains because the node_gyp unpacked dependency uses a prebuilt Python3 itself
|
# But asar complains because the node_gyp unpacked dependency uses a prebuilt Python3 itself
|
||||||
|
|
||||||
rm $opt/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins/python3
|
rm $opt/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins/python3
|
||||||
ln -s ${python3}/bin/python3 $opt/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins/python3
|
ln -s ${python3.interpreter} $opt/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins/python3
|
||||||
'' + ''
|
'' + ''
|
||||||
# Patch the bundled node executables
|
# Patch the bundled node executables
|
||||||
find $opt -name "*.node" -exec patchelf --set-rpath "${newLibpath}:$opt" {} \;
|
find $opt -name "*.node" -exec patchelf --set-rpath "${newLibpath}:$opt" {} \;
|
||||||
|
|
|
@ -13,6 +13,17 @@ const constants = {
|
||||||
targetFile: new URL("default.nix", import.meta.url).pathname,
|
targetFile: new URL("default.nix", import.meta.url).pathname,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function utf16ToUtf8(blob) {
|
||||||
|
// Sometime, upstream saves the SHA256SUMS.txt file in UTF-16, which absolutely breaks node's string handling
|
||||||
|
// So we need to convert this blob to UTF-8
|
||||||
|
|
||||||
|
// We need to skip the first 2 bytes, which are the BOM
|
||||||
|
const arrayBuffer = await blob.slice(2).arrayBuffer();
|
||||||
|
const buffer = Buffer.from(arrayBuffer);
|
||||||
|
const utf8String = buffer.toString('utf16le');
|
||||||
|
return utf8String;
|
||||||
|
}
|
||||||
|
|
||||||
async function getLatestVersion() {
|
async function getLatestVersion() {
|
||||||
const requestResult = await fetch(constants.githubUrl);
|
const requestResult = await fetch(constants.githubUrl);
|
||||||
if (!requestResult.ok) {
|
if (!requestResult.ok) {
|
||||||
|
@ -37,6 +48,7 @@ async function getSha256Sum(hashFileContent, targetFile) {
|
||||||
|
|
||||||
let sha256 = hashFileContent.
|
let sha256 = hashFileContent.
|
||||||
split('\n').
|
split('\n').
|
||||||
|
map(line => line.replace("\r", "")). // Side-effect of the UTF-16 conversion, if the file was created from Windows
|
||||||
filter((line) => line.endsWith(targetFile))[0].
|
filter((line) => line.endsWith(targetFile))[0].
|
||||||
split(' ')[0];
|
split(' ')[0];
|
||||||
|
|
||||||
|
@ -47,14 +59,21 @@ async function getSha256Sums(newVersion) {
|
||||||
// Upstream provides a file with the hashes of the files, but it's not in the SRI format, and it refers to the compressed tarball
|
// Upstream provides a file with the hashes of the files, but it's not in the SRI format, and it refers to the compressed tarball
|
||||||
// So let's just use nix-prefetch-url to get the hashes of the decompressed tarball, and `nix hash to-sri` to convert them to SRI format
|
// So let's just use nix-prefetch-url to get the hashes of the decompressed tarball, and `nix hash to-sri` to convert them to SRI format
|
||||||
const hashFileUrl = constants.sha256FileURL(newVersion);
|
const hashFileUrl = constants.sha256FileURL(newVersion);
|
||||||
const hashFileContent = await fetch(hashFileUrl).then((response) => response.text());
|
const hashFileContent = await fetch(hashFileUrl).then((response) => response.blob());
|
||||||
|
const headerbuffer = await hashFileContent.slice(0, 2).arrayBuffer()
|
||||||
|
const header = Buffer.from(headerbuffer).toString('hex');
|
||||||
|
|
||||||
|
// We must detect if it's UTF-16 or UTF-8. If it's UTF-16, we must convert it to UTF-8, otherwise just use it as-is
|
||||||
|
const hashFileContentString = header == 'fffe' ?
|
||||||
|
await utf16ToUtf8(hashFileContent) :
|
||||||
|
await hashFileContent.text();
|
||||||
|
|
||||||
let x86_64;
|
let x86_64;
|
||||||
let aarch64;
|
let aarch64;
|
||||||
console.log("Getting new hashes");
|
console.log("Getting new hashes");
|
||||||
let promises = [
|
let promises = [
|
||||||
getSha256Sum(hashFileContent, constants.x86_64FileName(newVersion)).then((hash) => { x86_64 = hash; }),
|
getSha256Sum(hashFileContentString, constants.x86_64FileName(newVersion)).then((hash) => { x86_64 = hash; }),
|
||||||
getSha256Sum(hashFileContent, constants.aarch64FileName(newVersion)).then((hash) => { aarch64 = hash; }),
|
getSha256Sum(hashFileContentString, constants.aarch64FileName(newVersion)).then((hash) => { aarch64 = hash; }),
|
||||||
];
|
];
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
return { x86_64, aarch64 };
|
return { x86_64, aarch64 };
|
||||||
|
|
Loading…
Reference in a new issue