2014-03-05 10:02:37 +00:00
|
|
|
# This hook extracts $distfiles into $XBPS_BUILDDIR if $distfiles and $checksum
|
|
|
|
# variables are set.
|
|
|
|
|
|
|
|
hook() {
|
|
|
|
local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
|
|
|
|
|
|
|
|
if [ -z "$distfiles" -a -z "$checksum" ]; then
|
|
|
|
mkdir -p $wrksrc
|
2014-03-12 09:32:50 +00:00
|
|
|
return 0
|
2014-03-05 10:02:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that distfiles are there before anything else.
|
|
|
|
for f in ${distfiles}; do
|
2014-03-12 15:43:37 +00:00
|
|
|
curfile=$(basename "${f#*>}")
|
2014-03-05 10:02:37 +00:00
|
|
|
if [ ! -f $srcdir/$curfile ]; then
|
|
|
|
msg_error "$pkgver: cannot find ${curfile}, use 'xbps-src fetch' first.\n"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "$create_wrksrc" ]; then
|
|
|
|
mkdir -p ${wrksrc} || msg_error "$pkgver: failed to create wrksrc.\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
msg_normal "$pkgver: extracting distfile(s), please wait...\n"
|
|
|
|
|
|
|
|
for f in ${distfiles}; do
|
2014-03-12 15:43:37 +00:00
|
|
|
curfile=$(basename "${f#*>}")
|
2014-03-05 10:02:37 +00:00
|
|
|
for j in ${skip_extraction}; do
|
|
|
|
if [ "$curfile" = "$j" ]; then
|
|
|
|
found=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -n "$found" ]; then
|
|
|
|
unset found
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2014-03-12 15:43:37 +00:00
|
|
|
case $curfile in
|
|
|
|
*.tar.lzma) cursufx="txz";;
|
2014-03-14 10:04:51 +00:00
|
|
|
*.tar.lz) cursufx="tlz";;
|
|
|
|
*.tlz) cursufx="tlz";;
|
2014-03-12 15:43:37 +00:00
|
|
|
*.tar.xz) cursufx="txz";;
|
|
|
|
*.txz) cursufx="txz";;
|
|
|
|
*.tar.bz2) cursufx="tbz";;
|
|
|
|
*.tbz) cursufx="tbz";;
|
|
|
|
*.tar.gz) cursufx="tgz";;
|
|
|
|
*.tgz) cursufx="tgz";;
|
|
|
|
*.gz) cursufx="gz";;
|
|
|
|
*.bz2) cursufx="bz2";;
|
|
|
|
*.tar) cursufx="tar";;
|
|
|
|
*.zip) cursufx="zip";;
|
2014-05-08 16:44:54 +00:00
|
|
|
*.rpm) cursufx="rpm";;
|
2015-10-23 17:43:43 +00:00
|
|
|
*.patch) cursufx="txt";;
|
|
|
|
*.diff) cursufx="txt";;
|
|
|
|
*.txt) cursufx="txt";;
|
2016-01-11 10:02:44 +00:00
|
|
|
*.7z) cursufx="7z";;
|
2014-03-12 15:43:37 +00:00
|
|
|
*) msg_error "$pkgver: unknown distfile suffix for $curfile.\n";;
|
|
|
|
esac
|
2014-03-05 10:02:37 +00:00
|
|
|
|
|
|
|
if [ -n "$create_wrksrc" ]; then
|
|
|
|
extractdir="$wrksrc"
|
|
|
|
else
|
|
|
|
extractdir="$XBPS_BUILDDIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case ${cursufx} in
|
2014-03-14 10:04:51 +00:00
|
|
|
txz|tbz|tlz|tgz)
|
2015-03-05 19:25:04 +00:00
|
|
|
tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
|
2014-03-05 10:02:37 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
gz|bz2)
|
|
|
|
cp -f $srcdir/$curfile $extractdir
|
2014-03-06 10:05:41 +00:00
|
|
|
if [ "$cursufx" = "gz" ]; then
|
2014-03-05 10:02:37 +00:00
|
|
|
cd $extractdir && gunzip $curfile
|
|
|
|
else
|
|
|
|
cd $extractdir && bunzip2 $curfile
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
tar)
|
2015-03-05 19:25:04 +00:00
|
|
|
tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
|
2014-03-05 10:02:37 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
zip)
|
2014-05-08 16:44:54 +00:00
|
|
|
if command -v unzip &>/dev/null; then
|
2014-12-12 09:32:08 +00:00
|
|
|
unzip -o -q $srcdir/$curfile -d $extractdir
|
2014-03-05 10:02:37 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg_error "$pkgver: cannot find unzip bin for extraction.\n"
|
|
|
|
fi
|
|
|
|
;;
|
2014-05-08 16:44:54 +00:00
|
|
|
rpm)
|
|
|
|
if command -v rpmextract &>/dev/null; then
|
|
|
|
cd $extractdir
|
|
|
|
rpmextract $srcdir/$curfile
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg_error "$pkgver: cannot find rpmextract for extraction.\n"
|
|
|
|
fi
|
|
|
|
;;
|
2015-10-23 17:43:43 +00:00
|
|
|
txt)
|
|
|
|
cp -f $srcdir/$curfile $extractdir
|
|
|
|
;;
|
2016-01-11 10:02:44 +00:00
|
|
|
7z)
|
|
|
|
if command -v 7z &>/dev/null; then
|
|
|
|
7z x $srcdir/$curfile -o$extractdir
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg_error "$pkgver: cannot find 7z bin for extraction.\n"
|
|
|
|
fi
|
|
|
|
;;
|
2014-03-05 10:02:37 +00:00
|
|
|
*)
|
|
|
|
msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|