From ce10c02a11c3727abcbcfaadf85d2edc1e91b7b2 Mon Sep 17 00:00:00 2001
From: Vitaly Lipatov <lav@etersoft.ru>
Date: Tue, 18 Feb 2020 22:25:52 +0300
Subject: [PATCH] epm repofix: replace sources.list only on ALT

---
 bin/epm-check   |  3 +++
 bin/epm-repofix | 30 +++++++++++++-----------------
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/bin/epm-check b/bin/epm-check
index 36e8c5e8..a4179ae8 100644
--- a/bin/epm-check
+++ b/bin/epm-check
@@ -74,6 +74,9 @@ case $PMTYPE in
 	homebrew)
 		docmd brew doctor
 		;;
+	xbps)
+		sudocmd xbps-pkgdb -a
+		;;
 	*)
 		fatal "Have no suitable command for $PMTYPE"
 		;;
diff --git a/bin/epm-repofix b/bin/epm-repofix
index 53d15679..91c490cb 100644
--- a/bin/epm-repofix
+++ b/bin/epm-repofix
@@ -46,7 +46,7 @@ __try_fix_apt_source_list()
 	fi
 }
 
-__fix_apt_sources_list()
+__fix_alt_sources_list()
 {
 	# for beauty spaces
 	local SUBST_ALT_RULE='s!^(.*)[/ ](ALTLinux|LINUX\@Etersoft)[/ ]*(Sisyphus|p8[/ ]branch|p7[/ ]branch|t7[/ ]branch|c7[/ ]branch|p6[/ ]branch|t6[/ ]branch)[/ ](x86_64|i586|x86_64-i586|noarch) !\1 \2/\3/\4 !gi'
@@ -77,26 +77,22 @@ epm_repofix()
 
 [ -z "$pkg_filenames" ] || fatal "No arguments are allowed here"
 
-case $PMTYPE in
-	apt-rpm)
+case $DISTRNAME in
+	ALTLinux)
 		assure_exists apt-repo
 		[ -n "$quiet" ] || docmd apt-repo list
-		__fix_apt_sources_list /etc/apt/sources.list
-		__fix_apt_sources_list /etc/apt/sources.list.d/*.list
+		__fix_alt_sources_list /etc/apt/sources.list
+		__fix_alt_sources_list /etc/apt/sources.list.d/*.list
 		docmd apt-repo list
-		# FIXME: what the best place?
-		# rebuild rpm database
-		#sudocmd rm -fv /var/lib/rpm/__db*
-		#sudocmd rpm --rebuilddb
-		;;
-	yum-rpm|dnf-rpm)
-		# FIXME: what the best place?
-		#sudocmd rm -fv /var/lib/rpm/__db*
-		#sudocmd rpm --rebuilddb
-		;;
-	xbps)
-		sudocmd xbps-pkgdb -a
+		return
 		;;
+esac
+
+case $PMTYPE in
+#	apt-rpm)
+#		;;
+#	yum-rpm|dnf-rpm)
+#		;;
 	*)
 		fatal "Have no suitable command for $PMTYPE"
 		;;
-- 
2.24.1