mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 01:55:19 +01:00
Add targets/pseudo/bootstrap-packages
Try to compensate for the lack any origin for a DIRDEPS build. bootstrap-packages will extract the PACKAGE lines from the tree's Makefiles and use them to populate targets/packages/Makefile.depend and targets/packages/*/Makefile.depend so we can at least try to keep the Makefile.depend files throughout the tree up to date. This is far from ideal, as we cannot (easily) take into account options that affect the contents of various packages. Reviewed by: stevek Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D47065
This commit is contained in:
parent
6621842ccf
commit
87b759f0fa
23
targets/pseudo/bootstrap-packages/Makefile
Normal file
23
targets/pseudo/bootstrap-packages/Makefile
Normal file
@ -0,0 +1,23 @@
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
# Compensate (a bit) for the lack of per package makefiles or other means
|
||||
# of knowing what goes in each package in the base system.
|
||||
# We can derive some of the information we want from the makefiles that
|
||||
# set PACKAGE.
|
||||
|
||||
all:
|
||||
.if ${.MAKE.LEVEL} > 0
|
||||
all: packages
|
||||
.endif
|
||||
|
||||
PACKAGES?= ${.CURDIR:H:H}/packages
|
||||
|
||||
packages: package-makefile.list
|
||||
@${.CURDIR}/bootstrap-packages.sh PACKAGES=${PACKAGES} ${.ALLSRC}
|
||||
|
||||
package-makefile.list:
|
||||
@(cd ${SRCTOP} && \
|
||||
find ${TOPS:U*bin etc lib*} -name 'Makefile' | \
|
||||
xargs grep '^PACKAGE[[:space:]]*=' ) | \
|
||||
sed 's/[[:space:]]*=[[:space:]]*/=/' > ${.TARGET}
|
||||
|
96
targets/pseudo/bootstrap-packages/bootstrap-packages.sh
Executable file
96
targets/pseudo/bootstrap-packages/bootstrap-packages.sh
Executable file
@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
# Our input is the output of something like:
|
||||
#
|
||||
# (cd ${SRCTOP} &&
|
||||
# find *bin etc lib* -name Makefile |
|
||||
# xargs grep '^PACKAGE[[:space:]]*=' )
|
||||
#
|
||||
# With some cleanup and looks like:
|
||||
#
|
||||
# usr.bin/ofed/libibverbs/Makefile:PACKAGE=FreeBSD-rdma
|
||||
# usr.bin/last/Makefile:PACKAGE=acct
|
||||
# usr.bin/lastcomm/Makefile:PACKAGE=acct
|
||||
# usr.bin/users/Makefile:PACKAGE=acct
|
||||
# usr.bin/who/Makefile:PACKAGE=acct
|
||||
# usr.sbin/ac/Makefile:PACKAGE=acct
|
||||
# usr.sbin/accton/Makefile:PACKAGE=acct
|
||||
# usr.sbin/lastlogin/Makefile:PACKAGE=acct
|
||||
# ..
|
||||
#
|
||||
# which we use to populate $PACKAGES/*/Makefile.depend
|
||||
# and $PACKAGES/Makefile.depend to make it easier to keep
|
||||
# Makefile.depend files throughout the tree up-to-date.
|
||||
#
|
||||
# The result is not ideal, as we do not (yet) take into account all
|
||||
# the MK_* knobs that can impact DIRDEPS.
|
||||
#
|
||||
|
||||
Mydir=`dirname $0`
|
||||
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
*=*) eval "$1"; shift;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
to_reldir() {
|
||||
sed "s,$SRCTOP/,,"
|
||||
}
|
||||
|
||||
SRCTOP=${SRCTOP:-$(realpath $Mydir/../../..)}
|
||||
PACKAGES=${PACKAGES:-$(realpath $Mydir/../..)}
|
||||
case "$PACKAGES" in
|
||||
/*) ;;
|
||||
*) PACKAGES=$SRCTOP/$PACKAGES;;
|
||||
esac
|
||||
|
||||
script_name=$(realpath $0 | to_reldir)
|
||||
|
||||
start_depend() {
|
||||
depfile=$1
|
||||
|
||||
mkdir -p ${depfile%/*}
|
||||
cat <<EOF > $depfile
|
||||
# Generated by $script_name
|
||||
|
||||
DIRDEPS= \\
|
||||
EOF
|
||||
}
|
||||
|
||||
end_depend() {
|
||||
depfile=$1
|
||||
|
||||
cat <<EOF >> $depfile
|
||||
|
||||
.include <dirdeps.mk>
|
||||
EOF
|
||||
}
|
||||
|
||||
start_depend $PACKAGES/Makefile.depend || exit 1
|
||||
sort -t= -k2 "$@" | sed 's,/Makefile:PACKAGE=, ,' |
|
||||
(
|
||||
lpackage=
|
||||
while read reldir package
|
||||
do
|
||||
case "$package" in \
|
||||
lib?{LIB}) package=${reldir##*/};;
|
||||
lib?{LIB:tl}) package=`echo ${reldir##*/} | tr 'A-Z' 'a-z'`;;
|
||||
esac
|
||||
if test "$package" != "$lpackage"; then \
|
||||
test -z "$lpackage" || end_depend $ddeps
|
||||
target=$PACKAGES/$package
|
||||
ddeps=$target/Makefile.depend
|
||||
start_depend $ddeps
|
||||
lpackage=$package
|
||||
echo " $target \\"
|
||||
fi
|
||||
echo " $reldir \\" >> $ddeps
|
||||
done
|
||||
end_depend $ddeps
|
||||
) | to_reldir >> $PACKAGES/Makefile.depend
|
||||
end_depend $PACKAGES/Makefile.depend
|
Loading…
Reference in New Issue
Block a user