carvel-dev / vendir

Easy way to vendor portions of git repos, github releases, helm charts, docker image contents, etc. declaratively
https://carvel.dev/vendir
Apache License 2.0
281 stars 50 forks source link

Vendir should preserve execution permissions on extract #47

Open braunsonm opened 3 years ago

braunsonm commented 3 years ago

What steps did you take:

- path: terraform.d/plugins
  contents:
  - path: carvel.dev/carvel/k14s/0.6.0
    githubRelease:
      slug: vmware-tanzu/terraform-provider-carvel
      tag: v0.6.0
      assetNames: ["terraform-provider-k14s-binaries.tgz"]
      unpackArchive:
        path: terraform-provider-k14s-binaries.tgz

vendir sync

What happened: The extracted package binaries will be set as non-executable even though in the archive they are executable.

What did you expect: The file permissions should be left alone and they should be executable.

Anything else you would like to add: This is very important for downloading of CLI tools

Environment:

cppforlife commented 3 years ago

this was an intentional design choice but i think its fair to preserve executable bit and provide a flag that disables that feature (to be used in kapp-controller for example).

aaronshurley commented 3 years ago

Thanks for submitting this. We may not get to this soon but would accept contributions :)

GrahamDumpleton commented 2 years ago

In light of changes in imgpkg to preserve permissions bits as per original intent I believe it is time that vendir got similar treatment. People use imgpkg and vendir for uses beyond just packaging up Carvel ytt resources. For example, for general application packaging/aggregation, where keeping execute bits is very important. Not having the ability to preserve execute bits limits the usefulness of the tool for use cases that original developers may not even have thought of. Tools should also ensure that group/other permissions are restored as well.

Related issues for preserving permissions (execute + restore group/others), or allowing them to be set are:

Boojapho commented 1 year ago

I would like to see this implemented. I saw that vendir supported GitHub releases and thought I could replace my bash script to keep my command line tools up to date. But, this is one of the items that make stopped me from migrating. I was attempting to download to /usr/local/bin and the entire folder's permissions were changed to 700 from 755. In addition, the binary was set to 644.

joaopapereira commented 1 year ago

Hello @Boojapho in your particular case, I do not think this issue will help you. As an example I just used wget to download vendir to my local machine and the binary bits are not preserved.

wget https://github.com/carvel-dev/vendir/releases/download/v0.33.1/vendir-darwin-amd64
--2023-04-20 09:46:00--  https://github.com/carvel-dev/vendir/releases/download/v0.33.1/vendir-darwin-amd64
Resolving github.com (github.com)... 140.82.112.4
Connecting to github.com (github.com)|140.82.112.4|:443... connected.
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20052928 (19M) [application/octet-stream]
Saving to: ‘vendir-darwin-amd64’

vendir-darwin-amd64                                        100%[========================================================================================================================================>]  19.12M  10.5MB/s    in 1.8s

2023-04-20 09:46:02 (10.5 MB/s) - ‘vendir-darwin-amd64’ saved [20052928/20052928]

$ ll vendir-darwin-amd64
-rw-r--r-- 1 joaopereira staff 20M Mar  6 10:52 vendir-darwin-amd64

I believe what you are looking for would be #148 am I correct?

GrahamDumpleton commented 1 year ago

The original example was unpacking a tar ball, but permissions of stuff inside of the tar ball were not preserved. The tar command usually always preserves permissions when unpacking so your example with wget is not necessarily the same if their script was downloading the tar ball and having to unpack it manually because of vendir not preserving permissions inside of the tarball when unpacked.