2014-04-09 16:40:27 +02:00
|
|
|
# vim: set ts=4 sw=4 et:
|
2014-03-22 12:31:42 +01:00
|
|
|
|
|
|
|
run_func() {
|
2014-12-11 11:02:22 +01:00
|
|
|
local func="$1" desc="$2" funcname="$3" restoretrap= logpipe= logfile= teepid=
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-12-11 11:02:22 +01:00
|
|
|
: ${funcname:=$func}
|
|
|
|
|
2019-06-17 17:38:07 +02:00
|
|
|
logpipe=$(mktemp -u -p ${XBPS_STATEDIR} ${pkgname}_${XBPS_CROSS_BUILD}_XXXXXXXX.logpipe) || exit 1
|
2014-12-11 11:02:22 +01:00
|
|
|
logfile=${XBPS_STATEDIR}/${pkgname}_${XBPS_CROSS_BUILD}_${funcname}.log
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
msg_normal "${pkgver:-xbps-src}: running ${desc:-${func}} ...\n"
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
set -E
|
|
|
|
restoretrap=$(trap -p ERR)
|
2014-12-11 11:02:22 +01:00
|
|
|
trap 'error_func $funcname $LINENO' ERR
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
mkfifo "$logpipe"
|
|
|
|
tee "$logfile" < "$logpipe" &
|
|
|
|
teepid=$!
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
$func &>"$logpipe"
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
wait $teepid
|
|
|
|
rm "$logpipe"
|
2014-03-22 12:31:42 +01:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
eval "$restoretrap"
|
|
|
|
set +E
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
2017-11-17 14:25:29 +01:00
|
|
|
ch_wrksrc() {
|
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
|
|
|
cd "$wrksrc" || msg_error "$pkgver: cannot access wrksrc directory [$wrksrc]\n"
|
|
|
|
if [ -n "$build_wrksrc" ]; then
|
2020-09-02 19:04:41 +02:00
|
|
|
cd "$build_wrksrc" || \
|
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
|
|
|
msg_error "$pkgver: cannot access build_wrksrc directory [$build_wrksrc]\n"
|
|
|
|
fi
|
2017-11-17 14:25:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# runs {pre,do,post}_X tripplets
|
|
|
|
run_step() {
|
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
|
|
|
local step_name="$1" optional_step="$2" skip_post_hook="$3"
|
2017-11-17 14:25:29 +01:00
|
|
|
|
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
|
|
|
ch_wrksrc
|
|
|
|
run_pkg_hooks "pre-$step_name"
|
2017-11-17 14:25:29 +01:00
|
|
|
|
|
|
|
# Run pre_* Phase
|
|
|
|
if declare -f "pre_$step_name" >/dev/null; then
|
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
|
|
|
ch_wrksrc
|
|
|
|
run_func "pre_$step_name"
|
2017-11-17 14:25:29 +01:00
|
|
|
fi
|
|
|
|
|
2017-11-28 21:21:26 +01:00
|
|
|
ch_wrksrc
|
2017-11-17 14:25:29 +01:00
|
|
|
# Run do_* Phase
|
|
|
|
if declare -f "do_$step_name" >/dev/null; then
|
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
|
|
|
run_func "do_$step_name"
|
2017-11-17 14:25:29 +01:00
|
|
|
elif [ -n "$build_style" ]; then
|
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
|
|
|
if [ -r $XBPS_BUILDSTYLEDIR/${build_style}.sh ]; then
|
|
|
|
. $XBPS_BUILDSTYLEDIR/${build_style}.sh
|
|
|
|
if declare -f "do_$step_name" >/dev/null; then
|
|
|
|
run_func "do_$step_name"
|
|
|
|
elif [ ! "$optional_step" ]; then
|
|
|
|
msg_error "$pkgver: cannot find do_$step_name() in $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
msg_error "$pkgver: cannot find build style $XBPS_BUILDSTYLEDIR/${build_style}.sh!\n"
|
2017-11-17 14:25:29 +01:00
|
|
|
fi
|
|
|
|
elif [ ! "$optional_step" ]; then
|
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
|
|
|
msg_error "$pkgver: cannot find do_$step_name()!\n"
|
2017-11-17 14:25:29 +01:00
|
|
|
fi
|
|
|
|
|
2019-03-03 16:45:39 +01:00
|
|
|
# Run do_ phase hooks
|
|
|
|
run_pkg_hooks "do-$step_name"
|
|
|
|
|
2017-11-17 14:25:29 +01:00
|
|
|
# Run post_* Phase
|
|
|
|
if declare -f "post_$step_name" >/dev/null; then
|
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
|
|
|
ch_wrksrc
|
|
|
|
run_func "post_$step_name"
|
2017-11-17 14:25:29 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ "$skip_post_hook" ]; then
|
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
|
|
|
ch_wrksrc
|
|
|
|
run_pkg_hooks "post-$step_name"
|
2017-11-17 14:25:29 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-03-22 12:31:42 +01:00
|
|
|
error_func() {
|
2018-03-28 11:20:50 +02:00
|
|
|
local err=$?
|
|
|
|
local src=
|
|
|
|
local i=
|
|
|
|
[ -n "$1" -a -n "$2" ] || exit 1;
|
|
|
|
|
|
|
|
msg_red "$pkgver: $1: '${BASH_COMMAND}' exited with $err\n"
|
|
|
|
for ((i=1;i<${#FUNCNAME[@]};i++)); do
|
|
|
|
src=${BASH_SOURCE[$i]}
|
|
|
|
src=${src#$XBPS_DISTDIR/}
|
|
|
|
msg_red " in ${FUNCNAME[$i]}() at $src:${BASH_LINENO[$i-1]}\n"
|
|
|
|
[ "${FUNCNAME[$i]}" = "$1" ] && break;
|
|
|
|
done
|
2015-03-20 09:17:40 +01:00
|
|
|
exit 1
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
2015-03-01 16:06:30 +01:00
|
|
|
exit_and_cleanup() {
|
|
|
|
local rval=$1
|
|
|
|
|
2015-03-01 16:45:16 +01:00
|
|
|
if [ -n "$XBPS_TEMP_MASTERDIR" -a "$XBPS_TEMP_MASTERDIR" != "1" ]; then
|
|
|
|
rm -rf "$XBPS_TEMP_MASTERDIR"
|
2015-03-01 16:06:30 +01:00
|
|
|
fi
|
|
|
|
exit ${rval:=0}
|
|
|
|
}
|
|
|
|
|
2014-03-22 12:31:42 +01:00
|
|
|
msg_red() {
|
2014-04-09 16:40:27 +02:00
|
|
|
# error messages in bold/red
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
|
|
|
|
printf >&2 "=> ERROR: $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_red_nochroot() {
|
2014-04-09 16:40:27 +02:00
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[31m"
|
|
|
|
printf >&2 "$@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_error() {
|
2014-04-09 16:40:27 +02:00
|
|
|
msg_red "$@"
|
2017-08-07 06:33:13 +02:00
|
|
|
[ -n "$XBPS_INFORMATIVE_RUN" ] || exit 1
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_warn() {
|
2014-04-09 16:40:27 +02:00
|
|
|
# warn messages in bold/yellow
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[33m"
|
|
|
|
printf >&2 "=> WARNING: $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_warn_nochroot() {
|
2014-04-09 16:40:27 +02:00
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[1m\033[33m"
|
|
|
|
printf >&2 "=> WARNING: $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf >&2 "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_normal() {
|
2017-08-07 06:39:41 +02:00
|
|
|
if [ -z "$XBPS_QUIET" ]; then
|
2019-07-25 11:49:44 +02:00
|
|
|
# normal messages in bold
|
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[1m"
|
|
|
|
printf "=> $@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[m"
|
2017-08-07 06:39:41 +02:00
|
|
|
fi
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg_normal_append() {
|
2014-04-09 16:40:27 +02:00
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[1m"
|
|
|
|
printf "$@"
|
|
|
|
[ -n "$NOCOLORS" ] || printf "\033[m"
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
set_build_options() {
|
2019-06-12 23:52:24 +02:00
|
|
|
local f j pkgopts _pkgname
|
2015-02-16 10:48:21 +01:00
|
|
|
local -A options
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
if [ -z "$build_options" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
for f in ${build_options}; do
|
2020-09-09 23:20:27 +02:00
|
|
|
# Select build options from conf
|
|
|
|
export XBPS_CURRENT_PKG=${pkgname}
|
|
|
|
pkgopts="$(
|
|
|
|
. $XBPS_CONFIG_FILE 2>/dev/null
|
|
|
|
var="XBPS_PKG_OPTIONS_${XBPS_CURRENT_PKG//[^A-Za-z0-9_]/_}"
|
|
|
|
echo ${!var:-${XBPS_PKG_OPTIONS}}
|
|
|
|
)"
|
|
|
|
unset XBPS_CURRENT_PKG
|
2020-08-28 19:19:13 +02:00
|
|
|
|
|
|
|
# If pkg options were set in config(s), merge them with command line
|
|
|
|
if [ -n "$XBPS_ARG_PKG_OPTIONS" ]; then
|
|
|
|
if [ -n "$pkgopts" ]; then
|
|
|
|
pkgopts+=",$XBPS_ARG_PKG_OPTIONS"
|
|
|
|
else
|
|
|
|
pkgopts="$XBPS_ARG_PKG_OPTIONS"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
OIFS="$IFS"; IFS=','
|
2014-06-30 11:32:07 +02:00
|
|
|
for j in ${pkgopts}; do
|
2019-06-12 23:52:24 +02:00
|
|
|
case "$j" 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
|
|
|
"$f") options[$j]=1 ;;
|
|
|
|
"~$f") options[${j#\~}]=0 ;;
|
2019-06-12 23:52:24 +02:00
|
|
|
esac
|
2014-04-09 16:40:27 +02:00
|
|
|
done
|
|
|
|
IFS="$OIFS"
|
|
|
|
done
|
|
|
|
|
|
|
|
for f in ${build_options_default}; do
|
2019-06-12 23:52:24 +02:00
|
|
|
[[ -z "${options[$f]}" ]] && options[$f]=1
|
2014-04-09 16:40:27 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# Prepare final options.
|
2020-08-28 19:19:14 +02:00
|
|
|
for f in ${build_options}; do
|
2019-06-12 23:52:24 +02:00
|
|
|
if [[ ${options[$f]} -eq 1 ]]; then
|
2015-02-16 10:48:21 +01:00
|
|
|
eval export build_option_${f}=1
|
2015-03-18 16:14:51 +01:00
|
|
|
else
|
|
|
|
eval unset build_option_${f}
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Re-read pkg template to get conditional vars.
|
|
|
|
if [ -z "$XBPS_BUILD_OPTIONS_PARSED" ]; then
|
|
|
|
source_file $XBPS_SRCPKGDIR/$pkgname/template
|
|
|
|
XBPS_BUILD_OPTIONS_PARSED=1
|
|
|
|
unset PKG_BUILD_OPTIONS
|
|
|
|
set_build_options
|
2014-07-24 18:40:52 +02:00
|
|
|
unset XBPS_BUILD_OPTIONS_PARSED
|
2014-04-09 16:40:27 +02:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Sort pkg build options alphabetically.
|
2019-06-12 23:52:24 +02:00
|
|
|
export PKG_BUILD_OPTIONS=$(
|
|
|
|
for f in ${build_options}; do
|
|
|
|
[[ "${options[$f]}" -eq 1 ]] || printf '~'
|
|
|
|
printf '%s\n' "$f"
|
2019-12-29 20:19:54 +01:00
|
|
|
done | sort | tr -s '\n' ' '
|
2019-06-12 23:52:24 +02:00
|
|
|
)
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
source_file() {
|
2014-04-09 16:40:27 +02:00
|
|
|
local f="$1"
|
|
|
|
|
|
|
|
if [ ! -f "$f" -o ! -r "$f" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
if ! source "$f"; then
|
|
|
|
msg_error "xbps-src: failed to read $f!\n"
|
|
|
|
fi
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
run_pkg_hooks() {
|
2015-02-25 18:54:00 +01:00
|
|
|
local phase="$1" hookn f
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
eval unset -f hook
|
|
|
|
for f in ${XBPS_COMMONDIR}/hooks/${phase}/*.sh; do
|
|
|
|
[ ! -r $f ] && continue
|
2015-09-11 07:55:40 +02:00
|
|
|
hookn=${f##*/}
|
2014-04-09 16:40:27 +02:00
|
|
|
hookn=${hookn%.sh}
|
|
|
|
. $f
|
2014-12-11 11:02:22 +01:00
|
|
|
run_func hook "$phase hook: $hookn" ${phase}_${hookn}
|
2014-04-09 16:40:27 +02:00
|
|
|
done
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
2015-02-25 18:54:00 +01:00
|
|
|
unset_package_funcs() {
|
|
|
|
local f
|
|
|
|
|
2019-08-26 21:32:38 +02:00
|
|
|
for f in $(typeset -F); do
|
2019-06-12 23:51:09 +02:00
|
|
|
case "$f" 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
|
|
|
*_package)
|
|
|
|
unset -f "$f"
|
|
|
|
;;
|
2019-06-12 23:51:09 +02:00
|
|
|
esac
|
2015-02-25 18:54:00 +01:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-08-03 23:07:23 +02:00
|
|
|
get_endian() {
|
|
|
|
local arch="${1%-*}"
|
|
|
|
|
|
|
|
case "$arch" in
|
|
|
|
aarch64) echo "le";;
|
|
|
|
armv5tel) echo "le";;
|
|
|
|
armv6l) echo "le";;
|
|
|
|
armv7l) echo "le";;
|
|
|
|
i686) echo "le";;
|
|
|
|
mipsel*) echo "le";;
|
|
|
|
mips*) echo "be";;
|
2020-04-30 00:44:25 +02:00
|
|
|
ppc*le) echo "le";;
|
|
|
|
ppc*) echo "be";;
|
2019-08-03 23:07:23 +02:00
|
|
|
x86_64) echo "le";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
get_libc() {
|
|
|
|
local arch="${1%-*}"
|
|
|
|
|
|
|
|
if [ "${arch}" = "$1" ]; then
|
|
|
|
echo "glibc"
|
|
|
|
else
|
|
|
|
echo "${1#${arch}-}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_wordsize() {
|
|
|
|
local arch="${1%-*}"
|
|
|
|
|
|
|
|
case "$arch" in
|
|
|
|
aarch64) echo "64";;
|
|
|
|
armv5tel) echo "32";;
|
|
|
|
armv6l) echo "32";;
|
|
|
|
armv7l) echo "32";;
|
|
|
|
i686) echo "32";;
|
|
|
|
mipsel*) echo "32";;
|
|
|
|
mips*) echo "32";;
|
2020-04-30 00:44:25 +02:00
|
|
|
ppc64*) echo "64";;
|
|
|
|
ppc*) echo "32";;
|
2019-08-03 23:07:23 +02:00
|
|
|
x86_64) echo "64";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2020-02-07 21:41:39 +01:00
|
|
|
get_no_atomic8() {
|
2020-02-07 21:18:28 +01:00
|
|
|
local arch="${1%-*}"
|
|
|
|
|
|
|
|
case "$arch" in
|
|
|
|
armv5tel) echo "yes";;
|
|
|
|
armv6l) echo "yes";;
|
|
|
|
mips*) echo "yes";;
|
2020-04-30 00:44:25 +02:00
|
|
|
ppcle) echo "yes";;
|
2020-02-07 21:18:28 +01:00
|
|
|
ppc) echo "yes";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2014-03-22 12:31:42 +01:00
|
|
|
get_subpkgs() {
|
2019-06-12 23:51:09 +02:00
|
|
|
local f
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2019-06-12 23:51:09 +02:00
|
|
|
for f in $(typeset -F); do
|
|
|
|
case "$f" 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
|
|
|
*_package)
|
|
|
|
echo "${f%_package}"
|
|
|
|
;;
|
2019-06-12 23:51:09 +02:00
|
|
|
esac
|
2014-04-09 16:40:27 +02:00
|
|
|
done
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setup_pkg() {
|
2017-08-07 06:35:13 +02:00
|
|
|
local pkg="$1" cross="$2" show_problems="$3"
|
2019-12-09 02:38:41 +01:00
|
|
|
local basepkg val _vars f dbgflags arch extrarepo
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 1
|
2015-09-02 11:17:01 +02:00
|
|
|
basepkg=${pkg%-32bit}
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
# Start with a sane environment
|
2019-03-23 06:48:59 +01:00
|
|
|
unset -v PKG_BUILD_OPTIONS XBPS_CROSS_CFLAGS XBPS_CROSS_CXXFLAGS XBPS_CROSS_FFLAGS XBPS_CROSS_CPPFLAGS XBPS_CROSS_LDFLAGS XBPS_TARGET_QEMU_MACHINE
|
2015-02-25 18:54:00 +01:00
|
|
|
unset -v subpackages run_depends build_depends host_build_depends
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-02-25 18:54:00 +01:00
|
|
|
unset_package_funcs
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
if [ -n "$cross" ]; then
|
|
|
|
source_file $XBPS_CROSSPFDIR/${cross}.sh
|
|
|
|
|
2019-08-03 23:07:23 +02:00
|
|
|
_vars="TARGET_MACHINE CROSS_TRIPLET CROSS_CFLAGS CROSS_CXXFLAGS TARGET_QEMU_MACHINE"
|
2019-08-03 22:48:01 +02:00
|
|
|
for f in ${_vars}; do
|
2014-04-09 16:40:27 +02:00
|
|
|
eval val="\$XBPS_$f"
|
|
|
|
if [ -z "$val" ]; then
|
|
|
|
echo "ERROR: XBPS_$f is not defined!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
export XBPS_CROSS_BASE=/usr/$XBPS_CROSS_TRIPLET
|
2019-07-25 11:49:44 +02:00
|
|
|
export XBPS_TARGET_QEMU_MACHINE
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2020-01-27 03:48:07 +01:00
|
|
|
XBPS_INSTALL_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_INSTALL_CMD -c /host/repocache-$XBPS_TARGET_MACHINE -r $XBPS_CROSS_BASE"
|
|
|
|
XBPS_QUERY_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_QUERY_CMD -c /host/repocache-$XBPS_TARGET_MACHINE -r $XBPS_CROSS_BASE"
|
2016-04-27 16:47:05 +02:00
|
|
|
XBPS_RECONFIGURE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RECONFIGURE_CMD -r $XBPS_CROSS_BASE"
|
|
|
|
XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_REMOVE_CMD -r $XBPS_CROSS_BASE"
|
|
|
|
XBPS_RINDEX_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE $XBPS_RINDEX_CMD"
|
|
|
|
XBPS_UHELPER_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-uhelper -r $XBPS_CROSS_BASE"
|
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
|
|
|
XBPS_CHECKVERS_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-checkvers -r $XBPS_CROSS_BASE"
|
2014-04-09 16:40:27 +02:00
|
|
|
else
|
|
|
|
export XBPS_TARGET_MACHINE=${XBPS_ARCH:-$XBPS_MACHINE}
|
2017-03-08 17:28:31 +01:00
|
|
|
unset XBPS_CROSS_BASE XBPS_CROSS_LDFLAGS XBPS_CROSS_FFLAGS
|
2014-04-09 16:40:27 +02:00
|
|
|
unset XBPS_CROSS_CFLAGS XBPS_CROSS_CXXFLAGS XBPS_CROSS_CPPFLAGS
|
2019-02-08 17:36:42 +01:00
|
|
|
unset XBPS_CROSS_RUSTFLAGS XBPS_CROSS_RUST_TARGET
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
XBPS_INSTALL_XCMD="$XBPS_INSTALL_CMD"
|
|
|
|
XBPS_QUERY_XCMD="$XBPS_QUERY_CMD"
|
|
|
|
XBPS_RECONFIGURE_XCMD="$XBPS_RECONFIGURE_CMD"
|
|
|
|
XBPS_REMOVE_XCMD="$XBPS_REMOVE_CMD"
|
|
|
|
XBPS_RINDEX_XCMD="$XBPS_RINDEX_CMD"
|
|
|
|
XBPS_UHELPER_XCMD="$XBPS_UHELPER_CMD"
|
2019-07-10 19:48:54 +02:00
|
|
|
XBPS_CHECKVERS_XCMD="$XBPS_CHECKVERS_CMD"
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
|
2019-08-03 23:07:23 +02:00
|
|
|
export XBPS_ENDIAN=$(get_endian ${XBPS_MACHINE})
|
|
|
|
export XBPS_TARGET_ENDIAN=$(get_endian ${XBPS_TARGET_MACHINE})
|
|
|
|
export XBPS_LIBC=$(get_libc ${XBPS_MACHINE})
|
|
|
|
export XBPS_TARGET_LIBC=$(get_libc ${XBPS_TARGET_MACHINE})
|
|
|
|
export XBPS_WORDSIZE=$(get_wordsize ${XBPS_MACHINE})
|
|
|
|
export XBPS_TARGET_WORDSIZE=$(get_wordsize ${XBPS_TARGET_MACHINE})
|
2020-02-07 21:41:39 +01:00
|
|
|
export XBPS_NO_ATOMIC8=$(get_no_atomic8 ${XBPS_MACHINE})
|
|
|
|
export XBPS_TARGET_NO_ATOMIC8=$(get_no_atomic8 ${XBPS_TARGET_MACHINE})
|
2019-08-03 23:07:23 +02:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
export XBPS_INSTALL_XCMD XBPS_QUERY_XCMD XBPS_RECONFIGURE_XCMD \
|
|
|
|
XBPS_REMOVE_XCMD XBPS_RINDEX_XCMD XBPS_UHELPER_XCMD
|
|
|
|
|
|
|
|
# Source all sourcepkg environment setup snippets.
|
|
|
|
# Source all subpkg environment setup snippets.
|
|
|
|
for f in ${XBPS_COMMONDIR}/environment/setup-subpkg/*.sh; do
|
|
|
|
source_file "$f"
|
|
|
|
done
|
2015-02-25 18:54:00 +01:00
|
|
|
for f in ${XBPS_COMMONDIR}/environment/setup/*.sh; do
|
|
|
|
source_file "$f"
|
|
|
|
done
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-09-02 11:17:01 +02:00
|
|
|
if [ ! -f ${XBPS_SRCPKGDIR}/${basepkg}/template ]; then
|
|
|
|
msg_error "xbps-src: unexistent file: ${XBPS_SRCPKGDIR}/${basepkg}/template\n"
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
if [ -n "$cross" ]; then
|
|
|
|
export CROSS_BUILD="$cross"
|
2015-09-02 11:17:01 +02:00
|
|
|
source_file ${XBPS_SRCPKGDIR}/${basepkg}/template
|
2014-04-09 16:40:27 +02:00
|
|
|
else
|
|
|
|
unset CROSS_BUILD
|
2015-09-02 11:17:01 +02:00
|
|
|
source_file ${XBPS_SRCPKGDIR}/${basepkg}/template
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
|
2017-09-25 20:39:14 +02:00
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
# Check if required vars weren't set.
|
|
|
|
_vars="pkgname version short_desc revision homepage license"
|
|
|
|
for f in ${_vars}; do
|
|
|
|
eval val="\$$f"
|
|
|
|
if [ -z "$val" -o -z "$f" ]; then
|
|
|
|
msg_error "\"$f\" not set on $pkgname template.\n"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-03-20 19:06:18 +01:00
|
|
|
# Check if version is valid.
|
|
|
|
case "$version" in
|
|
|
|
*-*) msg_error "version contains invalid character: -\n";;
|
|
|
|
*_*) msg_error "version contains invalid character: _\n";;
|
|
|
|
esac
|
|
|
|
case "$version" in
|
|
|
|
*[0-9]*) : good ;;
|
|
|
|
*) msg_error "version must contain at least one digit.\n";;
|
|
|
|
esac
|
|
|
|
|
2014-04-09 16:40:27 +02:00
|
|
|
# Check if base-chroot is already installed.
|
2019-06-12 23:50:19 +02:00
|
|
|
if [ -z "$bootstrap" -a -z "$CHROOT_READY" -a "z$show_problems" != "zignore-problems" ]; then
|
|
|
|
msg_red "${pkg} is not a bootstrap package and cannot be built without it.\n"
|
|
|
|
msg_error "Please install bootstrap packages and try again.\n"
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
sourcepkg="${pkgname}"
|
2014-07-23 15:44:36 +02:00
|
|
|
if [ -z "$subpackages" ]; then
|
|
|
|
subpackages="$(get_subpkgs)"
|
|
|
|
fi
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-09-02 11:17:01 +02:00
|
|
|
if [ -h $XBPS_SRCPKGDIR/$basepkg ]; then
|
2014-04-09 16:40:27 +02:00
|
|
|
# Source all subpkg environment setup snippets.
|
|
|
|
for f in ${XBPS_COMMONDIR}/environment/setup-subpkg/*.sh; do
|
|
|
|
source_file "$f"
|
|
|
|
done
|
|
|
|
pkgname=$pkg
|
2015-09-02 11:17:01 +02:00
|
|
|
if ! declare -f ${basepkg}_package >/dev/null; then
|
|
|
|
msg_error "$pkgname: missing ${basepkg}_package() function!\n"
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
pkgver="${pkg}-${version}_${revision}"
|
|
|
|
|
|
|
|
# If build_style() unset, a do_install() function must be defined.
|
|
|
|
if [ -z "$build_style" ]; then
|
|
|
|
# Check that at least do_install() is defined.
|
|
|
|
if ! declare -f do_install >/dev/null; then
|
|
|
|
msg_error "$pkgver: missing do_install() function!\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
FILESDIR=$XBPS_SRCPKGDIR/$sourcepkg/files
|
|
|
|
PATCHESDIR=$XBPS_SRCPKGDIR/$sourcepkg/patches
|
|
|
|
DESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${sourcepkg}-${version}
|
|
|
|
PKGDESTDIR=$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET/${pkg}-${version}
|
|
|
|
|
2015-07-10 10:07:02 +02:00
|
|
|
if [ -n "$disable_parallel_build" -o -z "$XBPS_MAKEJOBS" ]; then
|
|
|
|
XBPS_MAKEJOBS=1
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
2015-07-10 10:07:02 +02:00
|
|
|
makejobs="-j$XBPS_MAKEJOBS"
|
2014-04-09 16:40:27 +02:00
|
|
|
|
2015-12-03 10:04:16 +01:00
|
|
|
# strip whitespaces to make " noarch " valid too.
|
|
|
|
if [ "${archs// /}" = "noarch" ]; then
|
2015-03-01 16:57:27 +01:00
|
|
|
arch="noarch"
|
2015-03-01 16:06:30 +01:00
|
|
|
else
|
2015-03-01 16:57:27 +01:00
|
|
|
arch="$XBPS_TARGET_MACHINE"
|
2015-03-01 16:06:30 +01:00
|
|
|
fi
|
2015-03-15 09:54:02 +01:00
|
|
|
if [ -n "$XBPS_BINPKG_EXISTS" ]; then
|
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
|
|
|
local _binpkgver="$($XBPS_QUERY_XCMD -R -ppkgver $pkgver 2>/dev/null)"
|
|
|
|
if [ "$_binpkgver" = "$pkgver" ]; then
|
|
|
|
if [ -z "$XBPS_DEPENDENCY" ]; then
|
|
|
|
local _repo="$($XBPS_QUERY_XCMD -R -prepository $pkgver 2>/dev/null)"
|
|
|
|
msg_normal "xbps-src: $pkgver: found ($XBPS_TARGET_MACHINE) ($_repo)\n"
|
|
|
|
fi
|
2015-03-15 09:54:02 +01:00
|
|
|
exit_and_cleanup
|
|
|
|
fi
|
2015-02-28 10:29:27 +01:00
|
|
|
fi
|
|
|
|
|
2014-11-05 17:29:28 +01:00
|
|
|
if [ -z "$XBPS_DEBUG_PKGS" -o "$repository" = "nonfree" ]; then
|
2014-11-16 11:52:36 +01:00
|
|
|
nodebug=yes
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
# -g is required to build -dbg packages.
|
2014-11-16 11:52:36 +01:00
|
|
|
if [ -z "$nodebug" ]; then
|
2014-04-09 16:40:27 +02:00
|
|
|
dbgflags="-g"
|
|
|
|
fi
|
|
|
|
|
2019-02-10 19:07:28 +01:00
|
|
|
# build profile is used always in order to expose the host triplet,
|
|
|
|
# but the compiler flags from it are only used when not crossing
|
|
|
|
if [ -z "$CHROOT_READY" ]; then
|
|
|
|
source_file ${XBPS_COMMONDIR}/build-profiles/bootstrap.sh
|
|
|
|
else
|
|
|
|
source_file ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
|
2014-11-10 11:15:53 +01:00
|
|
|
fi
|
2015-03-04 15:17:05 +01:00
|
|
|
|
2017-11-22 23:09:25 +01:00
|
|
|
set_build_options
|
|
|
|
|
2019-02-10 19:07:28 +01:00
|
|
|
export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
|
|
|
|
export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
|
|
|
|
export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS"
|
|
|
|
export CPPFLAGS="$XBPS_CPPFLAGS $XBPS_CROSS_CPPFLAGS $CPPFLAGS"
|
|
|
|
export LDFLAGS="$XBPS_LDFLAGS $XBPS_CROSS_LDFLAGS $LDFLAGS"
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
export BUILD_CC="cc"
|
2019-06-10 16:18:23 +02:00
|
|
|
export BUILD_CXX="c++"
|
|
|
|
export BUILD_CPP="cpp"
|
|
|
|
export BUILD_FC="gfortran"
|
|
|
|
export BUILD_LD="ld"
|
2014-04-09 16:40:27 +02:00
|
|
|
export BUILD_CFLAGS="$XBPS_CFLAGS"
|
2016-08-08 21:56:54 +02:00
|
|
|
export BUILD_CXXFLAGS="$XBPS_CXXFLAGS"
|
|
|
|
export BUILD_CPPFLAGS="$XBPS_CPPFLAGS"
|
|
|
|
export BUILD_LDFLAGS="$XBPS_LDFLAGS"
|
2017-03-08 16:03:59 +01:00
|
|
|
export BUILD_FFLAGS="$XBPS_FFLAGS"
|
2016-08-08 21:56:54 +02:00
|
|
|
|
2014-09-25 16:31:20 +02:00
|
|
|
export CC_FOR_BUILD="cc"
|
|
|
|
export CXX_FOR_BUILD="g++"
|
|
|
|
export CPP_FOR_BUILD="cpp"
|
2017-03-08 16:06:54 +01:00
|
|
|
export FC_FOR_BUILD="gfortran"
|
2014-09-25 16:31:20 +02:00
|
|
|
export LD_FOR_BUILD="ld"
|
2020-05-07 19:43:49 +02:00
|
|
|
export PKG_CONFIG_FOR_BUILD="/usr/bin/pkg-config"
|
2014-09-25 16:31:20 +02:00
|
|
|
export CFLAGS_FOR_BUILD="$XBPS_CFLAGS"
|
|
|
|
export CXXFLAGS_FOR_BUILD="$XBPS_CXXFLAGS"
|
|
|
|
export CPPFLAGS_FOR_BUILD="$XBPS_CPPFLAGS"
|
|
|
|
export LDFLAGS_FOR_BUILD="$XBPS_LDFLAGS"
|
2017-03-08 16:03:59 +01:00
|
|
|
export FFLAGS_FOR_BUILD="$XBPS_FFLAGS"
|
2014-04-09 16:40:27 +02:00
|
|
|
|
|
|
|
if [ -n "$cross" ]; then
|
2016-08-08 21:56:54 +02:00
|
|
|
# Regular tools names
|
2014-04-09 16:40:27 +02:00
|
|
|
export CC="${XBPS_CROSS_TRIPLET}-gcc"
|
|
|
|
export CXX="${XBPS_CROSS_TRIPLET}-c++"
|
|
|
|
export CPP="${XBPS_CROSS_TRIPLET}-cpp"
|
2017-03-08 16:06:54 +01:00
|
|
|
export FC="${XBPS_CROSS_TRIPLET}-gfortran"
|
2014-04-09 16:40:27 +02:00
|
|
|
export GCC="$CC"
|
|
|
|
export LD="${XBPS_CROSS_TRIPLET}-ld"
|
|
|
|
export AR="${XBPS_CROSS_TRIPLET}-ar"
|
|
|
|
export AS="${XBPS_CROSS_TRIPLET}-as"
|
|
|
|
export RANLIB="${XBPS_CROSS_TRIPLET}-ranlib"
|
|
|
|
export STRIP="${XBPS_CROSS_TRIPLET}-strip"
|
|
|
|
export OBJDUMP="${XBPS_CROSS_TRIPLET}-objdump"
|
|
|
|
export OBJCOPY="${XBPS_CROSS_TRIPLET}-objcopy"
|
|
|
|
export NM="${XBPS_CROSS_TRIPLET}-nm"
|
|
|
|
export READELF="${XBPS_CROSS_TRIPLET}-readelf"
|
2020-05-07 19:43:49 +02:00
|
|
|
export PKG_CONFIG="${XBPS_CROSS_TRIPLET}-pkg-config"
|
2016-08-08 21:56:54 +02:00
|
|
|
# Target tools
|
|
|
|
export CC_target="$CC"
|
|
|
|
export CXX_target="$CXX"
|
|
|
|
export CPP_target="$CPP"
|
|
|
|
export GCC_target="$GCC"
|
2017-03-08 16:06:54 +01:00
|
|
|
export FC_target="$FC"
|
2016-08-08 21:56:54 +02:00
|
|
|
export LD_target="$LD"
|
|
|
|
export AR_target="$AR"
|
|
|
|
export AS_target="$AS"
|
|
|
|
export RANLIB_target="$RANLIB"
|
|
|
|
export STRIP_target="$STRIP"
|
|
|
|
export OBJDUMP_target="$OBJDUMP"
|
|
|
|
export OBJCOPY_target="$OBJCOPY"
|
|
|
|
export NM_target="$NM"
|
|
|
|
export READELF_target="$READELF"
|
|
|
|
# Target flags
|
|
|
|
export CFLAGS_target="$CFLAGS"
|
|
|
|
export CXXFLAGS_target="$CXXFLAGS"
|
|
|
|
export CPPFLAGS_target="$CPPFLAGS"
|
|
|
|
export LDFLAGS_target="$LDFLAGS"
|
|
|
|
# Host tools
|
|
|
|
export CC_host="cc"
|
|
|
|
export CXX_host="g++"
|
|
|
|
export CPP_host="cpp"
|
|
|
|
export GCC_host="$CC_host"
|
2017-03-08 16:06:54 +01:00
|
|
|
export FC_host="gfortran"
|
2016-08-08 21:56:54 +02:00
|
|
|
export LD_host="ld"
|
|
|
|
export AR_host="ar"
|
|
|
|
export AS_host="as"
|
|
|
|
export RANLIB_host="ranlib"
|
|
|
|
export STRIP_host="strip"
|
|
|
|
export OBJDUMP_host="objdump"
|
|
|
|
export OBJCOPY_host="objcopy"
|
|
|
|
export NM_host="nm"
|
|
|
|
export READELF_host="readelf"
|
|
|
|
# Host flags
|
|
|
|
export CFLAGS_host="$XBPS_CFLAGS"
|
|
|
|
export CXXFLAGS_host="$XBPS_CXXFLAGS"
|
|
|
|
export CPPFLAGS_host="$XBPS_CPPFLAGS"
|
|
|
|
export LDFLAGS_host="$XBPS_LDFLAGS"
|
2018-10-11 20:35:46 +02:00
|
|
|
# Rust flags which are passed to rustc
|
|
|
|
export RUSTFLAGS="$XBPS_CROSS_RUSTFLAGS"
|
|
|
|
# Rust target, which differs from our triplets
|
|
|
|
export RUST_TARGET="$XBPS_CROSS_RUST_TARGET"
|
2019-02-10 19:07:28 +01:00
|
|
|
# Rust build, which is the host system, may also differ
|
|
|
|
export RUST_BUILD="$XBPS_RUST_TARGET"
|
2014-04-09 16:40:27 +02:00
|
|
|
else
|
2019-02-10 19:07:28 +01:00
|
|
|
# Target flags from build-profile
|
|
|
|
export CFLAGS="$XBPS_TARGET_CFLAGS $CFLAGS"
|
|
|
|
export CXXFLAGS="$XBPS_TARGET_CXXFLAGS $CXXFLAGS"
|
|
|
|
export FFLAGS="$XBPS_TARGET_FFLAGS $FFLAGS"
|
|
|
|
export CPPFLAGS="$XBPS_TARGET_CPPFLAGS $CPPFLAGS"
|
|
|
|
export LDFLAGS="$XBPS_TARGET_LDFLAGS $LDFLAGS"
|
|
|
|
# Tools
|
2014-04-09 16:40:27 +02:00
|
|
|
export CC="cc"
|
|
|
|
export CXX="g++"
|
|
|
|
export CPP="cpp"
|
|
|
|
export GCC="$CC"
|
2017-03-08 16:06:54 +01:00
|
|
|
export FC="gfortran"
|
2014-04-09 16:40:27 +02:00
|
|
|
export LD="ld"
|
|
|
|
export AR="ar"
|
|
|
|
export AS="as"
|
|
|
|
export RANLIB="ranlib"
|
|
|
|
export STRIP="strip"
|
|
|
|
export OBJDUMP="objdump"
|
|
|
|
export OBJCOPY="objcopy"
|
|
|
|
export NM="nm"
|
|
|
|
export READELF="readelf"
|
2020-05-29 14:30:06 +02:00
|
|
|
export PKG_CONFIG="pkg-config"
|
2018-10-11 20:35:46 +02:00
|
|
|
export RUST_TARGET="$XBPS_RUST_TARGET"
|
2019-02-10 19:07:28 +01:00
|
|
|
export RUST_BUILD="$XBPS_RUST_TARGET"
|
2019-01-19 11:03:10 +01:00
|
|
|
# Unset cross evironment variables
|
2017-03-08 16:06:54 +01:00
|
|
|
unset CC_target CXX_target CPP_target GCC_target FC_target LD_target AR_target AS_target
|
2016-10-28 14:46:25 +02:00
|
|
|
unset RANLIB_target STRIP_target OBJDUMP_target OBJCOPY_target NM_target READELF_target
|
|
|
|
unset CFLAGS_target CXXFLAGS_target CPPFLAGS_target LDFLAGS_target
|
2017-03-08 16:06:54 +01:00
|
|
|
unset CC_host CXX_host CPP_host GCC_host FC_host LD_host AR_host AS_host
|
2016-10-28 14:46:25 +02:00
|
|
|
unset RANLIB_host STRIP_host OBJDUMP_host OBJCOPY_host NM_host READELF_host
|
|
|
|
unset CFLAGS_host CXXFLAGS_host CPPFLAGS_host LDFLAGS_host
|
2019-02-08 17:36:42 +01:00
|
|
|
unset RUSTFLAGS
|
2014-04-09 16:40:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup some specific package vars.
|
|
|
|
if [ -z "$wrksrc" ]; then
|
|
|
|
wrksrc="$XBPS_BUILDDIR/${sourcepkg}-${version}"
|
|
|
|
else
|
|
|
|
wrksrc="$XBPS_BUILDDIR/$wrksrc"
|
|
|
|
fi
|
2014-03-27 10:06:27 +01:00
|
|
|
|
2019-07-10 19:48:54 +02:00
|
|
|
if [ "$cross" -a "$nocross" -a "$show_problems" != "ignore-problems" ]; then
|
2014-08-22 16:47:35 +02:00
|
|
|
msg_red "$pkgver: cannot be cross compiled, exiting...\n"
|
2018-05-01 16:28:30 +02:00
|
|
|
msg_red "$pkgver: $nocross\n"
|
2015-03-19 10:08:02 +01:00
|
|
|
exit 2
|
2019-07-10 19:48:54 +02:00
|
|
|
elif [ "$broken" -a "$show_problems" != "ignore-problems" ]; then
|
2014-11-11 22:10:30 +01:00
|
|
|
msg_red "$pkgver: cannot be built, it's currently broken; see the build log:\n"
|
|
|
|
msg_red "$pkgver: $broken\n"
|
2015-03-19 10:08:02 +01:00
|
|
|
exit 2
|
2014-08-21 12:07:44 +02:00
|
|
|
fi
|
2014-09-28 08:02:12 +02:00
|
|
|
|
2019-07-10 19:48:54 +02:00
|
|
|
if [ -n "$restricted" -a -z "$XBPS_ALLOW_RESTRICTED" -a "$show_problems" != "ignore-problems" ]; then
|
2015-07-26 10:22:35 +02:00
|
|
|
msg_red "$pkgver: does not allow redistribution of sources/binaries (restricted license).\n"
|
2015-11-14 11:55:04 +01:00
|
|
|
msg_red "If you really need this software, run 'echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf'\n"
|
2015-07-26 10:22:35 +02:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2014-12-22 12:15:34 +01:00
|
|
|
export XBPS_STATEDIR="${XBPS_BUILDDIR}/.xbps-${sourcepkg}"
|
2014-12-11 11:02:22 +01:00
|
|
|
export XBPS_WRAPPERDIR="${XBPS_STATEDIR}/wrappers"
|
2015-04-24 11:01:59 +02:00
|
|
|
|
2020-04-14 14:14:13 +02:00
|
|
|
mkdir -p $XBPS_STATEDIR $XBPS_WRAPPERDIR
|
|
|
|
|
2015-02-21 12:13:07 +01:00
|
|
|
source_file $XBPS_COMMONDIR/environment/build-style/${build_style}.sh
|
2019-01-21 03:50:35 +01:00
|
|
|
|
2019-02-26 21:27:15 +01:00
|
|
|
# Source all build-helper files that are defined
|
2019-01-21 03:50:35 +01:00
|
|
|
for f in $build_helper; do
|
|
|
|
if [ ! -r $XBPS_BUILDHELPERDIR/${f}.sh ]; then
|
|
|
|
msg_error "$pkgver: cannot find build helper $XBPS_BUILDHELPERDIR/${f}.sh!\n"
|
|
|
|
fi
|
|
|
|
. $XBPS_BUILDHELPERDIR/${f}.sh
|
|
|
|
done
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|