diff options
author | 2019-03-11 02:11:16 +0100 | |
---|---|---|
committer | 2019-03-11 05:54:44 +0100 | |
commit | 47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b (patch) | |
tree | 97d998ba9a29997507d8991c56e1d9e9046ab3e5 | |
parent | Add and make use of find_missing_broken_symlinks() (diff) | |
download | eselect-rust-47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b.tar.gz eselect-rust-47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b.tar.bz2 eselect-rust-47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b.zip |
Add cleanup action
Cleanup action will make use of new find_missing_broken_symlinks() function
and should be called by ebuild during package removal.
If we detect a missing or broken symlink, we will automatically mark latest
available version as default (which will basically fix missing or broken
symlinks).
Bug: https://bugs.gentoo.org/671182
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r-- | rust.eselect.in | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/rust.eselect.in b/rust.eselect.in index d0f3361..1360dc2 100644 --- a/rust.eselect.in +++ b/rust.eselect.in @@ -177,6 +177,33 @@ set_version() { die -q "symlink list copying failed" } +### cleanup action ### +describe_cleanup() { + echo "This action is not to be called manually." +} + +do_cleanup() { + [[ -z ${@} ]] || die -q "This function does not expect any arguments" + + # Do we need to clean up? + local missing_symlinks=( $(find_missing_broken_symlinks) ) + if [[ ${#missing_symlinks[@]} -eq 0 ]]; then + echo "Nothing to clean up." + return + fi + + unset_version + + local targets=( $(find_targets) ) + + if [[ ${#targets[@]} -ne 0 ]]; then + echo "Marking the latest still installed version as default..." + do_set ${#targets[@]} + else + echo "No Rust profiles left on the system. Stale symlinks removed." + fi +} + ### list action ### describe_list() { |