Skip to content

Refactor dep binary approach#281

Open
stefanvanburen wants to merge 2 commits intomainfrom
svanburen/refactor-dep-binary-pattern
Open

Refactor dep binary approach#281
stefanvanburen wants to merge 2 commits intomainfrom
svanburen/refactor-dep-binary-pattern

Conversation

@stefanvanburen
Copy link
Member

Our current approach with these deps is that we download the binary directly to $CACHE_BIN/<binary>, and then touch an associated empty file at $CACHE_VERSIONS/<binary>/<version>. This is annoying when you want to wipe away an existing binary to get a new version; you ought to be able to rm (which <binary>), but you can't, because you also have to remove the version.

This changes the approach to what we've done in some internal projects, where instead we create a $CACHE_VERSIONS/<binary>/<binary>-<version> file that gets symlinked in to $CACHE_BIN. You can now wipe away the binary and always get the version back in place:

$ which golangci-lint
/Users/stefanvanburen/.cache/makego/Darwin/arm64/bin/golangci-lint

$ rm (which golangci-lint) # remove the linked binary

$ make dockerdeps # relinks the binary
ln -sf /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0 /Users/stefanvanburen/.cache/makego/Darwin/arm64/bin/golangci-lint

$ rm (which golangci-lint) # remove the linked binary

$ rm /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0 # remove the versioned binary

$ make dockerdeps # re-downloads the binary and relinks the version
curl -fsSL -o /var/folders/q9/562j68913xs71bhqdrqh8drh0000gn/T/tmp.UMVVIYlet2/golangci-lint.tar.gz \
                https://github.com/golangci/golangci-lint/releases/download/v2.9.0/golangci-lint-2.9.0-darwin-arm64.tar.gz
cd /var/folders/q9/562j68913xs71bhqdrqh8drh0000gn/T/tmp.UMVVIYlet2; tar zxf golangci-lint.tar.gz --strip-components 1 && mv golangci-lint /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0
ln -sf /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0 /Users/stefanvanburen/.cache/makego/Darwin/arm64/bin/golangci-lint

Inspired by @pkwarren.

Our current approach with these deps is that we download the binary
directly to `$CACHE_BIN/<binary>`, and then touch an associated empty
file at `$CACHE_VERSIONS/<binary>/<version>`. This is annoying when you
want to wipe away an existing binary to get a new version; you ought to
be able to `rm (which <binary>)`, but you can't, because you also have
to remove the version.

This changes the approach to what we've done in some internal projects,
where instead we create a `$CACHE_VERSIONS/<binary>/<binary>-<version>`
file that gets symlinked in to `$CACHE_BIN`. You can now wipe away the
binary and always get the version back in place:

```console
$ which golangci-lint
/Users/stefanvanburen/.cache/makego/Darwin/arm64/bin/golangci-lint

$ rm (which golangci-lint) # remove the linked binary

$ make dockerdeps # relinks the binary
ln -sf /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0 /Users/stefanvanburen/.cache/makego/Darwin/arm64/bin/golangci-lint

$ rm (which golangci-lint) # remove the linked binary

$ rm /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0 # remove the versioned binary

$ make dockerdeps # re-downloads the binary and relinks the version
curl -fsSL -o /var/folders/q9/562j68913xs71bhqdrqh8drh0000gn/T/tmp.UMVVIYlet2/golangci-lint.tar.gz \
                https://github.com/golangci/golangci-lint/releases/download/v2.9.0/golangci-lint-2.9.0-darwin-arm64.tar.gz
cd /var/folders/q9/562j68913xs71bhqdrqh8drh0000gn/T/tmp.UMVVIYlet2; tar zxf golangci-lint.tar.gz --strip-components 1 && mv golangci-lint /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0
ln -sf /Users/stefanvanburen/.cache/makego/Darwin/arm64/versions/golangci-lint/golangci-lint-v2.9.0 /Users/stefanvanburen/.cache/makego/Darwin/arm64/bin/golangci-lint
```

Inspired by @pkwarren.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant