mk: add cpe.mk for defining CPE_URI values for packages by default

Mostly from tm@, thanks!
This commit is contained in:
wiz 2023-01-02 21:17:52 +00:00
parent 97e2643c51
commit 97aba50aa3
2 changed files with 102 additions and 1 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: bsd.pkg.mk,v 1.2045 2022/11/23 13:30:38 jperkin Exp $
# $NetBSD: bsd.pkg.mk,v 1.2046 2023/01/02 21:17:52 wiz Exp $
#
# This file is in the public domain.
#
@ -843,3 +843,4 @@ ${_MAKEVARS_MK.${_phase_}}: ${WRKDIR}
.endif
.include "misc/warnings.mk"
.include "misc/can-be-built-here.mk"
.include "misc/cpe.mk"

100
mk/misc/cpe.mk Normal file
View file

@ -0,0 +1,100 @@
# $NetBSD: cpe.mk,v 1.1 2023/01/02 21:17:53 wiz Exp $
# Derived from: FreeBSD MK/Uses/cpe.mk (3e1b730be0f27, 2014-07-26)
#
# This Makefile fragment includes CPE information into packages based on the
# CPE 2.3 formatting string. Additional information could be found on the
# official NIST documentation:
#
# https://csrc.nist.gov/projects/security-content-automation-protocol/specifications/cpe
#
# User-settable variables:
#
# (none)
#
# Package-settable variables:
#
# CPE_PART
# This is sometimes referred as "type" of CPE. Character describing the
# type. Could be "a" for application, "h" for hardware and "o" for
# operating system.
# Default: "a"
#
# CPE_VENDOR
# Should describe or identify the organisation that created the product.
# Default: ${CPE_PRODUCT} (below)
#
# CPE_PRODUCT
# Name of the system/package or component. Should not contains any
# special characters. On applications CPE_VENDOR and CPE_PRODUCT may be
# identical.
# Default: ${PKGBASE}
#
# CPE_VERSION
# The version of the system/package or component.
# Default: ${PKGVERSION_NOREV}
#
# CPE_UPDATE
# Used for updates, service pack information or sometimes minor versions.
# Most often left blank.
# Default: empty
#
# CPE_EDITION
# Further granularity describing the build of the system/package or
# component, beyond version.
# Default: empty
#
# CPE_LANG
# A valid language tag as defined by IETF RFC 4646. Not relevant for
# pkgsrc at the moment.
# Default: empty
#
# CPE_SW_EDITION
# Characterise how the product is tailored to a particular market or
# class of end users.
# Default: empty
#
# CPE_TARGET_SW
# Describe the software computing environment within which the product
# operates.
# Default: operating system (${OPSYS}) and version (${OS_VERSION})
#
# CPE_TARGET_HW
# Instruction set architecture (e.g. x86) on which the product being
# described or identified by the WFN operates.
# Default: x86 for i386, x64 for amd64, otherwise ${MACHINE_ARCH}
#
# CPE_OTHER
# Any other general descriptive or identifying information. Used for
# PKGREVISION in pkgsrc.
# Default: ${PKGREVISION} if exists
#
#
# Variables defined by this file:
#
# CPE_URI
# The CPE URI uniquely identifies a device or program by its vendor,
# product name, version, revision. Based on the above variables.
#
# Keywords: cpe
.if !defined(CPE_MK)
CPE_MK= # defined
CPE_PART?= a
CPE_PRODUCT?= ${PKGBASE:Q}
CPE_VENDOR?= ${CPE_PRODUCT}
CPE_VERSION?= ${PKGVERSION_NOREV}
CPE_UPDATE?=
CPE_EDITION?=
CPE_LANG?=
CPE_SW_EDITION?=
CPE_TARGET_SW?= ${OPSYS:tl}${OS_VERSION:C/\..*//}
CPE_TARGET_HW?= ${MACHINE_ARCH:S/i386/x86/:S/amd64/x64/}
CPE_OTHER?= ${PKGREVISION}
_CPE_STR= cpe:2.3:${CPE_PART}:${CPE_VENDOR}:${CPE_PRODUCT}:${CPE_VERSION}:${CPE_UPDATE}:${CPE_EDITION}:${CPE_LANG}:${CPE_SW_EDITION}:${CPE_TARGET_SW}:${CPE_TARGET_HW}:${CPE_OTHER}
CPE_URI?= ${_CPE_STR:C/:+$//}
BUILD_DEFS+= CPE_URI
.endif