common/libexec/build.sh: register all packages at once to prevent inconistent staging

This commit is contained in:
Enno Boland 2018-09-06 10:30:21 +02:00 committed by Enno Boland
parent a053e1b57c
commit 50e86ef640
2 changed files with 22 additions and 10 deletions

View file

@ -7,16 +7,7 @@ registerpkg() {
msg_error "Unexistent binary package ${repo}/${pkg}!\n"
fi
msg_normal "Registering ${pkg} into ${repo} ...\n"
if [ -n "${arch}" ]; then
XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${repo}/${pkg}
else
if [ -n "$XBPS_CROSS_BUILD" ]; then
$XBPS_RINDEX_XCMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${repo}/${pkg}
else
$XBPS_RINDEX_CMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${repo}/${pkg}
fi
fi
printf "%s:%s:%s\n" "${arch}" "${repo}" "${pkg}" >> "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg"
}
hook() {

View file

@ -84,11 +84,32 @@ for subpkg in ${subpackages} ${sourcepkg}; do
fi
done
# Clean list of preregistered packages
printf "" > ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg
# If install went ok generate the binpkgs.
for subpkg in ${subpackages} ${sourcepkg}; do
$XBPS_LIBEXECDIR/xbps-src-dopkg.sh $subpkg "$XBPS_REPOSITORY" "$XBPS_CROSS_BUILD" || exit 1
done
# Registering packages at once per repository. This makes sure that staging is
# triggered for all new packages if any of them introduces inconsistencies.
cut -d: -f 1,2 ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg | sort -u | \
while IFS=: read -r arch repo; do
paths=$(grep "^$arch:$repo:" "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg" | \
cut -f 2,3 | tr ':' '/')
if [ -n "${arch}" ]; then
msg_normal "Registering new packages to $repo ($arch)\n"
XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
else
msg_normal "Registering new packages to $repo\n"
if [ -n "$XBPS_CROSS_BUILD" ]; then
$XBPS_RINDEX_XCMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
else
$XBPS_RINDEX_CMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
fi
fi
done
# pkg cleanup
if declare -f do_clean >/dev/null; then
run_func do_clean