twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.9k stars 478 forks source link

externals fail unpack tar archive with .yaml files inside #2835

Closed stonevil closed 1 year ago

stonevil commented 1 year ago

Describe the bug

externals fail unpack tar archive with .yaml files inside

To reproduce

Example of the .chezmoiexternal.toml

[".local/lima"] type = "archive" exact = true refreshPeriod = "168h" url = "https://github.com/lima-vm/lima/releases/download/v{{ .tools.limactl.version }}/lima-{{ .tools.limactl.version }}-{{ .chezmoi.os | title }}-{{ .arch.opt2 }}.tar.gz"

Expected behavior

tar file should be unpacked at configured directory.

Output of command with the --verbose flag

chezmoi apply --verbose
chezmoi: .local/lima: https://github.com/lima-vm/lima/releases/download/v0.15.0/lima-0.15.0-Linux-x86_64.tar.gz: ./share/lima/examples/oraclelinux.yaml: unsupported typeflag '1

Same issue on macOS Ventura, Fedora 37, Alpine Edge.

Output of chezmoi doctor

chezmoi doctor
RESULT    CHECK                MESSAGE
ok        version              v2.31.1, commit b53467c8cc56e46ef848624193b753c927b89689, built at 2023-03-02T00:10:57Z, built by goreleaser
ok        latest-version       v2.31.1
ok        os-arch              linux/amd64 (Fedora Linux 37 (Container Image))
ok        uname                Linux ec5743a62351 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
ok        go-version           go1.20.1 (gc)
ok        executable           /usr/bin/chezmoi
ok        upgrade-method       upgrade-package
ok        config-file          ~/.config/chezmoi/chezmoi.toml, last modified 2023-03-08T23:46:34Z
error     source-dir           ~/.local/share/chezmoi is a git working tree (error)
ok        suspicious-entries   no suspicious entries
error     working-tree         ~/.local/share/chezmoi is a git working tree (error)
ok        dest-dir             ~ is a directory
ok        umask                022
ok        cd-command           found /bin/bash
ok        cd-args              /bin/bash
info      diff-command         not set
ok        edit-command         found /usr/bin/vi
ok        edit-args            /usr/bin/vi
warning   git-command          git not found in $PATH
warning   merge-command        vimdiff not found in $PATH
ok        shell-command        found /bin/bash
ok        shell-args           /bin/bash
info      age-command          age not found in $PATH
ok        gpg-command          found /usr/bin/gpg, version 2.3.8
info      pinentry-command     not set
info      1password-command    op not found in $PATH
info      bitwarden-command    bw not found in $PATH
info      gopass-command       gopass not found in $PATH
info      keepassxc-command    keepassxc-cli not found in $PATH
info      keepassxc-db         not set
info      keeper-command       keeper not found in $PATH
info      lastpass-command     lpass not found in $PATH
info      pass-command         pass not found in $PATH
info      passhole-command     ph not found in $PATH
info      vault-command        vault not found in $PATH
info      secret-command       not set

Additional context

Looks like chezmoi trying to interpret yaml file inside tar.gz like golang template.

tar archive structure:

tar -tf lima-0.15.0-Linux-x86_64.tar.gz
./
./bin/
./bin/kubectl.lima
./bin/limactl
./bin/lima
./bin/apptainer.lima
./bin/docker.lima
./bin/nerdctl.lima
./bin/podman.lima
./share/
./share/lima/
./share/lima/lima-guestagent.Linux-riscv64
./share/lima/lima-guestagent.Linux-aarch64
./share/lima/lima-guestagent.Linux-x86_64
./share/lima/examples/
./share/lima/examples/rocky-8.yaml
./share/lima/examples/README.md
./share/lima/examples/fedora.yaml
./share/lima/examples/k3s.yaml
./share/lima/examples/experimental/
./share/lima/examples/experimental/9p.yaml
./share/lima/examples/experimental/vz.yaml
./share/lima/examples/experimental/opensuse-tumbleweed.yaml
./share/lima/examples/experimental/riscv64.yaml
./share/lima/examples/oraclelinux-9.yaml
./share/lima/examples/almalinux-8.yaml
./share/lima/examples/buildkit.yaml
./share/lima/examples/debian.yaml
./share/lima/examples/opensuse.yaml
./share/lima/examples/centos-stream-8.yaml
./share/lima/examples/alpine.yaml
./share/lima/examples/apptainer.yaml
./share/lima/examples/nomad.yaml
./share/lima/examples/almalinux.yaml
./share/lima/examples/default.yaml
./share/lima/examples/deprecated/
./share/lima/examples/deprecated/centos-7.yaml
./share/lima/examples/podman.yaml
./share/lima/examples/vmnet.yaml
./share/lima/examples/rocky-9.yaml
./share/lima/examples/centos-stream.yaml
./share/lima/examples/oraclelinux.yaml
./share/lima/examples/rocky.yaml
./share/lima/examples/k8s.yaml
./share/lima/examples/ubuntu-lts.yaml
./share/lima/examples/docker.yaml
./share/lima/examples/ubuntu.yaml
./share/lima/examples/apptainer-rootful.yaml
./share/lima/examples/docker-rootful.yaml
./share/lima/examples/podman-rootful.yaml
./share/lima/examples/oraclelinux-8.yaml
./share/lima/examples/archlinux.yaml
./share/lima/examples/faasd.yaml
./share/lima/examples/centos-stream-9.yaml
./share/lima/examples/almalinux-9.yaml
./share/doc/
./share/doc/lima/
./share/doc/lima/README.md
./share/doc/lima/MAINTAINERS.md
./share/doc/lima/docs/
./share/doc/lima/docs/multi-arch.md
./share/doc/lima/docs/internal.md
./share/doc/lima/docs/mount.md
./share/doc/lima/docs/images/
./share/doc/lima/docs/images/lima-sequence-diagram.png
./share/doc/lima/docs/images/lima-logo-01.svg
./share/doc/lima/docs/images/lima-sequence-diagram.puml
./share/doc/lima/docs/network.md
./share/doc/lima/docs/talks.md
./share/doc/lima/docs/experimental.md
./share/doc/lima/docs/deprecated.md
./share/doc/lima/docs/vmtype.md
./share/doc/lima/VERSION
./share/doc/lima/ROADMAP.md
./share/doc/lima/README.ja.md
./share/doc/lima/README.zh.md
./share/doc/lima/LICENSE
./share/doc/lima/examples
./share/doc/lima/SECURITY.md

oraclelinux.yaml contant

cat lima-0.15.0-Linux-x86_64/share/lima/examples/oraclelinux.yaml
# This example requires Lima v0.11.3 or later.
# Oracle image licence: https://www.oracle.com/downloads/licenses/oracle-linux-license.html
# Image source: https://yum.oracle.com/oracle-linux-templates.html

images:
- location: "https://yum.oracle.com/templates/OracleLinux/OL9/u1/x86_64/OL9U1_x86_64-kvm-b158.qcow"
  arch: "x86_64"
  digest: "sha256:ca655beba34038349827c5ab365df4f7936a7f6226a04d0452bbe4430f4d6658"
- location: "https://yum.oracle.com/templates/OracleLinux/OL9/u1/aarch64/OL9U1_aarch64-kvm-b13.qcow"
  arch: "aarch64"
  digest: "sha256:a71abfd60713cd5c37443287dd267efd30f1715f8db075e0377b43e2d6ec44cf"
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
firmware:
  # Oracle Linux 9 still requires legacyBIOS, while AlmaLinux 9 and Rocky Linux 9 do not.
  legacyBIOS: true
twpayne commented 1 year ago

Looks like chezmoi trying to interpret yaml file inside tar.gz like golang template.

No, the problem is in the error message:

chezmoi: .local/lima: https://github.com/lima-vm/lima/releases/download/v0.15.0/lima-0.15.0-Linux-x86_64.tar.gz: ./share/lima/examples/oraclelinux.yaml: unsupported typeflag '1'

According to Go's documentation, typeflag 1 in tar archives are hard links. You can verify this with tar:

$ tar tzvf lima-0.15.0-Linux-x86_64.tar.gz | grep ^h
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/oraclelinux.yaml link to ./share/lima/examples/oraclelinux-9.yaml
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/rocky.yaml link to ./share/lima/examples/rocky-9.yaml
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/centos-stream-9.yaml link to ./share/lima/examples/centos-stream.yaml
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/almalinux-9.yaml link to ./share/lima/examples/almalinux.yaml
~/src/github.com/twpayne/chezmoi master *5 ?1                                                                                             

chezmoi does not support hardlinks.

Possible workarounds:

stonevil commented 1 year ago

Looks like chezmoi trying to interpret yaml file inside tar.gz like golang template.

No, the problem is in the error message:

chezmoi: .local/lima: https://github.com/lima-vm/lima/releases/download/v0.15.0/lima-0.15.0-Linux-x86_64.tar.gz: ./share/lima/examples/oraclelinux.yaml: unsupported typeflag '1'

According to Go's documentation, typeflag 1 in tar archives are hard links. You can verify this with tar:

$ tar tzvf lima-0.15.0-Linux-x86_64.tar.gz | grep ^h
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/oraclelinux.yaml link to ./share/lima/examples/oraclelinux-9.yaml
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/rocky.yaml link to ./share/lima/examples/rocky-9.yaml
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/centos-stream-9.yaml link to ./share/lima/examples/centos-stream.yaml
hrw-r--r-- runner/docker        0 2023-02-28 13:25 ./share/lima/examples/almalinux-9.yaml link to ./share/lima/examples/almalinux.yaml
~/src/github.com/twpayne/chezmoi master *5 ?1                                                                                             

chezmoi does not support hardlinks.

Possible workarounds:

  • Either, unpack the tarball with tar, rather than using a chezmoi external,
  • Or, contact the developers of lima-vm/lima and ask them to release tarballs with symbolic links or copies of the files instead of hardlinks.

Oh, ok. Thanks.