Merge pull request #244583 from COLAMAroro/backport-23.05/pulsar-104-106

[Backport release-23.05] pulsar: 1.104.0 -> 1.106.0
This commit is contained in:
Norbert Melzer
2023-07-21 17:00:55 +02:00
committed by GitHub
3 changed files with 27 additions and 24 deletions

View File

@@ -1,27 +1,11 @@
--- a/resources/pulsar.sh 2023-03-16 04:11:14.000000000 +0100
+++ b/resources/pulsar.sh 2023-03-24 14:37:13.468813964 +0100
@@ -123,22 +123,9 @@
@@ -123,7 +123,7 @@
elif [ $OS == 'Linux' ]; then
SCRIPT=$(readlink -f "$0")
- PULSAR_PATH="/opt/Pulsar/pulsar"
+ # PULSAR_PATH is set-up via `wrapProgram` in the postFixup phase
- #Will allow user to get context menu on cinnamon desktop enviroment
- #Add a check to make sure that DESKTOP_SESSION is set before attempting to grep it
- #expr substr is expecting 3 arguments string, index, length
- #If grep doesnt find anything is provides an empty string which causes the expr: syntax error: missing argument after '8' error - see pulsar-edit/pulsar#174
- #Im also not quite sure why they used grep instead of simply [ "${DESKTOP_SESSION}" == "cinnamon" ]
- if [ -n "${DESKTOP_SESSION}" ] && [ "$(expr substr $(printenv | grep 'DESKTOP_SESSION=') 17 8)" == "cinnamon" ]; then
- #This local path is almost assuredly wrong as it shouldnt exist in a standard install
- ACTION_PATH="resources/linux/desktopenviroment/cinnamon/pulsar.nemo_action"
-
- #Validate the file exists before attempting to copy it
- if [ -f "${ACTION_PATH}" ]; then
- cp "${$ACTION_PATH}" "/usr/share/nemo/actions/pulsar.nemo_action"
- fi
- fi
+ # We remove the nemo integration. It is handled by the postFixup phase
#Set tmpdir only if tmpdir is unset
: ${TMPDIR:=/tmp}

View File

@@ -23,13 +23,13 @@
let
pname = "pulsar";
version = "1.104.0";
version = "1.106.0";
sourcesPath = {
x86_64-linux.tarname = "Linux.${pname}-${version}.tar.gz";
x86_64-linux.hash = "sha256-HEMUQVNPb6qWIXX25N79HwHo7j11MyFiBRsq9otdAL8=";
x86_64-linux.hash = "sha256-Wd0z6kHd6qZgrgZBxZQjwVC1dDqYtJ94L7aAnbuJoO8=";
aarch64-linux.tarname = "ARM.Linux.${pname}-${version}-arm64.tar.gz";
aarch64-linux.hash = "sha256-f+s54XtLLdhTFY9caKTKngJF6zLai0F7ur9v37bwuNE=";
aarch64-linux.hash = "sha256-Xadjqw8PRrq0ksif6te0gxn8xeYTCYnJcsrezfl2SYs=";
}.${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" {} \;

View File

@@ -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 };