Merge pull request #282659 from teto/backblaze-b2

backblaze2-b2: support alternative executable name
This commit is contained in:
maxine 2024-01-22 18:16:29 +01:00 committed by GitHub
commit 0700399e62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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 { python3Packages.buildPythonApplication rec {
pname = "backblaze-b2"; pname = "backblaze-b2";
@ -68,17 +71,18 @@ python3Packages.buildPythonApplication rec {
"test/unit/console_tool" "test/unit/console_tool"
]; ];
postInstall = '' postInstall = lib.optionalString (execName != "b2") ''
mv "$out/bin/b2" "$out/bin/backblaze-b2" mv "$out/bin/b2" "$out/bin/${execName}"
''
installShellCompletion --cmd backblaze-b2 \ + ''
--bash <(${python3Packages.argcomplete}/bin/register-python-argcomplete backblaze-b2) \ installShellCompletion --cmd ${execName} \
--zsh <(${python3Packages.argcomplete}/bin/register-python-argcomplete backblaze-b2) --bash <(${python3Packages.argcomplete}/bin/register-python-argcomplete ${execName}) \
--zsh <(${python3Packages.argcomplete}/bin/register-python-argcomplete ${execName})
''; '';
passthru.tests.version = (testers.testVersion { passthru.tests.version = (testers.testVersion {
package = backblaze-b2; package = backblaze-b2;
command = "backblaze-b2 version --short"; command = "${execName} version --short";
}).overrideAttrs (old: { }).overrideAttrs (old: {
# workaround the error: Permission denied: '/homeless-shelter' # workaround the error: Permission denied: '/homeless-shelter'
# backblaze-b2 fails to create a 'b2' directory under the XDG config path # backblaze-b2 fails to create a 'b2' directory under the XDG config path