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, cannot 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}
300 . if defined(LICENSE_FILE)
301 . for lic in ${_LICENSE}
302 LICENSE_FILE_${lic}?= ${LICENSE_FILE}
306 . for lic in ${_LICENSE}
308 _LICENSE_GROUPS_${lic}?=#
309 . if ${_LICENSE_LIST:M${lic}} != ""
310 # Case 1: license defined in the framework.
311 _LICENSE_TYPE_${lic}= known
312 . for var in ${_LICENSE_LIST_PORT_VARS}
313 . if defined(LICENSE_${var}_${lic})
314 _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
316 . if !defined(_LICENSE_${var}_${lic})
317 _LICENSE_ERROR?= ERROR: missing _LICENSE_${var}_${lic} in bsd.licenses.db.mk
320 # Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
321 . if !defined(LICENSE_FILE_${lic})
322 . if !defined(LICENSE_TEXT_${lic})
323 . if exists(${_LICENSE_STORE}/${lic})
324 _LICENSE_FILE_${lic}= ${_LICENSE_STORE}/${lic}
326 # No license file in /usr/ports/Templates/Licenses
327 _LICENSE_TEXT_${lic}= The license: ${lic} (${_LICENSE_NAME_${lic}}) is standard, please read from the web.
328 _LICENSE_FILE_${lic}= ${WRKDIR}/${lic}
331 _LICENSE_ERROR?= defining LICENSE_TEXT_${lic} is not allowed for known licenses
334 _LICENSE_FILE_${lic}= ${LICENSE_FILE_${lic}}
338 # Case 2: license only known by the port.
339 _LICENSE_TYPE_${lic}= unknown
340 . for var in ${_LICENSE_LIST_PORT_VARS}
341 . if defined(LICENSE_${var}_${lic})
342 _LICENSE_${var}_${lic}= ${LICENSE_${var}_${lic}}
343 . elif !defined(_LICENSE_${var}_${lic})
344 _LICENSE_ERROR?= for unknown licenses, defining LICENSE_${var}_${lic} is mandatory (otherwise use a known LICENSE)
347 # Check LICENSE_PERMS for invalid, ambiguous and duplicate components
349 . for comp in ${_LICENSE_PERMS_${lic}}
350 . if ${_LICENSE_LIST_PERMS:M${comp:C/^no-//}} == ""
351 _LICENSE_ERROR?= invalid LICENSE_PERMS_${var} component "${comp}"
352 . elif ${__LICENSE_PERMS:M${comp}} == "" && \
353 ${_LICENSE_PERMS_${lic}:Mno-${comp:C/^no-//}} == ""
354 __LICENSE_PERMS+= ${comp}
357 _LICENSE_PERMS_${lic}:= ${__LICENSE_PERMS}
358 . undef __LICENSE_PERMS
359 # Check for LICENSE_FILE or at least LICENSE_TEXT (which simulates it)
360 . if !defined(LICENSE_FILE_${lic})
361 . if !defined(LICENSE_TEXT_${lic})
362 _LICENSE_ERROR?= either LICENSE_FILE_${lic} or LICENSE_TEXT_${lic} must be defined
364 _LICENSE_TEXT_${lic}= ${LICENSE_TEXT_${lic}}
365 _LICENSE_FILE_${lic}= ${WRKDIR}/${lic}
368 _LICENSE_FILE_${lic}= ${LICENSE_FILE_${lic}}
372 # Only one is allowed
373 . if defined(LICENSE_FILE_${lic}) && defined(LICENSE_TEXT_${lic})
374 _LICENSE_ERROR?= defining both LICENSE_FILE_${lic} and LICENSE_TEXT_${lic}is not allowed
377 . if !defined(LICENSE_DISTFILES_${lic})
378 _LICENSE_DISTFILES_${lic}= ${_DISTFILES}
380 _LICENSE_DISTFILES_${lic}= ${LICENSE_DISTFILES_${lic}}
385 # Check if the user agrees with the license
387 # Make sure these are defined
389 LICENSES_ACCEPTED?= #
390 LICENSES_REJECTED?= #
391 LICENSES_GROUPS_ACCEPTED?= #
392 LICENSES_GROUPS_REJECTED?= #
394 # Evaluate per-license status
396 .if ${_LICENSE_COMB} == "single"
397 . for lic in ${_LICENSE}
398 . if ${LICENSES_REJECTED:M${lic}} != ""
399 _LICENSE_STATUS?= rejected
401 . for group in ${_LICENSE_GROUPS}
402 . if ${LICENSES_GROUPS_REJECTED:M${group}} != ""
403 _LICENSE_STATUS?= rejected
405 . if ${LICENSES_GROUPS_ACCEPTED:M${group}} != ""
406 _LICENSE_STATUS?= accepted
409 . if ${LICENSES_ACCEPTED:M${lic}} != ""
410 _LICENSE_STATUS?= accepted
412 . if ${_LICENSE_PERMS:Mauto-accept} != "" && !defined(LICENSES_ASK)
413 _LICENSE_STATUS?= accepted
415 _LICENSE_STATUS?= ask
419 . for lic in ${_LICENSE}
420 . if ${LICENSES_REJECTED:M${lic}} != ""
421 _LICENSE_STATUS_${lic}?= rejected
423 . for group in ${_LICENSE_GROUPS_${lic}}
424 . if ${LICENSES_GROUPS_REJECTED:M${group}} != ""
425 _LICENSE_STATUS_${lic}?= rejected
427 . if ${LICENSES_GROUPS_ACCEPTED:M${group}} != ""
428 _LICENSE_STATUS_${lic}?= accepted
431 . if ${LICENSES_ACCEPTED:M${lic}} != ""
432 _LICENSE_STATUS_${lic}?= accepted
434 . if ${_LICENSE_PERMS_${lic}:Mauto-accept} != "" && !defined(LICENSES_ASK)
435 _LICENSE_STATUS_${lic}?= accepted
437 _LICENSE_STATUS_${lic}?= ask
441 # Evaluate general status
443 .if ${_LICENSE_COMB} == "dual"
444 . for lic in ${_LICENSE}
445 . if ${_LICENSE_STATUS_${lic}} == "accepted"
446 _LICENSE_STATUS= accepted
447 . elif ${_LICENSE_STATUS_${lic}} == "ask"
448 _LICENSE_STATUS?= ask
449 _LICENSE_TO_ASK+= ${lic}
451 _LICENSE_STATUS?= rejected
454 .elif ${_LICENSE_COMB} == "multi"
455 . for lic in ${_LICENSE}
456 . if ${_LICENSE_STATUS_${lic}} == "rejected"
457 _LICENSE_STATUS= rejected
458 . elif ${_LICENSE_STATUS_${lic}} == "ask"
459 _LICENSE_STATUS?= ask
460 _LICENSE_TO_ASK+= ${lic}
463 _LICENSE_STATUS?= accepted
466 # For dual/multi licenses, after processing all sub-licenses, the following
467 # must be determined: _LICENSE_NAME, _LICENSE_PERMS and _LICENSE_GROUPS.
469 .if ${_LICENSE_COMB} == "dual"
470 _LICENSE_NAME= Dual (any of): ${_LICENSE}
471 # Calculate least restrictive permissions (union)
473 . for lic in ${_LICENSE}
474 . for comp in ${_LICENSE_LIST_PERMS}
475 . if ${_LICENSE_PERMS_${lic}:M${comp}} != "" && \
476 ${_LICENSE_PERMS:M${comp}} == ""
477 _LICENSE_PERMS+= ${comp}
481 # Calculate least restrictive groups (union)
483 . for lic in ${_LICENSE}
484 . for comp in ${_LICENSE_LIST_GROUPS}
485 . if ${_LICENSE_GROUPS_${lic}:M${comp}} != "" && \
486 ${_LICENSE_GROUPS:M${comp}} == ""
487 _LICENSE_GROUPS+= ${comp}
492 .elif ${_LICENSE_COMB} == "multi"
493 _LICENSE_NAME= Multiple (all of): ${_LICENSE}
494 # Calculate most restrictive permissions (intersection)
495 _LICENSE_PERMS:= ${_LICENSE_LIST_PERMS}
496 . for lic in ${_LICENSE}
497 . for comp in ${_LICENSE_LIST_PERMS}
498 . if ${_LICENSE_PERMS_${lic}:M${comp}} == ""
499 _LICENSE_PERMS:= ${_LICENSE_PERMS:N${comp}}
503 # Calculate most restrictive groups (intersection)
504 _LICENSE_GROUPS:= ${_LICENSE_LIST_GROUPS}
505 . for lic in ${_LICENSE}
506 . for comp in ${_LICENSE_LIST_GROUPS}
507 . if ${_LICENSE_GROUPS_${lic}:M${comp}} == ""
508 _LICENSE_GROUPS:= ${_LICENSE_GROUPS:N${comp}}
514 # Prepare information for asking license to the user
516 .if ${_LICENSE_STATUS} == "ask" && ${_LICENSE_COMB} != "single"
517 _LICENSE_ASK_DATA!= mktemp -ut portslicense
520 # Calculate restrictions and set RESTRICTED_FILES when
521 # appropiate, together with cleaning targets.
523 # XXX For multiple licenses restricted distfiles are always removed from both
524 # CDROM and FTP, but the current framework supports separating them (would
525 # require better/new delete-package and delete-distfiles targets)
527 .if ${_LICENSE_PERMS:Mpkg-mirror} == ""
528 _LICENSE_RESTRICTED+= delete-package
529 .elif ${_LICENSE_PERMS:Mpkg-sell} == ""
530 _LICENSE_CDROM+= delete-package
533 .if ${_LICENSE_COMB} == "multi"
534 . for lic in ${_LICENSE}
535 . if ${_LICENSE_PERMS_${lic}:Mdist-mirror} == "" || ${_LICENSE_PERMS_${lic}:Mdist-sell} == ""
536 RESTRICTED_FILES+= ${_LICENSE_DISTFILES_${lic}}
539 . if defined(RESTRICTED_FILES)
540 RESTRICTED_FILES+= ${_PATCHFILES}
541 _LICENSE_RESTRICTED+= delete-distfiles
542 _LICENSE_CDROM+= delete-distfiles
545 . if ${_LICENSE_PERMS:Mdist-mirror} == ""
546 _LICENSE_RESTRICTED+= delete-distfiles
547 RESTRICTED_FILES= ${_PATCHFILES} ${_DISTFILES}
548 . elif ${_LICENSE_PERMS:Mdist-sell} == ""
549 _LICENSE_CDROM+= delete-distfiles
550 RESTRICTED_FILES= ${_PATCHFILES} ${_DISTFILES}
554 .if defined(_LICENSE_RESTRICTED)
555 # _LICENSE_RESTRICTED contains 'delete-distfiles' and 'delete-package' if
556 # needed with RESTRICTED_FILES filled from above.
557 clean-restricted: ${_LICENSE_RESTRICTED}
558 clean-restricted-list: ${_LICENSE_RESTRICTED:C/$/-list/}
561 clean-restricted-list:
564 .if defined(_LICENSE_CDROM)
565 clean-for-cdrom: ${_LICENSE_CDROM}
566 clean-for-cdrom-list: ${_LICENSE_CDROM:C/$/-list/}
569 clean-for-cdrom-list:
572 # Check variables are correctly defined and print status up to here
574 .if ${_LICENSE_STATUS} == "ask" && defined(BATCH)
575 IGNORE= License ${_LICENSE} needs confirmation, but BATCH is defined
578 # This should probably be incrementally done while parsing all the license
580 debug-license: check-license
581 .if ${_LICENSE_PERMS:Mdist-mirror}
582 @${ECHO_MSG} "===> License allows mirroring distribution files"
584 @${ECHO_MSG} "===> License does not allow mirroring distribution files"
586 .if ${_LICENSE_PERMS:Mdist-sell}
587 @${ECHO_MSG} "===> License allows selling distribution files"
589 @${ECHO_MSG} "===> License does not allow selling distribution files"
591 .if ${_LICENSE_PERMS:Mpkg-mirror}
592 @${ECHO_MSG} "===> License allows mirroring pre-built packages"
594 @${ECHO_MSG} "===> License does not allow mirroring pre-build packages"
596 .if ${_LICENSE_PERMS:Mpkg-sell}
597 @${ECHO_MSG} "===> License allows selling pre-build packages"
599 @${ECHO_MSG} "===> License does not allow selling pre-build packages"
601 .if ${_LICENSE_PERMS:Mauto-accept}
602 @${ECHO_MSG} "===> License allows being auto-accepted"
604 @${ECHO_MSG} "===> License requires manual intervention by the user to accept its terms"
609 .if defined(_LICENSE_ERROR)
610 @${ECHO_MSG} "===> License not correctly defined: ${_LICENSE_ERROR}"
613 .if ${_LICENSE_STATUS} == "rejected"
614 @${ECHO_MSG} "===> License ${_LICENSE} rejected by the user"
616 @${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}
619 .elif ${_LICENSE_STATUS} == "accepted"
620 @${ECHO_MSG} "===> License ${_LICENSE} accepted by the user"
621 .elif ${_LICENSE_STATUS} == "ask"
622 @${ECHO_MSG} "===> License ${_LICENSE} needs confirmation, will ask later"
625 # Display, ask and save preference if requested
627 ask-license: ${_LICENSE_COOKIE}
630 # Make sure all required license files exist
631 .if ${_LICENSE_COMB} == "single"
632 . if !defined(LICENSE_FILE) && defined(_LICENSE_TEXT)
633 @test -f ${_LICENSE_FILE} || ${ECHO_CMD} "${_LICENSE_TEXT}" | ${FMT} > ${_LICENSE_FILE}
635 @test -f ${_LICENSE_FILE} || \
636 (${ECHO_MSG} "===> Missing license file for ${_LICENSE} in ${_LICENSE_FILE}"; exit 1)
638 . for lic in ${_LICENSE}
639 . if !defined(LICENSE_FILE_${lic}) && defined(_LICENSE_TEXT_${lic})
640 @test -f ${_LICENSE_FILE_${lic}} || ${ECHO_CMD} "${_LICENSE_TEXT_${lic}}" | ${FMT} > ${_LICENSE_FILE_${lic}}
642 @test -f ${_LICENSE_FILE_${lic}} || \
643 (${ECHO_MSG} "===> Missing license file for ${lic} in ${_LICENSE_FILE_${lic}}"; exit 1)
647 .if ${_LICENSE_STATUS} == "ask"
648 . if !defined(NO_LICENSES_DIALOGS)
650 . if ${_LICENSE_COMB} == "single"
651 @${DIALOG} --title "License for ${PKGNAME} (${_LICENSE})" \
652 --yes-label Accept --no-label Reject --yesno \
653 "$$(${CAT} ${_LICENSE_FILE})" 21 76
655 . elif ${_LICENSE_COMB} == "dual"
656 @${RM} ${_LICENSE_ASK_DATA}
657 . for lic in ${_LICENSE_TO_ASK}
658 @${ECHO_CMD} "${lic}:${_LICENSE_FILE_${lic}}" >> ${_LICENSE_ASK_DATA}
660 @menu_cmd="${DIALOG} --hline \"This port requires you to accept at least one license\" --menu \"License for ${PKGNAME} (dual)\" 21 70 15"; \
661 trap '${RM} $$tmpfile' EXIT INT TERM; \
662 tmpfile=$$(mktemp -t portlicenses); \
663 for lic in ${_LICENSE_TO_ASK}; do \
664 menu_cmd="$${menu_cmd} VIEW_$${lic} \"View the license $${lic}\" USE_$${lic} \"Accept the license $${lic}\""; \
666 menu_cmd="$${menu_cmd} REJECT \"Reject the licenses (all)\""; \
668 ${SH} -c "$${menu_cmd} 2>\"$${tmpfile}\""; \
669 result=$$(${CAT} "$${tmpfile}"); \
672 VIEW_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^VIEW_//'); \
673 file=$$(${GREP} "^$${name}:" ${_LICENSE_ASK_DATA} | ${CUT} -d : -f 2); \
674 ${DIALOG} --textbox "$${file}" 21 75 ;; \
675 USE_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^USE_//'); \
676 ${ECHO_CMD} $${name} > ${_LICENSE_COOKIE}; \
681 . elif ${_LICENSE_COMB} == "multi"
682 @${RM} ${_LICENSE_ASK_DATA}
683 . for lic in ${_LICENSE_TO_ASK}
684 @${ECHO_CMD} "${lic}:${_LICENSE_FILE_${lic}}" >> ${_LICENSE_ASK_DATA}
686 @menu_cmd="${DIALOG} --hline \"This port requires you to accept all mentioned licenses\" --menu \"License for ${PKGNAME} (multi)\" 21 70 15"; \
687 trap '${RM} $$tmpfile' EXIT INT TERM; \
688 tmpfile=$$(mktemp -t portlicenses); \
689 for lic in ${_LICENSE_TO_ASK}; do \
690 menu_cmd="$${menu_cmd} VIEW_$${lic} \"View the license $${lic}\""; \
692 menu_cmd="$${menu_cmd} ACCEPT \"Accept the licenses (all)\" REJECT \"Reject the licenses (all)\""; \
694 ${SH} -c "$${menu_cmd} 2>\"$${tmpfile}\""; \
695 result=$$(${CAT} "$${tmpfile}"); \
699 VIEW_*) name=$$(${ECHO_CMD} $${result} | ${SED} -e 's/^VIEW_//'); \
700 file=$$(${GREP} "^$${name}:" ${_LICENSE_ASK_DATA} | ${CUT} -d : -f 2); \
701 ${DIALOG} --textbox "$${file}" 21 75 ;; \
709 . if ${_LICENSE_COMB} == "single"
710 @${ECHO_MSG} "To install the port you must agree to the license: ${_LICENSE} (${_LICENSE_NAME})." | ${FMT}
712 @${ECHO_MSG} "You can view the license at ${_LICENSE_FILE:S/${WRKDIR}\//${WRKDIR:T}\//}."
713 . elif ${_LICENSE_COMB} == "dual"
714 @${ECHO_MSG} "To install the port you must agree to any of the following licenses:"
715 . elif ${_LICENSE_COMB} == "multi"
716 @${ECHO_MSG} "To install the port you must agree to all of the following licenses:"
719 . if ${_LICENSE_COMB} != "single"
720 . for lic in ${_LICENSE_TO_ASK}
721 . if defined(WRKDIRPREFIX)
722 @${ECHO_MSG} "- ${lic} (${_LICENSE_NAME_${lic}}), available at ${_LICENSE_FILE_${lic}}"
724 @${ECHO_MSG} "- ${lic} (${_LICENSE_NAME_${lic}}), available at ${_LICENSE_FILE_${lic}:S/${WRKDIR}\//${WRKDIR:T}\//}"
729 @${ECHO_MSG} "If you agree with the corresponding license(s), add them to LICENSES_ACCEPTED either in make arguments or /etc/make.conf." | ${FMT}
733 @${RM} ${_LICENSE_ASK_DATA}
736 # Create report and catalog
737 .if !defined(NO_LICENSES_INSTALL)
738 @${RM} ${_LICENSE_CATALOG_TMP} ${_LICENSE_REPORT_TMP}
739 . if ${_LICENSE_COMB} == "single"
741 . for var in _LICENSE _LICENSE_NAME _LICENSE_PERMS _LICENSE_GROUPS _LICENSE_DISTFILES
742 @${ECHO_CMD} "${var}=${${var}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
745 @${ECHO_CMD} "This package has a single license: ${_LICENSE} (${_LICENSE_NAME})." > ${_LICENSE_REPORT_TMP}
748 . for var in _LICENSE _LICENSE_COMB _LICENSE_NAME _LICENSE_PERMS _LICENSE_GROUPS
749 @${ECHO_CMD} "${var}=${${var}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
751 . if ${_LICENSE_COMB} == "dual" && ${_LICENSE_STATUS} == "ask"
752 @${SED} -e 's/^/_LICENSE_SELECTED=/' ${_LICENSE_COOKIE} >> ${_LICENSE_CATALOG_TMP}
754 . for lic in ${_LICENSE}
755 . for var in NAME PERMS GROUPS DISTFILES
756 @${ECHO_CMD} "_LICENSE_${var}_${lic} =${_LICENSE_${var}_${lic}:C/^[[:blank:]]*//}" >> ${_LICENSE_CATALOG_TMP}
760 . if ${_LICENSE_COMB} == "dual"
761 @${ECHO_CMD} "This package has dual licenses (any of):" >> ${_LICENSE_REPORT_TMP}
762 . elif ${_LICENSE_COMB} == "multi"
763 @${ECHO_CMD} "This package has multiple licenses (all of):" >> ${_LICENSE_REPORT_TMP}
765 . for lic in ${_LICENSE}
766 @${ECHO_CMD} "- ${lic} (${_LICENSE_NAME_${lic}})" >> ${_LICENSE_REPORT_TMP}
772 @${TOUCH} ${_LICENSE_COOKIE}
774 # Package list entries, and installation
776 .if !defined(NO_LICENSES_INSTALL)
777 PLIST_FILES+= ${_LICENSE_CATALOG} \
780 .if ${_LICENSE_COMB} == "single"
781 PLIST_FILES+= ${_LICENSE_DIR}/${_LICENSE}
783 . for lic in ${_LICENSE}
784 . if defined(_LICENSE_FILE_${lic})
785 PLIST_FILES+= ${_LICENSE_DIR}/${lic}
791 @${MKDIR} ${STAGEDIR}${_LICENSE_DIR}
792 @${INSTALL_DATA} ${_LICENSE_CATALOG_TMP} ${STAGEDIR}${_LICENSE_CATALOG}
793 @${INSTALL_DATA} ${_LICENSE_REPORT_TMP} ${STAGEDIR}${_LICENSE_REPORT}
794 .if ${_LICENSE_COMB} == "single"
795 @${INSTALL_DATA} ${_LICENSE_FILE} ${STAGEDIR}${_LICENSE_DIR}/${_LICENSE}
797 . for lic in ${_LICENSE}
798 @${INSTALL_DATA} ${_LICENSE_FILE_${lic}} ${STAGEDIR}${_LICENSE_DIR}/${lic}
806 . if defined(LICENSE_VERBOSE)
807 @${ECHO_MSG} "===> License debug empty, port has not defined LICENSE"
811 . if defined(LICENSE_VERBOSE)
812 @${ECHO_MSG} "===> License check disabled, port has not defined LICENSE"