symlink archive/dir/symlink -> file
exec tar czf www/archive.tar.gz archive

httpd www

# test that chezmoi reads external files from .chezmoiexternal.toml
chezmoi apply --force
cmp $HOME/.file golden/.file
[!windows] cmpmod 666 $HOME/.file

chhome home2/user

# test that chezmoi reads executable external files from .chezmoiexternal.toml
chezmoi apply --force
cmp $HOME/.file golden/.file
[!windows] cmpmod 777 $HOME/.file

chhome home3/user

# test that chezmoi reads external archives from .chezmoiexternal.yaml
chezmoi apply --force
cmp $HOME/.dir/dir/file golden/dir/file
[!windows] readlink $HOME/.dir/dir/symlink file
exists $HOME/.dir/file

chhome home4/user

# test that chezmoi reads exact external archives from .chezmoiexternal.yaml
chezmoi apply --force
cmp $HOME/.dir/dir/file golden/dir/file
[!windows] readlink $HOME/.dir/dir/symlink file
! exists $HOME/.dir/file

chhome home5/user

# test that chezmoi reads externals from subdirectories
chezmoi apply --force
cmp $HOME/.dir/subdir/dir/file golden/dir/file
[!windows] readlink $HOME/.dir/subdir/dir/symlink file

chhome home6/user

# test that .chezmoiignore applies to entries in externals
chezmoi apply --force
exists $HOME/.dir/dir/
exists $HOME/.dir/dir/file
! exists $HOME/.dir/dir/symlink

chhome home7/user

# test that .chezmoiignore applies to entire externals
chezmoi apply --force

chhome home8/user

# test that parent directories are created if needed
chezmoi apply --force
cmp $HOME/.dir1/file golden/dir/file
cmp $HOME/.dir2/dir2/file golden/dir/file
cmp $HOME/.dir3/dir3/dir3/file golden/dir/file

chhome home9/user

# test that duplicate equivalent directories are allowed
chezmoi apply --force

-- archive/dir/file --
# contents of dir/file
-- golden/.file --
# contents of .file
-- golden/dir/file --
# contents of dir/file
-- home/user/.local/share/chezmoi/.chezmoiexternal.toml --
[".file"]
    type = "file"
    url = "{{ env "HTTPD_URL" }}/.file"
-- home2/user/.local/share/chezmoi/.chezmoiexternal.toml --
[".file"]
    type = "file"
    url = "{{ env "HTTPD_URL" }}/.file"
    executable = true
-- home3/user/.dir/file --
-- home3/user/.local/share/chezmoi/.chezmoiexternal.yaml --
.dir:
    type: archive
    url: {{ env "HTTPD_URL" }}/archive.tar.gz
    stripComponents: 1
-- home4/user/.dir/file --
-- home4/user/.local/share/chezmoi/.chezmoiexternal.yaml --
.dir:
    type: archive
    url: {{ env "HTTPD_URL" }}/archive.tar.gz
    exact: true
    stripComponents: 1
-- home5/user/.local/share/chezmoi/dot_dir/.chezmoiexternal.yaml --
subdir:
    type: archive
    url: {{ env "HTTPD_URL" }}/archive.tar.gz
    exact: true
    stripComponents: 1
-- home6/user/.local/share/chezmoi/.chezmoiexternal.yaml --
.dir:
    type: archive
    url: {{ env "HTTPD_URL" }}/archive.tar.gz
    exact: true
    stripComponents: 1
-- home6/user/.local/share/chezmoi/.chezmoiignore --
.dir/dir/symlink
-- home7/user/.local/share/chezmoi/.chezmoiexternal.yaml --
.dir:
    type: archive
    url: {{ env "HTTPD_URL" }}/non-existent-archive.tar.gz
-- home7/user/.local/share/chezmoi/.chezmoiignore --
.dir
-- home8/user/.local/share/chezmoi/.chezmoiexternal.toml --
[".dir1"]
    type = "archive"
    url = "{{ env "HTTPD_URL" }}/archive.tar.gz"
    stripComponents = 2
[".dir2/dir2"]
    type = "archive"
    url = "{{ env "HTTPD_URL" }}/archive.tar.gz"
    stripComponents = 2
[".dir3/dir3/dir3"]
    type = "archive"
    url = "{{ env "HTTPD_URL" }}/archive.tar.gz"
    stripComponents = 2
-- home9/user/.local/share/chezmoi/.chezmoiexternal.toml --
[".dir"]
    type = "archive"
    url = "{{ env "HTTPD_URL" }}/archive.tar.gz"
    stripComponents = 1
-- home9/user/.local/share/chezmoi/dot_dir/file2 --
# contents of .dir/file2
-- www/.file --
# contents of .file
