PERFORCE change 146750 for review
Alejandro Pulver
alepulver at FreeBSD.org
Wed Aug 6 05:05:48 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146750
Change 146750 by alepulver at alepulver_deimos on 2008/08/06 05:05:41
- In previous commit SHA256 checksum was saved for unknown licenses.
- Add comment about LICENSES_CONFIG.
- Use underscore (internal) variables for processing reports.
- Clean up.
- Use ECHO_MSG when appropiate.
- Allow saving the choice "no", and clean up selection menu.
- Add target clean-user-license-config which outputs the licenses and
groups the user has configured which are not present in the database.
- Ready for multiple licenses (code is still not there).
Affected files ...
.. //depot/projects/soc2008/alepulver-portslicense/ports/Mk/README#4 edit
.. //depot/projects/soc2008/alepulver-portslicense/ports/Mk/bsd.licenses.mk#4 edit
Differences ...
==== //depot/projects/soc2008/alepulver-portslicense/ports/Mk/README#4 (text+ko) ====
@@ -73,13 +73,15 @@
==============================================================================
Interface:
-* incorporate pattern matching in licenses/groups/distfiles/lic files
- -> only if variables are solely used in commands
* extend LICENSE=... for dual/multiple
use (), [], {} or <> (use shell/commands as make can't parse this notation)
LICENSE= dual(BSD,GPLv2,multi(ART,etc))
dual/multiple licenses (need parsing code), start with only one of them
-> For now use =LIC1|LIC2 LIC2|LIC3 ('|' is OR and ' ' is AND)
+ -> 2 nested loops are needed, and 2 scans: 1 for "license combinations" (OR),
+ containing inside individual licenses (AND), a minimal report has to be made
+ about each combination
+* allow to view license properties from menu (prepend info to license)
General:
* additional targets (show-license, show-license-report,
@@ -87,20 +89,13 @@
and ports framework configuration
* add common licenses (check a web page or try FOSSology)
-NOW:
-- * make list of error messages (by component/type) and the like, so targets are more dynamic
-- * unify echo messages, use ECHO_MSG, add a debug variable maybe
-- * prepare for multiple licenses support:
- -> use _LICENSE in for loops, with AND criteria
-
Maybe:
* separate groups into another variable (either internally and/or externally->better)
-* provide target to assist cleaning LICENSES_ACCEPTED and LICENSES_REJECTED,
* Consider licenses that need manual agreement/manual fetching
provide framework help for manual distfile placing, etc
maybe also add pkg-fetch-message or some variables to avoid manual IGNORE/printf?
-
-Reports:
+* incorporate pattern matching in licenses/groups/distfiles/lic files
+ -> only if variables are solely used in commands
Other:
* make 3 ports, each being an example of the 3 cases
==== //depot/projects/soc2008/alepulver-portslicense/ports/Mk/bsd.licenses.mk#4 (text+ko) ====
@@ -37,6 +37,7 @@
# 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").
@@ -174,7 +175,7 @@
# _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
+_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_/}
@@ -206,7 +207,7 @@
# _LICENSE_SINGLE - Defined for a single license
# _LICENSE_MULTI - Set to "and"/"or"? (XXX Not implemented)
-.for lic in ${LICENSE}
+.for lic in ${_LICENSE}
. if defined(_LICENSE_DEFINED)
_LICENSE_MULTI= yes
. else
@@ -229,7 +230,7 @@
# and negative) and duplicated components.
.if defined(_LICENSE_SINGLE)
-. for lic in ${LICENSE}
+. for lic in ${_LICENSE}
. if ${_LICENSE_LIST:M${lic}} != ""
. for var in ${_LICENSE_LIST_PORT_VARS}
. if defined(LICENSE_${var})
@@ -301,15 +302,16 @@
# could be added to avoid installing licenses present in the database
. if !defined(LICENSE_FILE)
. if !defined(LICENSE_TEXT)
-. if ${_LICENSE_TYPE} != "known"
+. 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
-_LICENSE_FILE_SIM= yes
+_LICENSE_FILE= ${WRKDIR}/License-freebsd-port
. endif
+. else
+_LICENSE_FILE= ${LICENSE_FILE}
. endif
. endfor
.else
@@ -358,15 +360,15 @@
.if defined(_LICENSE_SINGLE)
# User and saved configuration
-. for lic in ${LICENSE}
+. 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= rejected
_LICENSE_STATUS_FROM:= ${_LC_TYPE}
. elif ${${_LC_VAR}_ACCEPTED:M${lic}} != "" && !defined(_LICENSE_STATUS)
-_LICENSE_STATUS= accepted
+_LICENSE_STATUS= accepted
_LICENSE_STATUS_FROM:= ${_LC_TYPE}
. endif
. endfor
@@ -376,31 +378,31 @@
# Check groups (only available for user configuration)
. for group in ${_LICENSE_LIST_GROUPS}
. if ${LICENSES_REJECTED:M\@${group}} != ""
-_LICENSE_STATUS?= rejected
+_LICENSE_STATUS?= rejected
_LICENSE_STATUS_FROM?= user
. endif
. if ${LICENSES_ACCEPTED:M\@${group}} != ""
-_LICENSE_STATUS?= accepted
+_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?= accepted
_LICENSE_STATUS_FROM?= default
. else
-_LICENSE_STATUS?= ask
+_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?= rejected
_LICENSE_STATUS_FROM?= user
. endif
# Otherwise ask to the user
-_LICENSE_STATUS?= ask
+_LICENSE_STATUS?= ask
_LICENSE_STATUS_FROM?= default
. endif
. endfor
@@ -418,16 +420,16 @@
.endif
.if defined(_LICENSE_SINGLE)
. if ${_LICENSE_STATUS} == "rejected"
- @${ECHO_MSG} "===> License ${LICENSE} rejected by the user (by ${_LICENSE_STATUS_FROM})"
+ @${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})"
+ @${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})"
+ @${ECHO_MSG} "===> License ${_LICENSE} needs agreement, will ask later (by ${_LICENSE_STATUS_FROM})"
. endif
-. if defined(_LICENSE_FILE_SIM)
+. if !defined(LICENSE_FILE) && defined(LICENSE_TEXT)
# XXX escape shell chars
- @${ECHO_CMD} ${LICENSE_TEXT} > ${LICENSE_FILE}
+ @${ECHO_CMD} ${LICENSE_TEXT} > ${_LICENSE_FILE}
. endif
.else
# XXX dual/multiple licenses
@@ -442,47 +444,59 @@
# Display, ask and save preference if requested
ask-license:
- @if [ ! -f ${LICENSE_FILE} ]; then \
- ${ECHO_CMD} "License not found in \"${LICENSE_FILE}\", aborting."; \
+ @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, reconfiguring..."; \
+ 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} "===> Can't reconfigure, as user is manually defining the status"; \
+ ${ECHO_MSG} "===> Configuration failed because manual settings are present"; \
exit 1; \
else \
status=ask; \
- fi \
+ fi; \
fi; \
until [ "$$status" = done ]; do \
- ${ECHO_CMD} "Press 'Y' to accept, 'S' to accept and save, 'N' to reject or 'V' to view." | ${FMT}; \
+ ${PRINTF} "\nPress 'y'/'n' (yes/no, upper-case saves choice) or 'v' to view: "; \
read ans; \
+ ${PRINTF} "\n"; \
case $$ans in \
- [Yy]) ${ECHO_CMD} "License was accepted."; \
+ y) ${ECHO_MSG} "===> License accepted by user"; \
status=done;; \
- [Nn]) ${ECHO_CMD} "License was rejected."; \
+ n) ${ECHO_MSG} "===> License rejected by user"; \
exit 1;; \
- [Ss]) if [ ${UID} != 0 ]; then \
- ${ECHO_CMD} "You don't have permissions to save the license"; \
- else \
- ${MKDIR} ${_LICENSE_CFG:H}; \
- (${ECHO_CMD} _LICENSES_ACCEPTED=${LICENSE}; \
- if [ ${_LICENSE_TYPE} != "known" ]; then \
- ${ECHO_CMD} _LICENSE_${LICENSE}_CHK=`${SHA256} -q ${LICENSE_FILE}`; \
- fi) > ${LICENSE_FILE}; \
- ${ECHO_CMD} "License was accepted and saved."; \
- status=done; \
- fi;; \
- [Vv]) more ${LICENSE_FILE}; \
+ 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=${_LICENSE}; \
+ if [ ${_LICENSE_TYPE} != "known" ]; then \
+ ${ECHO_CMD} _LICENSE_${_LICENSE}_CHK=`${SHA256} -q ${_LICENSE_FILE}`; \
+ fi) > ${_LICENSE_FILE}; \
+ ${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_REJECTED=${_LICENSE}; \
+ if [ ${_LICENSE_TYPE} != "known" ]; then \
+ ${ECHO_CMD} _LICENSE_${_LICENSE}_CHK=`${SHA256} -q ${_LICENSE_FILE}`; \
+ fi) > ${_LICENSE_FILE}; \
+ ${ECHO_MSG} "===> License rejected by user and saved"; \
+ exit 1; \
+ fi;; \
+ [Vv]) more ${_LICENSE_FILE};; \
esac; \
done
@@ -495,7 +509,7 @@
. 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
+IGNORE= depends on ${port:T} that uses license "${lic}" which is incompatible with "${_LICENSE}" used by this port
. endif
. endfor
. endfor
@@ -506,14 +520,14 @@
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}
+.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}
+.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}
@@ -522,6 +536,26 @@
. 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:
More information about the p4-projects
mailing list