File etc-update-opensuse.patch of Package etc-update

Index: portage-portage-2.3.31/bin/etc-update
===================================================================
--- portage-portage-2.3.31.orig/bin/etc-update
+++ portage-portage-2.3.31/bin/etc-update
@@ -32,10 +32,11 @@ get_config() {
 		"${PORTAGE_CONFIGROOT}"etc/etc-update.conf)
 }
 
-OS_RELEASE_ID=$(cat /etc/os-release 2>/dev/null | grep '^ID=' | cut -d'=' -f2)
+OS_RELEASE_ID=$(cat /etc/os-release 2>/dev/null | grep '^ID=' | cut -d'=' -f2 | sed -e 's/"//g')
 
 case $OS_RELEASE_ID in
-	suse|opensuse) OS_FAMILY='suse' NEW_EXT='rpmnew';;
+	suse|opensuse|opensuse-leap|opensuse-tumbleweed) OS_FAMILY='rpm' ;;
+	fedora|rhel) OS_FAMILY='rpm' ;;
 	arch|manjaro|antergos) OS_FAMILY='arch' NEW_EXT='pacnew';;
 	*) OS_FAMILY='gentoo' ;;
 esac
@@ -53,7 +54,7 @@ if [[ $OS_FAMILY == 'gentoo' ]]; then
 	get_live_file() {
 		echo "${rpath}/${rfile:10}"
 	}
-elif [[ $OS_FAMILY == 'suse' ]] || [[ $OS_FAMILY == 'arch' ]]; then
+elif [[ $OS_FAMILY == 'arch' ]]; then
 	get_basename() {
 		printf -- '%s\n' "${1%.${NEW_EXT}}"
 	}
@@ -61,11 +62,25 @@ elif [[ $OS_FAMILY == 'suse' ]] || [[ $O
 		printf -- '%s\n' "${1}.${NEW_EXT}"
 	}
 	get_scan_regexp() {
-		echo "s:\(^.*/\)\(.*\)\(\.rpmnew\):\1\2\3$b\1$b\3$b\2:"
+		echo "s:\(^.*/\)\(.*\)\(\.${NEW_EXT}\):\1\2\3$b\1$b\3$b\2:"
 	}
 	get_live_file() {
 		printf -- '%s\n' "${cfg_file%.${NEW_EXT}}"
 	}
+# In rpm we have rpmsave, rpmorig, and rpmnew.
+elif [[ $OS_FAMILY == 'rpm' ]]; then
+	get_basename() {
+		printf -- '%s\n' "${1}" |sed -e 's/\.rpmsave$//' -e 's/\.rpmnew$//' -e 's/\.rpmorig$//'
+	}
+	get_basename_find_opt() {
+		printf -- '%s\n' "${1}.rpm???*"
+	}
+	get_scan_regexp() {
+		echo "s:\(^.*/\)\(.*\)\(\.\(rpmnew|rpmsave|rpmorig\)\):\1\2\3$b\1$b\3$b\2:"
+	}
+	get_live_file() {
+		printf -- '%s\n' "${cfg_file}" |sed -e 's/\.rpmsave$//' -e 's/\.rpmnew$//' -e 's/\.rpmorig$//'
+	}
 fi
 
 cmd_var_is_valid() {
@@ -557,7 +572,7 @@ do_merge() {
 
 	local file="${1}"
 	local ofile="${2}"
-	local mfile="${TMP}/${2}.merged"
+	local mfile="${TMP}/${2#/}.merged"
 	local -i my_input=0
 
 	if [[ -L ${file} && -L ${ofile} ]] ; then
@@ -754,10 +769,10 @@ while [[ -n $1 ]] ; do
 done
 ${SET_X} && set -x
 
-if [[ $OS_FAMILY == 'suse' ]]; then
+if [[ $OS_FAMILY == 'rpm' ]]; then
 	PORTAGE_CONFIGROOT='/'
 	PORTAGE_TMPDIR='/tmp'
-	CONFIG_PROTECT='/etc'
+	CONFIG_PROTECT='/etc /usr/share'
 	CONFIG_PROTECT_MASK=''
 	[[ -f /etc/sysconfig/etc-update ]] && . /etc/sysconfig/etc-update
 elif [[ $OS_FAMILY == 'arch' ]]; then
openSUSE Build Service is sponsored by