Elliot Lee 03bb291
#!/bin/sh
Elliot Lee 03bb291
# If using normal root, avoid changing anything.
Elliot Lee 03bb291
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
Elliot Lee 03bb291
	exit 0
Elliot Lee 03bb291
fi
Elliot Lee 03bb291
files=
Elliot Lee 03bb291
LC_ALL=
Elliot Lee 03bb291
LANG=
Elliot Lee 03bb291
Elliot Lee 03bb291
# Move 64bit ELF objects from /lib, /usr/lib, /usr/X11R6/lib to */lib64
Elliot Lee 03bb291
# directories
Elliot Lee 03bb291
Elliot Lee 03bb291
for f in `find $RPM_BUILD_ROOT{,/usr,/usr/X11R6}/lib -maxdepth 1 -type f -o -type l 2>/dev/null`; do
Elliot Lee 03bb291
	ff=$f
Elliot Lee 03bb291
	while [ -L $ff ]; do
Elliot Lee 03bb291
		l=`ls -l $ff | awk '{ print $11 }'`
Elliot Lee 03bb291
		case $l in
Elliot Lee 03bb291
		/*) ff=$RPM_BUILD_ROOT$l ;;
Elliot Lee 03bb291
		*) ff=`dirname $ff`/$l ;;
Elliot Lee 03bb291
		esac
Elliot Lee 03bb291
	done
Elliot Lee 03bb291
	if file $ff 2>/dev/null | grep ': ELF 64-bit .SB' | grep -v ': ELF 64-bit .SB executable' > /dev/null; then
Elliot Lee 03bb291
		files="$files $f"
Elliot Lee 03bb291
	elif file $ff 2>/dev/null | grep 'ar archive' > /dev/null; then
Elliot Lee 03bb291
		if objdump -h $ff 2>/dev/null | grep ':[        ]*file format elf64-sparc' > /dev/null; then
Elliot Lee 03bb291
			files="$files $f"
Elliot Lee 03bb291
		fi
Elliot Lee 03bb291
	fi
Elliot Lee 03bb291
done
Elliot Lee 03bb291
for f in $files; do
Elliot Lee 03bb291
	d=`dirname $f`
Elliot Lee 03bb291
	n=`basename $f`
Elliot Lee 03bb291
	if [ ! -d ${d}64 ]; then mkdir -p ${d}64; fi
Elliot Lee 03bb291
	if [ -L $f ]; then
Elliot Lee 03bb291
		l=`ls -l $f | awk '{ print $11 }' | sed 's_lib\(/[^/]*\)$_lib64\1_'`
Elliot Lee 03bb291
		ln -sf $l ${d}64/$n
Elliot Lee 03bb291
		rm -f $f
Elliot Lee 03bb291
	else
Elliot Lee 03bb291
		mv -f $f ${d}64/$n
Elliot Lee 03bb291
	fi
Elliot Lee 03bb291
done