xbps-src: multiple improvements for -B and run_func.
* run_func now errors out by itself if the function returned any error. * if -B flag is enabled and binpkg already exists, skip updating local repo pkg-index.
This commit is contained in:
parent
e22c565811
commit
110aede193
7 changed files with 74 additions and 78 deletions
|
@ -70,10 +70,8 @@ install_src_phase()
|
|||
# Run pre_install func.
|
||||
if [ ! -f $XBPS_PRE_INSTALL_DONE ]; then
|
||||
run_func pre_install
|
||||
if [ $? -eq 0 ]; then
|
||||
msg_normal "'$pkgname-$lver': pre_install (destdir) phase done.\n"
|
||||
touch -f $XBPS_PRE_INSTALL_DONE
|
||||
fi
|
||||
msg_normal "'$pkgname-$lver': pre_install (destdir) phase done.\n"
|
||||
touch -f $XBPS_PRE_INSTALL_DONE
|
||||
fi
|
||||
|
||||
# Type of installation: custom, make or python.
|
||||
|
@ -92,10 +90,8 @@ install_src_phase()
|
|||
# Run post_install func.
|
||||
if [ ! -f $XBPS_POST_INSTALL_DONE ]; then
|
||||
run_func post_install
|
||||
if [ $? -eq 0 ]; then
|
||||
msg_normal "'$pkgname-$lver': post_install (destdir) phase done.\n"
|
||||
touch -f $XBPS_POST_INSTALL_DONE
|
||||
fi
|
||||
msg_normal "'$pkgname-$lver': post_install (destdir) phase done.\n"
|
||||
touch -f $XBPS_POST_INSTALL_DONE
|
||||
fi
|
||||
|
||||
# Remove libtool archives by default.
|
||||
|
@ -141,9 +137,7 @@ install_src_phase()
|
|||
set_tmpl_common_vars
|
||||
if [ ! -f ${wrksrc}/.xbps_do_install_${pkgname}_done ]; then
|
||||
run_func do_install
|
||||
if [ $? -eq 0 ]; then
|
||||
touch -f ${wrksrc}/.xbps_do_install_${pkgname}_done
|
||||
fi
|
||||
touch -f ${wrksrc}/.xbps_do_install_${pkgname}_done
|
||||
else
|
||||
msg_warn "'$sourcepkg-$lver': skipping '$pkgname' subpkg, already installed into destdir.\n"
|
||||
fi
|
||||
|
|
|
@ -37,9 +37,9 @@ do_make_build()
|
|||
|
||||
build_src_phase()
|
||||
{
|
||||
local pkg="$pkgname-$version" pkgparam="$1" f lver
|
||||
local pkg="$pkgname-$version" f lver
|
||||
|
||||
[ -z $pkgparam ] && [ -z $pkgname -o -z $version ] && return 1
|
||||
[ -z $pkgname -o -z $version ] && return 1
|
||||
|
||||
#
|
||||
# Skip this phase for meta-template and only-install style builds.
|
||||
|
@ -72,10 +72,8 @@ build_src_phase()
|
|||
# Run pre_build func.
|
||||
if [ ! -f $XBPS_PRE_BUILD_DONE ]; then
|
||||
run_func pre_build
|
||||
if [ $? -eq 0 ]; then
|
||||
msg_normal "'$pkgname-$lver': pre_build phase done.\n"
|
||||
touch -f $XBPS_PRE_BUILD_DONE
|
||||
fi
|
||||
msg_normal "'$pkgname-$lver': pre_build phase done.\n"
|
||||
touch -f $XBPS_PRE_BUILD_DONE
|
||||
fi
|
||||
|
||||
if [ "$build_style" = "custom-install" ]; then
|
||||
|
@ -89,10 +87,8 @@ build_src_phase()
|
|||
# Run post_build func.
|
||||
if [ ! -f $XBPS_POST_BUILD_DONE ]; then
|
||||
run_func post_build
|
||||
if [ $? -eq 0 ]; then
|
||||
msg_normal "'$pkgname-l$ver': post_build phase done.\n"
|
||||
touch -f $XBPS_POST_BUILD_DONE
|
||||
fi
|
||||
msg_normal "'$pkgname-l$ver': post_build phase done.\n"
|
||||
touch -f $XBPS_POST_BUILD_DONE
|
||||
fi
|
||||
|
||||
unset makejobs
|
||||
|
|
|
@ -38,7 +38,8 @@ run_func_error()
|
|||
lver="${version}"
|
||||
fi
|
||||
|
||||
msg_error "'${pkgname}-${lver}': '$func' phase didn't complete due to errors or SIGINT!\n"
|
||||
echo
|
||||
msg_error "${pkgname}-${lver}: '$func' interrupted!\n"
|
||||
}
|
||||
|
||||
remove_pkgdestdir_sighandler()
|
||||
|
@ -116,14 +117,17 @@ run_func()
|
|||
tee "$logfile" < "$logpipe" &
|
||||
exec 1>"$logpipe" 2>"$logpipe"
|
||||
set -e
|
||||
trap "run_func_error $func" 0
|
||||
trap "run_func_error $func && return $?" INT
|
||||
msg_normal "'$pkgname-$lver': running $func phase...\n"
|
||||
$func 2>&1
|
||||
rval=$?
|
||||
set +e
|
||||
trap '' 0
|
||||
trap - INT
|
||||
exec 1>&3 2>&3 3>&-
|
||||
rm -f "$logpipe"
|
||||
return 0
|
||||
if [ $rval -ne 0 ]; then
|
||||
msg_error "${pkgname}-${lver}: $func failed!\n"
|
||||
fi
|
||||
fi
|
||||
return 255 # function not found.
|
||||
}
|
||||
|
|
|
@ -65,12 +65,6 @@ configure_src_phase()
|
|||
local f lver
|
||||
|
||||
[ -z $pkgname ] && return 1
|
||||
|
||||
# Apply patches if requested by template file
|
||||
if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then
|
||||
apply_tmpl_patches
|
||||
fi
|
||||
|
||||
#
|
||||
# Skip this phase for: meta-template, only-install,
|
||||
# gnu_makefile and python-module style builds.
|
||||
|
@ -91,10 +85,8 @@ configure_src_phase()
|
|||
# Run pre_configure func.
|
||||
if [ ! -f $XBPS_PRECONFIGURE_DONE ]; then
|
||||
run_func pre_configure
|
||||
if [ $? -eq 0 ]; then
|
||||
msg_normal "'$pkgname-$lver': pre_configure phase done.\n"
|
||||
touch -f $XBPS_PRECONFIGURE_DONE
|
||||
fi
|
||||
msg_normal "'$pkgname-$lver': pre_configure phase done.\n"
|
||||
touch -f $XBPS_PRECONFIGURE_DONE
|
||||
fi
|
||||
|
||||
[ -z "$configure_script" ] && configure_script="./configure"
|
||||
|
@ -104,28 +96,28 @@ configure_src_phase()
|
|||
cd $build_wrksrc || return 1
|
||||
fi
|
||||
|
||||
case "$build_style" in
|
||||
gnu_configure|gnu-configure) run_func do_gnu_configure ;;
|
||||
configure) run_func do_nongnu_configure ;;
|
||||
perl-module|perl_module) run_func do_perl_configure ;;
|
||||
custom-install) run_func do_configure;;
|
||||
*)
|
||||
if [ "$build_style" = "gnu_configure" ]; then
|
||||
run_func do_gnu_configure
|
||||
elif [ "$build_style" = "configure" ]; then
|
||||
run_func do_nongnu_configure
|
||||
elif [ "$build_style" = "perl-module" ]; then
|
||||
run_func do_perl_configure
|
||||
elif [ "$build_style" = "custom-install" ]; then
|
||||
run_func do_configure
|
||||
else
|
||||
#
|
||||
# Unknown build_style type won't work :-)
|
||||
#
|
||||
msg_error "'$pkgname-$lver': unknown build_style [$build_style]\n"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
msg_normal "'$pkgname-$lver': configure phase done.\n"
|
||||
|
||||
# Run post_configure func.
|
||||
if [ ! -f $XBPS_POSTCONFIGURE_DONE ]; then
|
||||
run_func post_configure
|
||||
if [ $? -eq 0 ]; then
|
||||
msg_normal "'$pkgname-$lver': post_configure phase done."
|
||||
touch -f $XBPS_POSTCONFIGURE_DONE
|
||||
fi
|
||||
msg_normal "'$pkgname-$lver': post_configure phase done.\n"
|
||||
touch -f $XBPS_POSTCONFIGURE_DONE
|
||||
fi
|
||||
|
||||
touch -f $XBPS_CONFIGURE_DONE
|
||||
|
|
|
@ -40,6 +40,11 @@ extract_distfiles()
|
|||
#
|
||||
[ -n "$pkg" -a -z "$pkgname" ] && return 1
|
||||
|
||||
if [ -n "$revision" ]; then
|
||||
lver="${version}_${revision}"
|
||||
else
|
||||
lver="${version}"
|
||||
fi
|
||||
#
|
||||
# If noextract is set, do a "fake extraction".
|
||||
#
|
||||
|
|
|
@ -48,7 +48,7 @@ binpkg_cleanup()
|
|||
local pkgdir="$1" binpkg="$2"
|
||||
|
||||
[ -z "$pkgdir" -o -z "$binpkg" ] && return 1
|
||||
msg_red "\nInterrupted! removing $binpkg file!\n"
|
||||
msg_red "Interrupted! removing $binpkg file!\n"
|
||||
rm -f $pkgdir/$binpkg
|
||||
exit 1
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ xbps_make_binpkg_real()
|
|||
#
|
||||
if [ -f $pkgdir/$binpkg ]; then
|
||||
msg_normal "Skipping existing $binpkg pkg...\n"
|
||||
return 0
|
||||
return 6 # EEXIST
|
||||
fi
|
||||
|
||||
#
|
||||
|
@ -111,13 +111,14 @@ xbps_make_binpkg_real()
|
|||
|
||||
# Remove binpkg if interrupted...
|
||||
trap "binpkg_cleanup $pkgdir $binpkg" INT
|
||||
|
||||
msg_normal "Building $binpkg... "
|
||||
${fakeroot_cmd} ${fakeroot_cmd_args} \
|
||||
tar --exclude "var/db/xbps/metadata/*/flist" \
|
||||
-cpf - ${mfiles} ${dirs} | \
|
||||
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
|
||||
rval=$?
|
||||
trap - INT
|
||||
|
||||
if [ $rval -eq 0 ]; then
|
||||
msg_normal_append "done.\n"
|
||||
else
|
||||
|
|
|
@ -73,27 +73,20 @@ install_pkg()
|
|||
# Fetch, extract, build and install into the destination directory.
|
||||
#
|
||||
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
|
||||
extract_distfiles
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_red "cannot extract distfiles for '$pkgname'!\n"
|
||||
return 1
|
||||
fi
|
||||
extract_distfiles || return $?
|
||||
fi
|
||||
|
||||
# Apply patches if requested by template file
|
||||
if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then
|
||||
apply_tmpl_patches || return $?
|
||||
fi
|
||||
|
||||
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
|
||||
configure_src_phase
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_red "cannot configure '$pkgname'!\n"
|
||||
return 1
|
||||
fi
|
||||
configure_src_phase || return $?
|
||||
fi
|
||||
|
||||
if [ ! -f "$XBPS_BUILD_DONE" ]; then
|
||||
build_src_phase
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_red "cannot build '$pkgname'!\n"
|
||||
return 1
|
||||
fi
|
||||
build_src_phase || return $?
|
||||
fi
|
||||
|
||||
# Install pkg into destdir.
|
||||
|
@ -127,20 +120,24 @@ install_pkg()
|
|||
# -B is set.
|
||||
if [ -n "$BUILD_BINPKG" ]; then
|
||||
xbps_make_binpkg
|
||||
[ $? -ne 0 ] && return $?
|
||||
msg_normal "Updating pkg-index for local repository at:\n"
|
||||
msg_normal " $XBPS_PACKAGESDIR\n"
|
||||
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
|
||||
rval=$?
|
||||
if [ $rval -ne 0 -a $rval -ne 6 ]; then
|
||||
return $?
|
||||
elif [ $rval -eq 6 ]; then
|
||||
# binpkg exists, no need to update
|
||||
# repo pkg-index.
|
||||
:
|
||||
else
|
||||
msg_normal "Updating pkg-index for local repository at:\n"
|
||||
msg_normal " $XBPS_PACKAGESDIR\n"
|
||||
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Stow package into masterdir.
|
||||
stow_pkg_handler stow
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_red "cannot stow '$pkgname'!\n"
|
||||
return 1
|
||||
fi
|
||||
stow_pkg_handler stow || return $?
|
||||
|
||||
# Copy generated pkg metadata files into its metadata dir.
|
||||
if [ ! -f ${DESTDIR}/files.plist ]; then
|
||||
|
@ -176,10 +173,17 @@ install_pkg()
|
|||
# -B is set.
|
||||
if [ -n "$BUILD_BINPKG" ]; then
|
||||
xbps_make_binpkg
|
||||
[ $? -ne 0 ] && return $?
|
||||
msg_normal "Updating pkg-index for local repository at:\n"
|
||||
msg_normal " $XBPS_PACKAGESDIR\n"
|
||||
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
|
||||
rval=$?
|
||||
if [ "$rval" -ne 0 -a "$rval" -ne 6 ]; then
|
||||
return $rval
|
||||
elif [ "$rval" -eq 6 ]; then
|
||||
# binpkg exists no need to update pkg-index in repo.
|
||||
:
|
||||
else
|
||||
msg_normal "Updating pkg-index for local repository at:\n"
|
||||
msg_normal " $XBPS_PACKAGESDIR\n"
|
||||
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
return $?
|
||||
|
|
Loading…
Reference in a new issue