2014-04-09 16:40:27 +02:00
|
|
|
# vim: set ts=4 sw=4 et:
|
2014-03-22 12:31:42 +01:00
|
|
|
|
|
|
|
check_pkg_arch() {
|
2014-04-09 16:55:58 +02:00
|
|
|
local cross="$1"
|
|
|
|
|
|
|
|
if [ -n "$BEGIN_INSTALL" -a -n "$only_for_archs" ]; then
|
|
|
|
if [ -n "$cross" ]; then
|
|
|
|
_arch="$XBPS_TARGET_MACHINE"
|
|
|
|
elif [ -n "$XBPS_ARCH" ]; then
|
|
|
|
_arch="$XBPS_ARCH"
|
|
|
|
else
|
|
|
|
_arch="$XBPS_MACHINE"
|
|
|
|
fi
|
|
|
|
for f in ${only_for_archs}; do
|
|
|
|
if [ "$f" = "${_arch}" ]; then
|
|
|
|
found=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -z "$found" ]; then
|
|
|
|
msg_red "$pkgname: this package cannot be built for ${_arch}.\n"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
install_pkg() {
|
2014-04-09 16:55:58 +02:00
|
|
|
local target="$1" cross="$2" lrepo subpkg opkg
|
|
|
|
|
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
|
2014-06-30 11:32:07 +02:00
|
|
|
show_pkg_build_options
|
2014-04-09 16:55:58 +02:00
|
|
|
check_pkg_arch $cross
|
|
|
|
install_cross_pkg $cross
|
|
|
|
|
|
|
|
if [ -z "$XBPS_SKIP_DEPS" ]; then
|
|
|
|
install_pkg_deps $sourcepkg $cross || return 1
|
|
|
|
if [ "$TARGETPKG_PKGDEPS_DONE" ]; then
|
|
|
|
setup_pkg $XBPS_TARGET_PKG $cross
|
|
|
|
unset TARGETPKG_PKGDEPS_DONE
|
|
|
|
install_cross_pkg $cross
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Fetch distfiles after installing required dependencies,
|
|
|
|
# because some of them might be required for do_fetch().
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-dofetch.sh $sourcepkg $cross || exit 1
|
|
|
|
[ "$target" = "fetch" ] && return 0
|
|
|
|
|
|
|
|
# Fetch, extract, build and install into the destination directory.
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doextract.sh $sourcepkg $cross || exit 1
|
|
|
|
[ "$target" = "extract" ] && return 0
|
|
|
|
|
|
|
|
# Run configure phase
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doconfigure.sh $sourcepkg $cross || exit 1
|
|
|
|
[ "$target" = "configure" ] && return 0
|
|
|
|
|
|
|
|
# Run build phase
|
|
|
|
$XBPS_LIBEXECDIR/xbps-src-dobuild.sh $sourcepkg $cross || exit 1
|
|
|
|
[ "$target" = "build" ] && return 0
|
|
|
|
|
2014-08-25 22:34:13 +02:00
|
|
|
# Install pkgs into destdir.
|
2014-09-24 19:51:17 +02:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doinstall.sh $sourcepkg $cross || exit 1
|
2014-04-09 16:55:58 +02:00
|
|
|
|
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
2014-09-24 19:51:17 +02:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-doinstall.sh $subpkg $cross || exit 1
|
2014-08-25 22:34:13 +02:00
|
|
|
done
|
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
2014-09-24 19:51:17 +02:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-prepkg.sh $subpkg $cross || exit 1
|
2014-04-09 16:55:58 +02:00
|
|
|
done
|
|
|
|
|
2014-12-06 12:32:56 +01:00
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
|
|
|
if [ "$XBPS_TARGET_PKG" = "${subpkg}" -a "$target" = "install" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
2014-04-09 16:55:58 +02:00
|
|
|
|
|
|
|
# If install went ok generate the binpkgs.
|
2014-08-25 22:34:13 +02:00
|
|
|
for subpkg in ${subpackages} ${sourcepkg}; do
|
2014-09-24 19:51:17 +02:00
|
|
|
$XBPS_LIBEXECDIR/xbps-src-dopkg.sh $subpkg "$XBPS_REPOSITORY" "$cross" || exit 1
|
2014-04-09 16:55:58 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# pkg cleanup
|
|
|
|
if declare -f do_clean >/dev/null; then
|
|
|
|
run_func do_clean
|
|
|
|
fi
|
|
|
|
|
|
|
|
opkg=$pkgver
|
|
|
|
if [ -z "$XBPS_KEEP_ALL" ]; then
|
|
|
|
remove_pkg_autodeps
|
|
|
|
remove_pkg_wrksrc
|
|
|
|
setup_pkg $sourcepkg $cross
|
|
|
|
remove_pkg $cross
|
2014-12-13 09:42:11 +01:00
|
|
|
remove_pkg_statedir
|
2014-04-09 16:55:58 +02:00
|
|
|
fi
|
|
|
|
|
2014-08-26 10:33:15 +02:00
|
|
|
# If base-chroot not installed, install "base-files" into masterdir
|
|
|
|
# from local repository; this is the only pkg required to be able to build
|
|
|
|
# the bootstrap pkgs from scratch.
|
|
|
|
if [ -z "$CHROOT_READY" -a "$pkgname" = "base-files" ]; then
|
2014-04-09 16:55:58 +02:00
|
|
|
msg_normal "Installing $opkg into masterdir...\n"
|
|
|
|
local _log=$(mktemp --tmpdir|| exit 1)
|
|
|
|
if [ -n "$XBPS_BUILD_FORCEMODE" ]; then
|
|
|
|
local _flags="-f"
|
|
|
|
fi
|
|
|
|
$XBPS_INSTALL_CMD ${_flags} -y $opkg >${_log} 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_red "Failed to install $opkg into masterdir, see below for errors:\n"
|
|
|
|
cat ${_log}
|
|
|
|
rm -f ${_log}
|
|
|
|
msg_error "Cannot continue!"
|
|
|
|
fi
|
|
|
|
rm -f ${_log}
|
|
|
|
fi
|
|
|
|
|
2015-01-05 17:11:23 +01:00
|
|
|
if [ "$XBPS_TARGET_PKG" = "$sourcepkg" ]; then
|
|
|
|
if [ "$XBPS_TARGET" = "bootstrap" ]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
# Package built successfully. Exit directly due to nested install_pkg
|
|
|
|
# and install_pkg_deps functions.
|
|
|
|
remove_cross_pkg $cross
|
|
|
|
exit 0
|
|
|
|
fi
|
2014-04-09 16:55:58 +02:00
|
|
|
fi
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
2014-09-05 11:10:07 +02:00
|
|
|
remove_pkg_autodeps() {
|
|
|
|
local rval= tmplogf=
|
|
|
|
|
|
|
|
cd $XBPS_MASTERDIR || return 1
|
|
|
|
msg_normal "${pkgver:-xbps-src}: removing autodeps, please wait...\n"
|
|
|
|
tmplogf=$(mktemp)
|
|
|
|
|
|
|
|
if [ -z "$CHROOT_READY" ]; then
|
2014-09-24 19:51:17 +02:00
|
|
|
xbps-reconfigure -r $XBPS_MASTERDIR -a >> $tmplogf 2>&1
|
|
|
|
xbps-remove -r $XBPS_MASTERDIR -Ryo >> $tmplogf 2>&1
|
2014-09-05 11:10:07 +02:00
|
|
|
else
|
|
|
|
remove_pkg_cross_deps
|
2014-09-24 19:51:17 +02:00
|
|
|
xbps-reconfigure -a >> $tmplogf 2>&1
|
|
|
|
xbps-remove -Ryo >> $tmplogf 2>&1
|
2014-09-05 11:10:07 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
msg_red "${pkgver:-xbps-src}: failed to remove autodeps:\n"
|
|
|
|
cat $tmplogf && rm -f $tmplogf
|
|
|
|
msg_error "${pkgver:-xbps-src}: cannot continue!\n"
|
|
|
|
fi
|
|
|
|
rm -f $tmplogf
|
|
|
|
}
|
|
|
|
|
2014-03-22 12:31:42 +01:00
|
|
|
remove_pkg_wrksrc() {
|
2014-04-09 16:55:58 +02:00
|
|
|
if [ -d "$wrksrc" ]; then
|
|
|
|
msg_normal "$pkgver: cleaning build directory...\n"
|
|
|
|
rm -rf $wrksrc
|
|
|
|
fi
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|
|
|
|
|
2014-12-13 09:42:11 +01:00
|
|
|
remove_pkg_statedir() {
|
|
|
|
if [ -d "$XBPS_STATEDIR" ]; then
|
|
|
|
rm -rf "$XBPS_STATEDIR"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-03-22 12:31:42 +01:00
|
|
|
remove_pkg() {
|
2014-04-09 16:55:58 +02:00
|
|
|
local cross="$1" _destdir f
|
|
|
|
|
|
|
|
[ -z $pkgname ] && msg_error "unexistent package, aborting.\n"
|
|
|
|
|
|
|
|
if [ -n "$cross" ]; then
|
|
|
|
_destdir="$XBPS_DESTDIR/$XBPS_CROSS_TRIPLET"
|
|
|
|
else
|
|
|
|
_destdir="$XBPS_DESTDIR"
|
|
|
|
fi
|
|
|
|
|
2014-08-21 12:16:53 +02:00
|
|
|
[ ! -d ${_destdir} ] && return
|
|
|
|
|
2014-04-09 16:55:58 +02:00
|
|
|
for f in ${sourcepkg} ${subpackages}; do
|
|
|
|
if [ -d "${_destdir}/${f}-${version}" ]; then
|
|
|
|
msg_normal "$f: removing files from destdir...\n"
|
|
|
|
rm -rf ${_destdir}/${f}-${version}
|
|
|
|
fi
|
|
|
|
if [ -d "${_destdir}/${f}-dbg-${version}" ]; then
|
|
|
|
msg_normal "$f: removing dbg files from destdir...\n"
|
|
|
|
rm -rf ${_destdir}/${f}-dbg-${version}
|
|
|
|
fi
|
|
|
|
if [ -d "${_destdir}/${f}-32bit-${version}" ]; then
|
|
|
|
msg_normal "$f: removing 32bit files from destdir...\n"
|
|
|
|
rm -rf ${_destdir}/${f}-32bit-${version}
|
|
|
|
fi
|
2014-12-11 11:02:22 +01:00
|
|
|
rm -f ${XBPS_STATEDIR}/${f}_${cross}_subpkg_install_done
|
|
|
|
rm -f ${XBPS_STATEDIR}/${f}_${cross}_prepkg_done
|
2014-04-09 16:55:58 +02:00
|
|
|
done
|
2014-12-11 11:02:22 +01:00
|
|
|
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_install_done
|
|
|
|
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_pre_install_done
|
|
|
|
rm -f ${XBPS_STATEDIR}/${sourcepkg}_${cross}_post_install_done
|
2014-03-22 12:31:42 +01:00
|
|
|
}
|