[Midnightbsd-cvs] mports [15868] trunk/Mk: start work on importing FreeBSD license framework with our own mport license system.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Feb 20 08:28:12 EST 2014
Revision: 15868
http://svnweb.midnightbsd.org/mports/?rev=15868
Author: laffer1
Date: 2014-02-20 08:28:12 -0500 (Thu, 20 Feb 2014)
Log Message:
-----------
start work on importing FreeBSD license framework with our own mport license system. They have a few features that we do not from the experience of planning after we and openbsd did this.
Modified Paths:
--------------
trunk/Mk/bsd.mport.mk
Added Paths:
-----------
trunk/Mk/components/licenses.db.mk
trunk/Mk/components/licenses.mk
Modified: trunk/Mk/bsd.mport.mk
===================================================================
--- trunk/Mk/bsd.mport.mk 2014-02-20 13:22:36 UTC (rev 15867)
+++ trunk/Mk/bsd.mport.mk 2014-02-20 13:28:12 UTC (rev 15868)
@@ -1140,6 +1140,10 @@
INSTALL_TARGET?= install
INSTALL_TARGET+= ${LATE_INSTALL_ARGS}
+# Integrate with the license auditing framework
+.if !defined (DISABLE_LICENSES)
+.include "${PORTSDIR}/Mk/components/licenses.mk"
+.endif
# Popular master sites
.include "${PORTSDIR}/Mk/components/sites.mk"
@@ -1642,8 +1646,8 @@
CONFIGURE_ENV+= CONFIG_SITE=${CONFIG_SITE} lt_cv_sys_max_cmd_len=${CONFIGURE_MAX_CMD_LEN}
HAS_CONFIGURE= yes
-INTUIT_LATE_CONFIGURE_ARGS= \
- _LATE_CONFIGURE_ARGS=""; \
+SET_LATE_CONFIGURE_ARGS= \
+ _LATE_CONFIGURE_ARGS="" ; \
_configure_help="`./${CONFIGURE_SCRIPT} --help 2>&1`"; \
if ${ECHO_CMD} $$_configure_help | ${GREP} -- '--mandir' >/dev/null && !(${ECHO_CMD} ${CONFIGURE_ARGS} | ${GREP} -- '--mandir' >/dev/null); then \
_LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} --mandir=${MANPREFIX}/man"; \
@@ -1769,7 +1773,7 @@
.else # defined(NOT_FOR_ARCHS)
IGNORE= does not run on ${NOT_FOR_ARCHS},
.endif
-IGNORE+= while you are running ${ARCH}.
+IGNORE+= while you are running ${ARCH}
.if defined(ONLY_FOR_ARCHS_REASON_${ARCH})
IGNORE+= (reason: ${ONLY_FOR_ARCHS_REASON_${ARCH}})
@@ -1799,12 +1803,27 @@
.if !defined(TRYBROKEN)
IGNORE= is marked as broken: ${BROKEN}
.endif
+.elif defined(BROKEN_${ARCH})
+.if !defined(TRYBROKEN)
+IGNORE= is marked as broken on ${ARCH}: ${BROKEN_${ARCH}}
+.endif
.elif defined(FORBIDDEN)
IGNORE= is forbidden: ${FORBIDDEN}
.endif
+# Define the text to be output to LEGAL
+.if defined(LEGAL_TEXT)
+LEGAL= ${LEGAL_TEXT}
+.elif defined(RESTRICTED)
+LEGAL= ${RESTRICTED}
+.elif defined(NO_CDROM)
+LEGAL= ${NO_CDROM}
+.elif defined(NO_PACKAGE) && ! defined(LEGAL_PACKAGE)
+LEGAL= ${NO_PACKAGE}
+.endif
+
.if (defined(MANUAL_PACKAGE_BUILD) && defined(PACKAGE_BUILDING))
-IGNORE= has to be built manually: ${MANUAL_PACKAGE_BUILD}
+IGNORE= has to be built manually: ${MANUAL_PACKAGE_BUILD}
clean:
@${IGNORECMD}
.endif
@@ -2317,7 +2336,8 @@
done
.endif
.if defined(HAS_CONFIGURE)
- @(cd ${CONFIGURE_WRKSRC} && ${INTUIT_LATE_CONFIGURE_ARGS} \
+ @(cd ${CONFIGURE_WRKSRC} && \
+ ${SET_LATE_CONFIGURE_ARGS} \
if ! ${SETENV} CC="${CC}" CPP="${CPP}" CXX="${CXX}" \
CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS}" \
Added: trunk/Mk/components/licenses.db.mk
===================================================================
--- trunk/Mk/components/licenses.db.mk (rev 0)
+++ trunk/Mk/components/licenses.db.mk 2014-02-20 13:28:12 UTC (rev 15868)
@@ -0,0 +1,169 @@
+# $MidnightBSD$
+
+_LICENSES= agpl gpl gpl2 gpl3 lgpl lgpl2.1 lgpl3 bsd4 bsd3 bsd2 \
+ apache2 apache1.1 apache1 apsl2 apsl1 artistic artistic2 \
+ bdb boost bzip2 cddl epl fdl1.1 fdl1.2 fdl1.3 guile \
+ ibm ilm infozip iscl \
+ liberation mit modula3 mpl npl nvidia openldap2.8 opera owl \
+ perl pgsql php python ruby sgi subversion x11 zlib \
+ publicdom unknown other agg restricted
+
+# List of groups (only names must be present)
+
+_LICENSE_NAME_FSF= Free Software Foundation Approved
+
+_LICENSE_NAME_GPL= GPL Compatible
+
+_LICENSE_NAME_OSI= OSI Approved
+
+_LICENSE_NAME_COPYFREE= Comply with Copyfree Standard Definition.
+
+_LICENSE_NAME_FONTS= Font licenses
+
+# Default permissions for licenses here, if not defined
+
+_LICENSE_PERMS_DEFAULT= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
+
+# Properties of license "xxx" (similar to port variables, but single)
+#
+# _LICENSE_NAME_xxx - Full name/description of license/group
+# _LICENSE_PERMS_xxx - Permissions (if not defined defaults to
+# ${_LICENSE_PERMS_DEFAULT}.
+# _LICENSE_GROUPS_xxx - Groups (optional)
+#
+# Notes:
+# - General permissions from groups are added to each license, if not defined.
+#
+
+
+_LICENSE_NAME_agpl= GNU Affero General Public License version 3
+_LICENSE_GROUPS_agpl= FSF GPL OSI
+
+_LICENSE_NAME_APACHE10= Apache License 1.0
+_LICENSE_GROUPS_APACHE10= FSF
+
+_LICENSE_NAME_APACHE11= Apache License 1.1
+_LICENSE_GROUPS_APACHE11= FSF OSI
+
+_LICENSE_NAME_apache2= Apache License 2.0
+_LICENSE_GROUPS_APACHE20= FSF OSI
+
+_LICENSE_NAME_artistic= Artistic License version 1.0
+_LICENSE_GROUPS_artistic= OSI
+
+_LICENSE_NAME_perl=Artistic License (perl) version 1.0
+_LICENSE_GROUPS_perl= OSI
+
+_LICENSE_NAME_artistic2= Artistic License version 2.0
+_LICENSE_GROUPS_artistic2= FSF GPL OSI
+
+_LICENSE_NAME_bsd2= BSD 2-clause "Simplified" License
+_LICENSE_GROUPS_bsd2= FSF OSI COPYFREE
+
+_LICENSE_NAME_bsd3= BSD 3-clause "New" or "Revised" License
+_LICENSE_GROUPS_bsd3= FSF OSI COPYFREE
+
+_LICENSE_NAME_bsd4= BSD 4-clause "Original" or "Old" License
+_LICENSE_GROUPS_bsd4= FSF
+
+_LICENSE_NAME_BSL= Boost Software License
+_LICENSE_GROUPS_BSL= FSF OSI COPYFREE
+
+_LICENSE_NAME_cddl= Common Development and Distribution License
+_LICENSE_GROUPS_cddl= FSF OSI
+
+_LICENSE_NAME_epl= Eclipse Public License
+_LICENSE_GROUPS_epl= FSF OSI
+
+_LICENSE_NAME_gfdl= GNU Free Documentation License
+_LICENSE_GROUPS_gfdl= FSF
+
+_LICENSE_NAME_gpl= GNU General Public License version 1
+_LICENSE_GROUPS_gpl= FSF GPL OSI
+
+_LICENSE_NAME_gpl2= GNU General Public License version 2
+_LICENSE_GROUPS_gpl2= FSF GPL OSI
+
+_LICENSE_NAME_gpl3= GNU General Public License version 3
+_LICENSE_GROUPS_gpl3= FSF GPL OSI
+
+_LICENSE_NAME_isc= Internet Systems Consortium License
+_LICENSE_GROUPS_isc= FSF GPL OSI COPYFREE
+
+_LICENSE_NAME_lgpl= GNU Library General Public License generic depricated
+_LICENSE_GROUP_lgpl= FSF GPL OSI
+
+_LICENSE_NAME_lgpl20= GNU Library General Public License version 2.0
+_LICENSE_GROUPS_lgpl20= FSF GPL OSI
+
+_LICENSE_NAME_lgpl21= GNU Lesser General Public License version 2.1
+_LICENSE_GROUPS_lgpl21= FSF GPL OSI
+
+_LICENSE_NAME_lgpl3= GNU Lesser General Public License version 3
+_LICENSE_GROUPS_lgpl3= FSF GPL OSI
+
+_LICENSE_NAME_LPPL10= LaTeX Project Public License version 1.0
+_LICENSE_GROUPS_LPPL10= FSF OSI
+_LICENSE_PERMS_LPPL10= dist-mirror dist-sell
+
+_LICENSE_NAME_LPPL11= LaTeX Project Public License version 1.1
+_LICENSE_GROUPS_LPPL11= FSF OSI
+_LICENSE_PERMS_LPPL11= dist-mirror dist-sell
+
+_LICENSE_NAME_LPPL12= LaTeX Project Public License version 1.2
+_LICENSE_GROUPS_LPPL12= FSF OSI
+_LICENSE_PERMS_LPPL12= dist-mirror dist-sell
+
+_LICENSE_NAME_LPPL13= LaTeX Project Public License version 1.3
+_LICENSE_GROUPS_LPPL13= FSF OSI
+_LICENSE_PERMS_LPPL13= dist-mirror dist-sell
+
+_LICENSE_NAME_LPPL13a= LaTeX Project Public License version 1.3a
+_LICENSE_GROUPS_LPPL13a= FSF OSI
+_LICENSE_PERMS_LPPL13a= xdist-mirror dist-sell
+
+_LICENSE_NAME_LPPL13b= LaTeX Project Public License version 1.3b
+_LICENSE_GROUPS_LPPL13b= FSF OSI
+_LICENSE_PERMS_LPPL13b= dist-mirror dist-sell
+
+_LICENSE_NAME_LPPL13c= LaTeX Project Public License version 1.3c
+_LICENSE_GROUPS_LPPL13c= FSF OSI
+_LICENSE_PERMS_LPPL13c= dist-mirror dist-sell
+
+_LICENSE_NAME_mit= MIT license / X11 license
+_LICENSE_GROUPS_mit= FSF GPL OSI COPYFREE
+
+_LICENSE_NAME_mpl= Mozilla Public License
+_LICENSE_GROUPS_mpl= FSF OSI
+
+_LICENSE_NAME_OFL10= SIL Open Font License version 1.0 (http://scripts.sil.org/OFL)
+_LICENSE_GROUPS_OFL10= FONTS
+
+_LICENSE_NAME_OFL11= SIL Open Font License version 1.1 (http://scripts.sil.org/OFL)
+_LICENSE_GROUPS_OFL11= FONTS
+
+_LICENSE_NAME_owl= Open Works License (owl.apotheon.org)
+_LICENSE_GROUPS_owl= COPYFREE
+
+_LICENSE_NAME_pgsql= PostgreSQL Licence (PostgreSQL)
+_LICENSE_GROUPS_pqgsql= OSI COPYFREE
+
+_LICENSE_NAME_php= PHP License version 3.01
+_LICENSE_GROUPS_php= FSF OSI
+
+_LICENSE_NAME_python= Python Software Foundation License
+_LICENSE_GROUPS_python= FSF GPL OSI
+
+_LICENSE_NAME_ruby= Ruby License
+_LICENSE_GROUPS_ruby= FSF
+
+_LICENSE_NAME_zlib= zlib License
+_LICENSE_GROUPS_zlib= GPL FSF OSI
+
+# Set default permissions if not defined
+
+.for lic in ${_LICENSES}
+. if !defined(_LICENSE_PERMS_${lic})
+_LICENSE_PERMS_${lic}= ${_LICENSE_PERMS_DEFAULT}
+. endif
+.endfor
Added: trunk/Mk/components/licenses.mk
===================================================================
--- trunk/Mk/components/licenses.mk (rev 0)
+++ trunk/Mk/components/licenses.mk 2014-02-20 13:28:12 UTC (rev 15868)
@@ -0,0 +1,661 @@
+# $MidnightBSD$
+
+Licenses_Include_MAINTAINER= ports at MidnightBSD.org
+
+.if defined(_POSTMKINCLUDED) && !defined(BEFOREPORTMK)
+
+.if defined(LICENSE)
+
+# Include known licenses from database
+
+.include "${PORTSDIR}/Mk/components/licenses.db.mk"
+
+# Lists of variables and valid components
+#
+# _LICENSE_LIST_PERMS - Valid permission components
+# _LICENSE_LIST_PORT_VARS - License variables defined by the port
+
+_LICENSE_LIST_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept none
+_LICENSE_LIST_PORT_VARS= PERMS NAME GROUPS
+
+# Path variables
+#
+# _LICENSE_DIR - Directory to install licenses
+# _LICENSE_DIR_REL - Same as above, without ${PREFIX}
+# _LICENSE_STORE - Store for known license files
+# _LICENSE_CATALOG - License catalog (make include file) to be created (dst)
+# _LICENSE_CATALOG_TMP - Same as above, but in WRKDIR (src)
+# _LICENSE_REPORT - License summary, shows licenses and how they are combined (dst)
+# _LICENSE_REPORT_TMP - Same as above, but in WRKDIR (src)
+# _LICENSE_COOKIE - Set when license is accepted, it is not present in
+# bsd.port.mk to avoid creating LICENSE_{REQ,SEQ} for a
+# few more targets only.
+
+_LICENSE_DIR?= ${PREFIX}/share/licenses/${PKGNAME}
+_LICENSE_DIR_REL?= share/licenses/${PKGNAME}
+_LICENSE_STORE?= ${PORTSDIR}/Templates/Licenses
+_LICENSE_CATALOG?= ${_LICENSE_DIR}/catalog.mk
+_LICENSE_CATALOG_TMP?= ${WRKDIR}/.license-catalog.mk
+_LICENSE_REPORT?= ${_LICENSE_DIR}/LICENSE
+_LICENSE_REPORT_TMP?= ${WRKDIR}/.license-report
+_LICENSE_COOKIE?= ${WRKDIR}/.license_done.${PORTNAME}.${PREFIX:S/\//_/g}
+
+# Defaults (never overriden for now)
+#
+# _LICENSE - Copy of LICENSE (for now)
+# _LICENSE_COMB - Copy of LICENSE_COMB (but "single" instead of empty)
+
+_LICENSE?= ${LICENSE}
+.if !defined(LICENSE_COMB)
+_LICENSE_COMB= single
+.else
+_LICENSE_COMB= ${LICENSE_COMB}
+.endif
+
+# Check if single or dual/multiple license
+#
+# Make sure LICENSE_COMB is only used with more than one license.
+
+.if ${_LICENSE_COMB} != "single" && ${_LICENSE_COMB} != "dual" && ${_LICENSE_COMB} != "multi"
+_LICENSE_ERROR?= invalid value for LICENSE_COMB: "${_LICENSE_COMB}" (should be "single", "dual" or "multi")
+.endif
+
+.for lic in ${_LICENSE}
+. if defined(_LICENSE_DEFINED)
+. if ${_LICENSE_COMB} == "single"
+_LICENSE_ERROR?= multiple licenses in LICENSE, but LICENSE_COMB is set to "single" (or undefined)
+. else
+_LICENSE_MULTI= yes
+. endif
+. else
+_LICENSE_DEFINED= yes
+. endif
+.endfor
+.if ${_LICENSE_COMB} != "single" && !defined(_LICENSE_MULTI)
+_LICENSE_ERROR?= single license in LICENSE, but LICENSE_COMB is set to "${_LICENSE_COMB}" (requires more than one)
+.endif
+.if !defined(_LICENSE_DEFINED)
+_LICENSE_ERROR?= no licenses present in LICENSE (empty string)
+.endif
+.undef _LICENSE_DEFINED
+.undef _LICENSE_MULTI
+
+# Evaluate port license groups and permissions
+#
+# Available values for _LICENSE_TYPE:
+#
+# Case 1: "known" (license info taken from internal database)
+# Case 2: "unknown" (LICENSE is not known, and info taken from port)
+#
+# Make sure required variables are defined, and remove conflicting (positive
+# and negative) duplicated components.
+
+.if ${_LICENSE_COMB} == "single"
+# Defaults to empty
+_LICENSE_GROUPS?= #
+# Start
+. for lic in ${_LICENSE}
+. if ${_LICENSES:M${lic}} != ""
+# Case 1: license defined in the framework.
+_LICENSE_TYPE= known
+. for var in ${_LICENSE_LIST_PORT_VARS}
+. if defined(LICENSE_${var})
+_LICENSE_ERROR?= redefining LICENSE_${var} is not allowed for known licenses, to define a custom license try another LICENSE name like ${_LICENSE}-variant
+. endif
+. if !defined(_LICENSE_${var}_${lic})
+_LICENSE_ERROR?= ERROR: missing _LICENSE_${var}_${lic} in bsd.licenses.db.mk
+. else
+_LICENSE_${var}= ${_LICENSE_${var}_${lic}}
+. endif
+. endfor
+# Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
+. if !defined(LICENSE_FILE)
+. if !defined(LICENSE_TEXT)
+. if exists(${_LICENSE_STORE}/${lic})
+_LICENSE_FILE= ${_LICENSE_STORE}/${lic}
+. else
+# No license file in /usr/ports/Templates/Licenses
+_LICENSE_TEXT= The license: ${_LICENSE} (${_LICENSE_NAME}) is standard, please read from the web.
+_LICENSE_FILE= ${WRKDIR}/${lic}
+. endif
+. else
+_LICENSE_ERROR?= defining LICENSE_TEXT is not allowed for known licenses
+. endif
+. else
+_LICENSE_FILE= ${LICENSE_FILE}
+. endif
+
+. else
+# Case 2: license only known by the port.
+_LICENSE_TYPE= unknown
+. for var in ${_LICENSE_LIST_PORT_VARS}
+. if defined(LICENSE_${var})
+_LICENSE_${var}= ${LICENSE_${var}}
+. elif !defined(_LICENSE_${var})
+_LICENSE_ERROR?= for unknown licenses, defining LICENSE_${var} is mandatory (otherwise use a known LICENSE)
+. endif
+. endfor
+# Check LICENSE_PERMS for invalid, ambiguous and duplicate components
+__LICENSE_PERMS:= #
+. for comp in ${_LICENSE_PERMS}
+. if ${_LICENSE_LIST_PERMS:M${comp:C/^no-//}} == ""
+_LICENSE_ERROR?= invalid LICENSE_PERMS component "${comp}"
+. elif ${__LICENSE_PERMS:M${comp}} == "" && \
+ ${_LICENSE_PERMS:Mno-${comp:C/^no-//}} == ""
+__LICENSE_PERMS+= ${comp}
+. endif
+. endfor
+_LICENSE_PERMS:= ${__LICENSE_PERMS}
+. undef __LICENSE_PERMS
+# Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
+. if !defined(LICENSE_FILE)
+. if !defined(LICENSE_TEXT)
+_LICENSE_ERROR?= either LICENSE_FILE or LICENSE_TEXT must be defined
+. else
+_LICENSE_TEXT= ${LICENSE_TEXT}
+_LICENSE_FILE= ${WRKDIR}/${lic}
+. endif
+. else
+_LICENSE_FILE= ${LICENSE_FILE}
+. endif
+. endif
+
+# Only one is allowed
+. if defined(LICENSE_FILE) && defined(LICENSE_TEXT)
+_LICENSE_ERROR?= defining both LICENSE_FILE and LICENSE_TEXT is not allowed
+. endif
+# Distfiles
+. if !defined(LICENSE_DISTFILES)
+_LICENSE_DISTFILES= ${_DISTFILES}
+. else
+_LICENSE_DISTFILES= ${LICENSE_DISTFILES}
+. endif
+. endfor
+
+.else
+. for lic in ${_LICENSE}
+# Defaults to empty
+_LICENSE_GROUPS_${lic}?=#
+. if ${_LICENSE_LIST:M${lic}} != ""
+# Case 1: license defined in the framework.
+_LICENSE_TYPE_${lic}= known
+. for var in ${_LICENSE_LIST_PORT_VARS}
+. if defined(LICENSE_${var}_${lic})
+_LICENSE_ERROR?= redefining LICENSE_${var}_${lic} is not allowed for known licenses, to define a custom license try another LICENSE name for ${lic} like ${lic}-variant
+. endif
+. if !defined(_LICENSE_${var}_${lic})
+_LICENSE_ERROR?= ERROR: missing _LICENSE_${var}_${lic} in bsd.licenses.db.mk
+. endif
+. endfor
+# Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
+. if !defined(LICENSE_FILE_${lic})
+. if !defined(LICENSE_TEXT_${lic})
+. if exists(${_LICENSE_STORE}/${lic})
+_LICENSE_FILE_${lic}= ${_LICENSE_STORE}/${lic}
+. else
+# No license file in /usr/ports/Templates/Licenses
+_LICENSE_TEXT_${lic}= The license: ${lic} (${_LICENSE_NAME_${lic}}) is standard, please read from the web.
+_LICENSE_FILE_${lic}= ${WRKDIR}/${lic}
+. endif
+. else
+_LICENSE_ERROR?= defining LICENSE_TEXT_${lic} is not allowed for known licenses
+. endif
+. else
+_LICENSE_FILE_${lic}= ${LICENSE_FILE_${lic}}
+. endif
+
+. else
+# Case 2: license only known by the port.
+_LICENSE_TYPE_${lic}= unknown
+. for var in ${_LICENSE_LIST_PORT_VARS}
+. if defined(LICENSE_${var}_${lic})
+_LICENSE_${var}_${lic}= ${LICENSE_${var}_${lic}}
+. elif !defined(_LICENSE_${var}_${lic})
+_LICENSE_ERROR?= for unknown licenses, defining LICENSE_${var}_${lic} is mandatory (otherwise use a known LICENSE)
+. endif
+. endfor
+# Check LICENSE_PERMS for invalid, ambiguous and duplicate components
+__LICENSE_PERMS:= #
+. for comp in ${_LICENSE_PERMS_${lic}}
+. if ${_LICENSE_LIST_PERMS:M${comp:C/^no-//}} == ""
+_LICENSE_ERROR?= invalid LICENSE_PERMS_${var} component "${comp}"
+. elif ${__LICENSE_PERMS:M${comp}} == "" && \
+ ${_LICENSE_PERMS_${lic}:Mno-${comp:C/^no-//}} == ""
+__LICENSE_PERMS+= ${comp}
+. endif
+. endfor
+_LICENSE_PERMS_${lic}:= ${__LICENSE_PERMS}
+. undef __LICENSE_PERMS
+# Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
+. if !defined(LICENSE_FILE_${lic})
+. if !defined(LICENSE_TEXT_${lic})
+_LICENSE_ERROR?= either LICENSE_FILE_${lic} or LICENSE_TEXT_${lic} must be defined
+. else
+_LICENSE_TEXT_${lic}= ${LICENSE_TEXT_${lic}}
+_LICENSE_FILE_${lic}= ${WRKDIR}/${lic}
+. endif
+. else
+_LICENSE_FILE_${lic}= ${LICENSE_FILE_${lic}}
+. endif
+. endif
+
+# Only one is allowed
+. if defined(LICENSE_FILE_${lic}) && defined(LICENSE_TEXT_${lic})
+_LICENSE_ERROR?= defining both LICENSE_FILE_${lic} and LICENSE_TEXT_${lic}is not allowed
+. endif
+# Distfiles
+. if !defined(LICENSE_DISTFILES_${lic})
+_LICENSE_DISTFILES_${lic}= ${_DISTFILES}
+. else
+_LICENSE_DISTFILES_${lic}= ${LICENSE_DISTFILES_${lic}}
+. endif
+. endfor
+.endif
+
+# Check if the user agrees with the license
+
+# Make sure these are defined
+
+LICENSES_ACCEPTED?= #
+LICENSES_REJECTED?= #
+LICENSES_GROUPS_ACCEPTED?= #
+LICENSES_GROUPS_REJECTED?= #
+
+# Evaluate per-license status
+
+.if ${_LICENSE_COMB} == "single"
+. for lic in ${_LICENSE}
+. if ${LICENSES_REJECTED:M${lic}} != ""
+_LICENSE_STATUS?= rejected
+. endif
+. for group in ${_LICENSE_GROUPS}
+. if ${LICENSES_GROUPS_REJECTED:M${group}} != ""
+_LICENSE_STATUS?= rejected
+. endif
+. if ${LICENSES_GROUPS_ACCEPTED:M${group}} != ""
+_LICENSE_STATUS?= accepted
+. endif
+. endfor
+. if ${LICENSES_ACCEPTED:M${lic}} != ""
+_LICENSE_STATUS?= accepted
+. endif
+. if ${_LICENSE_PERMS:Mauto-accept} != "" && !defined(LICENSES_ASK)
+_LICENSE_STATUS?= accepted
+. endif
+_LICENSE_STATUS?= ask
+. endfor
+
+.else
+. for lic in ${_LICENSE}
+. if ${LICENSES_REJECTED:M${lic}} != ""
+_LICENSE_STATUS_${lic}?= rejected
+. endif
+. for group in ${_LICENSE_GROUPS_${lic}}
+. if ${LICENSES_GROUPS_REJECTED:M${group}} != ""
+_LICENSE_STATUS_${lic}?= rejected
+. endif
+. if ${LICENSES_GROUPS_ACCEPTED:M${group}} != ""
+_LICENSE_STATUS_${lic}?= accepted
+. endif
+. endfor
+. if ${LICENSES_ACCEPTED:M${lic}} != ""
+_LICENSE_STATUS_${lic}?= accepted
+. endif
+. if ${_LICENSE_PERMS_${lic}:Mauto-accept} != "" && !defined(LICENSES_ASK)
+_LICENSE_STATUS_${lic}?= accepted
+. endif
+_LICENSE_STATUS_${lic}?= ask
+. endfor
+.endif
+
+# Evaluate general status
+
+.if ${_LICENSE_COMB} == "dual"
+. for lic in ${_LICENSE}
+. if ${_LICENSE_STATUS_${lic}} == "accepted"
+_LICENSE_STATUS= accepted
+. elif ${_LICENSE_STATUS_${lic}} == "ask"
+_LICENSE_STATUS?= ask
+_LICENSE_TO_ASK+= ${lic}
+. endif
+_LICENSE_STATUS?= rejected
+. endfor
+
+.elif ${_LICENSE_COMB} == "multi"
+. for lic in ${_LICENSE}
+. if ${_LICENSE_STATUS_${lic}} == "rejected"
+_LICENSE_STATUS= rejected
+. elif ${_LICENSE_STATUS_${lic}} == "ask"
+_LICENSE_STATUS?= ask
+_LICENSE_TO_ASK+= ${lic}
+. endif
+. endfor
+_LICENSE_STATUS?= accepted
+.endif
+
+# For dual/multi licenses, after processing all sub-licenses, the following
+# must be determined: _LICENSE_NAME, _LICENSE_PERMS and _LICENSE_GROUPS.
+
+.if ${_LICENSE_COMB} == "dual"
+_LICENSE_NAME= Dual (any of): ${_LICENSE}
+# Calculate least restrictive permissions (union)
+_LICENSE_PERMS:= #
+. for lic in ${_LICENSE}
+. for comp in ${_LICENSE_LIST_PERMS}
+. if ${_LICENSE_PERMS_${lic}:M${comp}} != "" && \
+ ${_LICENSE_PERMS:M${comp}} == ""
+_LICENSE_PERMS+= ${comp}
+. endif
+. endfor
+. endfor
+# Calculate least restrictive groups (union)
+_LICENSE_GROUPS:= #
+. for lic in ${_LICENSE}
+. for comp in ${_LICENSE_LIST_GROUPS}
+. if ${_LICENSE_GROUPS_${lic}:M${comp}} != "" && \
+ ${_LICENSE_GROUPS:M${comp}} == ""
+_LICENSE_GROUPS+= ${comp}
+. endif
+. endfor
+. endfor
+
+.elif ${_LICENSE_COMB} == "multi"
+_LICENSE_NAME= Multiple (all of): ${_LICENSE}
+# Calculate most restrictive permissions (intersection)
+_LICENSE_PERMS:= ${_LICENSE_LIST_PERMS}
+. for lic in ${_LICENSE}
+. for comp in ${_LICENSE_LIST_PERMS}
+. if ${_LICENSE_PERMS_${lic}:M${comp}} == ""
+_LICENSE_PERMS:= ${_LICENSE_PERMS:N${comp}}
+. endif
+. endfor
+. endfor
+# Calculate most restrictive groups (intersection)
+_LICENSE_GROUPS:= ${_LICENSE_LIST_GROUPS}
+. for lic in ${_LICENSE}
+. for comp in ${_LICENSE_LIST_GROUPS}
+. if ${_LICENSE_GROUPS_${lic}:M${comp}} == ""
+_LICENSE_GROUPS:= ${_LICENSE_GROUPS:N${comp}}
+. endif
+. endfor
+. endfor
+.endif
+
+# Prepare information for asking license to the user
+
+.if ${_LICENSE_STATUS} == "ask" && ${_LICENSE_COMB} != "single"
+_LICENSE_ASK_DATA!= mktemp -ut portslicense
+.endif
+
+# Calculate restrictions and set RESTRICTED_FILES when
+# appropiate, together with cleaning targets.
+#
+# XXX For multiple licenses restricted distfiles are always removed from both
+# CDROM and FTP, but the current framework supports separating them (would
+# require better/new delete-package and delete-distfiles targets)
+
+.if ${_LICENSE_PERMS:Mpkg-mirror} == ""
+_LICENSE_RESTRICTED+= delete-package
+.elif ${_LICENSE_PERMS:Mpkg-sell} == ""
+_LICENSE_CDROM+= delete-package
+.endif
+
+.if ${_LICENSE_COMB} == "multi"
+. for lic in ${_LICENSE}
+. if ${_LICENSE_PERMS_${lic}:Mdist-mirror} == "" || ${_LICENSE_PERMS_${lic}:Mdist-sell} == ""
+RESTRICTED_FILES+= ${_LICENSE_DISTFILES_${lic}}
+. endif
+. endfor
+. if defined(RESTRICTED_FILES)
+RESTRICTED_FILES+= ${_PATCHFILES}
+_LICENSE_RESTRICTED+= delete-distfiles
+_LICENSE_CDROM+= delete-distfiles
+. endif
+.else
+. if ${_LICENSE_PERMS:Mdist-mirror} == ""
+_LICENSE_RESTRICTED+= delete-distfiles
+RESTRICTED_FILES= ${_PATCHFILES} ${_DISTFILES}
+. elif ${_LICENSE_PERMS:Mdist-sell} == ""
+_LICENSE_CDROM+= delete-distfiles
+RESTRICTED_FILES= ${_PATCHFILES} ${_DISTFILES}
+. endif
+.endif
+
+.if defined(_LICENSE_RESTRICTED)
+clean-restricted: ${_LICENSE_RESTRICTED}
+clean-restricted-list: ${_LICENSE_RESTRICTED:C/$/-list/}
+.else
+clean-restricted:
+clean-restricted-list:
+.endif
+
+.if defined(_LICENSE_CDROM)
+clean-for-cdrom: ${_LICENSE_CDROM}
+clean-for-cdrom-list: ${_LICENSE_CDROM:C/$/-list/}
+.else
+clean-for-cdrom:
+clean-for-cdrom-list:
+.endif
+
+# Check variables are correctly defined and print status up to here
+
+.if ${_LICENSE_STATUS} == "ask" && defined(BATCH)
+IGNORE= License ${_LICENSE} needs confirmation, but BATCH is defined
+.endif
+
+check-license:
+.if defined(_LICENSE_ERROR)
+ @${ECHO_MSG} "===> License not correctly defined: ${_LICENSE_ERROR}"
+ @exit 1
+.endif
+.if ${_LICENSE_STATUS} == "rejected"
+ @${ECHO_MSG} "===> License ${_LICENSE} rejected by the user"
+ @${ECHO_MSG}
+ @${ECHO_MSG} "If you want to install this port make sure the following license(s) are not present in LICENSES_REJECTED, either in make arguments or /etc/make.conf: ${_LICENSE}. Also check LICENSES_GROUPS_REJECTED in case they contain a group this license(s) belong to." | ${FMT}
+ @${ECHO_MSG}
+ @exit 1
+.elif ${_LICENSE_STATUS} == "accepted"
+ @${ECHO_MSG} "===> License ${_LICENSE} accepted by the user"
+.elif ${_LICENSE_STATUS} == "ask"
+ @${ECHO_MSG} "===> License ${_LICENSE} needs confirmation, will ask later"
+.endif
+
+# Display, ask and save preference if requested
+
+ask-license: ${_LICENSE_COOKIE}
+
+${_LICENSE_COOKIE}:
+# Make sure all required license files exist
+.if ${_LICENSE_COMB} == "single"
+. if !defined(LICENSE_FILE) && defined(_LICENSE_TEXT)
+ @test -f ${_LICENSE_FILE} || ${ECHO_CMD} "${_LICENSE_TEXT}" | ${FMT} > ${_LICENSE_FILE}
+. endif
+ @test -f ${_LICENSE_FILE} || \
+ (${ECHO_MSG} "===> Missing license file for ${_LICENSE} in ${_LICENSE_FILE}"; exit 1)
+.else
+. for lic in ${_LICENSE}
+. if !defined(LICENSE_FILE_${lic}) && defined(_LICENSE_TEXT_${lic})
+ @test -f ${_LICENSE_FILE_${lic}} || ${ECHO_CMD} "${_LICENSE_TEXT_${lic}}" | ${FMT} > ${_LICENSE_FILE_${lic}}
+. endif
+ @test -f ${_LICENSE_FILE_${lic}} || \
+ (${ECHO_MSG} "===> Missing license file for ${lic} in ${_LICENSE_FILE_${lic}}"; exit 1)
+. endfor
+.endif
+
+.if ${_LICENSE_STATUS} == "ask"
+. if !defined(NO_LICENSES_DIALOGS)
+# Dialog interface
+. if ${_LICENSE_COMB} == "single"
+ @trap '${RM} -f $$tmpfile' EXIT INT TERM; \
+ tmpfile=$$(mktemp -t portlicenses); \
+ while true; do \
+ ${DIALOG} --menu "License for ${PKGNAME} (${_LICENSE})" 21 70 15 accept "Accept license" reject "Reject license" view "View license" 2>"$${tmpfile}"; \
+ result=`${CAT} $${tmpfile}`; \
+ case $${result} in \
+ accept) break ;; \
+ reject) exit 1;; \
+ view) ${DIALOG} --textbox "${_LICENSE_FILE}" 21 75 ;; \
+ esac; \
+ done
+
+. elif ${_LICENSE_COMB} == "dual"
+ @${RM} -f ${_LICENSE_ASK_DATA}
+. for lic in ${_LICENSE_TO_ASK}
+ @${ECHO_CMD} "${lic}:${_LICENSE_FILE_${lic}}" >> ${_LICENSE_ASK_DATA}
+. endfor
+ @menu_cmd="${DIALOG} --hline \"This port requires you to accept at least one license\" --menu \"License for ${PKGNAME} (dual)\" 21 70 15"; \
+ trap '${RM} -f $$tmpfile' EXIT INT TERM; \
+ tmpfile=$$(mktemp -t portlicenses); \
+ for lic in ${_LICENSE_TO_ASK}; do \
+ menu_cmd="$${menu_cmd} VIEW_$${lic} \"View the license $${lic}\" USE_$${lic} \"Accept the license $${lic}\""; \
+ done; \
+ menu_cmd="$${menu_cmd} REJECT \"Reject the licenses (all)\""; \
+ while true; do \
+ ${SH} -c "$${menu_cmd} 2>\"$${tmpfile}\""; \
+ result=$$(${CAT} "$${tmpfile}"); \
+ case $${result} in \
+ REJECT) exit 1;; \
+ VIEW_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^VIEW_//'); \
+ file=$$(${GREP} "^$${name}:" ${_LICENSE_ASK_DATA} | ${CUT} -d : -f 2); \
+ ${DIALOG} --textbox "$${file}" 21 75 ;; \
+ USE_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^USE_//'); \
+ ${ECHO_CMD} $${name} > ${_LICENSE_COOKIE}; \
+ break ;; \
+ esac; \
+ done
+
+. elif ${_LICENSE_COMB} == "multi"
+ @${RM} -f ${_LICENSE_ASK_DATA}
+. for lic in ${_LICENSE_TO_ASK}
+ @${ECHO_CMD} "${lic}:${_LICENSE_FILE_${lic}}" >> ${_LICENSE_ASK_DATA}
+. endfor
+ @menu_cmd="${DIALOG} --hline \"This port requires you to accept all mentioned licenses\" --menu \"License for ${PKGNAME} (multi)\" 21 70 15"; \
+ trap '${RM} -f $$tmpfile' EXIT INT TERM; \
+ tmpfile=$$(mktemp -t portlicenses); \
+ for lic in ${_LICENSE_TO_ASK}; do \
+ menu_cmd="$${menu_cmd} VIEW_$${lic} \"View the license $${lic}\""; \
+ done; \
+ menu_cmd="$${menu_cmd} ACCEPT \"Accept the licenses (all)\" REJECT \"Reject the licenses (all)\""; \
+ while true; do \
+ ${SH} -c "$${menu_cmd} 2>\"$${tmpfile}\""; \
+ result=$$(${CAT} "$${tmpfile}"); \
+ case $${result} in \
+ ACCEPT) break ;; \
+ REJECT) exit 1 ;; \
+ VIEW_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^VIEW_//'); \
+ file=$$(${GREP} "^$${name}:" ${_LICENSE_ASK_DATA} | ${CUT} -d : -f 2); \
+ ${DIALOG} --textbox "$${file}" 21 75 ;; \
+ esac; \
+ done
+. endif
+
+. else
+# Text interface
+ @${ECHO_MSG}
+. if ${_LICENSE_COMB} == "single"
+ @${ECHO_MSG} "To install the port you must agree to the license: ${_LICENSE} (${_LICENSE_NAME})." | ${FMT}
+ @${ECHO_MSG}
+ @${ECHO_MSG} "You can view the license at ${_LICENSE_FILE:S/${WRKDIR}\//${WRKDIR:T}\//}."
+. elif ${_LICENSE_COMB} == "dual"
+ @${ECHO_MSG} "To install the port you must agree to any of the following licenses:"
+. elif ${_LICENSE_COMB} == "multi"
+ @${ECHO_MSG} "To install the port you must agree to all of the following licenses:"
+. endif
+ @${ECHO_MSG}
+. if ${_LICENSE_COMB} != "single"
+. for lic in ${_LICENSE_TO_ASK}
+ @${ECHO_MSG} "- ${lic} (${_LICENSE_NAME_${lic}}), available at ${_LICENSE_FILE_${lic}:S/${WRKDIR}\//${WRKDIR:T}\//}"
+. endfor
+ @${ECHO_MSG}
+. endif
+ @${ECHO_MSG} "If you agree with the corresponding license(s), add them to LICENSES_ACCEPTED either in make arguments or /etc/make.conf." | ${FMT}
+ @${ECHO_MSG}
+ @exit 1
+. endif
+ @${RM} -f ${_LICENSE_ASK_DATA}
+.endif
+
+# Create report and catalog
+.if !defined(NO_LICENSES_INSTALL)
+ @${RM} -f ${_LICENSE_CATALOG_TMP} ${_LICENSE_REPORT_TMP}
+. if ${_LICENSE_COMB} == "single"
+# Catalog
+. for var in _LICENSE _LICENSE_NAME _LICENSE_PERMS _LICENSE_GROUPS _LICENSE_DISTFILES
+ @${ECHO_CMD} "${var}=${${var}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
+. endfor
+# Report
+ @${ECHO_CMD} "This package has a single license: ${_LICENSE} (${_LICENSE_NAME})." > ${_LICENSE_REPORT_TMP}
+. else
+# Catalog
+. for var in _LICENSE _LICENSE_COMB _LICENSE_NAME _LICENSE_PERMS _LICENSE_GROUPS
+ @${ECHO_CMD} "${var}=${${var}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
+. endfor
+. if ${_LICENSE_COMB} == "dual" && ${_LICENSE_STATUS} == "ask"
+ @${SED} -e 's/^/_LICENSE_SELECTED=/' ${_LICENSE_COOKIE} >> ${_LICENSE_CATALOG_TMP}
+. endif
+. for lic in ${_LICENSE}
+. for var in NAME PERMS GROUPS DISTFILES
+ @${ECHO_CMD} "_LICENSE_${var}_${lic}=${_LICENSE_${var}_${lic}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
+. endfor
+. endfor
+# Report
+. if ${_LICENSE_COMB} == "dual"
+ @${ECHO_CMD} "This package has dual licenses (any of):" >> ${_LICENSE_REPORT_TMP}
+. elif ${_LICENSE_COMB} == "multi"
+ @${ECHO_CMD} "This package has multiple licenses (all of):" >> ${_LICENSE_REPORT_TMP}
+. endif
+. for lic in ${_LICENSE}
+ @${ECHO_CMD} "- ${lic} (${_LICENSE_NAME_${lic}})" >> ${_LICENSE_REPORT_TMP}
+. endfor
+. endif
+.endif
+
+# Cookie (done here)
+ @${TOUCH} ${_LICENSE_COOKIE}
+
+# Package list entries, and installation
+
+.if !defined(NO_LICENSES_INSTALL)
+PLIST_FILES+= ${_LICENSE_DIR_REL}/${_LICENSE_CATALOG:T} \
+ ${_LICENSE_DIR_REL}/${_LICENSE_REPORT:T}
+
+.if ${_LICENSE_COMB} == "single"
+PLIST_FILES+= ${_LICENSE_DIR_REL}/${_LICENSE}
+.else
+. for lic in ${_LICENSE}
+. if defined(_LICENSE_FILE_${lic})
+PLIST_FILES+= ${_LICENSE_DIR_REL}/${lic}
+. endif
+. endfor
+.endif
+
+install-license:
+ @${MKDIR} ${STAGEDIR}${_LICENSE_DIR}
+ @${INSTALL_DATA} ${_LICENSE_CATALOG_TMP} ${STAGEDIR}${_LICENSE_CATALOG}
+ @${INSTALL_DATA} ${_LICENSE_REPORT_TMP} ${STAGEDIR}${_LICENSE_REPORT}
+.if ${_LICENSE_COMB} == "single"
+ @${INSTALL_DATA} ${_LICENSE_FILE} ${STAGEDIR}${_LICENSE_DIR}/${_LICENSE}
+.else
+. for lic in ${_LICENSE}
+ @${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${STAGEDIR}${_LICENSE_DIR}/${lic}
+. endfor
+.endif
+# XXX @dirrmtry entry must be here (no way to do with PLIST_* vars)
+ @${ECHO_CMD} "@owner root" >> ${TMPPLIST}
+ @${ECHO_CMD} "@group wheel" >> ${TMPPLIST}
+ @${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
+ @${ECHO_CMD} "@dirrm ${_LICENSE_DIR_REL}" >> ${TMPPLIST}
+ @${ECHO_CMD} "@unexec rmdir %D/share/licenses 2>/dev/null || true" >> ${TMPPLIST}
+
+.endif
+
+.else # !LICENSE
+
+check-license:
+. if defined(LICENSE_VERBOSE)
+ @${ECHO_MSG} "===> License check disabled, port has not defined LICENSE"
+. endif
+
+.endif # LICENSE
+
+.endif
More information about the Midnightbsd-cvs
mailing list