diff -ruN ports/Mk/bsd.licenses.db.mk p4/portslicense/ports/Mk/bsd.licenses.db.mk --- ports/Mk/bsd.licenses.db.mk 1970-01-01 00:00:00.000000000 +0000 +++ p4/portslicense/ports/Mk/bsd.licenses.db.mk 2009-06-11 07:50:40.496320000 +0000 @@ -0,0 +1,96 @@ +#-*- mode: makefile; tab-width: 4; -*- +# ex:ts=4 +# +# $FreeBSD$ +# +# bsd.licenses.db.mk - License database for bsd.licenses.mk +# +# Created by: Alejandro Pulver +# +# Please view me with 4 column tabs! +# + +# Possible sources for information: +# - FOSSology (see "Default License Groups") +# http://fossology.org/interpret_the_license_group_analysis_report +# +# - Wikipedia (article "Comparison of Free Software Licenses") +# http://en.wikipedia.org/wiki/Comparison_of_free_software_licences +# +# Probably will be automatically incorporated from FOSSology's software. + +# XXX Start of editable section + +# License definitions +# +# _LICENSE_LIST - List of defined licenses +# _LICENSE_LIST_GROUPS - List of defined license groups +# + +_LICENSE_LIST= ASL BSD BSL CDDL GPLv2 GPLv3 LGPL MIT MPL +_LICENSE_LIST_GROUPS= FSF GPL OSI + +# Properties of license/group "xxx" (similar to port's variables, but single) +# _LICENSE_NAME_xxx - Full name/description of license/group +# _LICENSE_PERMS_xxx - Permissions +# _LICENSE_COMPAT_xxx - Compatibility +# _LICENSE_INCOMPAT_xxx - Incompatibility + +# List of licenses + +_LICENSE_NAME_ASL= Apache License + +_LICENSE_NAME_BSD= BSD license + +_LICENSE_NAME_BSL= Boost Software License + +_LICENSE_NAME_CDDL= Common Development and Distribution License + +_LICENSE_NAME_GPLv2= GNU General Public License version 2 + +_LICENSE_NAME_GPLv3= GNU General Public License version 3 + +_LICENSE_NAME_LGPL= GNU Lesser General Public License + +_LICENSE_NAME_MIT= MIT license / X11 license + +_LICENSE_NAME_MPL= Mozilla Public License + +# List of groups + +_LICENSE_NAME_FSF= Free Software Foundation Approved +_LICENSE_PERMS_FSF= pkg-redist dist-redist pkg-sell dist-sell auto-accept + +_LICENSE_NAME_GPL= GPL Compatible +_LICENSE_PERMS_GPL= pkg-redist dist-redist pkg-sell dist-sell auto-accept + +_LICENSE_NAME_OSI= OSI Approved +_LICENSE_PERMS_OSI= pkg-redist dist-redist pkg-sell dist-sell auto-accept + +# Grouping +# +# - Method 1: +# _LICENSE_LIST_GROUP_xxx - List of licenses under the "xxx" group + +_LICENSE_LIST_GROUP_FSF= ASL BSD BSL CDDL GPLv2 GPLv3 LGPL MIT MPL + +_LICENSE_LIST_GROUP_GPL= GPLv2 GPLv3 LGPL MIT + +_LICENSE_LIST_GROUP_OSI= ASL BSD BSL CDDL GPLv2 GPLv3 LGPL MIT MPL + +# - Method 2: +# _LICENSE_GROUPS_xxx - Groups the license/group belongs to + +# empty + +# XXX End of editable section + +# Method 1 expands to method 2 +.for group in ${_LICENSE_LIST_GROUPS} +. for lic in ${_LICENSE_LIST_GROUP_${group}} +_LICENSE_GROUPS_${lic}?= # +. if ${_LICENSE_GROUPS_${lic}:M${group}} == "" +_LICENSE_GROUPS_${lic}+= ${group} +. endif +. endfor +.endfor diff -ruN ports/Mk/bsd.licenses.mk p4/portslicense/ports/Mk/bsd.licenses.mk --- ports/Mk/bsd.licenses.mk 1970-01-01 00:00:00.000000000 +0000 +++ p4/portslicense/ports/Mk/bsd.licenses.mk 2009-05-31 15:50:57.601762000 +0000 @@ -0,0 +1,535 @@ +#-*- mode: makefile; tab-width: 4; -*- +# ex:ts=4 +# +# $FreeBSD$ +# +# bsd.licenses.mk - License auditing framework. +# +# Created by: Alejandro Pulver +# +# Please view me with 4 column tabs! +# + +# The following cases are not considered: +# +# - Redistribution of modified distfiles, because is never been done. +# - Creating binaries from modified sources, because packages almost always +# contain modifications to the source, and can not be autodetected (i.e. +# patch-* in ${FILESDIR}, post-* targets, etc), and these licenses tend to +# have more restrictions. +# + +# Integration with target sequences +# +# _SANITY_SEQ+= check-license (after check-vulnerable) +# _EXTRACT_SEQ+= ask-license (after post-extract-script) +# _INSTALL_SUSEQ+= install-license (after install-desktop-entries) +# +# The 'check-license' target will determine if the license was rejected or has +# to be asked later in 'ask-license' (by then LICENSE_FILE should be available +# for presenting to the user). +# The 'install-license' target installs both the application's license and a +# restriction report (to be used by ports scripts and similar tools). + +# Variables provided to users +# +# LICENSES_ACCEPTED - Accepted licenses and groups. +# LICENSES_REJECTED - Rejected licenses and groups. +# LICENSE_ASK - Require explicit user approval for all licenses not +# present in configuration nor LICENSES_ACCEPTED. +# LICENSES_CONFIG - If defined, will ask again when already saved +# +# The components of LICENSES_{ACCEPTED,REJECTED} can be one of: +# - A license code (like "GPLv2"). +# - A license group prefixed by '@' (like "@OSI"). +# +# Note that the framework configuration format is the same (without groups +# syntax), but stored in ${LICENSE_CFG} or ${LICENSE_CFG_PORT}. The user +# variables take precedence (anyways the other configuration is also made by +# the user). +# + +# Variables provided to ports +# +# LICENSE - Code of license (short name). +# LICENSE_PERMS - Permissions; use "none" if empty. +# LICENSE_GROUPS - Groups the license belongs. +# LICENSE_COMPAT - Compatibility with other licenses/groups (default: all). +# LICENSE_INCOMPAT - Incompatibility with other licenses/groups (default: none). +# LICENSE_NAME - Full license name (for the reports). +# LICENSE_NOTES - A note about restrictions (not needed), to replace +# RESTRICTED and ports/LEGAL. +# LICENSE_FILE - Full path to license (or use LICENSE_TEXT). +# LICENSE_TEXT - Text to use as a license, useful when referencing to +# another place if it's not in the distfile. +# LICENSE_DISTFILE - Name of licensed files (defaults to ${DISTFILES}). +# +# The following cases are supported (see _LICENSE_TYPE): +# +# Case 1: license defined in the framework (aka "known"). +# Define LICENSE; framework defines license variables, by redefining any of +# them the port falls in Case 2. +# +# Case 2: license is based on a defined one (aka "variant"). +# All license variables must be defined by the port (but LICENSE is set to +# a known value). +# XXX This case is being considered, and if it has to inherit properties from +# its base license or just let it fall in Case 3 (as now). +# +# Case 3: license only known by the port (aka "unknown"). +# All license variables must be defined by the port. +# +# Notes: +# - Permissions use a default-deny policy (that's why groups are there). +# - Adding a license to a group makes it inherit their properties (PERMS, +# GROUPS and COMPAT/INCOMPAT). +# - Components can be negated by prefixing them with "no-" (like +# "no-pkg-sell"). Useful for exceptions. +# - For multiple licenses components can be grouped, for example: +# LICENSE= GPLv2 BSD +# LICENSE_PERMS= GPLv2:no-pkg-sell,pkg-redist BSD:no-pkg-sell,pkg-redist +# LICENSE_NOTES= GPLv2:"No sell" BSD:"Allows everything" +# +# Available components for LICENSE_PERMS: +# dist-redist - No free redistribution of distfile (like FTP mirroring; RESTRICTED). +# dist-sell - No selling of distfile (like in CD-ROM; NO_CDROM). +# pkg-redist - No free redistribution of package (like FTP upload; NO_PACKAGE). +# pkg-sell - No selling of package (like in CD-ROM; NO_CDROM). +# auto-accept - If license is accepted by default, without presented agreement. +# none - Explicit universal restriction (to make sure that is the intention). +# And the following aliases (can also be negated): pkg, dist, sell and redist. +# + +.if defined(_POSTMKINCLUDED) && !defined(BEFOREPORTMK) + +.if defined(LICENSE) + +# Organization +# - Define common license properties. +# - Define internal variables. +# - Check for single or multiple port licenses. +# - Check defined properties and compare with database. +# - Check user and framework configuration. +# - Define targets. + +# Include known licenses from database + +.include "${PORTSDIR}/Mk/bsd.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_GROUP_VARS - License variables inherited from groups +# _LICENSE_LIST_SAVE_VARS - License variables present in the report + +_LICENSE_LIST_PERMS= dist-redist dist-sell pkg-redist pkg-sell auto-accept none +_LICENSE_LIST_PORT_VARS= PERMS GROUPS NAME COMPAT INCOMPAT +_LICENSE_LIST_GROUP_VARS= PERMS COMPAT INCOMPAT +_LICENSE_LIST_SAVE_VARS= _LICENSE _LICENSE_NOTES _LICENSE_DISTFILES \ + _LICENSE_COMPAT _LICENSE_INCOMPAT ${_LICENSE_LIST_PORT_VARS:S/^/_LICENSE_/} + +# Defaults + +LICENSE_DISTFILE?= ${DISTFILES} +# XXX internal variables will be useful for multiple licenses +_LICENSE= ${LICENSE} +_LICENSE_NOTES= ${LICENSE_NOTES} +_LICENSE_DISTFILE= ${LICENSE_DISTFILE} + +# Path variables +# +# _LICENSE_DIR - Directory to install licenses +# _LICENSE_DIR_REL - Same as above, without ${PREFIX} +# _LICENSE_CFG_GLOB - Global license configuration file +# _LICENSE_CFG_PORT - Per port license configuration file +# _LICENSE_REPORT - License report to be created (under ${LICENSE_DIR}) + +_LICENSE_DIR?= ${PREFIX}/share/licenses/${UNIQUENAME} +_LICENSE_DIR_REL?= share/licenses/${UNIQUENAME} +_LICENSE_CFG_GLOB?= ${PORT_DBDIR}/license-config +_LICENSE_CFG_PORT?= ${PORT_DBDIR}/${UNIQUENAME}/license +_LICENSE_REPORT?= ${_LICENSE_DIR}/report + +# Check if single or dual/multiple license +# +# _LICENSE_SINGLE - Defined for a single license +# _LICENSE_MULTI - Set to "and"/"or"? (XXX Not implemented) + +#.for lic in ${_LICENSE} +#. if defined(_LICENSE_DEFINED) +#_LICENSE_MULTI= yes +#. else +#_LICENSE_DEFINED?= ${lic} +#. endif +#.endfor +#.if !defined(_LICENSE_MULTI) +#_LICENSE_SINGLE= yes +#.endif +#.undef _LICENSE_DEFINED + +# Evaluate port license groups and permissions +# +# Available values for _LICENSE_TYPE: +# Case 1: "known" (license info taken from internal database) +# Case 2: "variant" (LICENSE is known, but info taken from port) +# Case 3: "unknown" (LICENSE is not known, and info taken from port) +# # Make sure required variables are defined, and remove conflicting (positive +# and negative) and duplicated components. + +#.if defined(_LICENSE_SINGLE) +. for lic in ${_LICENSE} +. if ${_LICENSE_LIST:M${lic}} != "" +. for var in ${_LICENSE_LIST_PORT_VARS} +. if defined(LICENSE_${var}) +_LICENSE_TYPE= variant +. endif +. endfor +_LICENSE_TYPE?= known +. for var in ${_LICENSE_LIST_PORT_VARS} +# Case 1: license defined in the framework. +. if ${_LICENSE_TYPE} == "known" +_LICENSE_${var}= ${_LICENSE_${var}_${lic}} +# Case 2: license is based on a defined one. +# XXX Should here be inheritance of non defined values? +. elif ${_LICENSE_TYPE} == "variant" && defined(LICENSE_${var}) +_LICENSE_${var}= ${LICENSE_${var}} +. endif +. endfor +# Case 3: license only known by the port. +. else +_LICENSE_TYPE?= unknown +. for var in ${_LICENSE_LIST_PORT_VARS} +. if defined(LICENSE_${var}) +_LICENSE_${var}= ${LICENSE_${var}} +. endif +. endfor +. endif +# XXX here it does not affect _LICENSE_TYPE +_LICENSE_COMPAT?= # +_LICENSE_INCOMPAT?= # +# Check everything needed is defined. +. for var in ${_LICENSE_LIST_PORT_VARS} +. if !defined(_LICENSE_${var}) +. if ${_LICENSE_TYPE} == "variant" +_LICENSE_ERROR?= for a modified license, defining LICENSE_${var} is mandatory (otherwise define LICENSE alone) +. elif ${_LICENSE_TYPE} == "unknown" +_LICENSE_ERROR?= for a new/unknown license, defining LICENSE_${var} is mandatory (otherwise use a known LICENSE) +. endif +. endif +. endfor +# Groups are always inherited (and were expanded so no recursion) +. for group in ${_LICENSE_LIST_GROUPS} +. for var in ${_LICENSE_LIST_GROUP_VARS} +_LICENSE_${var}+= ${_LICENSE_${var}_${group}} +. endfor +. endfor +# Expand LICENSE_PERMS aliases +# pkg -> pkg-redist pkg-sell +# dist -> dist-redist dist-sell +# redist -> pkg-redist dist-redist +# sell -> pkg-sell dist-sell +_LICENSE_PERMS:= ${_LICENSE_PERMS:Nno-*:C/^(pkg|dist)$/\1-redist \1-sell/:C/^(sell|redist)$/dist-\1 pkg-\1/} \ + ${_LICENSE_PERMS:Mno-*:C/^(no-)(pkg|dist)$/\1\2-redist \1\2-sell/:C/^(no-)(sell|redist)$/\1dist-\2 \1pkg-\2/} +# XXX Cleaner, but outputs an error when (no-)? is not found but referenced later by \1 +#_LICENSE_PERMS:= ${_LICENSE_PERMS:C/^(no-)?(pkg|dist)$/\1\2-redist \1\2-sell/:C/^(no-)?(sell|redist)$/\1dist-\2 \1pkg-\2/} +# 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) +# XXX License file is optional for licenses present in database, maybe an option +# could be added to avoid installing licenses present in the database +. if !defined(LICENSE_FILE) +. if !defined(LICENSE_TEXT) +. if ${_LICENSE_TYPE} == "known" +LICENSE_TEXT= License ${lic} is in internal database, please check ... +. else +_LICENSE_ERROR?= LICENSE_FILE or LICENSE_TEXT must be defined for unknown licenses +. endif +. else +_LICENSE_FILE= ${WRKDIR}/License-freebsd-port +. endif +. else +_LICENSE_FILE= ${LICENSE_FILE} +. endif +. endfor +#.else +# XXX dual/multiple licenses +#.endif + +# Check if the user agrees with the license +# +# _LICENSE_CFG - Path to cfg file (either global or per port) +# _LICENSE_CFG_TYPE - "global" or "port", according to the previous +# +# LICENSES_ACCEPTED - List of accepted licenses (user version) +# LICENSES_REJECTED - List of rejected licenses (user version) +# _LICENSES_ACCEPTED - List of accepted licenses (configuration file) +# _LICENSES_REJECTED - List of rejected licenses (configuration file) + +# If _LICENSE_TYPE is "known", configuration is global, otherwise per port. + +.if ${_LICENSE_TYPE} == "known" +_LICENSE_CFG= ${_LICENSE_CFG_GLOB} +_LICENSE_CFG_TYPE= global +.else +_LICENSE_CFG= ${_LICENSE_CFG_PORT} +_LICENSE_CFG_TYPE= port +.endif + +.if exists(${_LICENSE_CFG}) +. include "${_LICENSE_CFG}" +.endif + +# Make sure these are defined +LICENSES_ACCEPTED?= # +LICENSES_REJECTED?= # +_LICENSES_ACCEPTED?= # +_LICENSES_REJECTED?= # + +# Evaluate status (accepted, rejected or ask) +# +# _LICENSE_STATUS - Status: "accepted", "rejected" or "ask" +# _LICENSE_STATUS_FROM - Status origin: "user", "config" or "default" +# _LICENSE_STATUS_REASON - Text reason of license status (XXX Required?) + +_LICENSE_TYPE_PAIRS_known= LICENSES,user _LICENSES,config +_LICENSE_TYPE_PAIRS_variant= _LICENSES,config +_LICENSE_TYPE_PAIRS_unknown= _LICENSES,config + +#.if defined(_LICENSE_SINGLE) +# User and saved configuration +. for lic in ${_LICENSE} +. for pair in ${_LICENSE_TYPE_PAIRS_${_LICENSE_TYPE}} +_LC_VAR:= ${pair:C/,.*//} +_LC_TYPE:= ${pair:C/.*,//} +. if ${${_LC_VAR}_REJECTED:M${lic}} != "" && !defined(_LICENSE_STATUS) +_LICENSE_STATUS= rejected +_LICENSE_STATUS_FROM:= ${_LC_TYPE} +. elif ${${_LC_VAR}_ACCEPTED:M${lic}} != "" && !defined(_LICENSE_STATUS) +_LICENSE_STATUS= accepted +_LICENSE_STATUS_FROM:= ${_LC_TYPE} +. endif +. endfor + +# Automatic configuration +. if !defined(_LICENSE_STATUS) +# Check groups (only available for user configuration) +. for group in ${_LICENSE_LIST_GROUPS} +. if ${LICENSES_REJECTED:M\@${group}} != "" +_LICENSE_STATUS?= rejected +_LICENSE_STATUS_FROM?= user +. endif +. if ${LICENSES_ACCEPTED:M\@${group}} != "" +_LICENSE_STATUS?= accepted +_LICENSE_STATUS_FROM?= user +. endif +. endfor +# Auto-accept if LICENSE_PERMS has auto-accept, and !LICENSES_ASK +. if ${_LICENSE_PERMS:Mauto-accept} != "" +. if !defined(LICENSES_ASK) +_LICENSE_STATUS?= accepted +_LICENSE_STATUS_FROM?= default +. else +_LICENSE_STATUS?= ask +_LICENSE_STATUS_FROM?= user +. endif +. endif +# If defined BATCH and need to ask, it fails +. if defined(BATCH) +_LICENSE_STATUS?= rejected +_LICENSE_STATUS_FROM?= user +. endif +# Otherwise ask to the user +_LICENSE_STATUS?= ask +_LICENSE_STATUS_FROM?= default +. endif +. endfor + +#.else +# XXX dual/multiple licenses +#.endif + +# Check variables are correctly defined and print status up to here + +check-license: +.if defined(_LICENSE_ERROR) + @${ECHO_MSG} "===> License not correctly defined: ${_LICENSE_ERROR}" + @exit 1 +.endif +#.if defined(_LICENSE_SINGLE) +. if ${_LICENSE_STATUS} == "rejected" + @${ECHO_MSG} "===> License ${_LICENSE} rejected by the user (by ${_LICENSE_STATUS_FROM})" + @exit 1 +. elif ${_LICENSE_STATUS} == "accepted" + @${ECHO_MSG} "===> License ${_LICENSE} accepted by the user (by ${_LICENSE_STATUS_FROM})" +. elif ${_LICENSE_STATUS} == "ask" + @${ECHO_MSG} "===> License ${_LICENSE} needs agreement, will ask later (by ${_LICENSE_STATUS_FROM})" +. endif +#.else +# XXX dual/multiple licenses +#.endif + +.if defined(LICENSES_CONFIG) +_LICENSES_CONFIG= yes +.else +_LICENSES_CONFIG= no +.endif + +# For config when user accepts +_LICENSES_ACCEPTED_YES= ${_LICENSES_ACCEPTED} ${_LICENSE} +.for lic in ${_LICENSE} +_LICENSES_REJECTED_YES= ${_LICENSES_REJECTED:N${lic}} +.endfor +# For config when user rejects +.for lic in ${_LICENSE} +_LICENSES_ACCEPTED_NO= ${_LICENSES_ACCEPTED:N${lic}} +.endfor +_LICENSES_REJECTED_NO= ${_LICENSES_REJECTED} ${_LICENSE} + +# Display, ask and save preference if requested + +ask-license: +.if !defined(LICENSE_FILE) && defined(LICENSE_TEXT) +# XXX escape shell chars? + @${ECHO_CMD} ${LICENSE_TEXT} > ${_LICENSE_FILE} +.endif + @if [ ! -f ${_LICENSE_FILE} ]; then \ + ${ECHO_MSG} "===> License not found in \"${_LICENSE_FILE}\", aborting."; \ + exit 1; \ + fi + @if [ ${_LICENSE_STATUS} = "accepted" ]; then \ + status=done; \ + fi; \ + if [ ${_LICENSE_STATUS} = "accepted" -a ${_LICENSE_TYPE} != "known" ]; then \ + if [ ${_LICENSE_${_LICENSE}_CHK} != `${SHA256} -q ${_LICENSE_FILE}` ]; then \ + ${ECHO_MSG} "===> License has changed, agreement will be presented"; \ + status=ask; \ + fi; \ + fi; \ + if [ ${_LICENSE_STATUS} != "ask" -a ${_LICENSES_CONFIG} = "yes" ]; then \ + if [ ${_LICENSE_STATUS_FROM} = "user" ]; then \ + ${ECHO_MSG} "===> Configuration failed because manual settings are present"; \ + exit 1; \ + else \ + status=ask; \ + fi; \ + fi; \ + until [ "$$status" = done ]; do \ + ${PRINTF} "\nPress 'y'/'n' (yes/no, upper-case saves choice) or 'v' to view: "; \ + read ans; \ + ${PRINTF} "\n"; \ + case $$ans in \ + y) ${ECHO_MSG} "===> License accepted by user"; \ + status=done;; \ + n) ${ECHO_MSG} "===> License rejected by user"; \ + exit 1;; \ + Y) if [ ${UID} != 0 ]; then \ + ${ECHO_MSG} "===> You don't have permissions to save the choice"; \ + else \ + ${MKDIR} ${_LICENSE_CFG:H}; \ + (${ECHO_CMD} _LICENSES_ACCEPTED=${_LICENSES_ACCEPTED_YES}; \ + ${ECHO_CMD} _LICENSES_REJECTED=${_LICENSES_REJECTED_YES}; \ + if [ ${_LICENSE_TYPE} != "known" ]; then \ + ${ECHO_CMD} _LICENSE_${_LICENSE}_CHK=`${SHA256} -q ${_LICENSE_FILE}`; \ + fi) > ${_LICENSE_CFG}; \ + ${ECHO_MSG} "===> License accepted by user and saved"; \ + status=done; \ + fi;; \ + N) if [ ${UID} != 0 ]; then \ + ${ECHO_MSG} "===> You don't have permissions to save the choice"; \ + else \ + ${MKDIR} ${_LICENSE_CFG:H}; \ + (${ECHO_CMD} _LICENSES_ACCEPTED=${_LICENSES_ACCEPTED_NO}; \ + ${ECHO_CMD} _LICENSES_REJECTED=${_LICENSES_REJECTED_NO}; \ + if [ ${_LICENSE_TYPE} != "known" ]; then \ + ${ECHO_CMD} _LICENSE_${_LICENSE}_CHK=`${SHA256} -q ${_LICENSE_FILE}`; \ + fi) > ${_LICENSE_CFG}; \ + ${ECHO_MSG} "===> License rejected by user and saved"; \ + exit 1; \ + fi;; \ + [Vv]) more ${_LICENSE_FILE};; \ + esac; \ + done + +# License compatibility check + +# XXX is it useful? Maybe BUILD/LIB depends too? +# also empty vaules of COMPAT do not mean "incompatible with all" + +.if !empty(_LICENSE_COMPAT) || !empty(_LICENSE_INCOMPAT) +. for port in ${RUN_DEPENDS} +_LICENSE_RESULT!= cd ${port} && ${MAKE} -V LICENSE +. for lic in ${_LICENSE_RESULT} +. if (!empty(_LICENSE_COMPAT) && ${LICENSE_COMPAT:M${lic}} == "") || \ + (!empty(_LICENSE_INCOMPAT) && ${LICENSE_INCOMPAT:M${lic}} != "") +IGNORE= depends on ${port:T} that uses license "${lic}" which is incompatible with "${_LICENSE}" used by this port +. endif +. endfor +. endfor +.endif + +# Package list entries, and installation + +PLIST_FILES+= ${_LICENSE_DIR_REL}/${_LICENSE_REPORT:T} +PLIST_DIRS+= ${_LICENSE_DIR_REL} + +.if defined(_LICENSE_FILE) +PLIST_FILES+= ${_LICENSE_DIR_REL}/${_LICENSE_FILE:T} +.endif + +install-license: + @${MKDIR} ${_LICENSE_DIR} +.if defined(_LICENSE_FILE) + @test -f ${_LICENSE_FILE} && ${INSTALL_DATA} ${_LICENSE_FILE} ${_LICENSE_DIR} +.endif + @${TRUE} > ${_LICENSE_REPORT} +. for var in ${_LICENSE_LIST_SAVE_VARS} +. if !empty(${var}) + @${ECHO_CMD} ${var}=${${var}:C/^[[:blank:]]*//} >> ${_LICENSE_REPORT} +. endif +. endfor + +.if make(clean-user-license-config) +. for lic in ${LICENSES_APPROVED:N\@*} ${LICENSES_REJECTED:N\@*} +. if ${_LICENSE_LIST:M${lic}} == "" +_LICENSES_INV+= ${lic} +. endif +. endfor +. for group in ${LICENSES_APPROVED:M\@*} ${LICENSES_REJECTED:M\@*} +. if ${_LICENSE_LIST_GROUPS:M${group}} == "" +_LICENSES_INV_GRP+= ${group} +. endif +. endfor +.endif +clean-user-license-config: +.if !empty(_LICENSES_INV) + @${ECHO_CMD} "Invalid user approved/rejected licenses: ${_LICENSES_INV}" +.endif +.if !empty(_LICENSES_INV_GRP) + @${ECHO_CMD} "Invalid user approved/rejected license groups: ${_LICENSES_INV_GRP}" +.endif + +.else # !LICENSE + +check-license: + @${ECHO_MSG} "===> License check disabled, port has not defined LICENSE" + +ask-license: + @${DO_NADA} + +install-license: + @${DO_NADA} + +.endif # LICENSE + +.endif diff -ruN ports/Mk/bsd.port.mk p4/portslicense/ports/Mk/bsd.port.mk --- ports/Mk/bsd.port.mk 2009-06-11 09:09:29.343323000 +0000 +++ p4/portslicense/ports/Mk/bsd.port.mk 2009-06-13 11:06:51.478081000 +0000 @@ -2412,6 +2412,9 @@ ALL_TARGET?= all INSTALL_TARGET?= install +# Integrate with the license auditing framework +.include "${PORTSDIR}/Mk/bsd.licenses.mk" + # Popular master sites .include "${PORTSDIR}/Mk/bsd.sites.mk" @@ -4172,15 +4175,15 @@ .endif _SANITY_SEQ= ${_CHROOT_SEQ} pre-everything check-makefile check-categories \ check-makevars check-desktop-entries check-depends \ - check-deprecated check-vulnerable buildanyway-message \ - options-message + check-deprecated check-vulnerable check-license \ + buildanyway-message options-message _FETCH_DEP= check-sanity _FETCH_SEQ= fetch-depends pre-fetch pre-fetch-script \ do-fetch post-fetch post-fetch-script _EXTRACT_DEP= fetch _EXTRACT_SEQ= extract-message checksum extract-depends pre-extract \ pre-extract-script do-extract \ - post-extract post-extract-script + post-extract post-extract-script ask-license _PATCH_DEP= extract _PATCH_SEQ= patch-message patch-depends patch-dos2unix pre-patch \ pre-patch-script do-patch post-patch post-patch-script @@ -4197,7 +4200,7 @@ pre-install-script generate-plist check-already-installed _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \ pre-su-install-script do-install install-desktop-entries \ - post-install post-install-script add-plist-info \ + install-license post-install post-install-script add-plist-info \ add-plist-docs add-plist-examples add-plist-data \ add-plist-post install-rc-script compress-man \ install-ldconfig-file fake-pkg security-check @@ -5868,6 +5871,9 @@ ${CAT} /tmp/${PKGNAME}-required-by >> ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY; \ ${RM} -f /tmp/${PKGNAME}-required-by; \ fi +.if defined(REGISTER_LICENSE) +# XXX concat prepared file to +CONTENTS (or directly use .if exists()) +.endif .else @${DO_NADA} .endif diff -ruN ports/Mk/test-license-1/Makefile p4/portslicense/ports/Mk/test-license-1/Makefile --- ports/Mk/test-license-1/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ p4/portslicense/ports/Mk/test-license-1/Makefile 2009-05-31 15:50:57.759762000 +0000 @@ -0,0 +1,32 @@ +# New ports collection makefile for: test-license +# Date created: 2008-07-06 +# Whom: alepulver +# +# $FreeBSD$ +# + +PORTNAME= test-license +PORTVERSION= 1.0 +CATEGORIES= devel +MASTER_SITES= # +DISTFILES= # + +MAINTAINER= alepulver@FreeBSD.org +COMMENT= Port to test the Ports License Framework + +NO_BUILD= yes +NO_WRKSUBDIR= yes + +LICENSE= MyLic +LICENSE_TEXT= This license is at www.example.com +LICENSE_PERMS= redist +LICENSE_NAME= My Example License +LICENSE_GROUPS= # + +do-extract: + @${MKDIR} ${WRKDIR} + +do-install: + +.include +.include diff -ruN ports/Mk/test-license-1/pkg-descr p4/portslicense/ports/Mk/test-license-1/pkg-descr --- ports/Mk/test-license-1/pkg-descr 1970-01-01 00:00:00.000000000 +0000 +++ p4/portslicense/ports/Mk/test-license-1/pkg-descr 2009-05-31 15:50:57.770763000 +0000 @@ -0,0 +1,3 @@ +[description of the port] + +WWW: http://port.home.page/ diff -ruN ports/Mk/test-license-1/pkg-plist p4/portslicense/ports/Mk/test-license-1/pkg-plist --- ports/Mk/test-license-1/pkg-plist 1970-01-01 00:00:00.000000000 +0000 +++ p4/portslicense/ports/Mk/test-license-1/pkg-plist 2009-05-31 15:50:57.773760000 +0000 @@ -0,0 +1 @@ +@comment $FreeBSD$