Unverified Commit 4ae51c77 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

Merge pull request #232196 from COLAMAroro/submit/update-pulsar-1.105.0

pulsar: 1.104.0 -> 1.105.0
parents 464b6243 a5304185
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -23,13 +23,13 @@

let
  pname = "pulsar";
  version = "1.104.0";
  version = "1.105.0";

  sourcesPath = {
    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.hash = "sha256-f+s54XtLLdhTFY9caKTKngJF6zLai0F7ur9v37bwuNE=";
    aarch64-linux.hash = "sha256-iZVE1R30Tynyn/cAwNIiGrsCMTkWKFUforOkGXSzMsw=";
  }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  additionalLibs = lib.makeLibraryPath [
@@ -119,7 +119,7 @@ stdenv.mkDerivation rec {
    # 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
    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
    find $opt -name "*.node" -exec patchelf --set-rpath "${newLibpath}:$opt" {} \;
+22 −3
Original line number Diff line number Diff line
@@ -13,6 +13,17 @@ const constants = {
    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() {
    const requestResult = await fetch(constants.githubUrl);
    if (!requestResult.ok) {
@@ -37,6 +48,7 @@ async function getSha256Sum(hashFileContent, targetFile) {

    let sha256 = hashFileContent.
        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].
        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
    // 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 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 aarch64;
    console.log("Getting new hashes");
    let promises = [
        getSha256Sum(hashFileContent, constants.x86_64FileName(newVersion)).then((hash) => { x86_64 = hash; }),
        getSha256Sum(hashFileContent, constants.aarch64FileName(newVersion)).then((hash) => { aarch64 = hash; }),
        getSha256Sum(hashFileContentString, constants.x86_64FileName(newVersion)).then((hash) => { x86_64 = hash; }),
        getSha256Sum(hashFileContentString, constants.aarch64FileName(newVersion)).then((hash) => { aarch64 = hash; }),
    ];
    await Promise.all(promises);
    return { x86_64, aarch64 };