From 4824bcb5fa5a3b367a99353eead5ea1fd5d4220a Mon Sep 17 00:00:00 2001 From: emre Date: Wed, 29 Jul 2026 14:37:09 +0300 Subject: [PATCH] Add spdx short identifiers, use it as asdf :license. --- data/README.org | 20 ++++++++++++++++++++ src/license.lisp | 28 ++++++++++++++++++++-------- src/starter.lisp | 3 ++- 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 data/README.org diff --git a/data/README.org b/data/README.org new file mode 100644 index 0000000..3e89afb --- /dev/null +++ b/data/README.org @@ -0,0 +1,20 @@ +This directory contains license templates. + +Template arguments are designated with an identifier inside +~{{}}~. Possible identifiers are: +- ~current-year~ +- ~project-author~ +- ~project-name~ + +* license sources + +- [[https://choosealicense.com/licenses/]] + +** [[https://spdx.org/licenses/][spdx]] + +- [[https://spdx.org/licenses/Apache-2.0.html][Apache-2.0]] +- [[https://spdx.org/licenses/BSD-2-Clause.html][BSD-2-Clause]] +- [[https://spdx.org/licenses/BSD-3-Clause.html][BSD-3-Clause]] +- [[https://spdx.org/licenses/GPL-3.0-or-later.html][GPL-3.0-or-later]] +- [[https://spdx.org/licenses/MIT.html][MIT]] +- [[https://spdx.org/licenses/Unlicense.html][Unlicense]] diff --git a/src/license.lisp b/src/license.lisp index 06c3191..0f8a0b2 100644 --- a/src/license.lisp +++ b/src/license.lisp @@ -11,7 +11,12 @@ :accessor license-file-name :initform *license-default-filename*) (writer :initform nil - :accessor license-writer))) + :accessor license-writer) + (spdx-short :initarg :license-spdx-short + :initform nil + :accessor license-spdx-short + :type (or string null) + :documentation "SPDX short identifier for the license. See at https://spdx.org/licenses/"))) (defun get-license (key) (gethash key *licenses*)) @@ -28,10 +33,11 @@ (setf (gethash key *notices*) value))) (eval-always - (defmacro deflicense (keys template-name &key file-name notice-name) + (defmacro deflicense (keys template-name &key file-name notice-name spdx) (let ((sym (gensym "LICENSE"))) `(progn (let ((,sym (make-instance ' :license-template-name ,template-name + :license-spdx-short ,spdx ,@(unless (null file-name) `(:license-file-name ,file-name))))) ,@(loop for key in (uiop:ensure-list keys) @@ -43,21 +49,27 @@ ,@(loop for key in (uiop:ensure-list keys) collect `(set-notice ,key ,sym))))))))) -(deflicense :mit "mit.txt") +(deflicense :mit "mit.txt" + :spdx "MIT") (deflicense :gpl3+ "gpl-3.0-or-later.txt" :file-name "COPYING" - :notice-name "gpl-3.0-or-later-notice.txt") + :notice-name "gpl-3.0-or-later-notice.txt" + :spdx "GPL-3.0-or-later") (deflicense :apache2 "apache-2.0.txt" - :notice-name "apache-2.0-notice.txt") + :notice-name "apache-2.0-notice.txt" + :spdx "Apache-2.0") (deflicense :unlicense "unlicense.txt" - :file-name "UNLICENSE") + :file-name "UNLICENSE" + :spdx "Unlicense") -(deflicense :bsd2 "bsd-2-clause.txt") +(deflicense :bsd2 "bsd-2-clause.txt" + :spdx "BSD-2-Clause") -(deflicense :bsd3 "bsd-3-clause.txt") +(deflicense :bsd3 "bsd-3-clause.txt" + :spdx "BSD-3-Clause") (defmethod license-find-template ((license )) (with-slots (template-name) license diff --git a/src/starter.lisp b/src/starter.lisp index 5846c13..88391ff 100644 --- a/src/starter.lisp +++ b/src/starter.lisp @@ -42,7 +42,8 @@ (format stream "defsystem ~S" name) (format stream "~& :author ~S" author) (format stream "~& :description ~S" description) - (format stream "~& :license ~S" license) + (let ((l (get-license license))) + (format stream "~& :license ~S" (license-spdx-short l))) (format stream "~& :version ~S" version) (unless (null pathname) (format stream "~& :pathname ~S" pathname))