etcupdate: Consolidate nobuild cases and make more robust

The distrib-dirs and distribution steps are shared between the two, the
only difference is whether MAKEOBJDIRPREFIX is in the environment for
the latter. Having in the environment for the former is currently not
needed but does no harm and will be needed in future, so we can just
export it up-front in the subshell. When we do distrib-dirs relative to
_obj and everything also doesn't matter, so move it next to distribution
where it makes more sense. Finally, to avoid complicated && chains, use
"|| exit 1" everywhere to make the subshell fail, and add an extra one
on to the cd $SRCDIR to handle that failing (otherwise we'd go on and
try to build the current directory after cd prints its error, which is
unhelpful).

These changes will make it easier to bundle these steps up into new
top-level targets to allow the build system to manage the steps rather
than etcupdate, which will also handle BUILD_WITH_STRICT_TMPPATH, which
currently does not work with etcupdate.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D41204
This commit is contained in:
Jessica Clarke 2023-07-27 05:10:48 +01:00
parent 8fc3059b00
commit 03e62670c3

View File

@ -214,15 +214,17 @@ build_tree()
mkdir -p $1/etc || return 1
cp -p $SRCDIR/$file $1/etc/$name || return 1
done
elif ! [ -n "$nobuild" ]; then
(cd $SRCDIR; $make DESTDIR=$destdir distrib-dirs &&
MAKEOBJDIRPREFIX=$destdir/usr/obj $make _obj SUBDIR_OVERRIDE=etc &&
MAKEOBJDIRPREFIX=$destdir/usr/obj $make everything SUBDIR_OVERRIDE=etc &&
MAKEOBJDIRPREFIX=$destdir/usr/obj $make DESTDIR=$destdir distribution) || \
return 1
else
(cd $SRCDIR; $make DESTDIR=$destdir distrib-dirs &&
$make DESTDIR=$destdir distribution) || return 1
(
cd $SRCDIR || exit 1;
if ! [ -n "$nobuild" ]; then
export MAKEOBJDIRPREFIX=$destdir/usr/obj;
$make _obj SUBDIR_OVERRIDE=etc || exit 1
$make everything SUBDIR_OVERRIDE=etc || exit 1
fi
$make DESTDIR=$destdir distrib-dirs || exit 1
$make DESTDIR=$destdir distribution || exit 1
) || return 1
fi
chflags -R noschg $1 || return 1
rm -rf $1/usr/obj || return 1