Page MenuHomeFreeBSD

D56474.diff
No OneTemporary

D56474.diff

diff --git a/Makefile.inc1 b/Makefile.inc1
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -774,6 +774,7 @@
MK_HTML=no \
MK_MAN=no \
MK_RETPOLINE=no \
+ MK_SBOM=no \
MK_SSP=no \
MK_TESTS=no \
MK_UBSAN=no \
@@ -3065,10 +3066,17 @@
_ar=usr.bin/ar
.endif
+.if ${MK_PKGCONF} != "no"
+_sbom= lib/libpkgconf \
+ usr.bin/bomtool \
+ usr.bin/spdxtool
+.endif
+
cross-tools: .MAKE .PHONY
.for _tool in \
${LOCAL_XTOOL_DIRS} \
${_ar} \
+ ${_sbom} \
${_clang_libs} \
${_clang} \
${_lld} \
@@ -3960,7 +3968,7 @@
NOFUN=-DNO_FSCHG MK_HTML=no \
MK_MAN=no MK_NLS=no \
- MK_KERBEROS=no MK_RESCUE=no MK_TESTS=no MK_WERROR=no \
+ MK_KERBEROS=no MK_RESCUE=no MK_SBOM=no MK_TESTS=no MK_WERROR=no \
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
CPUTYPE=${XDEV_CPUTYPE}
diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist
--- a/etc/mtree/BSD.usr.dist
+++ b/etc/mtree/BSD.usr.dist
@@ -837,6 +837,12 @@
triggers
..
..
+ sbom
+ spdx-2.2
+ ..
+ spdx-3.0.1
+ ..
+ ..
security
..
sendmail
diff --git a/lib/libpkgconf/Makefile b/lib/libpkgconf/Makefile
--- a/lib/libpkgconf/Makefile
+++ b/lib/libpkgconf/Makefile
@@ -42,6 +42,11 @@
CFLAGS+= -DSYSTEM_INCLUDEDIR=\"/usr/include\"
CFLAGS+= -DSYSTEM_LIBDIR=\"/usr/lib\"
CFLAGS+= -I${SRCTOP}/lib/libpkgconf -I${PKGCONFDIR}
+.if defined(TOOLS_PREFIX)
+# for sane defaults when cross-compiling for bomtool(1) and spdxtool(1)
+CFLAGS+= -DPERSONALITY_PATH=\"/usr/share/pkgconfig/personality.d:/etc/pkgconfig/personality.d:${LOCALBASE:U/usr/local}/etc/pkgconfig/personality.d\"
+CFLAGS+= -DPKG_DEFAULT_PATH=\"${LOCALBASE:U/usr/local}/libdata/pkgconfig:/usr/libdata/pkgconfig:${LOCALBASE:U/usr/local}/share/pkgconfig\"
+.endif
.PATH: ${PKGCONFDIR}/libpkgconf
.PATH: ${PKGCONFDIR}/man
diff --git a/lib/libpkgconf/Makefile.sbom b/lib/libpkgconf/Makefile.sbom
new file mode 100644
--- /dev/null
+++ b/lib/libpkgconf/Makefile.sbom
@@ -0,0 +1,4 @@
+SBOM_DESC= Package compiler and linker metadata toolkit
+SBOM_VERSION= 2.9.93
+SBOM_SOURCE= https://github.com/pkgconf/pkgconf
+SBOM_URL= https://pkgconf.org
diff --git a/share/mk/bsd.README b/share/mk/bsd.README
--- a/share/mk/bsd.README
+++ b/share/mk/bsd.README
@@ -43,6 +43,7 @@
bsd.port.subdir.mk - targets for building subdirectories for ports
bsd.prog.mk - building programs from source files
bsd.progs.mk - build multiple programs from sources
+bsd.sbom.mk - generate SBOM artefacts from pkg-config definitions
bsd.snmpmod.mk - building modules for the SNMP daemon bsnmpd
bsd.subdir.mk - targets for building subdirectories
bsd.sys.mk - common settings used for building FreeBSD sources
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -527,3 +527,4 @@
.include <bsd.clang-analyze.mk>
.include <bsd.obj.mk>
.include <bsd.sys.mk>
+.include <bsd.sbom.mk>
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -364,3 +364,4 @@
.include <bsd.clang-analyze.mk>
.include <bsd.obj.mk>
.include <bsd.sys.mk>
+.include <bsd.sbom.mk>
diff --git a/share/mk/bsd.sbom.mk b/share/mk/bsd.sbom.mk
new file mode 100644
--- /dev/null
+++ b/share/mk/bsd.sbom.mk
@@ -0,0 +1,120 @@
+# Generate SBOM files from definitions in the pkg-config format
+#
+# +++ variables +++
+#
+# BOMTOOL Tool converting pkg-config files into SPDX version 2 files
+# JSONLDDIR Destination directory for the SPDX version 3 files
+# SBOMDATA Location for the SBOM meta-data
+# SBOMDIR Destination directory for the SBOM files
+# SPDXDIR Destination directory for the SPDX version 2 files
+# SPDXTOOL Tool converting pkg-config files into SPDX version 3 files
+
+.if ${MK_SBOM} != "no"
+
+BOMTOOL?= bomtool
+JSONLDDIR?= ${SBOMDIR}/spdx-3.0.1
+SBOMDIR?= /usr/share/sbom
+SPDXDIR?= ${SBOMDIR}/spdx-2.2
+SPDXTOOL?= spdxtool
+TOOLARGS=
+SBOMDATA?= Makefile.sbom
+
+# meta-data
+. if exists(${.CURDIR}/${SBOMDATA})
+
+FREEBSD_COPYRIGHT!=grep ^Copyright ${SRCTOP}/COPYRIGHT | head -1
+SBOM_COPYRIGHT?=${FREEBSD_COPYRIGHT}
+SBOM_DESC?= ${SBOM_NAME}
+SBOM_LICENSE?= BSD-2-Clause
+SBOM_VERSION?= ${FREEBSD_RELEASE}
+SBOM_SOURCE?= https://cgit.FreeBSD.org/src/tree/${RELDIR}
+
+. if defined(LIB)
+SBOM_NAME?= lib${LIB}
+SBOM_KIND?=
+SBOMTAGS= package=${PACKAGE:Uutilities},lib
+. elif defined(SHLIB)
+SBOM_NAME?= lib${SHLIB}
+SBOM_KIND?=
+SBOMTAGS= package=${PACKAGE:Uutilities},lib
+. elif defined(PROG)
+SBOM_NAME?= ${PROG}
+SBOM_KIND?= tool
+SBOMTAGS= package=${PACKAGE:Uutilities}
+. elif defined(SCRIPTS) && defined(PACKAGE)
+SBOM_NAME?= ${PACKAGE}
+SBOM_KIND?= tool
+SBOMTAGS= package=${PACKAGE}
+. else
+SBOM_NAME?=
+SBOM_KIND?=
+SBOMTAGS=
+. endif
+
+. include "${SBOMDATA}"
+
+. if !empty(SBOM_NAME) && !empty(SBOM_DESC) && !empty(SBOM_VERSION)
+SBOMFILE?= ${OBJTOP}/share/sbom/${SBOM_NAME}.pc
+. endif # !empty(SBOM_NAME)
+SBOM_TAG_ARGS= -T ${SBOMTAGS:ts,:[*]}
+
+. if !empty(SBOMFILE)
+
+_SBOMREQUIRES=
+. for l in ${LIBADD}
+_SBOMREQUIRES+= lib${l}
+. endfor
+SBOM_REQUIRES?= ${_SBOMREQUIRES:S/ /,/gW}
+SBOM_PROVIDES?=
+
+${SBOMFILE}: ${.CURDIR}/${SBOMDATA}
+ mkdir -p ${SBOMFILE:H}
+ (echo "# ${FREEBSD_COPYRIGHT}"; echo "#"; \
+ echo "# BSD-2-Clause"; echo "#"; \
+ echo "Copyright: ${SBOM_COPYRIGHT}"; \
+ echo "Name: ${SBOM_NAME}"; \
+ echo "Description: ${SBOM_DESC}"; \
+ echo "Version: ${SBOM_VERSION}"; \
+ echo "License: ${SBOM_LICENSE}"; \
+ [ -z "${SBOM_SOURCE}" ] || echo "Source: ${SBOM_SOURCE}"; \
+ [ -z "${SBOM_URL}" ] || echo "URL: ${SBOM_URL}"; \
+ [ -z "${SBOM_KIND}" ] || echo "Kind: ${SBOM_KIND}"; \
+ [ -z "${SBOM_REQUIRES}" ] || echo "Requires: ${SBOM_REQUIRES}"; \
+ [ -z "${SBOM_PROVIDES}" ] || echo "Provides: ${SBOM_PROVIDES}") \
+ > ${.TARGET}
+
+. if !defined(NO_JSONLD_SBOM)
+JSONLDFILE?= ${SBOMFILE:R}.jsonld
+
+all: ${JSONLDFILE}
+
+${JSONLDFILE}: ${SBOMFILE}
+ ${SPDXTOOL} ${TOOLARGS} ${SBOMFILE} > ${.TARGET}
+
+jsonldinstall: .PHONY ${JSONLDFILE}
+ ${INSTALL} ${SBOM_TAG_ARGS} -m 0644 ${JSONLDFILE} \
+ ${DESTDIR}${JSONLDDIR}/${JSONLDFILE:T}
+
+realinstall: jsonldinstall
+.ORDER: beforeinstall jsonldinstall
+. endif # !defined(NO_JSONLD_SBOM)
+
+. if !defined(NO_SPDX_SBOM)
+SPDXFILE?= ${SBOMFILE:R}.spdx
+
+all: ${SPDXFILE}
+
+${SPDXFILE}: ${SBOMFILE}
+ ${BOMTOOL} ${TOOLARGS} ${SBOMFILE} > ${.TARGET}
+
+spdxinstall: .PHONY ${SPDXFILE}
+ ${INSTALL} ${SBOM_TAG_ARGS} -m 0644 ${SPDXFILE} \
+ ${DESTDIR}${SPDXDIR}/${SPDXFILE:T}
+
+realinstall: spdxinstall
+.ORDER: beforeinstall spdxinstall
+. endif # !defined(NO_SPDX_SBOM)
+
+. endif # !empty(SBOM_NAME) && !empty(SBOM_DESC) && !empty(SBOM_VERSION)
+. endif # exists(${.CURDIR}/${SBOMDATA})
+.endif # ${MK_SBOM}
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -168,6 +168,7 @@
RBOOTD \
RESCUE \
ROUTED \
+ SBOM \
SENDMAIL \
SERVICESDB \
SETUID_LOGIN \
diff --git a/usr.bin/pkgconf/Makefile.sbom b/usr.bin/pkgconf/Makefile.sbom
new file mode 100644
--- /dev/null
+++ b/usr.bin/pkgconf/Makefile.sbom
@@ -0,0 +1 @@
+.include "../../lib/libpkgconf/Makefile.sbom"
diff --git a/usr.bin/spdxtool/Makefile b/usr.bin/spdxtool/Makefile
--- a/usr.bin/spdxtool/Makefile
+++ b/usr.bin/spdxtool/Makefile
@@ -13,10 +13,6 @@
LIBADD= pkgconf
-.if defined(TOOLS_PREFIX)
-NO_SHARED= yes
-.endif
-
PKGCONFDIR= ${SRCTOP}/contrib/pkgconf
WARNS?= 3

File Metadata

Mime Type
text/plain
Expires
Tue, Sep 8, 11:28 PM (14 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38545870
Default Alt Text
D56474.diff (7 KB)

Event Timeline