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:
Juan RP 2011-07-18 13:43:22 +02:00
parent e22c565811
commit 110aede193
7 changed files with 74 additions and 78 deletions

View file

@ -70,10 +70,8 @@ install_src_phase()
# Run pre_install func. # Run pre_install func.
if [ ! -f $XBPS_PRE_INSTALL_DONE ]; then if [ ! -f $XBPS_PRE_INSTALL_DONE ]; then
run_func pre_install run_func pre_install
if [ $? -eq 0 ]; then msg_normal "'$pkgname-$lver': pre_install (destdir) phase done.\n"
msg_normal "'$pkgname-$lver': pre_install (destdir) phase done.\n" touch -f $XBPS_PRE_INSTALL_DONE
touch -f $XBPS_PRE_INSTALL_DONE
fi
fi fi
# Type of installation: custom, make or python. # Type of installation: custom, make or python.
@ -92,10 +90,8 @@ install_src_phase()
# Run post_install func. # Run post_install func.
if [ ! -f $XBPS_POST_INSTALL_DONE ]; then if [ ! -f $XBPS_POST_INSTALL_DONE ]; then
run_func post_install run_func post_install
if [ $? -eq 0 ]; then msg_normal "'$pkgname-$lver': post_install (destdir) phase done.\n"
msg_normal "'$pkgname-$lver': post_install (destdir) phase done.\n" touch -f $XBPS_POST_INSTALL_DONE
touch -f $XBPS_POST_INSTALL_DONE
fi
fi fi
# Remove libtool archives by default. # Remove libtool archives by default.
@ -141,9 +137,7 @@ install_src_phase()
set_tmpl_common_vars set_tmpl_common_vars
if [ ! -f ${wrksrc}/.xbps_do_install_${pkgname}_done ]; then if [ ! -f ${wrksrc}/.xbps_do_install_${pkgname}_done ]; then
run_func do_install run_func do_install
if [ $? -eq 0 ]; then touch -f ${wrksrc}/.xbps_do_install_${pkgname}_done
touch -f ${wrksrc}/.xbps_do_install_${pkgname}_done
fi
else else
msg_warn "'$sourcepkg-$lver': skipping '$pkgname' subpkg, already installed into destdir.\n" msg_warn "'$sourcepkg-$lver': skipping '$pkgname' subpkg, already installed into destdir.\n"
fi fi

View file

@ -37,9 +37,9 @@ do_make_build()
build_src_phase() 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. # Skip this phase for meta-template and only-install style builds.
@ -72,10 +72,8 @@ build_src_phase()
# Run pre_build func. # Run pre_build func.
if [ ! -f $XBPS_PRE_BUILD_DONE ]; then if [ ! -f $XBPS_PRE_BUILD_DONE ]; then
run_func pre_build run_func pre_build
if [ $? -eq 0 ]; then msg_normal "'$pkgname-$lver': pre_build phase done.\n"
msg_normal "'$pkgname-$lver': pre_build phase done.\n" touch -f $XBPS_PRE_BUILD_DONE
touch -f $XBPS_PRE_BUILD_DONE
fi
fi fi
if [ "$build_style" = "custom-install" ]; then if [ "$build_style" = "custom-install" ]; then
@ -89,10 +87,8 @@ build_src_phase()
# Run post_build func. # Run post_build func.
if [ ! -f $XBPS_POST_BUILD_DONE ]; then if [ ! -f $XBPS_POST_BUILD_DONE ]; then
run_func post_build run_func post_build
if [ $? -eq 0 ]; then msg_normal "'$pkgname-l$ver': post_build phase done.\n"
msg_normal "'$pkgname-l$ver': post_build phase done.\n" touch -f $XBPS_POST_BUILD_DONE
touch -f $XBPS_POST_BUILD_DONE
fi
fi fi
unset makejobs unset makejobs

View file

@ -38,7 +38,8 @@ run_func_error()
lver="${version}" lver="${version}"
fi 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() remove_pkgdestdir_sighandler()
@ -116,14 +117,17 @@ run_func()
tee "$logfile" < "$logpipe" & tee "$logfile" < "$logpipe" &
exec 1>"$logpipe" 2>"$logpipe" exec 1>"$logpipe" 2>"$logpipe"
set -e set -e
trap "run_func_error $func" 0 trap "run_func_error $func && return $?" INT
msg_normal "'$pkgname-$lver': running $func phase...\n" msg_normal "'$pkgname-$lver': running $func phase...\n"
$func 2>&1 $func 2>&1
rval=$?
set +e set +e
trap '' 0 trap - INT
exec 1>&3 2>&3 3>&- exec 1>&3 2>&3 3>&-
rm -f "$logpipe" rm -f "$logpipe"
return 0 if [ $rval -ne 0 ]; then
msg_error "${pkgname}-${lver}: $func failed!\n"
fi
fi fi
return 255 # function not found. return 255 # function not found.
} }

View file

@ -65,12 +65,6 @@ configure_src_phase()
local f lver local f lver
[ -z $pkgname ] && return 1 [ -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, # Skip this phase for: meta-template, only-install,
# gnu_makefile and python-module style builds. # gnu_makefile and python-module style builds.
@ -91,10 +85,8 @@ configure_src_phase()
# Run pre_configure func. # Run pre_configure func.
if [ ! -f $XBPS_PRECONFIGURE_DONE ]; then if [ ! -f $XBPS_PRECONFIGURE_DONE ]; then
run_func pre_configure run_func pre_configure
if [ $? -eq 0 ]; then msg_normal "'$pkgname-$lver': pre_configure phase done.\n"
msg_normal "'$pkgname-$lver': pre_configure phase done.\n" touch -f $XBPS_PRECONFIGURE_DONE
touch -f $XBPS_PRECONFIGURE_DONE
fi
fi fi
[ -z "$configure_script" ] && configure_script="./configure" [ -z "$configure_script" ] && configure_script="./configure"
@ -104,28 +96,28 @@ configure_src_phase()
cd $build_wrksrc || return 1 cd $build_wrksrc || return 1
fi fi
case "$build_style" in if [ "$build_style" = "gnu_configure" ]; then
gnu_configure|gnu-configure) run_func do_gnu_configure ;; run_func do_gnu_configure
configure) run_func do_nongnu_configure ;; elif [ "$build_style" = "configure" ]; then
perl-module|perl_module) run_func do_perl_configure ;; run_func do_nongnu_configure
custom-install) run_func do_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 :-) # Unknown build_style type won't work :-)
# #
msg_error "'$pkgname-$lver': unknown build_style [$build_style]\n" msg_error "'$pkgname-$lver': unknown build_style [$build_style]\n"
;; fi
esac
msg_normal "'$pkgname-$lver': configure phase done.\n" msg_normal "'$pkgname-$lver': configure phase done.\n"
# Run post_configure func. # Run post_configure func.
if [ ! -f $XBPS_POSTCONFIGURE_DONE ]; then if [ ! -f $XBPS_POSTCONFIGURE_DONE ]; then
run_func post_configure run_func post_configure
if [ $? -eq 0 ]; then msg_normal "'$pkgname-$lver': post_configure phase done.\n"
msg_normal "'$pkgname-$lver': post_configure phase done." touch -f $XBPS_POSTCONFIGURE_DONE
touch -f $XBPS_POSTCONFIGURE_DONE
fi
fi fi
touch -f $XBPS_CONFIGURE_DONE touch -f $XBPS_CONFIGURE_DONE

View file

@ -40,6 +40,11 @@ extract_distfiles()
# #
[ -n "$pkg" -a -z "$pkgname" ] && return 1 [ -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". # If noextract is set, do a "fake extraction".
# #

View file

@ -48,7 +48,7 @@ binpkg_cleanup()
local pkgdir="$1" binpkg="$2" local pkgdir="$1" binpkg="$2"
[ -z "$pkgdir" -o -z "$binpkg" ] && return 1 [ -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 rm -f $pkgdir/$binpkg
exit 1 exit 1
} }
@ -84,7 +84,7 @@ xbps_make_binpkg_real()
# #
if [ -f $pkgdir/$binpkg ]; then if [ -f $pkgdir/$binpkg ]; then
msg_normal "Skipping existing $binpkg pkg...\n" msg_normal "Skipping existing $binpkg pkg...\n"
return 0 return 6 # EEXIST
fi fi
# #
@ -111,13 +111,14 @@ xbps_make_binpkg_real()
# Remove binpkg if interrupted... # Remove binpkg if interrupted...
trap "binpkg_cleanup $pkgdir $binpkg" INT trap "binpkg_cleanup $pkgdir $binpkg" INT
msg_normal "Building $binpkg... " msg_normal "Building $binpkg... "
${fakeroot_cmd} ${fakeroot_cmd_args} \ ${fakeroot_cmd} ${fakeroot_cmd_args} \
tar --exclude "var/db/xbps/metadata/*/flist" \ tar --exclude "var/db/xbps/metadata/*/flist" \
-cpf - ${mfiles} ${dirs} | \ -cpf - ${mfiles} ${dirs} | \
$XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg $XBPS_COMPRESS_CMD ${clevel} -qf > $pkgdir/$binpkg
rval=$? rval=$?
trap - INT
if [ $rval -eq 0 ]; then if [ $rval -eq 0 ]; then
msg_normal_append "done.\n" msg_normal_append "done.\n"
else else

View file

@ -73,27 +73,20 @@ install_pkg()
# Fetch, extract, build and install into the destination directory. # Fetch, extract, build and install into the destination directory.
# #
if [ ! -f "$XBPS_EXTRACT_DONE" ]; then if [ ! -f "$XBPS_EXTRACT_DONE" ]; then
extract_distfiles extract_distfiles || return $?
if [ $? -ne 0 ]; then fi
msg_red "cannot extract distfiles for '$pkgname'!\n"
return 1 # Apply patches if requested by template file
fi if [ ! -f $XBPS_APPLYPATCHES_DONE ]; then
apply_tmpl_patches || return $?
fi fi
if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then if [ ! -f "$XBPS_CONFIGURE_DONE" ]; then
configure_src_phase configure_src_phase || return $?
if [ $? -ne 0 ]; then
msg_red "cannot configure '$pkgname'!\n"
return 1
fi
fi fi
if [ ! -f "$XBPS_BUILD_DONE" ]; then if [ ! -f "$XBPS_BUILD_DONE" ]; then
build_src_phase build_src_phase || return $?
if [ $? -ne 0 ]; then
msg_red "cannot build '$pkgname'!\n"
return 1
fi
fi fi
# Install pkg into destdir. # Install pkg into destdir.
@ -127,20 +120,24 @@ install_pkg()
# -B is set. # -B is set.
if [ -n "$BUILD_BINPKG" ]; then if [ -n "$BUILD_BINPKG" ]; then
xbps_make_binpkg xbps_make_binpkg
[ $? -ne 0 ] && return $? rval=$?
msg_normal "Updating pkg-index for local repository at:\n" if [ $rval -ne 0 -a $rval -ne 6 ]; then
msg_normal " $XBPS_PACKAGESDIR\n" return $?
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null 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 fi
return 0 return 0
fi fi
# Stow package into masterdir. # Stow package into masterdir.
stow_pkg_handler stow stow_pkg_handler stow || return $?
if [ $? -ne 0 ]; then
msg_red "cannot stow '$pkgname'!\n"
return 1
fi
# Copy generated pkg metadata files into its metadata dir. # Copy generated pkg metadata files into its metadata dir.
if [ ! -f ${DESTDIR}/files.plist ]; then if [ ! -f ${DESTDIR}/files.plist ]; then
@ -176,10 +173,17 @@ install_pkg()
# -B is set. # -B is set.
if [ -n "$BUILD_BINPKG" ]; then if [ -n "$BUILD_BINPKG" ]; then
xbps_make_binpkg xbps_make_binpkg
[ $? -ne 0 ] && return $? rval=$?
msg_normal "Updating pkg-index for local repository at:\n" if [ "$rval" -ne 0 -a "$rval" -ne 6 ]; then
msg_normal " $XBPS_PACKAGESDIR\n" return $rval
${XBPS_REPO_CMD} genindex ${XBPS_PACKAGESDIR} 2>/dev/null 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 fi
return $? return $?