git: 87b759f0fa1f - main - Add targets/pseudo/bootstrap-packages
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Oct 2024 21:16:43 UTC
The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=87b759f0fa1f7554d50ce640c40138512bbded44 commit 87b759f0fa1f7554d50ce640c40138512bbded44 Author: Simon J. Gerraty <sjg@FreeBSD.org> AuthorDate: 2024-10-11 21:15:47 +0000 Commit: Simon J. Gerraty <sjg@FreeBSD.org> CommitDate: 2024-10-11 21:15:47 +0000 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 --- targets/pseudo/bootstrap-packages/Makefile | 23 ++++++ .../bootstrap-packages/bootstrap-packages.sh | 96 ++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/targets/pseudo/bootstrap-packages/Makefile b/targets/pseudo/bootstrap-packages/Makefile new file mode 100644 index 000000000000..6523e88f84db --- /dev/null +++ b/targets/pseudo/bootstrap-packages/Makefile @@ -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} + diff --git a/targets/pseudo/bootstrap-packages/bootstrap-packages.sh b/targets/pseudo/bootstrap-packages/bootstrap-packages.sh new file mode 100755 index 000000000000..a2fe250d68a3 --- /dev/null +++ b/targets/pseudo/bootstrap-packages/bootstrap-packages.sh @@ -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