6 # ** Please run changes to this file by eadler@ first **
8 Licenses_Include_MAINTAINER= portmgr@FreeBSD.org
11 # bsd.licenses.mk - License auditing framework.
13 # Created by: Alejandro Pulver <alepulver@FreeBSD.org>
15 # Please view me with 4 column tabs!
19 # - Bring back save and checksum with new dialog interface (only offers to do
20 # so if ran by root, otherwise silently remove the options). Also only allow
21 # saving per-port options (known or unknown), and only when accepted.
22 # - Add custom restriction targets for better integration (now some files are
23 # removed from FTP if restricted for CDROM for example, as the old
26 # The following cases are not considered:
28 # - Redistribution of modified distfiles, because is never done.
29 # - Creating binaries from modified sources, because packages almost always
30 # contain modifications to the source, can not be autodetected (i.e.
31 # patch-* in ${FILESDIR}, post-* targets, etc), and these licenses tend to
32 # have more restrictions anyways.
35 # Integration with target sequences
37 # _SANITY_SEQ+= check-license (after check-vulnerable)
38 # _PATCH_SEQ+= ask-license (before any other targets)
39 # _INSTALL_SUSEQ+= install-license (after install-desktop-entries)
41 # The 'check-license' target will determine if the license was accepted,
42 # rejected or has to be asked later to the user in 'ask-license' (by then
43 # licenses should be extracted). The 'install-license' target installs the
44 # applications' licenses, a general package license mentioning them, and a
45 # restriction report (to be used by ports, scripts and similar tools).
47 # Variables provided to the ports system and users in general, to modify the
48 # behavior of the framework
50 # DISABLE_LICENSES - Disable license auditing framework completely.
51 # NO_LICENSES_INSTALL - Do not install catalog, report and licenses.
52 # NO_LICENSES_DIALOGS - Disable interactive menus for asking licenses.
54 #NO_LICENSES_INSTALL= yes
55 #NO_LICENSES_DIALOGS= yes
57 # Variables provided to users (can be passed to make or set in /etc/make.conf)
59 # LICENSES_ACCEPTED - Accepted licenses.
60 # LICENSES_REJECTED - Rejected licenses.
61 # LICENSES_GROUPS_ACCEPTED - Accepted license groups.
62 # LICENSES_GROUPS_REJECTED - Rejected license groups.
63 # LICENSES_ASK - Require explicit user approval for all licenses not
64 # present in previous variables (for example, stock
65 # accepted licenses will ask confirmation).
68 # Variables provided to ports
70 # LICENSE - Code of license (short name).
71 # LICENSE_PERMS - Permissions; use "none" if empty.
72 # LICENSE_GROUPS - Groups the license belongs.
73 # LICENSE_NAME - Full license name (for the reports).
74 # LICENSE_FILE - Full path to license (or use LICENSE_TEXT).
75 # LICENSE_TEXT - Text to use as a license, useful when referencing to
76 # another place if it's not in the distfile.
77 # LICENSE_DISTFILES - Name of licensed files (defaults to ${_DISTFILES}).
78 # LICENSE_COMB - Set to "dual" or "multi", for OR/AND behavior
79 # (defaults to "single" if undefined, the common case)
81 # The following cases are supported after defining LICENSE:
83 # Case 1: license defined in the framework (aka "known").
85 # In this case the only allowed variables to set are LICENSE_FILE and
86 # LICENSE_DISTFILES. The rest are managed by the framework and are not allowed
89 # Case 2: license only known by the port (aka "unknown").
91 # In this case LICENSE_{PERMS,NAME} are mandatory, in addition to
92 # either LICENSE_FILE or LICENSE_TEXT. Optional variable is
95 # Available components for LICENSE_PERMS:
96 # dist-mirror - Redistribution of distfile is permitted
97 # (like FTP mirroring; port is not RESTRICTED).
98 # dist-sell - Selling of distfile, e.g. on CD-ROM is permitted
99 # (port does not need to set NO_CDROM).
100 # pkg-mirror - Free redistribution of package is permitted
101 # (like FTP upload; port does not set NO_PACKAGE).
102 # pkg-sell - Selling of package is permitted, e.g. on CD-ROM.
103 # auto-accept - License is accepted by default, without presented
104 # agreement, unless the user defines LICENSES_ASK.
106 # Notes about permissions:
107 # - Permissions use a default-deny policy (e.g. not setting "dist-mirror"
108 # means it is automatically excluded).
109 # - Components can be negated by prefixing them with "no-" (like
111 # - In case a component is present and also excluded (i.e. no-dist-sell and
112 # dist-sell together in LICENSE_PERMS), it will be excluded.
113 # - XXX Currently there is no point in "no-" prefixes, as permissions are not
114 # inherited from groups. Maybe it looks more clear that way than leaving the
117 # Dual/multiple licenses:
119 # If LICENSE_COMB is set to "dual", then LICENSE can (must, actually) have
120 # more than one component. After that each license "lic" in LICENSE falls in
121 # previous cases (known or unknown), but their variables are prefixed by
122 # _LICENSE_ and suffixed by _lic. The main license name, perms and groups will
123 # be set automatically (following appropiate logic). The idea is that any
124 # license from LICENSE can be chosen to use the package.
126 # The case when LICENSE_COMB is set to "multi" is similar. But the idea is
127 # that all of the licenses in LICENSE must be agreed to use the package.
130 .if defined(_POSTMKINCLUDED) && !defined(BEFOREPORTMK)
134 # Include known licenses from database
136 .include "${PORTSDIR}/Mk/bsd.licenses.db.mk"
138 # Lists of variables and valid components
140 # _LICENSE_LIST_PERMS - Valid permission components
141 # _LICENSE_LIST_PORT_VARS - License variables defined by the port
143 _LICENSE_LIST_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept none
144 _LICENSE_LIST_PORT_VARS= PERMS NAME GROUPS
148 # _LICENSE_DIR - Directory to install licenses
149 # _LICENSE_STORE - Store for known license files
150 # _LICENSE_CATALOG - License catalog (make include file) to be created (dst)
151 # _LICENSE_CATALOG_TMP - Same as above, but in WRKDIR (src)
152 # _LICENSE_REPORT - License summary, shows licenses and how they are combined (dst)
153 # _LICENSE_REPORT_TMP - Same as above, but in WRKDIR (src)
154 # _LICENSE_COOKIE - Set when license is accepted, it is not present in
155 # bsd.port.mk to avoid creating LICENSE_{REQ,SEQ} for a
156 # few more targets only.
158 _LICENSE_DIR?= ${PREFIX}/share/licenses/${PKGNAME}
159 _LICENSE_STORE?= ${PORTSDIR}/Templates/Licenses
160 _LICENSE_CATALOG?= ${_LICENSE_DIR}/catalog.mk
161 _LICENSE_CATALOG_TMP?= ${WRKDIR}/.license-catalog.mk
162 _LICENSE_REPORT?= ${_LICENSE_DIR}/LICENSE
163 _LICENSE_REPORT_TMP?= ${WRKDIR}/.license-report
164 _LICENSE_COOKIE?= ${WRKDIR}/.license_done.${PORTNAME}.${PREFIX:S/\//_/g}
166 # Defaults (never overriden for now)
168 # _LICENSE - Copy of LICENSE (for now)
169 # _LICENSE_COMB - Copy of LICENSE_COMB (but "single" instead of empty)
171 _LICENSE?= ${LICENSE}
172 .if !defined(LICENSE_COMB)
173 _LICENSE_COMB= single
175 _LICENSE_COMB= ${LICENSE_COMB}
178 # Check if single or dual/multiple license
180 # Make sure LICENSE_COMB is only used with more than one license.
182 .if ${_LICENSE_COMB} != "single" && ${_LICENSE_COMB} != "dual" && ${_LICENSE_COMB} != "multi"
183 _LICENSE_ERROR?= invalid value for LICENSE_COMB: "${_LICENSE_COMB}" (should be "single", "dual" or "multi")
186 .for lic in ${_LICENSE}
187 . if defined(_LICENSE_DEFINED)
188 . if ${_LICENSE_COMB} == "single"
189 _LICENSE_ERROR?= multiple licenses in LICENSE, but LICENSE_COMB is set to "single" (or undefined)
194 _LICENSE_DEFINED= yes
197 .if ${_LICENSE_COMB} != "single" && !defined(_LICENSE_MULTI)
198 _LICENSE_ERROR?= single license in LICENSE, but LICENSE_COMB is set to "${_LICENSE_COMB}" (requires more than one)
200 .if !defined(_LICENSE_DEFINED)
201 _LICENSE_ERROR?= no licenses present in LICENSE (empty string)
203 .undef _LICENSE_DEFINED
204 .undef _LICENSE_MULTI
206 # Evaluate port license groups and permissions
208 # Available values for _LICENSE_TYPE:
210 # Case 1: "known" (license info taken from internal database)
211 # Case 2: "unknown" (LICENSE is not known, and info taken from port)
213 # Make sure required variables are defined, and remove conflicting (positive
214 # and negative) duplicated components.
216 .if ${_LICENSE_COMB} == "single"
220 . for lic in ${_LICENSE}
221 . if ${_LICENSE_LIST:M${lic}} != ""
222 # Case 1: license defined in the framework.
224 . for var in ${_LICENSE_LIST_PORT_VARS}
225 . if defined(LICENSE_${var})
226 _LICENSE_ERROR?= redefining LICENSE_${var} is not allowed for known licenses, to define a custom license try another LICENSE name like ${_LICENSE}-variant
228 . if !defined(_LICENSE_${var}_${lic})
229 _LICENSE_ERROR?= ERROR: missing _LICENSE_${var}_${lic} in bsd.licenses.db.mk
231 _LICENSE_${var}= ${_LICENSE_${var}_${lic}}
234 # Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
235 . if !defined(LICENSE_FILE)
236 . if !defined(LICENSE_TEXT)
237 . if exists(${_LICENSE_STORE}/${lic})
238 _LICENSE_FILE= ${_LICENSE_STORE}/${lic}
240 # No license file in /usr/ports/Templates/Licenses
241 _LICENSE_TEXT= The license: ${_LICENSE} (${_LICENSE_NAME}) is standard, please read from the web.
242 _LICENSE_FILE= ${WRKDIR}/${lic}
245 _LICENSE_ERROR?= defining LICENSE_TEXT is not allowed for known licenses
248 _LICENSE_FILE= ${LICENSE_FILE}
252 # Case 2: license only known by the port.
253 _LICENSE_TYPE= unknown
254 . for var in ${_LICENSE_LIST_PORT_VARS}
255 . if defined(LICENSE_${var})
256 _LICENSE_${var}= ${LICENSE_${var}}
257 . elif !defined(_LICENSE_${var})
258 _LICENSE_ERROR?= for unknown licenses, defining LICENSE_${var} is mandatory (otherwise use a known LICENSE)
261 # Check LICENSE_PERMS for invalid, ambiguous and duplicate components
263 . for comp in ${_LICENSE_PERMS}
264 . if ${_LICENSE_LIST_PERMS:M${comp:C/^no-//}} == ""
265 _LICENSE_ERROR?= invalid LICENSE_PERMS component "${comp}"
266 . elif ${__LICENSE_PERMS:M${comp}} == "" && \
267 ${_LICENSE_PERMS:Mno-${comp:C/^no-//}} == ""
268 __LICENSE_PERMS+= ${comp}
271 _LICENSE_PERMS:= ${__LICENSE_PERMS}
272 . undef __LICENSE_PERMS
273 # Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
274 . if !defined(LICENSE_FILE)
275 . if !defined(LICENSE_TEXT)
276 _LICENSE_ERROR?= either LICENSE_FILE or LICENSE_TEXT must be defined
278 _LICENSE_TEXT= ${LICENSE_TEXT}
279 _LICENSE_FILE= ${WRKDIR}/${lic}
282 _LICENSE_FILE= ${LICENSE_FILE}
286 # Only one is allowed
287 . if defined(LICENSE_FILE) && defined(LICENSE_TEXT)
288 _LICENSE_ERROR?= defining both LICENSE_FILE and LICENSE_TEXT is not allowed
291 . if !defined(LICENSE_DISTFILES)
292 _LICENSE_DISTFILES= ${_DISTFILES}
294 _LICENSE_DISTFILES= ${LICENSE_DISTFILES}
299 . for lic in ${_LICENSE}
301 _LICENSE_GROUPS_${lic}?=#
302 . if ${_LICENSE_LIST:M${lic}} != ""
303 # Case 1: license defined in the framework.
304 _LICENSE_TYPE_${lic} = known
305 . for var in ${_LICENSE_LIST_PORT_VARS}
306 . if defined(LICENSE_${var}_${lic})
307 _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
309 . if !defined(_LICENSE_${var}_${lic})
310 _LICENSE_ERROR?= ERROR: missing _LICENSE_${var}_${lic} in bsd.licenses.db.mk
313 # Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
314 . if !defined(LICENSE_FILE_${lic})
315 . if !defined(LICENSE_TEXT_${lic})
316 . if exists(${_LICENSE_STORE}/${lic})
317 _LICENSE_FILE_${lic} = ${_LICENSE_STORE}/${lic}
319 # No license file in /usr/ports/Templates/Licenses
320 _LICENSE_TEXT_${lic} = The license: ${lic} (${_LICENSE_NAME_${lic}}) is standard, please read from the web.
321 _LICENSE_FILE_${lic} = ${WRKDIR}/${lic}
324 _LICENSE_ERROR?= defining LICENSE_TEXT_${lic} is not allowed for known licenses
327 _LICENSE_FILE_${lic} = ${LICENSE_FILE_${lic}}
331 # Case 2: license only known by the port.
332 _LICENSE_TYPE_${lic} = unknown
333 . for var in ${_LICENSE_LIST_PORT_VARS}
334 . if defined(LICENSE_${var}_${lic})
335 _LICENSE_${var}_${lic} = ${LICENSE_${var}_${lic}}
336 . elif !defined(_LICENSE_${var}_${lic})
337 _LICENSE_ERROR?= for unknown licenses, defining LICENSE_${var}_${lic} is mandatory (otherwise use a known LICENSE)
340 # Check LICENSE_PERMS for invalid, ambiguous and duplicate components
342 . for comp in ${_LICENSE_PERMS_${lic}}
343 . if ${_LICENSE_LIST_PERMS:M${comp:C/^no-//}} == ""
344 _LICENSE_ERROR?= invalid LICENSE_PERMS_${var} component "${comp}"
345 . elif ${__LICENSE_PERMS:M${comp}} == "" && \
346 ${_LICENSE_PERMS_${lic}:Mno-${comp:C/^no-//}} == ""
347 __LICENSE_PERMS+= ${comp}
350 _LICENSE_PERMS_${lic}:= ${__LICENSE_PERMS}
351 . undef __LICENSE_PERMS
352 # Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
353 . if !defined(LICENSE_FILE_${lic})
354 . if !defined(LICENSE_TEXT_${lic})
355 _LICENSE_ERROR?= either LICENSE_FILE_${lic} or LICENSE_TEXT_${lic} must be defined
357 _LICENSE_TEXT_${lic} = ${LICENSE_TEXT_${lic}}
358 _LICENSE_FILE_${lic} = ${WRKDIR}/${lic}
361 _LICENSE_FILE_${lic} = ${LICENSE_FILE_${lic}}
365 # Only one is allowed
366 . if defined(LICENSE_FILE_${lic}) && defined(LICENSE_TEXT_${lic})
367 _LICENSE_ERROR?= defining both LICENSE_FILE_${lic} and LICENSE_TEXT_${lic}is not allowed
370 . if !defined(LICENSE_DISTFILES_${lic})
371 _LICENSE_DISTFILES_${lic} = ${_DISTFILES}
373 _LICENSE_DISTFILES_${lic} = ${LICENSE_DISTFILES_${lic}}
378 # Check if the user agrees with the license
380 # Make sure these are defined
382 LICENSES_ACCEPTED?= #
383 LICENSES_REJECTED?= #
384 LICENSES_GROUPS_ACCEPTED?= #
385 LICENSES_GROUPS_REJECTED?= #
387 # Evaluate per-license status
389 .if ${_LICENSE_COMB} == "single"
390 . for lic in ${_LICENSE}
391 . if ${LICENSES_REJECTED:M${lic}} != ""
392 _LICENSE_STATUS?= rejected
394 . for group in ${_LICENSE_GROUPS}
395 . if ${LICENSES_GROUPS_REJECTED:M${group}} != ""
396 _LICENSE_STATUS?= rejected
398 . if ${LICENSES_GROUPS_ACCEPTED:M${group}} != ""
399 _LICENSE_STATUS?= accepted
402 . if ${LICENSES_ACCEPTED:M${lic}} != ""
403 _LICENSE_STATUS?= accepted
405 . if ${_LICENSE_PERMS:Mauto-accept} != "" && !defined(LICENSES_ASK)
406 _LICENSE_STATUS?= accepted
408 _LICENSE_STATUS?= ask
412 . for lic in ${_LICENSE}
413 . if ${LICENSES_REJECTED:M${lic}} != ""
414 _LICENSE_STATUS_${lic}?= rejected
416 . for group in ${_LICENSE_GROUPS_${lic}}
417 . if ${LICENSES_GROUPS_REJECTED:M${group}} != ""
418 _LICENSE_STATUS_${lic}?= rejected
420 . if ${LICENSES_GROUPS_ACCEPTED:M${group}} != ""
421 _LICENSE_STATUS_${lic}?= accepted
424 . if ${LICENSES_ACCEPTED:M${lic}} != ""
425 _LICENSE_STATUS_${lic}?= accepted
427 . if ${_LICENSE_PERMS_${lic}:Mauto-accept} != "" && !defined(LICENSES_ASK)
428 _LICENSE_STATUS_${lic}?= accepted
430 _LICENSE_STATUS_${lic}?= ask
434 # Evaluate general status
436 .if ${_LICENSE_COMB} == "dual"
437 . for lic in ${_LICENSE}
438 . if ${_LICENSE_STATUS_${lic}} == "accepted"
439 _LICENSE_STATUS= accepted
440 . elif ${_LICENSE_STATUS_${lic}} == "ask"
441 _LICENSE_STATUS?= ask
442 _LICENSE_TO_ASK+= ${lic}
444 _LICENSE_STATUS?= rejected
447 .elif ${_LICENSE_COMB} == "multi"
448 . for lic in ${_LICENSE}
449 . if ${_LICENSE_STATUS_${lic}} == "rejected"
450 _LICENSE_STATUS= rejected
451 . elif ${_LICENSE_STATUS_${lic}} == "ask"
452 _LICENSE_STATUS?= ask
453 _LICENSE_TO_ASK+= ${lic}
456 _LICENSE_STATUS?= accepted
459 # For dual/multi licenses, after processing all sub-licenses, the following
460 # must be determined: _LICENSE_NAME, _LICENSE_PERMS and _LICENSE_GROUPS.
462 .if ${_LICENSE_COMB} == "dual"
463 _LICENSE_NAME= Dual (any of): ${_LICENSE}
464 # Calculate least restrictive permissions (union)
466 . for lic in ${_LICENSE}
467 . for comp in ${_LICENSE_LIST_PERMS}
468 . if ${_LICENSE_PERMS_${lic}:M${comp}} != "" && \
469 ${_LICENSE_PERMS:M${comp}} == ""
470 _LICENSE_PERMS+= ${comp}
474 # Calculate least restrictive groups (union)
476 . for lic in ${_LICENSE}
477 . for comp in ${_LICENSE_LIST_GROUPS}
478 . if ${_LICENSE_GROUPS_${lic}:M${comp}} != "" && \
479 ${_LICENSE_GROUPS:M${comp}} == ""
480 _LICENSE_GROUPS+= ${comp}
485 .elif ${_LICENSE_COMB} == "multi"
486 _LICENSE_NAME= Multiple (all of): ${_LICENSE}
487 # Calculate most restrictive permissions (intersection)
488 _LICENSE_PERMS:= ${_LICENSE_LIST_PERMS}
489 . for lic in ${_LICENSE}
490 . for comp in ${_LICENSE_LIST_PERMS}
491 . if ${_LICENSE_PERMS_${lic}:M${comp}} == ""
492 _LICENSE_PERMS:= ${_LICENSE_PERMS:N${comp}}
496 # Calculate most restrictive groups (intersection)
497 _LICENSE_GROUPS:= ${_LICENSE_LIST_GROUPS}
498 . for lic in ${_LICENSE}
499 . for comp in ${_LICENSE_LIST_GROUPS}
500 . if ${_LICENSE_GROUPS_${lic}:M${comp}} == ""
501 _LICENSE_GROUPS:= ${_LICENSE_GROUPS:N${comp}}
507 # Prepare information for asking license to the user
509 .if ${_LICENSE_STATUS} == "ask" && ${_LICENSE_COMB} != "single"
510 _LICENSE_ASK_DATA!= mktemp -ut portslicense
513 # Calculate restrictions and set RESTRICTED_FILES when
514 # appropiate, together with cleaning targets.
516 # XXX For multiple licenses restricted distfiles are always removed from both
517 # CDROM and FTP, but the current framework supports separating them (would
518 # require better/new delete-package and delete-distfiles targets)
520 .if ${_LICENSE_PERMS:Mpkg-mirror} == ""
521 _LICENSE_RESTRICTED+= delete-package
522 .elif ${_LICENSE_PERMS:Mpkg-sell} == ""
523 _LICENSE_CDROM+= delete-package
526 .if ${_LICENSE_COMB} == "multi"
527 . for lic in ${_LICENSE}
528 . if ${_LICENSE_PERMS_${lic}:Mdist-mirror} == "" || ${_LICENSE_PERMS_${lic}:Mdist-sell} == ""
529 RESTRICTED_FILES+= ${_LICENSE_DISTFILES_${lic}}
532 . if defined(RESTRICTED_FILES)
533 RESTRICTED_FILES+= ${_PATCHFILES}
534 _LICENSE_RESTRICTED+= delete-distfiles
535 _LICENSE_CDROM+= delete-distfiles
538 . if ${_LICENSE_PERMS:Mdist-mirror} == ""
539 _LICENSE_RESTRICTED+= delete-distfiles
540 RESTRICTED_FILES= ${_PATCHFILES} ${_DISTFILES}
541 . elif ${_LICENSE_PERMS:Mdist-sell} == ""
542 _LICENSE_CDROM+= delete-distfiles
543 RESTRICTED_FILES= ${_PATCHFILES} ${_DISTFILES}
547 .if defined(_LICENSE_RESTRICTED)
548 # _LICENSE_RESTRICTED contains 'delete-distfiles' and 'delete-package' if
549 # needed with RESTRICTED_FILES filled from above.
550 clean-restricted: ${_LICENSE_RESTRICTED}
551 clean-restricted-list: ${_LICENSE_RESTRICTED:C/$/-list/}
554 clean-restricted-list:
557 .if defined(_LICENSE_CDROM)
558 clean-for-cdrom: ${_LICENSE_CDROM}
559 clean-for-cdrom-list: ${_LICENSE_CDROM:C/$/-list/}
562 clean-for-cdrom-list:
565 # Check variables are correctly defined and print status up to here
567 .if ${_LICENSE_STATUS} == "ask" && defined(BATCH)
568 IGNORE= License ${_LICENSE} needs confirmation, but BATCH is defined
572 .if defined(_LICENSE_ERROR)
573 @${ECHO_MSG} "===> License not correctly defined: ${_LICENSE_ERROR}"
576 .if ${_LICENSE_STATUS} == "rejected"
577 @${ECHO_MSG} "===> License ${_LICENSE} rejected by the user"
579 @${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}
582 .elif ${_LICENSE_STATUS} == "accepted"
583 @${ECHO_MSG} "===> License ${_LICENSE} accepted by the user"
584 .elif ${_LICENSE_STATUS} == "ask"
585 @${ECHO_MSG} "===> License ${_LICENSE} needs confirmation, will ask later"
588 # Display, ask and save preference if requested
590 ask-license: ${_LICENSE_COOKIE}
593 # Make sure all required license files exist
594 .if ${_LICENSE_COMB} == "single"
595 . if !defined(LICENSE_FILE) && defined(_LICENSE_TEXT)
596 @test -f ${_LICENSE_FILE} || ${ECHO_CMD} "${_LICENSE_TEXT}" | ${FMT} > ${_LICENSE_FILE}
598 @test -f ${_LICENSE_FILE} || \
599 (${ECHO_MSG} "===> Missing license file for ${_LICENSE} in ${_LICENSE_FILE}"; exit 1)
601 . for lic in ${_LICENSE}
602 . if !defined(LICENSE_FILE_${lic}) && defined(_LICENSE_TEXT_${lic})
603 @test -f ${_LICENSE_FILE_${lic}} || ${ECHO_CMD} "${_LICENSE_TEXT_${lic}}" | ${FMT} > ${_LICENSE_FILE_${lic}}
605 @test -f ${_LICENSE_FILE_${lic}} || \
606 (${ECHO_MSG} "===> Missing license file for ${lic} in ${_LICENSE_FILE_${lic}}"; exit 1)
610 .if ${_LICENSE_STATUS} == "ask"
611 . if !defined(NO_LICENSES_DIALOGS)
613 . if ${_LICENSE_COMB} == "single"
614 @${DIALOG} --title "License for ${PKGNAME} (${_LICENSE})" \
615 --yes-label Accept --no-label Reject --yesno \
616 "$$(${CAT} ${_LICENSE_FILE})" 21 76
618 . elif ${_LICENSE_COMB} == "dual"
619 @${RM} -f ${_LICENSE_ASK_DATA}
620 . for lic in ${_LICENSE_TO_ASK}
621 @${ECHO_CMD} "${lic}:${_LICENSE_FILE_${lic}}" >> ${_LICENSE_ASK_DATA}
623 @menu_cmd="${DIALOG} --hline \"This port requires you to accept at least one license\" --menu \"License for ${PKGNAME} (dual)\" 21 70 15"; \
624 trap '${RM} -f $$tmpfile' EXIT INT TERM; \
625 tmpfile=$$(mktemp -t portlicenses); \
626 for lic in ${_LICENSE_TO_ASK}; do \
627 menu_cmd="$${menu_cmd} VIEW_$${lic} \"View the license $${lic}\" USE_$${lic} \"Accept the license $${lic}\""; \
629 menu_cmd="$${menu_cmd} REJECT \"Reject the licenses (all)\""; \
631 ${SH} -c "$${menu_cmd} 2>\"$${tmpfile}\""; \
632 result=$$(${CAT} "$${tmpfile}"); \
635 VIEW_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^VIEW_//'); \
636 file=$$(${GREP} "^$${name}:" ${_LICENSE_ASK_DATA} | ${CUT} -d : -f 2); \
637 ${DIALOG} --textbox "$${file}" 21 75 ;; \
638 USE_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^USE_//'); \
639 ${ECHO_CMD} $${name} > ${_LICENSE_COOKIE}; \
644 . elif ${_LICENSE_COMB} == "multi"
645 @${RM} -f ${_LICENSE_ASK_DATA}
646 . for lic in ${_LICENSE_TO_ASK}
647 @${ECHO_CMD} "${lic}:${_LICENSE_FILE_${lic}}" >> ${_LICENSE_ASK_DATA}
649 @menu_cmd="${DIALOG} --hline \"This port requires you to accept all mentioned licenses\" --menu \"License for ${PKGNAME} (multi)\" 21 70 15"; \
650 trap '${RM} -f $$tmpfile' EXIT INT TERM; \
651 tmpfile=$$(mktemp -t portlicenses); \
652 for lic in ${_LICENSE_TO_ASK}; do \
653 menu_cmd="$${menu_cmd} VIEW_$${lic} \"View the license $${lic}\""; \
655 menu_cmd="$${menu_cmd} ACCEPT \"Accept the licenses (all)\" REJECT \"Reject the licenses (all)\""; \
657 ${SH} -c "$${menu_cmd} 2>\"$${tmpfile}\""; \
658 result=$$(${CAT} "$${tmpfile}"); \
662 VIEW_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^VIEW_//'); \
663 file=$$(${GREP} "^$${name}:" ${_LICENSE_ASK_DATA} | ${CUT} -d : -f 2); \
664 ${DIALOG} --textbox "$${file}" 21 75 ;; \
672 . if ${_LICENSE_COMB} == "single"
673 @${ECHO_MSG} "To install the port you must agree to the license: ${_LICENSE} (${_LICENSE_NAME})." | ${FMT}
675 @${ECHO_MSG} "You can view the license at ${_LICENSE_FILE:S/${WRKDIR}\//${WRKDIR:T}\//}."
676 . elif ${_LICENSE_COMB} == "dual"
677 @${ECHO_MSG} "To install the port you must agree to any of the following licenses:"
678 . elif ${_LICENSE_COMB} == "multi"
679 @${ECHO_MSG} "To install the port you must agree to all of the following licenses:"
682 . if ${_LICENSE_COMB} != "single"
683 . for lic in ${_LICENSE_TO_ASK}
684 . if defined(WRKDIRPREFIX)
685 @${ECHO_MSG} "- ${lic} (${_LICENSE_NAME_${lic}}), available at ${_LICENSE_FILE_${lic}}"
687 @${ECHO_MSG} "- ${lic} (${_LICENSE_NAME_${lic}}), available at ${_LICENSE_FILE_${lic}:S/${WRKDIR}\//${WRKDIR:T}\//}"
692 @${ECHO_MSG} "If you agree with the corresponding license(s), add them to LICENSES_ACCEPTED either in make arguments or /etc/make.conf." | ${FMT}
696 @${RM} -f ${_LICENSE_ASK_DATA}
699 # Create report and catalog
700 .if !defined(NO_LICENSES_INSTALL)
701 @${RM} -f ${_LICENSE_CATALOG_TMP} ${_LICENSE_REPORT_TMP}
702 . if ${_LICENSE_COMB} == "single"
704 . for var in _LICENSE _LICENSE_NAME _LICENSE_PERMS _LICENSE_GROUPS _LICENSE_DISTFILES
705 @${ECHO_CMD} "${var}=${${var}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
708 @${ECHO_CMD} "This package has a single license: ${_LICENSE} (${_LICENSE_NAME})." > ${_LICENSE_REPORT_TMP}
711 . for var in _LICENSE _LICENSE_COMB _LICENSE_NAME _LICENSE_PERMS _LICENSE_GROUPS
712 @${ECHO_CMD} "${var}=${${var}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
714 . if ${_LICENSE_COMB} == "dual" && ${_LICENSE_STATUS} == "ask"
715 @${SED} -e 's/^/_LICENSE_SELECTED=/' ${_LICENSE_COOKIE} >> ${_LICENSE_CATALOG_TMP}
717 . for lic in ${_LICENSE}
718 . for var in NAME PERMS GROUPS DISTFILES
719 @${ECHO_CMD} "_LICENSE_${var}_${lic} =${_LICENSE_${var}_${lic}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
723 . if ${_LICENSE_COMB} == "dual"
724 @${ECHO_CMD} "This package has dual licenses (any of):" >> ${_LICENSE_REPORT_TMP}
725 . elif ${_LICENSE_COMB} == "multi"
726 @${ECHO_CMD} "This package has multiple licenses (all of):" >> ${_LICENSE_REPORT_TMP}
728 . for lic in ${_LICENSE}
729 @${ECHO_CMD} "- ${lic} (${_LICENSE_NAME_${lic}})" >> ${_LICENSE_REPORT_TMP}
735 @${TOUCH} ${_LICENSE_COOKIE}
737 # Package list entries, and installation
739 .if !defined(NO_LICENSES_INSTALL)
740 PLIST_FILES+= ${_LICENSE_CATALOG} \
743 .if ${_LICENSE_COMB} == "single"
744 PLIST_FILES+= ${_LICENSE_DIR}/${_LICENSE}
746 . for lic in ${_LICENSE}
747 . if defined(_LICENSE_FILE_${lic})
748 PLIST_FILES+= ${_LICENSE_DIR}/${lic}
754 @${MKDIR} ${STAGEDIR}${_LICENSE_DIR}
755 @${INSTALL_DATA} ${_LICENSE_CATALOG_TMP} ${STAGEDIR}${_LICENSE_CATALOG}
756 @${INSTALL_DATA} ${_LICENSE_REPORT_TMP} ${STAGEDIR}${_LICENSE_REPORT}
757 .if ${_LICENSE_COMB} == "single"
758 @${INSTALL_DATA} ${_LICENSE_FILE} ${STAGEDIR}${_LICENSE_DIR}/${_LICENSE}
760 . for lic in ${_LICENSE}
761 @${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${STAGEDIR}${_LICENSE_DIR}/${lic}
769 . if defined(LICENSE_VERBOSE)
770 @${ECHO_MSG} "===> License check disabled, port has not defined LICENSE"