summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-12-13 03:25:01 +0000
committerZac Medico <zmedico@gentoo.org>2009-12-13 03:25:01 +0000
commite40a94aae6fd8515622d018cb1615875364819ea (patch)
tree8b37a3b71c5b7a6419c6c630a5915303b20be1db
parent003ef79f1b4a4a0da3760f978fcdf24a3bca8734 (diff)
downloadportage-e40a94aae6fd8515622d018cb1615875364819ea.tar.gz
portage-e40a94aae6fd8515622d018cb1615875364819ea.tar.bz2
portage-e40a94aae6fd8515622d018cb1615875364819ea.zip
Bug #296554 - Add decompression support to ecompress (similar to ecompressdir
behavior) since dodoc can call ecompress with stuff that's already compressed in some way. svn path=/main/trunk/; revision=15058
-rwxr-xr-xbin/ebuild-helpers/ecompress57
1 files changed, 57 insertions, 0 deletions
diff --git a/bin/ebuild-helpers/ecompress b/bin/ebuild-helpers/ecompress
index 574a1c657..c6e0fc548 100755
--- a/bin/ebuild-helpers/ecompress
+++ b/bin/ebuild-helpers/ecompress
@@ -20,6 +20,54 @@ if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then
esac
fi
+# decompress_args(suffix, binary)
+# - suffix: the compression suffix to work with
+# - binary: the program to execute that'll compress/decompress
+# new_args: global array used to return revised arguments
+decompress_args() {
+ local suffix=$1 binary=$2
+ shift
+ shift
+
+ # Initialize the global new_args array.
+ new_args=()
+ declare -a decompress_args=()
+ local x i=0 decompress_count=0
+ for x in "$@" ; do
+ if [[ ${x%$suffix} = $x ]] ; then
+ new_args[$i]=$x
+ else
+ new_args[$i]=${x%$suffix}
+ decompress_args[$decompress_count]=$x
+ ((decompress_count++))
+ fi
+ ((i++))
+ done
+
+ if [ $decompress_count -gt 0 ] ; then
+ ${binary} "${decompress_args[@]}"
+ if [ $? -ne 0 ] ; then
+ # Apparently decompression failed for one or more files, so
+ # drop those since we don't want to compress them twice.
+ new_args=()
+ local x i=0
+ for x in "$@" ; do
+ if [[ ${x%$suffix} = $x ]] ; then
+ new_args[$i]=$x
+ ((i++))
+ elif [[ -f ${x%$suffix} ]] ; then
+ new_args[$i]=${x%$suffix}
+ ((i++))
+ else
+ # Apparently decompression failed for this one, so drop
+ # it since we don't want to compress it twice.
+ true
+ fi
+ done
+ fi
+ fi
+}
+
case $1 in
--suffix)
[[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2
@@ -63,6 +111,15 @@ case $1 in
exit 1
;;
*)
+ # Since dodoc calls ecompress on files that are already compressed,
+ # perform decompression here (similar to ecompressdir behavior).
+ decompress_args ".Z" "gunzip -f" "$@"
+ set -- "${new_args[@]}"
+ decompress_args ".gz" "gunzip -f" "$@"
+ set -- "${new_args[@]}"
+ decompress_args ".bz2" "bunzip2 -f" "$@"
+ set -- "${new_args[@]}"
+
mask_ext_re=""
set -f
for x in $PORTAGE_COMPRESS_EXCLUDE_SUFFIXES ; do