2015-03-14 06:50:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# vim: set ts=4 sw=4 et:
|
|
|
|
#
|
|
|
|
# Passed arguments:
|
|
|
|
# $1 - current pkgname to build [REQUIRED]
|
|
|
|
# $2 - target pkgname (origin) to build [REQUIRED]
|
|
|
|
# $3 - xbps target [REQUIRED]
|
|
|
|
# $4 - cross target [OPTIONAL]
|
2015-03-23 11:42:35 +00:00
|
|
|
# $5 - internal [OPTIONAL]
|
2015-03-14 06:50:05 +00:00
|
|
|
|
2015-03-23 11:42:35 +00:00
|
|
|
if [ $# -lt 3 -o $# -gt 5 ]; then
|
2015-09-11 05:55:40 +00:00
|
|
|
echo "${0##*/}: invalid number of arguments: pkgname targetpkg target [cross-target]"
|
2015-03-14 06:50:05 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
readonly PKGNAME="$1"
|
2015-09-24 14:12:10 +00:00
|
|
|
readonly XBPS_TARGET_PKG="$2"
|
|
|
|
readonly XBPS_TARGET="$3"
|
2015-03-14 06:50:05 +00:00
|
|
|
readonly XBPS_CROSS_BUILD="$4"
|
2015-03-23 11:42:35 +00:00
|
|
|
readonly XBPS_CROSS_PREPARE="$5"
|
2015-03-14 06:50:05 +00:00
|
|
|
|
2015-09-24 14:12:10 +00:00
|
|
|
export XBPS_TARGET
|
|
|
|
|
2015-03-14 06:50:05 +00:00
|
|
|
for f in $XBPS_SHUTILSDIR/*.sh; do
|
|
|
|
. $f
|
|
|
|
done
|
|
|
|
|
|
|
|
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
|
2015-03-30 18:24:11 +00:00
|
|
|
readonly SOURCEPKG="$sourcepkg"
|
|
|
|
|
2015-03-14 06:50:05 +00:00
|
|
|
show_pkg_build_options
|
|
|
|
check_pkg_arch $XBPS_CROSS_BUILD
|
2015-03-23 11:42:35 +00:00
|
|
|
|
|
|
|
if [ -z "$XBPS_CROSS_PREPARE" ]; then
|
2015-04-15 09:38:23 +00:00
|
|
|
prepare_cross_sysroot $XBPS_CROSS_BUILD || exit $?
|
2015-03-23 11:42:35 +00:00
|
|
|
fi
|
2015-07-29 08:52:10 +00:00
|
|
|
if [ -z "$XBPS_DEPENDENCY" -a -z "$XBPS_TEMP_MASTERDIR" -a -n "$XBPS_KEEP_ALL" -a "$XBPS_CHROOT_CMD" = "proot" ]; then
|
2015-07-16 07:38:02 +00:00
|
|
|
remove_pkg_autodeps
|
|
|
|
fi
|
2015-03-14 06:50:05 +00:00
|
|
|
# Install dependencies from binary packages
|
2015-09-24 14:12:10 +00:00
|
|
|
if [ "$PKGNAME" != "$XBPS_TARGET_PKG" -o -z "$XBPS_SKIP_DEPS" ]; then
|
|
|
|
install_pkg_deps $PKGNAME $XBPS_TARGET_PKG pkg $XBPS_CROSS_BUILD $XBPS_CROSS_PREPARE || exit $?
|
2015-03-14 06:50:05 +00:00
|
|
|
fi
|
|
|
|
|
2019-07-10 19:07:16 +00:00
|
|
|
if [ "$XBPS_CROSS_BUILD" ]; then
|
|
|
|
install_cross_pkg $XBPS_CROSS_BUILD || exit $?
|
|
|
|
fi
|
|
|
|
|
2015-03-14 06:50:05 +00:00
|
|
|
# Fetch distfiles after installing required dependencies,
|
|
|
|
# because some of them might be required for do_fetch().
|
2015-03-30 18:24:11 +00:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-dofetch.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
2015-09-24 14:12:10 +00:00
|
|
|
[ "$XBPS_TARGET" = "fetch" ] && exit 0
|
2015-03-14 06:50:05 +00:00
|
|
|
|
|
|
|
# Fetch, extract, build and install into the destination directory.
|
2015-03-30 18:24:11 +00:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doextract.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
2015-09-24 14:12:10 +00:00
|
|
|
[ "$XBPS_TARGET" = "extract" ] && exit 0
|
2015-03-14 06:50:05 +00:00
|
|
|
|
2019-02-26 13:17:26 +00:00
|
|
|
# Run patch phrase
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-dopatch.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
|
|
|
[ "$XBPS_TARGET" = "patch" ] && exit 0
|
|
|
|
|
2015-03-14 06:50:05 +00:00
|
|
|
# Run configure phase
|
2015-03-30 18:24:11 +00:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doconfigure.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
2015-09-24 14:12:10 +00:00
|
|
|
[ "$XBPS_TARGET" = "configure" ] && exit 0
|
2015-03-14 06:50:05 +00:00
|
|
|
|
|
|
|
# Run build phase
|
2015-03-30 18:24:11 +00:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-dobuild.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
2015-09-24 14:12:10 +00:00
|
|
|
[ "$XBPS_TARGET" = "build" ] && exit 0
|
2015-03-14 06:50:05 +00:00
|
|
|
|
2017-02-23 21:03:31 +00:00
|
|
|
# Run check phase
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-docheck.sh $SOURCEPKG $XBPS_CROSS_BUILD || exit 1
|
|
|
|
[ "$XBPS_TARGET" = "check" ] && exit 0
|
|
|
|
|
2015-03-14 06:50:05 +00:00
|
|
|
# Install pkgs into destdir.
|
2015-09-27 08:30:10 +00:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doinstall.sh $SOURCEPKG no $XBPS_CROSS_BUILD || exit 1
|
2015-03-14 06:50:05 +00:00
|
|
|
|
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
2015-09-27 08:30:10 +00:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doinstall.sh $subpkg yes $XBPS_CROSS_BUILD || exit 1
|
2015-03-14 06:50:05 +00:00
|
|
|
done
|
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-prepkg.sh $subpkg $XBPS_CROSS_BUILD || exit 1
|
|
|
|
done
|
|
|
|
|
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
2015-09-24 14:12:10 +00:00
|
|
|
if [ "$PKGNAME" = "${subpkg}" -a "$XBPS_TARGET" = "install" ]; then
|
2015-03-14 06:50:05 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-09-06 08:30:21 +00:00
|
|
|
# Clean list of preregistered packages
|
|
|
|
printf "" > ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg
|
2015-03-14 06:50:05 +00:00
|
|
|
# If install went ok generate the binpkgs.
|
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-dopkg.sh $subpkg "$XBPS_REPOSITORY" "$XBPS_CROSS_BUILD" || exit 1
|
|
|
|
done
|
|
|
|
|
2018-09-06 08:30:21 +00:00
|
|
|
# Registering packages at once per repository. This makes sure that staging is
|
|
|
|
# triggered for all new packages if any of them introduces inconsistencies.
|
|
|
|
cut -d: -f 1,2 ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg | sort -u | \
|
|
|
|
while IFS=: read -r arch repo; do
|
|
|
|
paths=$(grep "^$arch:$repo:" "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg" | \
|
2018-09-07 13:54:08 +00:00
|
|
|
cut -d : -f 2,3 | tr ':' '/')
|
2018-09-06 08:30:21 +00:00
|
|
|
if [ -n "${arch}" ]; then
|
|
|
|
msg_normal "Registering new packages to $repo ($arch)\n"
|
2019-06-25 08:52:37 +00:00
|
|
|
XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD \
|
|
|
|
${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
|
2018-09-06 08:30:21 +00:00
|
|
|
else
|
|
|
|
msg_normal "Registering new packages to $repo\n"
|
|
|
|
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
2019-06-25 08:52:37 +00:00
|
|
|
$XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
|
|
|
|
${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
|
2018-09-06 08:30:21 +00:00
|
|
|
else
|
2019-06-25 08:52:37 +00:00
|
|
|
$XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
|
|
|
|
${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
|
2018-09-06 08:30:21 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-03-14 06:50:05 +00:00
|
|
|
# pkg cleanup
|
|
|
|
if declare -f do_clean >/dev/null; then
|
|
|
|
run_func do_clean
|
|
|
|
fi
|
|
|
|
|
2015-05-02 01:40:52 +00:00
|
|
|
if [ -n "$XBPS_DEPENDENCY" -o -z "$XBPS_KEEP_ALL" ]; then
|
2015-03-14 06:50:05 +00:00
|
|
|
remove_pkg_autodeps
|
|
|
|
remove_pkg_wrksrc
|
|
|
|
remove_pkg $XBPS_CROSS_BUILD
|
|
|
|
remove_pkg_statedir
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|