[pacman-dev] FS #6246 - makepkg fails if the extensions is wrong on the archive

Johannes Weiner hannes at saeurebad.de
Sun Jan 21 13:38:25 EST 2007


Hi,

On Sun, Jan 21, 2007 at 12:43:43PM -0500, James Rosten wrote:
> +		# fix flyspray #6246
> +		file_type=$(file -biz $file)
> +		if [ -n "$(echo $file_type | grep tar | grep gzip)" ]; then
> +			ft=".tgz" 
> +		elif [ -n "$(echo $file_type | grep tar | grep bzip2)" ]; then
> +			ft=".tbz2"
> +		elif [ -n "$(echo $file_type | grep tar)" ]; then
> +			ft=".tar"
> +		elif [ -n "$(echo $file_type | grep -q zip)" ]; then
> +			ft=".zip"
> +		elif [ -n "$(echo $file_type | grep cpio | grep gzip)" ]; then
> +			ft=".cpio.gz"
> +		elif [ -n "$(echo $file_type | grep cpio | grep bzip2)" ]; then
> +			ft=".cpio.bz2"
> +		elif [ -n "$(echo $file_type | grep gzip)" ]; then
> +			ft=".gz"
> +		elif [ -n "$(echo $file_type | grep bzip2)" ]; then
> +			ft=".bz2"

What about this:

case $file_type in
	"application/x-tar")
		ft=".tar";;
	"application/x-tar*")
		case $file_type in
			"*x-gzip")
				ft=".tgz";;
			"*x-bzip2")
				ft=".tbz2";;
		ecac;;
	"application/x-zip*")
		ft=".zip";;
	[...]
esac

This would save a lot of external calls to grep ;)

Greetings,
Hannes




More information about the pacman-dev mailing list