backblaze2-b2: support alternative executable name

according to official doc backblaze.com/docs/cloud-storage-command-line-tools mentions the executable
is supposed to be called `b2`. Several distributions including nixpkgs renamed it to `backblaze-b2`
but it is annoying if you dont use boost's b2.
This commit makes it possible to override the executable name to
something else.
This commit is contained in:
Matthieu Coudron 2024-01-21 00:24:07 +01:00
parent 612f97239e
commit 0613638ecd

View File

@ -1,4 +1,7 @@
{ lib, python3Packages, fetchPypi, installShellFiles, testers, backblaze-b2 }:
{ lib, python3Packages, fetchPypi, installShellFiles, testers, backblaze-b2
# executable is renamed to backblaze-b2 by default, to avoid collision with boost's 'b2'
, execName ? "backblaze-b2"
}:
python3Packages.buildPythonApplication rec {
pname = "backblaze-b2";
@ -68,17 +71,18 @@ python3Packages.buildPythonApplication rec {
"test/unit/console_tool"
];
postInstall = ''
mv "$out/bin/b2" "$out/bin/backblaze-b2"
installShellCompletion --cmd backblaze-b2 \
--bash <(${python3Packages.argcomplete}/bin/register-python-argcomplete backblaze-b2) \
--zsh <(${python3Packages.argcomplete}/bin/register-python-argcomplete backblaze-b2)
postInstall = lib.optionalString (execName != "b2") ''
mv "$out/bin/b2" "$out/bin/${execName}"
''
+ ''
installShellCompletion --cmd ${execName} \
--bash <(${python3Packages.argcomplete}/bin/register-python-argcomplete ${execName}) \
--zsh <(${python3Packages.argcomplete}/bin/register-python-argcomplete ${execName})
'';
passthru.tests.version = (testers.testVersion {
package = backblaze-b2;
command = "backblaze-b2 version --short";
command = "${execName} version --short";
}).overrideAttrs (old: {
# workaround the error: Permission denied: '/homeless-shelter'
# backblaze-b2 fails to create a 'b2' directory under the XDG config path