2009-10-18 09:17:26 +00:00
|
|
|
#-
|
2010-01-04 15:05:13 +00:00
|
|
|
# Copyright (c) 2008-2010 Juan Romero Pardines.
|
2009-10-18 09:17:26 +00:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#-
|
|
|
|
|
|
|
|
#
|
|
|
|
# Extracts contents of distfiles specified in a template into
|
|
|
|
# the $wrksrc directory.
|
|
|
|
#
|
|
|
|
extract_distfiles()
|
|
|
|
{
|
2011-07-18 14:25:18 +00:00
|
|
|
local pkg="$1" curfile cursufx f
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
[ -f $XBPS_EXTRACT_DONE ] && return 0
|
2011-07-04 17:07:08 +00:00
|
|
|
[ -z "$IN_CHROOT" -a ! -w $XBPS_BUILDDIR ] && \
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "can't extract distfile(s) (permission denied)\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# If we are being called via the target, just extract and return.
|
|
|
|
#
|
|
|
|
[ -n "$pkg" -a -z "$pkgname" ] && return 1
|
|
|
|
|
|
|
|
#
|
|
|
|
# If noextract is set, do a "fake extraction".
|
|
|
|
#
|
2010-12-23 16:59:19 +00:00
|
|
|
if [ -z "$distfiles" -o -n "$noextract" ]; then
|
2011-07-02 16:05:20 +00:00
|
|
|
[ ! -d "$wrksrc" ] && mkdir -p $wrksrc
|
2010-12-23 01:13:40 +00:00
|
|
|
run_func do_extract
|
2009-10-18 09:17:26 +00:00
|
|
|
touch -f $XBPS_EXTRACT_DONE
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2010-04-18 16:50:43 +00:00
|
|
|
# Check that distfiles are there before anything else.
|
|
|
|
for f in ${distfiles}; do
|
|
|
|
curfile=$(basename $f)
|
|
|
|
if [ ! -f ${XBPS_SRCDISTDIR}/${curfile} ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "cannot find ${curfile}, use 'xbps-src fetch' first.\n"
|
2010-04-18 16:50:43 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-01-04 15:05:13 +00:00
|
|
|
if [ -n "$create_wrksrc" ]; then
|
|
|
|
mkdir -p ${wrksrc} || return 1
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
2011-07-18 14:25:18 +00:00
|
|
|
msg_normal "$pkgver: extracting distfile(s), please wait...\n"
|
2010-01-04 15:05:13 +00:00
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
for f in ${distfiles}; do
|
|
|
|
curfile=$(basename $f)
|
|
|
|
|
|
|
|
if $(echo $f|grep -q '.tar.lzma'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="txz"
|
|
|
|
elif $(echo $f|grep -q '.tar.xz'); then
|
|
|
|
cursufx="txz"
|
|
|
|
elif $(echo $f|grep -q '.txz'); then
|
|
|
|
cursufx="txz"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.tar.bz2'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="tbz"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.tbz'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="tbz"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.tar.gz'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="tgz"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.tgz'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="tgz"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.gz'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="gz"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.bz2'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="bz2"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.tar'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="tar"
|
2009-10-18 09:17:26 +00:00
|
|
|
elif $(echo $f|grep -q '.zip'); then
|
2009-12-13 12:38:53 +00:00
|
|
|
cursufx="zip"
|
2009-10-18 09:17:26 +00:00
|
|
|
else
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "unknown distfile suffix for $curfile.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
|
2010-01-04 15:05:13 +00:00
|
|
|
if [ -n "$create_wrksrc" ]; then
|
|
|
|
extractdir="$wrksrc"
|
|
|
|
else
|
|
|
|
extractdir="$XBPS_BUILDDIR"
|
|
|
|
fi
|
|
|
|
|
2009-10-18 09:17:26 +00:00
|
|
|
case ${cursufx} in
|
2009-12-13 12:38:53 +00:00
|
|
|
txz)
|
2011-06-30 22:58:52 +00:00
|
|
|
if ! command -v unxz 2>&1 >/dev/null; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "cannot find xz for extraction.\n"
|
2009-12-13 12:38:53 +00:00
|
|
|
fi
|
2011-06-30 22:58:52 +00:00
|
|
|
unxz -cf $XBPS_SRCDISTDIR/$curfile | tar xf - -C $extractdir
|
2009-12-13 12:38:53 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "extracting $curfile into $XBPS_BUILDDIR.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
;;
|
2009-12-13 12:38:53 +00:00
|
|
|
tbz)
|
2011-06-30 22:58:52 +00:00
|
|
|
bunzip2 -cf $XBPS_SRCDISTDIR/$curfile | tar xf - -C $extractdir
|
2009-10-18 09:17:26 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "extracting $curfile into $XBPS_BUILDDIR.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
;;
|
2009-12-13 12:38:53 +00:00
|
|
|
tgz)
|
2011-06-30 22:58:52 +00:00
|
|
|
gunzip -cf $XBPS_SRCDISTDIR/$curfile | tar xf - -C $extractdir
|
2009-10-18 09:17:26 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "extracting $curfile into $XBPS_BUILDDIR.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
;;
|
2009-12-13 12:38:53 +00:00
|
|
|
gz|bz2)
|
2010-01-04 15:05:13 +00:00
|
|
|
cp -f $XBPS_SRCDISTDIR/$curfile $extractdir
|
2009-10-18 09:17:26 +00:00
|
|
|
if [ "$cursufx" = ".gz" ]; then
|
2009-12-23 14:41:58 +00:00
|
|
|
cd $XBPS_BUILDDIR && gunzip $curfile
|
2009-10-18 09:17:26 +00:00
|
|
|
else
|
2009-12-23 14:41:58 +00:00
|
|
|
cd $XBPS_BUILDDIR && bunzip2 $curfile
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
;;
|
2009-12-13 12:38:53 +00:00
|
|
|
tar)
|
2010-01-04 15:05:13 +00:00
|
|
|
tar xf $XBPS_SRCDISTDIR/$curfile -C $extractdir
|
2009-10-18 09:17:26 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "extracting $curfile into $XBPS_BUILDDIR.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
;;
|
2009-12-13 12:38:53 +00:00
|
|
|
zip)
|
2010-11-17 01:46:08 +00:00
|
|
|
if command -v unzip 2>&1 >/dev/null; then
|
2011-10-25 18:53:31 +00:00
|
|
|
unzip -q $XBPS_SRCDISTDIR/$curfile -d $extractdir
|
2009-10-18 09:17:26 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "extracting $curfile into $XBPS_BUILDDIR.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
else
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "cannot find unzip bin for extraction.\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
2010-12-19 23:22:12 +00:00
|
|
|
msg_error "cannot guess $curfile extract suffix. ($cursufx)\n"
|
2009-10-18 09:17:26 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2010-04-24 10:52:29 +00:00
|
|
|
touch -f $XBPS_FETCH_DONE
|
2009-10-18 09:17:26 +00:00
|
|
|
touch -f $XBPS_EXTRACT_DONE
|
|
|
|
}
|