devops-works / binenv

One binary to rule them all. Manage all those pesky binaries (kubectl, helm, terraform, ...) easily.
MIT License
367 stars 44 forks source link

Implement Housekeeping features (`binenv purge`) #176

Open angrox opened 2 years ago

angrox commented 2 years ago

As a developer I want to have an easy possibility to do housekeeping on my installed binenv binaries in order to keep the storage footprint small over time.

Reason Over time the used storage of the installed binaries grow for you can easily upgrade but have no specific housekeeping option in place.

Proposed Solution Integrate a housekeeping function in the install/update and the uninstall feature:

Workaround Current solution for me is a helper script that cleans the binenv cache

leucos commented 2 years ago

Hello. I understand the need, that's an interesting feature.

However the purpose of binenv update is only to update the cache, i.e. what version of which distribution (thing) can be installed.

Also, I guess binenv uninstall "<someversion" would prove pretty useless, given we have hundreds of different binaries ranging various versions.

I suppose some kind of binenv purge --keep-last X could be a better approach I guess ?

leucos commented 2 years ago

In the meantime, binenv uninstall foo && binenv install foo does a pretty good job at cleaning up.

Or for the whole scoop:

for i in $(binenv versions | cut -f1 -d':' | grep -Ev '^(#|binenv)'); do binenv uninstall $i && binenv install $i; done

EDIT: well, the command above is not practical since we have to confirm each uninstall.

angrox commented 2 years ago

@leucos You could catch it with an expect script but still: A re-download of the software is just an ugly workaround.

Your suggestion for a purge subcommand would do the the trick, yes

leucos commented 2 years ago

@leucos You could catch it with an expect script but still: A re-download of the software is just an ugly workaround.

Sure

Your suggestion for a purge subcommand would do the the trick, yes

Quite busy on #104 currently, but will look into this afterwards.

angrox commented 2 years ago

Workaround: Small shell script for deleting everything but the latest version

#!/bin/bash

BINENV_BIN_DIR="$HOME/.binenv/binaries"

for i in "$BINENV_BIN_DIR"/*
do
  for j in $(ls -t "$i" | tail -n +2)
  do
    echo "rm -rf $i/$j"
    rm -rf "${i:?}/${j:?}"
  done
done