binenv icon indicating copy to clipboard operation
binenv copied to clipboard

Implement Housekeeping features (`binenv purge`)

Open angrox opened this issue 4 years ago • 5 comments

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:

  • binenv update --keep-only-latest
  • binenv uninstall "<1.0.0" (delete everything before version 1.0.0, respectivly < > <= >=)

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

angrox avatar Nov 17 '21 08:11 angrox

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 avatar Nov 17 '21 15:11 leucos

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.

leucos avatar Nov 17 '21 22:11 leucos

@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

angrox avatar Nov 18 '21 11:11 angrox

@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.

leucos avatar Nov 18 '21 11:11 leucos

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

angrox avatar Apr 01 '22 06:04 angrox