twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.

Home Page:https://www.chezmoi.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support .bz2 for external archives

goarano opened this issue Β· comments

commented

First of all, thank you so much for this project.
I use it on a daily basis and it has improved my workflow a great deal 😊

Is your feature request related to a problem? Please describe.

There are certain external projects that publish their releases inside a bzip2 (without tar). A popular example is Autorestic. Currently, there is no native support to add such projects as external files, the format is not detected:

chezmoi: unknown archive format

Describe the solution you'd like

I would like something akin to this to work:

{{ $autoresticVersion := "1.8.2" -}}
[".local/bin/autorestic"]
    type = "archive-file"
    url = "https://github.com/cupcakearmy/autorestic/releases/download/v{{ $autoresticVersion }}/autorestic_{{ $autoresticVersion }}_{{ .chezmoi.os }}_{{ .chezmoi.arch }}.bz2"
    path = "autorestic_{{ $autoresticVersion }}_{{ .chezmoi.os }}_{{ .chezmoi.arch }}"
    executable = true

Describe alternatives you've considered

I am currently using the following configuration with a custom filter. This works, however it is dependent on the bzip2 package being preinstalled onto the system, which was not the case in a recent fresh Debian 12 installation. It would be great to eliminate this dependency by introducing native bzip2 support.

{{ $autoresticVersion := "1.8.2" -}}
[".local/bin/autorestic"]
    type = "file"
    url = "https://github.com/cupcakearmy/autorestic/releases/download/v{{ $autoresticVersion }}/autorestic_{{ $autoresticVersion }}_{{ .chezmoi.os }}_{{ .chezmoi.arch }}.bz2"
    executable = true
    filter.command = "bzip2"
    filter.args = ["-d"]

Thanks for the kind words! This is a great idea. Implemented in #3854.

With this PR you can do:

{{ $autoresticVersion := "1.8.2" -}}
[".local/bin/autorestic"]
    type = "file"
    url = "https://github.com/cupcakearmy/autorestic/releases/download/v{{ $autoresticVersion }}/autorestic_{{ $autoresticVersion }}_{{ .chezmoi.os }}_{{ .chezmoi.arch }}.bz2"
    decompress = "bzip2" # <-- tell chezmoi to decompress the data received
    executable = true

Note that decompression is explicitly opt-in with the decompress field for backwards compatibility.

commented

Wow, you are crazy fast, thank you so much! :)