From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1141743-garchives=archives.gentoo.org@lists.gentoo.org>
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 86442138350
	for <garchives@archives.gentoo.org>; Fri, 31 Jan 2020 07:36:58 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id C582BE0891;
	Fri, 31 Jan 2020 07:36:57 +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 88902E0891
	for <gentoo-commits@lists.gentoo.org>; Fri, 31 Jan 2020 07:36:57 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(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 B8FAB34E609
	for <gentoo-commits@lists.gentoo.org>; Fri, 31 Jan 2020 07:36:56 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id D7F2F10B
	for <gentoo-commits@lists.gentoo.org>; Fri, 31 Jan 2020 07:36:54 +0000 (UTC)
From: "Sergei Trofimovich" <slyfox@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sergei Trofimovich" <slyfox@gentoo.org>
Message-ID: <1580456209.9ff664072a17b88a33e78addefc10d04c12e6197.slyfox@gentoo>
Subject: [gentoo-commits] proj/crossdev:master commit in: /
X-VCS-Repository: proj/crossdev
X-VCS-Files: crossdev
X-VCS-Directories: /
X-VCS-Committer: slyfox
X-VCS-Committer-Name: Sergei Trofimovich
X-VCS-Revision: 9ff664072a17b88a33e78addefc10d04c12e6197
X-VCS-Branch: master
Date: Fri, 31 Jan 2020 07:36:54 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 4a358c88-c73d-4529-9e08-4b4f6da03bef
X-Archives-Hash: 4a199d0beb4476c42c4fb1e58b86fea2

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}"