commit:     9ff664072a17b88a33e78addefc10d04c12e6197
Author:     Göktürk Yüksek <gokturk <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 31 02:56:08 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri Jan 31 07:36:49 2020 +0000
URL:        https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=9ff66407

crossdev: remove the repos.conf entry for the output overlay during uninstall

If the output overlay is completely removed during uninstall, it is
incorrect to leave behind the repos.conf file since the location
specified in the conf file points to a non-existing directory.

We scan all the conf files under ${CONFIGROOT}/repos.conf, looking for
the file that defines the output overlay and remove it if it is
managed by crossdev.

Signed-off-by: Göktürk Yüksek <gokturk <AT> gentoo.org>
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 crossdev | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/crossdev b/crossdev
index 4576e0f..12e14e3 100755
--- a/crossdev
+++ b/crossdev
@@ -580,6 +580,20 @@ uninstall() {
                        [[ ${i} -eq 2 ]] && rm -r "${CROSSDEV_OVERLAY}"
                fi
        fi
+       # Remove the repos.conf entry if the output overlay is completely 
removed
+       if [[ ! -e "${CROSSDEV_OVERLAY}" ]]; then
+               # There is no easy way to reverse map an overlay entry
+               # to a particular file under repos.conf
+               # We'll scan every conf file for a match on repo name and
+               # remove if the file is managed by crossdev
+               while IFS="" read -d $'\0' -r f ; do
+                       grep -qs "^${AUTOGEN_TAG}" "${f}" || continue
+                       if grep -qs "^\[${CROSSDEV_OVERLAY_NAME}\]$" "${f}"; 
then
+                               rm -f "${f}"
+                               break
+                       fi
+               done < <(find "${CONFIGROOT}"/repos.conf -type f -print0)
+       fi
        # crossdev stopped creating 'package.keywords' in Jan 2020
        for f in categories package.{accept_keywords,env,mask,keywords,use} 
profile/package.use.{force,mask} ; do
                f="${CONFIGROOT}/${f}"

Reply via email to