xbps-src: propagate error returned by xbps-src in the chroot.

Rather than pointing the user to cat the .log file, just cat it before exiting.
This commit is contained in:
Juan RP 2010-05-09 19:46:28 +02:00
parent e514b75180
commit 81d6978f02
5 changed files with 73 additions and 32 deletions

View File

@ -91,8 +91,12 @@ install_src_phase()
set_build_vars set_build_vars
# Run pre_install func. # Run pre_install func.
run_func pre_install 2>${wrksrc}/.xbps_pre_install.log \ run_func pre_install 2>${wrksrc}/.xbps_pre_install.log
|| msg_error "$pkgname: pre_install() failed! check $wrksrc/.xbps_pre_install.log" if [ $? -ne 0 ]; then
msg_red "$pkgname: pre_install() failed:"
cat $wrksrc/.xbps_pre_install.log
exit 1
fi
msg_normal "Running install phase for $pkgname-$lver." msg_normal "Running install phase for $pkgname-$lver."
@ -114,9 +118,12 @@ install_src_phase()
cd ${wrksrc} || msg_error "can't change cwd to wrksrc!" cd ${wrksrc} || msg_error "can't change cwd to wrksrc!"
# Run post_install func. # Run post_install func.
run_func post_install 2>${wrksrc}/.xbps_post_install.log \ run_func post_install 2>${wrksrc}/.xbps_post_install.log
|| msg_error "$pkgname: post_install() failed! check $wrksrc/.xbps_post_install.log" if [ $? -ne 0 ]; then
msg_red "$pkgname: post_install() failed:"
cat ${wrksrc}/.xbps_post_install.log
exit 1
fi
unset_build_vars unset_build_vars
# Remove libtool archives by default. # Remove libtool archives by default.
@ -163,9 +170,12 @@ install_src_phase()
pkgname=${subpkg} pkgname=${subpkg}
set_tmpl_common_vars set_tmpl_common_vars
set_build_vars set_build_vars
run_func do_install \ run_func do_install 2>${wrksrc}/.xbps_do_install_${pkgname}.log
2>${wrksrc}/.xbps_do_install_${pkgname}.log || \ if [ $? -ne 0 ]; then
msg_error "$pkgname: do_install() failed! check $wrksrc/.xbps_do_install_$pkgname.log" msg_red "$pkgname: do_install() failed:"
cat ${wrksrc}/.xbps_do_install_${pkgname}.log
exit 1
fi
unset_build_vars unset_build_vars
done done
@ -196,9 +206,8 @@ make_install()
# #
# Install package via make. # Install package via make.
# #
{ ${make_cmd} ${make_install_target} ${make_install_args} \ ${make_cmd} ${make_install_target} ${make_install_args} \
2>&1 | tee $wrksrc/.xbps_make_install.log; } \ || msg_error "$pkgname: make install failed!"
|| msg_error "$pkgname: make install failed! check $wrksrc/.xbps_make_install.log"
} }
[ -z "$PKG_TMPLNAME" ] && exit 1 [ -z "$PKG_TMPLNAME" ] && exit 1

View File

@ -57,8 +57,12 @@ build_src_phase()
makejobs="-j$XBPS_MAKEJOBS" makejobs="-j$XBPS_MAKEJOBS"
fi fi
# Run pre_build func. # Run pre_build func.
run_func pre_build 2>${wrksrc}/.xbps_pre_build.log \ run_func pre_build 2>${wrksrc}/.xbps_pre_build.log
|| msg_error "$pkgname: pre_build() failed! check $wrksrc/.xbps_pre_build.log" if [ $? -ne 0 ]; then
msg_red "$pkgname: pre_build() failed:"
cat $wrksrc/.xbps_pre_build.log
exit 1
fi
. $XBPS_SHUTILSDIR/buildvars_funcs.sh . $XBPS_SHUTILSDIR/buildvars_funcs.sh
set_build_vars set_build_vars
@ -78,8 +82,12 @@ build_src_phase()
fi fi
# Run post_build func. # Run post_build func.
run_func post_build 2>${wrksrc}/.xbps_post_build.log \ run_func post_build 2>${wrksrc}/.xbps_post_build.log
|| msg_error "$pkgname: post_build() failed! check $wrksrc/.xbps_post_build.log" if [ $? -ne 0 ]; then
msg_red "$pkgname: post_build() failed:"
cat $wrksrc/.xbps_post_build.log
exit 1
fi
unset makejobs unset makejobs

View File

@ -214,6 +214,20 @@ install_xbps_utils()
fi fi
} }
_mount()
{
MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount
return $?
}
_umount()
{
MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount
return $?
}
xbps_chroot_handler() xbps_chroot_handler()
{ {
local action="$1" local action="$1"
@ -237,9 +251,7 @@ xbps_chroot_handler()
create_busybox_links create_busybox_links
install_xbps_utils install_xbps_utils
MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ _mount || return $?
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper mount
[ $? -ne 0 ] && return $?
if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then if [ -n "$XBPS_PREFER_BINPKG_DEPS" ]; then
prepare_binpkg_repos prepare_binpkg_repos
@ -248,26 +260,26 @@ xbps_chroot_handler()
# Reinstall xbps-src in the chroot # Reinstall xbps-src in the chroot
if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then if [ ! -f $XBPS_MASTERDIR/usr/local/sbin/xbps-src ]; then
msg_normal "Installing xbps-src in the masterdir..." msg_normal "Installing xbps-src in the masterdir..."
{ env in_chroot=yes LANG=C PATH=$path \ env in_chroot=yes LANG=C PATH=$path \
${chroot_cmd} $XBPS_MASTERDIR sh -c \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \
"cd /xbps/xbps-src && make IN_CHROOT=1 install clean" \ "cd /xbps/xbps-src && make IN_CHROOT=1 install clean" \
2>&1 >/dev/null; } 2>&1 >/dev/null || return $?
fi fi
if [ "$action" = "chroot" ]; then if [ "$action" = "chroot" ]; then
{ env in_chroot=yes IN_CHROOT=1 LANG=C PATH=$path \ env in_chroot=yes IN_CHROOT=1 LANG=C PATH=$path \
${chroot_cmd} $XBPS_MASTERDIR /bin/sh; } ${chroot_cmd} $XBPS_MASTERDIR /bin/sh || return $?
else else
[ "$norm_builddir" = "yes" ] && \ [ "$norm_builddir" = "yes" ] && \
action="-C $action" action="-C $action"
{ env in_chroot=yes LANG=C PATH=$path \ env in_chroot=yes LANG=C PATH=$path \
${chroot_cmd} $XBPS_MASTERDIR sh -c \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \
"cd /xbps/srcpkgs/$pkg && xbps-src $action"; } "cd /xbps/srcpkgs/$pkg && xbps-src $action" || \
rv=$? && _umount && return $rv
fi fi
msg_normal "Exiting from the chroot on $XBPS_MASTERDIR." msg_normal "Exiting from the chroot on $XBPS_MASTERDIR."
MASTERDIR="${XBPS_MASTERDIR}" ${sudo_cmd} \ _umount
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount
return $? return $?
} }

View File

@ -1,5 +1,5 @@
#- #-
# Copyright (c) 2008-2009 Juan Romero Pardines. # Copyright (c) 2008-2010 Juan Romero Pardines.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -38,7 +38,7 @@ run_func()
fi fi
} }
msg_error() msg_red()
{ {
[ -z "$1" ] && return 1 [ -z "$1" ] && return 1
@ -50,7 +50,11 @@ msg_error()
echo "=> ERROR: $1" echo "=> ERROR: $1"
fi fi
printf "\033[m" printf "\033[m"
}
msg_error()
{
msg_red "$@"
exit 1 exit 1
} }

View File

@ -58,8 +58,12 @@ configure_src_phase()
cd $wrksrc || msg_error "unexistent build directory [$wrksrc]." cd $wrksrc || msg_error "unexistent build directory [$wrksrc]."
# Run pre_configure func. # Run pre_configure func.
run_func pre_configure 2>${wrksrc}/.xbps_pre_configure.log \ run_func pre_configure 2>${wrksrc}/.xbps_pre_configure.log
|| msg_error "$pkgname: pre_configure() failed! check $wrksrc/.xbps_pre_configure.log" if [ $? -ne 0 ]; then
msg_red "$pkgname: pre_configure() failed:"
cat $wrksrc/.xbps_pre_configure.log
exit 1
fi
# Export configure_env vars. # Export configure_env vars.
for f in ${configure_env}; do for f in ${configure_env}; do
@ -115,8 +119,12 @@ configure_src_phase()
fi fi
# Run post_configure func. # Run post_configure func.
run_func post_configure 2>${wrksrc}/.xbps_post_configure.log \ run_func post_configure 2>${wrksrc}/.xbps_post_configure.log
|| msg_error "$pkgname: post_configure() failed! check $wrksrc/.xbps_post_configure.log" if [ $? -ne 0 ]; then
msg_red "$pkgname: post_configure() failed:"
cat $wrksrc/.xbps_post_configure.log
exit 1
fi
# unset configure_env vars. # unset configure_env vars.
for f in ${configure_env}; do for f in ${configure_env}; do