commit:     33cef69aaf2199e760e0e4cdb85b5711c24b94cd
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Nov 17 01:23:40 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Nov 17 05:53:10 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=33cef69a

misc-functions.sh: don't run ecompress if PORTAGE_COMPRESS is empty

The 'PORTAGE_COMPRESS' variable allows for the user to select the
program used to compress documentation during the install phase. Those
wishing to disable compression may do so by defining the compressor as
an empty string. However, even in the case that compression is disabled,
the install_qa_check() function of the "misc-functions.sh" unit will
still execute the ecompress utility three times in succession.

  ecompress --queue "${PORTAGE_DOCOMPRESS[@]}"
  ecompress --ignore "${PORTAGE_DOCOMPRESS_SKIP[@]}"
  ecompress --dequeue

The outcome is that the 'queue' and 'ignore' phases are always executed
in full. Only the 'dequeue' phase recognises that compression has been
disabled, upon which it unlinks all of the files generated by the
'queue' phase before exiting. All of which is a waste of resources.

Address this issue by preventing the install_qa_check() function from
executing the ecompress utility in the case that the 'PORTAGE_COMPRESS'
variable is empty. Further, to compensate for this change, delegate the
responsibility of defining bzip2(1) as the default compressor to the
"make.globals" file.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/ecompress         | 7 ++-----
 bin/misc-functions.sh | 4 ++--
 cnf/make.globals      | 3 +++
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/bin/ecompress b/bin/ecompress
index 81e4dfee6f..1c0f04589a 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -225,11 +225,8 @@ while (( $# )); do
        esac
 done
 
-# Default to bzip2 if unset.
-if [[ ! ${PORTAGE_COMPRESS=bzip2} ]]; then
-       # It was set as the null string. Take it that no compression is desired.
-       printf '%s\0' "${ED}" | find0 -name '*.ecompress' ! -path $'*\n*' 
-delete
-       exit 0
+if [[ ! ${PORTAGE_COMPRESS} ]]; then
+       die "${0##*/}: aborting because PORTAGE_COMPRESS is either empty or 
unset"
 fi
 
 if [[ ! -v PORTAGE_COMPRESS_FLAGS ]] ; then

diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index 9b2f3b2ad2..204500e2ac 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -146,7 +146,7 @@ install_qa_check() {
 
        # If binpkg-docompress is enabled, apply compression before creating
        # the binary package.
-       if contains_word binpkg-docompress "${FEATURES}"; then
+       if [[ ${PORTAGE_COMPRESS} ]] && contains_word binpkg-docompress 
"${FEATURES}"; then
                "${PORTAGE_BIN_PATH}"/ecompress --queue 
"${PORTAGE_DOCOMPRESS[@]}"
                "${PORTAGE_BIN_PATH}"/ecompress --ignore 
"${PORTAGE_DOCOMPRESS_SKIP[@]}"
                "${PORTAGE_BIN_PATH}"/ecompress --dequeue
@@ -279,7 +279,7 @@ __dyn_instprep() {
 
        # If binpkg-docompress is disabled, we need to apply compression
        # before installing.
-       if ! contains_word binpkg-docompress "${FEATURES}"; then
+       if [[ ${PORTAGE_COMPRESS} ]] && ! contains_word binpkg-docompress 
"${FEATURES}"; then
                "${PORTAGE_BIN_PATH}"/ecompress --queue 
"${PORTAGE_DOCOMPRESS[@]}"
                "${PORTAGE_BIN_PATH}"/ecompress --ignore 
"${PORTAGE_DOCOMPRESS_SKIP[@]}"
                "${PORTAGE_BIN_PATH}"/ecompress --dequeue

diff --git a/cnf/make.globals b/cnf/make.globals
index 94eac65684..738047082f 100644
--- a/cnf/make.globals
+++ b/cnf/make.globals
@@ -104,6 +104,9 @@ AUTOCLEAN="no"
 
 PORTAGE_BZIP2_COMMAND="bzip2"
 
+# The program used to compress documentation during the install phase.
+PORTAGE_COMPRESS="bzip2"
+
 # Don't compress files with these suffixes.
 PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
 

Reply via email to