From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 212AA138336 for ; Mon, 11 Mar 2019 05:02:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 198ECE0C7C; Mon, 11 Mar 2019 05:02:49 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E2221E0C78 for ; Mon, 11 Mar 2019 05:02:48 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CDFC9335D3E for ; Mon, 11 Mar 2019 05:02:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id F3149568 for ; Mon, 11 Mar 2019 05:02:44 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1552280084.47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b.whissi@gentoo> Subject: [gentoo-commits] proj/eselect-rust:master commit in: / X-VCS-Repository: proj/eselect-rust X-VCS-Files: rust.eselect.in X-VCS-Directories: / X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b X-VCS-Branch: master Date: Mon, 11 Mar 2019 05:02:44 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2640c834-8e4c-4528-8941-02d028dedade X-Archives-Hash: cfa3bcb181dcf4c535431e51d17824d3 commit: 47ad9a4eeb74a053d1fbc854fca7d13c96fb1a5b Author: Thomas Deutschmann gentoo org> AuthorDate: Mon Mar 11 01:11:16 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Mon Mar 11 04:54:44 2019 +0000 URL: https://gitweb.gentoo.org/proj/eselect-rust.git/commit/?id=47ad9a4e 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 gentoo.org> rust.eselect.in | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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() {