2014-03-05 11:02:37 +01: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 10:32:50 +01:00
|
|
|
return 0
|
2014-03-05 11:02:37 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that distfiles are there before anything else.
|
|
|
|
for f in ${distfiles}; do
|
2014-03-12 16:43:37 +01:00
|
|
|
curfile=$(basename "${f#*>}")
|
2014-03-05 11:02:37 +01: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 16:43:37 +01:00
|
|
|
curfile=$(basename "${f#*>}")
|
2014-03-05 11:02:37 +01: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 16:43:37 +01:00
|
|
|
case $curfile in
|
|
|
|
*.tar.lzma) cursufx="txz";;
|
2014-03-14 11:04:51 +01:00
|
|
|
*.tar.lz) cursufx="tlz";;
|
|
|
|
*.tlz) cursufx="tlz";;
|
2014-03-12 16:43:37 +01: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 18:44:54 +02:00
|
|
|
*.rpm) cursufx="rpm";;
|
2015-10-23 19:43:43 +02:00
|
|
|
*.patch) cursufx="txt";;
|
|
|
|
*.diff) cursufx="txt";;
|
|
|
|
*.txt) cursufx="txt";;
|
2016-01-11 11:02:44 +01:00
|
|
|
*.7z) cursufx="7z";;
|
2018-10-26 21:39:18 +02:00
|
|
|
*.gem) cursufx="gem";;
|
2018-10-31 22:11:01 +01:00
|
|
|
*.crate) cursufx="crate";;
|
2014-03-12 16:43:37 +01:00
|
|
|
*) msg_error "$pkgver: unknown distfile suffix for $curfile.\n";;
|
|
|
|
esac
|
2014-03-05 11:02:37 +01:00
|
|
|
|
|
|
|
if [ -n "$create_wrksrc" ]; then
|
|
|
|
extractdir="$wrksrc"
|
|
|
|
else
|
|
|
|
extractdir="$XBPS_BUILDDIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
case ${cursufx} in
|
2018-10-31 22:11:01 +01:00
|
|
|
txz|tbz|tlz|tgz|crate)
|
2015-03-05 20:25:04 +01:00
|
|
|
tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
|
2014-03-05 11:02:37 +01: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 11:05:41 +01:00
|
|
|
if [ "$cursufx" = "gz" ]; then
|
2014-03-05 11:02:37 +01:00
|
|
|
cd $extractdir && gunzip $curfile
|
|
|
|
else
|
|
|
|
cd $extractdir && bunzip2 $curfile
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
tar)
|
2015-03-05 20:25:04 +01:00
|
|
|
tar -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C $extractdir
|
2014-03-05 11:02:37 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
zip)
|
2014-05-08 18:44:54 +02:00
|
|
|
if command -v unzip &>/dev/null; then
|
2014-12-12 10:32:08 +01:00
|
|
|
unzip -o -q $srcdir/$curfile -d $extractdir
|
2014-03-05 11:02:37 +01: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 18:44:54 +02: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 19:43:43 +02:00
|
|
|
txt)
|
|
|
|
cp -f $srcdir/$curfile $extractdir
|
|
|
|
;;
|
2016-01-11 11:02:44 +01: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
|
|
|
|
;;
|
2018-10-26 21:39:18 +02:00
|
|
|
gem)
|
|
|
|
tar -xOf $srcdir/$curfile data.tar.gz | tar -xz -C $extractdir --transform="s,^,$(basename $wrksrc)/,"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
|
|
|
;;
|
2014-03-05 11:02:37 +01:00
|
|
|
*)
|
|
|
|
msg_error "$pkgver: cannot guess $curfile extract suffix. ($cursufx)\n"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|