Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions bin/etc-update
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@ get_config() {
"${PORTAGE_CONFIGROOT}"etc/etc-update.conf)
}

OS_RELEASE_POSSIBLE_IDS=$(source /etc/os-release >/dev/null 2>&1; echo ":${ID}:${ID_LIKE//[[:space:]]/:}:")

case ${OS_RELEASE_POSSIBLE_IDS} in
*:suse:*|*:opensuse:*|*:opensuse-tumbleweed:*) OS_FAMILY='rpm';;
*:fedora:*|*:rhel:*) OS_FAMILY='rpm';;
*:arch:*) OS_FAMILY='arch' NEW_EXT='pacnew';;
*) OS_FAMILY='gentoo';;
esac
# Allow overriding the detected os family using an environment variable.
# The primary use is for the CI runner to force a specific behaviour for tests.
if [[ -n ${ETC_UPDATE_OS_FAMILY} ]]; then
OS_FAMILY="${ETC_UPDATE_OS_FAMILY}"
else
OS_RELEASE_POSSIBLE_IDS=$(source /etc/os-release >/dev/null 2>&1; echo ":${ID}:${ID_LIKE//[[:space:]]/:}:")

case ${OS_RELEASE_POSSIBLE_IDS} in
*:suse:*|*:opensuse:*|*:opensuse-tumbleweed:*) OS_FAMILY='rpm';;
*:fedora:*|*:rhel:*) OS_FAMILY='rpm';;
*:debian:*|*:ubuntu:*) OS_FAMILY='dpkg';;
*:arch:*) OS_FAMILY='arch' NEW_EXT='pacnew';;
*) OS_FAMILY='gentoo';;
esac
fi

if [[ ${OS_FAMILY} == 'gentoo' ]]; then
get_basename() {
Expand Down Expand Up @@ -83,6 +90,20 @@ elif [[ ${OS_FAMILY} == 'rpm' ]]; then
get_live_file() {
printf -- '%s\n' "${cfg_file}" |sed -e 's/\.rpmsave$//' -e 's/\.rpmnew$//' -e 's/\.rpmorig$//'
}
# In dpkg we have dpkg-old, dpkg-dist, dpkg-new.
elif [[ ${OS_FAMILY} == 'dpkg' ]]; then
get_basename() {
printf -- '%s\n' "${1}" |sed -e 's/\.dpkg-old$//' -e 's/\.dpkg-new$//' -e 's/\.dpkg-dist$//'
}
get_basename_find_opt() {
printf -- '%s\n' "${1}.dpkg-???*"
}
get_scan_regexp() {
echo "s:\(^.*/\)\(.*\)\(\.\(dpkg-old|dpkg-new|dpkg-dist\)\):\1\2\3$b\1$b\3$b\2:"
}
get_live_file() {
printf -- '%s\n' "${cfg_file}" |sed -e 's/\.dpkg-old$//' -e 's/\.dpkg-new$//' -e 's/\.dpkg-dist$//'
}
fi

cmd_var_is_valid() {
Expand Down Expand Up @@ -784,6 +805,12 @@ if [[ ${OS_FAMILY} == 'rpm' ]]; then
CONFIG_PROTECT='/etc /usr/share'
CONFIG_PROTECT_MASK=''
[[ -f /etc/sysconfig/etc-update ]] && . /etc/sysconfig/etc-update
elif [[ ${OS_FAMILY} == 'dpkg' ]]; then
PORTAGE_CONFIGROOT='/'
PORTAGE_TMPDIR='/tmp'
CONFIG_PROTECT='/etc /usr/share'
CONFIG_PROTECT_MASK=''
[[ -f /etc/default/etc-update ]] && . /etc/default/etc-update
elif [[ ${OS_FAMILY} == 'arch' ]]; then
PORTAGE_CONFIGROOT='/'
PORTAGE_TMPDIR='/tmp'
Expand Down
1 change: 1 addition & 0 deletions lib/portage/tests/emerge/test_config_protect.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def updated_config_files(count):
"DISTDIR": distdir,
"EMERGE_DEFAULT_OPTS": "-v",
"EMERGE_WARNING_DELAY": "0",
"ETC_UPDATE_OS_FAMILY": "gentoo",
"INFODIR": "",
"INFOPATH": "",
"PATH": path,
Expand Down
6 changes: 6 additions & 0 deletions man/etc-update.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ See \fBmake.conf\fR(5) for more information.
.PP
\fIetc\-update\fR respects the normal \fIPORTAGE_CONFIGROOT\fR and
\fIEROOT\fR variables for finding the aforementioned config protect variables.
.PP
Multiple target distributions are supported, including \fIportage\fR(5),
\fIrpm\fR(1), \fIpacman\fR(1), and \fIdpkg\fR(1) based systems. Detection of
the target package management system is done by inspecting
\fI/etc/os\-release\fR. \fIETC_UPDATE_OS_FAMILY\fR can be used to override this
detection.
.SH "OPTIONS"
.TP
.BR \-d ", " \-\-debug
Expand Down
Loading