xbps-src: improve run_func and always make a log in $wrksrc.

Also when or after the pkg is installed to destdir/stowned, and there was
any error, always remove the files that were installed into destdir.

With these changes there's no need to return any value in the do_foo()
functions because they are caught automatically. Also any function is now
logged into its own file to always log what happens.
This commit is contained in:
Juan RP 2010-12-18 22:38:21 +01:00
parent 4965921029
commit 08d47bc8b1
8 changed files with 158 additions and 151 deletions

View file

@ -42,7 +42,7 @@ set_defvars
install_src_phase()
{
local f i subpkg lver spkgrev saved_wrksrc
local f i subpkg lver spkgrev
[ -z $pkgname ] && return 2
@ -61,7 +61,6 @@ install_src_phase()
return 0
fi
saved_wrksrc=$wrksrc
cd $wrksrc || msg_error "can't change cwd to wrksrc!"
if [ -n "$build_wrksrc" ]; then
cd $build_wrksrc \
@ -70,12 +69,8 @@ install_src_phase()
# Run pre_install func.
if [ ! -f $XBPS_PRE_INSTALL_DONE ]; then
run_func pre_install 2>${wrksrc}/.xbps_pre_install.log
if [ $? -ne 0 -a $? -ne 255 ]; then
msg_red "Package '$pkgname': pre_install phase failed! errors below"
cat $wrksrc/.xbps_pre_install.log
exit 1
elif [ $? -eq 0 ]; then
run_func pre_install
if [ $? -eq 0 ]; then
msg_normal "Package '$pkgname': pre_install (destdir) phase done."
touch -f $XBPS_PRE_INSTALL_DONE
fi
@ -85,26 +80,12 @@ install_src_phase()
# Type of installation: custom, make or python.
case "$build_style" in
custom-install)
run_func do_install 2>${wrksrc}/.xbps_do_install.log
if [ $? -ne 0 -a $? -ne 255 ]; then
msg_red "Package '$pkgname': do_install phase failed! errors below:"
cat $wrksrc/.xbps_do_install.log
exit 1
fi
;;
custom-install) run_func do_install;;
python-module)
. $XBPS_HELPERSDIR/python-module.sh
run_func do_install 2>${wrksrc}/.xbps_do_install.log
if [ $? -ne 0 -a $? -ne 255 ]; then
msg_red "Package '$pkgname': install phase failed! errors below:"
cat $wrksrc/.xbps_do_install.log
exit 1
fi
;;
*)
make_install $lver 2>${wrksrc}/.xbps_make_install.log
run_func do_install
;;
*) run_func make_install;;
esac
cd ${wrksrc} || msg_error "can't change cwd to wrksrc!"
@ -112,12 +93,8 @@ install_src_phase()
# Run post_install func.
if [ ! -f $XBPS_POST_INSTALL_DONE ]; then
run_func post_install 2>${wrksrc}/.xbps_post_install.log
if [ $? -ne 0 -a $? -ne 255 ]; then
msg_red "Package '$pkgname': post_install phase failed! errors below:"
cat ${wrksrc}/.xbps_post_install.log
exit 1
elif [ $? -eq 0 ]; then
run_func post_install
if [ $? -eq 0 ]; then
msg_normal "Package '$pkgname': post_install (destdir) phase done."
touch -f $XBPS_POST_INSTALL_DONE
fi
@ -164,26 +141,14 @@ install_src_phase()
pkgname=${subpkg}
set_tmpl_common_vars
if [ ! -f ${wrksrc}/.xbps_do_install_${pkgname}_done ]; then
run_func do_install \
2>${wrksrc}/.xbps_do_install_${pkgname}.log
if [ $? -ne 0 -a $? -eq 255 ]; then
msg_red "Package '$pkgname': do_install phase failed! errors below:"
cat ${wrksrc}/.xbps_do_install_${pkgname}.log
exit 1
elif [ $? -eq 0 ]; then
run_func do_install
if [ $? -eq 0 ]; then
touch -f ${wrksrc}/.xbps_do_install_${pkgname}_done
fi
else
msg_normal "Package '$sourcepkg ($lver)': skipping '$pkgname' subpkg, already installed into destdir."
fi
done
#
# Remove $wrksrc if -C not specified.
#
if [ -d "$saved_wrksrc" -a "$dontrm_builddir" = "no" ]; then
remove_tmpl_wrksrc $saved_wrksrc
fi
}
#
@ -191,8 +156,6 @@ install_src_phase()
#
make_install()
{
local lver="$1"
if [ -z "$make_install_target" ]; then
make_install_target="DESTDIR=${DESTDIR} install"
fi
@ -201,11 +164,6 @@ make_install()
# Install package via make.
#
${make_cmd} ${make_install_target} ${make_install_args}
if [ $? -ne 0 -a -f ${wrksrc}/.xbps_make_install.log ]; then
msg_red "Package '$pkgname ($lver)': make install failed! full log below:"
cat ${wrksrc}/.xbps_make_install.log
exit 1
fi
}
[ -z "$PKG_TMPLNAME" ] && exit 2