config: move control of apt colour

being done in Prepare_config() meant that it would get saved into the
config stored on disk which is not what was intended.

being saved on disk is not a big problem, since the injection of the
dynamically determined option is always done on top of the value read
from the saved config anyway, so you'd always end up with two copies of
the option given to apt, the first being from the saved config, the second
being the more correct dynamically determined one, overriding the first.

so there is no functional change here, just better achieving what was
intended.

Gbp-Dch: Ignore
This commit is contained in:
Lyndon Brown 2020-03-28 16:46:16 +00:00 committed by Raphaël Hertzog
parent faa51b83c5
commit f4c8a28a21
2 changed files with 10 additions and 9 deletions

View File

@ -133,15 +133,6 @@ Prepare_config ()
APT_OPTIONS="${APT_OPTIONS:---yes}"
APTITUDE_OPTIONS="${APTITUDE_OPTIONS:---assume-yes}"
# Apt v2.0.1 introduced color support, but it needs to be explicitly enabled
if [ "${_COLOR_OUT}" = "true" ] && [ "${_COLOR_ERR}" = "true" ]; then
APT_OPTIONS="${APT_OPTIONS} -o APT::Color=true"
APTITUDE_OPTIONS="${APTITUDE_OPTIONS} -o APT::Color=true"
else
APT_OPTIONS="${APT_OPTIONS} -o APT::Color=false"
APTITUDE_OPTIONS="${APTITUDE_OPTIONS} -o APT::Color=false"
fi
BZIP2_OPTIONS="${BZIP2_OPTIONS:--6}"
GZIP_OPTIONS="${GZIP_OPTIONS:--6}"
LZIP_OPTIONS="${LZIP_OPTIONS:--6}"

View File

@ -29,6 +29,16 @@ Init_config_data ()
Read_conffiles $(Common_config_files)
Prepare_config
# Apt v2.0.1 introduced color support, but it needs to be explicitly enabled.
# This is done here so that the injection of the option does not get stored in the config file.
if [ "${_COLOR_OUT}" = "true" ] && [ "${_COLOR_ERR}" = "true" ]; then
APT_OPTIONS="${APT_OPTIONS} -o APT::Color=true"
APTITUDE_OPTIONS="${APTITUDE_OPTIONS} -o APT::Color=true"
else
APT_OPTIONS="${APT_OPTIONS} -o APT::Color=false"
APTITUDE_OPTIONS="${APTITUDE_OPTIONS} -o APT::Color=false"
fi
}
# "Auto" script redirection.