From 7dbe096c633dae2d2f8c0044368c5897bde47107 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 29 Oct 2014 14:03:46 +0100 Subject: import: snix: Handle license attributes. * guix/import/snix.scm (snix-derivation->guix-package)[license-variable]: Move to... (license-variable): ... here. Handle license attributes. --- guix/import/snix.scm | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'guix/import/snix.scm') diff --git a/guix/import/snix.scm b/guix/import/snix.scm index bcc4d6b7a6..adcea43c88 100644 --- a/guix/import/snix.scm +++ b/guix/import/snix.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2010, 2011, 2012, 2013 Ludovic Courtès +;;; Copyright © 2010, 2011, 2012, 2013, 2014 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -310,6 +310,29 @@ attributes, or #f if NAME cannot be found." (_ attributes)))) +(define (license-variable license) + "Return the name of the (guix licenses) variable for LICENSE." + (match license + ("GPLv2+" 'gpl2+) + ("GPLv3+" 'gpl3+) + ("LGPLv2+" 'lgpl2.1+) + ("LGPLv2.1+" 'lgpl2.1+) + ("LGPLv3+" 'lgpl3+) + (('attribute-set _ ...) + ;; At some point in 2013, Nixpkgs switched to attribute sets to represent + ;; licenses. These are listed in lib/licenses.nix. + (match (and=> (find-attribute-by-name "shortName" license) + attribute-value) + ("AGPL-3.0+" 'agpl3+) + ("GPL-2.0+" 'gpl2+) + ("GPL-3.0+" 'gpl3+) + ("LGPL-2.0+" 'lgpl2.0+) + ("LGPL-2.1+" 'lgpl2.1+) + ("LGPL-3.0+" 'lgpl3+) + ((? string? x) x) + (_ license))) + (_ license))) + (define (package-source-output-path package) "Return the output path of the \"src\" derivation of PACKAGE." (derivation-source-output-path (attribute-value package))) @@ -369,16 +392,6 @@ location of DERIVATION." (x x)) uri)) - (define (license-variable license) - ;; Return the name of the (guix licenses) variable for LICENSE. - (match license - ("GPLv2+" 'gpl2+) - ("GPLv3+" 'gpl3+) - ("LGPLv2+" 'lgpl2.1+) - ("LGPLv2.1+" 'lgpl2.1+) - ("LGPLv3+" 'lgpl3+) - (_ license))) - (let* ((source (find-attribute-by-name "src" attributes)) (urls (source-urls source)) (sha256 (source-sha256 source)) -- cgit v1.2.3