public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r15058 - main/trunk/bin/ebuild-helpers
@ 2009-12-13  3:25 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-12-13  3:25 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2009-12-13 03:25:01 +0000 (Sun, 13 Dec 2009)
New Revision: 15058

Modified:
   main/trunk/bin/ebuild-helpers/ecompress
Log:
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.


Modified: main/trunk/bin/ebuild-helpers/ecompress
===================================================================
--- main/trunk/bin/ebuild-helpers/ecompress	2009-12-13 01:45:45 UTC (rev 15057)
+++ main/trunk/bin/ebuild-helpers/ecompress	2009-12-13 03:25:01 UTC (rev 15058)
@@ -20,6 +20,54 @@
 	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 @@
 		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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-13  3:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-13  3:25 [gentoo-commits] portage r15058 - main/trunk/bin/ebuild-helpers Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox