go-passbolt-cli icon indicating copy to clipboard operation
go-passbolt-cli copied to clipboard

[feature] self upgrading release binary

Open kskarthik opened this issue 1 year ago • 24 comments

The idea is to have similar feature to deno upgrade & bun upgrade in which the user can upgrade the existing binary using a cli flag.

This will be a useful feature for many users whose distributions which always do not ship with latest versions of the cli

I wish to work on this patch if we can agree on implementing such feature.

kskarthik avatar Apr 07 '24 06:04 kskarthik

I do not know of any distributions that ships go-passbolt-cli in their repositories, which is why i always planned to provide my own deb and rpm repositories for easy updates but got stalled due to my limited time and low demand.

Would having generic deb and rpm repositories solve your Issue? I think building an Updater from Scratch would be quite complex since it would also need to handle things like man pages and shell completions. The security implications would also have to be considered.

speatzle avatar Apr 07 '24 15:04 speatzle

i have initially found this lib which can do the heavy lifing (also includes security aspects like checksum verification) https://github.com/creativeprojects/go-selfupdate

Would having generic deb and rpm repositories solve your Issue?

yes, it would. But it also implies user should add custom repos to their system

kskarthik avatar Apr 07 '24 17:04 kskarthik

I don't see how that library can update additional files like man pages or shell completions (maybe i missed it?). Also if anything goes wrong and can't start it anymore there is no possibility to downgrade again. I generally dislike the Windows Style Self updating.

I don't see adding custom repositories as such a big deal (you also have to do that if you are installing the passbolt server). go-passbolt-cli Simply is not big enough to be included in distros.

I tried to avoid having to add custom repos by looking into packaging the CLI as a Flatpak instead but their CLI Support has "Issues" we would have to work around https://github.com/flatpak/flatpak/issues/1188 .

speatzle avatar Apr 08 '24 12:04 speatzle

I don't see how that library can update additional files like man pages or shell completions (maybe i missed it?). Also if anything goes wrong and can't start it anymore there is no possibility to downgrade again. I generally dislike the Windows Style Self updating.

Yes, The lib i shared does not handle man pages & shell completions.

I tried to avoid having to add custom repos by looking into packaging the CLI as a Flatpak instead but their CLI Support has "Issues" we would have to work around https://github.com/flatpak/flatpak/issues/1188 .

yes, flatpaks are not ideal for CLIs. We have to add an alias & no support for man pages AFAIK

kskarthik avatar Apr 08 '24 16:04 kskarthik

In the meantime, go-passbolt-cli has been added as a nixpkg https://search.nixos.org/packages?channel=24.05&show=go-passbolt-cli&from=0&size=50&sort=relevance&type=packages&query=go-passbolt-cli

speatzle avatar Jun 06 '24 13:06 speatzle

I have also packaged for opensuse tumbleweed https://build.opensuse.org/request/show/1181068

It takes a few days to land in the main repositories!

kskarthik avatar Jun 16 '24 13:06 kskarthik

I have also packaged for opensuse tumbleweed https://build.opensuse.org/request/show/1181068

Cool, i will add that to the Readme once it has been released

speatzle avatar Jun 16 '24 20:06 speatzle

Sure, i will let you know

kskarthik avatar Jun 17 '24 05:06 kskarthik

@speatzle Now accepted to opensuse tumbleweed! https://build.opensuse.org/package/show/openSUSE:Factory/go-passbolt-cli

url: https://software.opensuse.org/package/go-passbolt-cli

kskarthik avatar Jul 01 '24 10:07 kskarthik

It might also reflect here https://repology.org/project/go:passbolt-cli/versions shortly

kskarthik avatar Jul 01 '24 16:07 kskarthik

Cool, i will give it a spin this weekend.

speatzle avatar Jul 02 '24 09:07 speatzle

btw is this project still community driven or made official ? since i set the disclaimer in pkg info as well

❯ zypper info go-passbolt-cli
Loading repository data...
Reading installed packages...


Information for package go-passbolt-cli:
----------------------------------------
Repository     : Main Repository (OSS)
Name           : go-passbolt-cli
Version        : 0.3.1-1.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 18.5 MiB
Installed      : No
Status         : not installed
Source package : go-passbolt-cli-0.3.1-1.1.src
Upstream URL   : https://github.com/passbolt/go-passbolt-cli
Summary        : A CLI tool to interact with Passbolt
Description    :
    This package provides a CLI tool to interact with Passbolt, An Open
    Source Password Manager for Teams

    Passbolt Website: https://www.passbolt.com/

    This project is community driven and not associated with Passbolt
    SA

kskarthik avatar Jul 04 '24 09:07 kskarthik

Yes, this Project is still Community Driven.

speatzle avatar Jul 04 '24 12:07 speatzle

Hey @kskarthik Sorry for the delay. I finally managed to setup a tumbleweed VM (the first few attempts ended in emergency mode due to broken virtio drivers...) and Test the Package.

It Seems to work well but both shell completions and man pages seem to be missing making it hard to use, could you add those to the package?

You can see how to generate them here: https://github.com/passbolt/go-passbolt-cli/blob/main/.github/workflows/.release.yml

speatzle avatar Jul 19 '24 13:07 speatzle

Sure, I will

kskarthik avatar Jul 19 '24 16:07 kskarthik

just added shell completions & man page support https://build.opensuse.org/package/rdiff/security:privacy/go-passbolt-cli?opackage=go-passbolt-cli&oproject=openSUSE%3AFactory&rev=4

Will reflect in tumbleweed in a few days

kskarthik avatar Jul 20 '24 12:07 kskarthik

I upgraded the package and the man pages work now, it also installed go-passbolt-cli-bash-completions during the upgrade but i can't get the completions to work. Do i need to enable them manually? image

speatzle avatar Jul 24 '24 09:07 speatzle

do you have the bash-completion package installed ?

zypper info bash-completion ?

kskarthik avatar Jul 24 '24 10:07 kskarthik

Yes, it was installed automatically:

slt@localhost:~> zypper search passbolt
Loading repository data...
Reading installed packages...

S  | Name                            | Summary                              | Type
---+---------------------------------+--------------------------------------+--------
i+ | go-passbolt-cli                 | A CLI tool to interact with Passbolt | package
i  | go-passbolt-cli-bash-completion | Bash Completion for go-passbolt-cli  | package
   | go-passbolt-cli-fish-completion | Fish Completion for go-passbolt-cli  | package
   | go-passbolt-cli-zsh-completion  | ZSH Completion for go-passbolt-cli   | package
slt@localhost:~> zypper info bash-completion
Loading repository data...
Reading installed packages...


Information for package bash-completion:
----------------------------------------
Repository     : Main Repository (OSS)
Name           : bash-completion
Version        : 2.12.0-2.2
Arch           : noarch
Vendor         : openSUSE
Installed Size : 1003.5 KiB
Installed      : Yes (automatically)
Status         : up-to-date
Source package : bash-completion-2.12.0-2.2.src
Upstream URL   : https://github.com/scop/bash-completion/
Summary        : Programmable Completion for Bash
Description    : 




    bash-completion is a collection of shell functions that take advantage
    of the programmable completion feature of Bash 2.04 and later.

slt@localhost:~> zypper info go-passbolt-cli-bash-completion
Loading repository data...
Reading installed packages...


Information for package go-passbolt-cli-bash-completion:
--------------------------------------------------------
Repository     : Main Repository (OSS)
Name           : go-passbolt-cli-bash-completion
Version        : 0.3.1-2.1
Arch           : noarch
Vendor         : openSUSE
Installed Size : 69.1 KiB
Installed      : Yes (automatically)
Status         : up-to-date
Source package : go-passbolt-cli-0.3.1-2.1.src
Upstream URL   : https://github.com/passbolt/go-passbolt-cli
Summary        : Bash Completion for go-passbolt-cli
Description    : 
    The official bash completion script for go-passbolt-cli, generated during the build.

speatzle avatar Jul 24 '24 10:07 speatzle

ok, https://build.opensuse.org/projects/openSUSE:Factory/packages/go-passbolt-cli/files/go-passbolt-cli.spec?expand=1 L94 is where the bash completions go

kskarthik avatar Jul 24 '24 13:07 kskarthik

i can see the bash completions listed. do you find any anomaly?

usr/share/man/man1/passbolt.1.gz
/usr/share/bash-completion/completions/go-passbolt-cli

kskarthik avatar Jul 25 '24 05:07 kskarthik

should the completions match the binary name ?

kskarthik avatar Jul 25 '24 05:07 kskarthik

Moving to file to match the binary name and restarting bash fixed it for me

slt@localhost:~> sudo mv /usr/share/bash-completion/completions/go-passbolt-cli  /usr/share/bash-completion/completions/passbolt
[sudo] password for root: 
slt@localhost:~> bash
slt@localhost:~> passbolt 
configure  create     delete     export     get        help       list       move       share      update     verify     
slt@localhost:~> passbolt list 
folder    group     resource  user      
slt@localhost:~> passbolt list resource 

speatzle avatar Jul 25 '24 12:07 speatzle

ok, i will correct it upstream too

kskarthik avatar Jul 25 '24 15:07 kskarthik