--- eclass/rpm.eclass 2003/06/22 16:31:23 1.6 +++ eclass/rpm.eclass 2003/06/25 23:50:02 1.7 @@ -1,6 +1,6 @@ # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.6 2003/06/22 16:31:23 liquidx Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/rpm.eclass,v 1.7 2003/06/25 23:50:02 liquidx Exp $ # Author : Alastair Tse (21 Jun 2003) # @@ -37,7 +37,7 @@ # extracts the contents of the RPM in ${WORKDIR} rpm_unpack() { - local rpmfile + local rpmfile rpmoff decompcmd rpmfile=$1 if [ -z "${rpmfile}" ]; then return 1 @@ -47,8 +47,15 @@ if [ -x /usr/bin/rpm2cpio -a -z "${USE_RPMOFFSET_ONLY}" ]; then rpm2cpio ${rpmfile} | cpio -idmu --no-preserve-owner --quiet || return 1 else - dd ibs=`rpmoffset < ${rpmfile}` skip=1 if=${rpmfile} 2> /dev/null \ - | gzip -dc \ + rpmoff=`rpmoffset < ${rpmfile}` + [ -z "${rpmoff}" ] && return 1 + + decompcmd="gzip -dc" + if [ -n "`dd if=${rpmfile} skip=${rpmoff} bs=1 count=3 2>/dev/null | file - | grep bzip2`" ]; then + decompcmd="bzip2 -dc" + fi + dd ibs=${rpmoff} skip=1 if=${rpmfile} 2> /dev/null \ + | ${decompcmd} \ | cpio -idmu --no-preserve-owner --quiet || return 1 fi