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"
|
2019-04-13 13:43:07 +02:00
|
|
|
local f j curfile found extractdir
|
2020-01-05 08:20:26 +01:00
|
|
|
local TAR_CMD
|
2014-03-05 11:02:37 +01:00
|
|
|
|
|
|
|
if [ -z "$distfiles" -a -z "$checksum" ]; then
|
2020-09-02 19:04:41 +02:00
|
|
|
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
|
2019-04-13 13:43:07 +02:00
|
|
|
curfile="${f#*>}"
|
|
|
|
curfile="${curfile##*/}"
|
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
|
2020-09-02 19:04:41 +02:00
|
|
|
mkdir -p "${wrksrc}" || msg_error "$pkgver: failed to create wrksrc.\n"
|
2014-03-05 11:02:37 +01:00
|
|
|
fi
|
|
|
|
|
2020-01-05 08:24:52 +01:00
|
|
|
# Disable trap on ERR; the code is smart enough to report errors and abort.
|
|
|
|
trap - ERR
|
|
|
|
|
2020-01-05 08:20:26 +01:00
|
|
|
TAR_CMD="$(command -v bsdtar)"
|
|
|
|
[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
|
|
|
|
[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
|
|
|
|
|
2014-03-05 11:02:37 +01:00
|
|
|
msg_normal "$pkgver: extracting distfile(s), please wait...\n"
|
|
|
|
|
|
|
|
for f in ${distfiles}; do
|
2019-04-13 13:43:07 +02:00
|
|
|
curfile="${f#*>}"
|
|
|
|
curfile="${curfile##*/}"
|
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";;
|
2020-02-11 22:29:57 +01:00
|
|
|
*.xz) cursufx="xz";;
|
2014-03-12 16:43:37 +01:00
|
|
|
*.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";;
|
2020-02-11 22:52:33 +01:00
|
|
|
*.sh) 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
|
xbps-src: base-chroot-v2 (reduce artifacts/deps)
This patchset contains multiple changes to xbps-src and
its required package "base-chroot" for building packages
via chroot.
- moved xbps.d(5) conf files to `etc/xbps.d`.
- renamed xbps.d(5) repository files to `etc/xbps.d/repos-{local,remote}*`.
- do not set `--repository` to any xbps command that supports it,
xbps-src now simply populates `rootdir/etc/xbps.d` with correct
settings (taking care of CHROOT_READY/IN_CHROOT).
- Unless `-C` is set (to preserve builddir/destdir/autodeps), when
entering to the chroot (if CHROOT_READY is set), xbps-src will
clean up the masterdir and then perform a system update to always
use a constant set of packages for that exact date.
- Improved some normal/error msgs.
- Includes support for `xbps>=0.58`.
- common/hooks: switch to bsdtar.
- base-chroot:
- base-chroot-musl is gone, now unified for glibc/musl.
- deps removed: gettext, mpfr, readline, texinfo, which, xz.
- deps changed: tar -> bsdtar.
Effectively this reduces dependencies in `base-chroot`, makes
it unified for musl and glibc, switches xbps-src to use `bsdtar`
rather than GNU `tar` and `xz`, gets rid of useless host dependencies
like GNU gettext, texinfo, etc.
I've been testing these changes for 1 month or so already,
I was able to build from scratch `base-system` for both native
and multiple targets, i.e `./xbps-src -a target -Nt pkg base-system`
2020-01-01 11:15:35 +01:00
|
|
|
tar|txz|tbz|tlz|tgz|crate)
|
2020-09-02 19:04:41 +02:00
|
|
|
$TAR_CMD -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
|
|
|
|
;;
|
2020-02-11 22:29:57 +01:00
|
|
|
gz|bz2|xz)
|
2020-09-02 19:04:41 +02:00
|
|
|
cp -f $srcdir/$curfile "$extractdir"
|
|
|
|
cd "$extractdir"
|
2020-02-11 22:29:57 +01:00
|
|
|
case ${cursufx} in
|
|
|
|
gz)
|
|
|
|
gunzip -f $curfile
|
|
|
|
;;
|
|
|
|
bz2)
|
|
|
|
bunzip2 -f $curfile
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
unxz -f $curfile
|
|
|
|
;;
|
|
|
|
esac
|
2014-03-05 11:02:37 +01:00
|
|
|
;;
|
|
|
|
zip)
|
2014-05-08 18:44:54 +02:00
|
|
|
if command -v unzip &>/dev/null; then
|
2020-09-02 19:04:41 +02: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
|
2020-01-19 20:06:55 +01:00
|
|
|
elif command -v bsdtar &>/dev/null; then
|
2020-09-02 19:04:41 +02:00
|
|
|
bsdtar -xf $srcdir/$curfile -C "$extractdir"
|
2020-01-19 20:06:55 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
2014-03-05 11:02:37 +01:00
|
|
|
else
|
2020-01-19 20:06:55 +01:00
|
|
|
msg_error "$pkgver: cannot find unzip or bsdtar bin for extraction.\n"
|
2014-03-05 11:02:37 +01:00
|
|
|
fi
|
|
|
|
;;
|
2014-05-08 18:44:54 +02:00
|
|
|
rpm)
|
|
|
|
if command -v rpmextract &>/dev/null; then
|
2020-09-02 19:04:41 +02:00
|
|
|
cd "$extractdir"
|
2014-05-08 18:44:54 +02:00
|
|
|
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)
|
2020-02-11 22:51:33 +01:00
|
|
|
if [ "$create_wrksrc" ]; then
|
2020-09-02 19:04:41 +02:00
|
|
|
cp -f $srcdir/$curfile "$extractdir"
|
2020-02-11 22:51:33 +01:00
|
|
|
else
|
|
|
|
msg_error "$pkgname: ${curfile##*.} files can only be extracted when create_wrksrc is set\n"
|
|
|
|
fi
|
2015-10-23 19:43:43 +02:00
|
|
|
;;
|
2016-01-11 11:02:44 +01:00
|
|
|
7z)
|
|
|
|
if command -v 7z &>/dev/null; then
|
2020-09-02 19:04:41 +02:00
|
|
|
7z x $srcdir/$curfile -o"$extractdir"
|
2016-01-11 11:02:44 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
2020-01-19 20:06:55 +01:00
|
|
|
elif command -v bsdtar &>/dev/null; then
|
2020-09-02 19:04:41 +02:00
|
|
|
bsdtar -xf $srcdir/$curfile -C "$extractdir"
|
2020-01-19 20:06:55 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
|
|
|
|
fi
|
2016-01-11 11:02:44 +01:00
|
|
|
else
|
2020-01-19 20:06:55 +01:00
|
|
|
msg_error "$pkgver: cannot find 7z or bsdtar bin for extraction.\n"
|
2016-01-11 11:02:44 +01:00
|
|
|
fi
|
|
|
|
;;
|
2018-10-26 21:39:18 +02:00
|
|
|
gem)
|
2020-01-11 18:43:48 +01:00
|
|
|
case "$TAR_CMD" in
|
|
|
|
*bsdtar)
|
|
|
|
$TAR_CMD -xOf $srcdir/$curfile data.tar.gz | \
|
2020-09-02 19:04:41 +02:00
|
|
|
$TAR_CMD -xz -C "$extractdir" -s ",^,${wrksrc##*/}/," -f -
|
2020-01-11 18:43:48 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
$TAR_CMD -xOf $srcdir/$curfile data.tar.gz | \
|
2020-09-02 19:04:41 +02:00
|
|
|
$TAR_CMD -xz -C "$extractdir" --transform="s,^,${wrksrc##*/}/,"
|
2020-01-11 18:43:48 +01:00
|
|
|
;;
|
|
|
|
esac
|
2018-10-26 21:39:18 +02:00
|
|
|
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
|
|
|
|
}
|