07/57: guix: Add lint-checker for packages which should be no inputs at all.

2016-10-15 Thread Hartmut Goebel
htgoebel pushed a commit to branch wip-python-build-system
in repository guix.

commit 503678c8e3321d4fa1bd320f3475bc78d26859d1
Author: Hartmut Goebel 
Date:   Wed Sep 28 11:36:35 2016 +0200

guix: Add lint-checker for packages which should be no inputs at all.

Also refactor some common code into a new function.

Examples for these pacakges are python(2)-setuptools and python(2)-pip, 
which
are installed together with python itself.

* guix/scripts/lint.scm (warn-if-package-has-input): New procedure.
  (check-inputs-should-be-native package): Use it; rename and clean-up
  variables. (check-inputs-should-not-be-an-input-at-all): New procedure.
  (%checkers) Add it.
* doc/guix.texi (Python Modules): Document it.
* tests/lint.scm: ("inputs: python-setuptools should not be an input at all
  (input)", "inputs: python-setuptools should not be an input at all
  (native-input)" "inputs: python-setuptools should not be an input at all
  (propagated-input)"): Add tests.
---
 doc/guix.texi |3 ++-
 guix/scripts/lint.scm |   63 +++--
 tests/lint.scm|   34 ++
 3 files changed, 81 insertions(+), 19 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 33d62b8..55ae89e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12367,7 +12367,8 @@ following check list to determine which dependency goes 
where.
 @item
 We currently package Python 2 with @code{setuptools} and @code{pip}
 installed like Python 3.4 has per default.  Thus you don't need to
-specify either of these as an input.
+specify either of these as an input.  @command{guix lint} will warn you
+if you do.
 
 @item
 Python dependencies required at run time go into
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index b3ec6d6..042c679 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès 
 ;;; Copyright © 2015, 2016 Mathieu Lirzin 
 ;;; Copyright © 2016 Danny Milosavljevic 
+;;; Copyright © 2016 Hartmut Goebel 
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -59,6 +60,7 @@
   #:export (guix-lint
 check-description-style
 check-inputs-should-be-native
+check-inputs-should-not-be-an-input-at-all
 check-patch-file-names
 check-synopsis-style
 check-derivation
@@ -213,34 +215,55 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
   (format #f (_ "invalid description: ~s") description)
   'description
 
+(define (warn-if-package-has-input linted inputs-to-check input-names message)
+  ;; Emit a warning MESSAGE if some of the inputs named in INPUT-NAMES are
+  ;; contained in INPUTS-TO-CHECK, which are assumed to be inputs of package
+  ;; LINTED.
+  (match inputs-to-check
+(((labels packages . outputs) ...)
+ (for-each (lambda (package output)
+ (when (package? package)
+   (let ((input (string-append
+ (package-name package)
+ (if (> (length output) 0)
+ (string-append ":" (car output))
+ ""
+ (when (member input input-names)
+   (emit-warning linted
+ (format #f (_ message) input)
+ 'inputs-to-check)
+   packages outputs
+
 (define (check-inputs-should-be-native package)
   ;; Emit a warning if some inputs of PACKAGE are likely to belong to its
   ;; native inputs.
-  (let ((linted package)
+  (let ((message "'~a' should probably be a native input")
 (inputs (package-inputs package))
-(native-inputs
+(input-names
   '("pkg-config"
 "extra-cmake-modules"
 "glib:bin"
 "intltool"
 "itstool"
 "qttools")))
-(match inputs
-  (((labels packages . outputs) ...)
-   (for-each (lambda (package output)
-   (when (package? package)
- (let ((input (string-append
-   (package-name package)
-   (if (> (length output) 0)
-   (string-append ":" (car output))
-   ""
-   (when (member input native-inputs)
- (emit-warning linted
-   (format #f (_ "'~a' should probably \
-be a native input")
-   input)
-   'inputs)
- packages outputs)
+

07/57: guix: Add lint-checker for packages which should be no inputs at all.

2016-10-13 Thread Hartmut Goebel
htgoebel pushed a commit to branch wip-python-build-system
in repository guix.

commit 4241426d66abdce97072e779d2e3822ab48a1412
Author: Hartmut Goebel 
Date:   Wed Sep 28 11:36:35 2016 +0200

guix: Add lint-checker for packages which should be no inputs at all.

Also refactor some common code into a new function.

Examples for these pacakges are python(2)-setuptools and python(2)-pip, 
which
are installed together with python itself.

* guix/scripts/lint.scm (warn-if-package-has-input): New procedure.
  (check-inputs-should-be-native package): Use it; rename and clean-up
  variables. (check-inputs-should-not-be-an-input-at-all): New procedure.
  (%checkers) Add it.
* doc/guix.texi (Python Modules): Document it.
* tests/lint.scm: ("inputs: python-setuptools should not be an input at all
  (input)", "inputs: python-setuptools should not be an input at all
  (native-input)" "inputs: python-setuptools should not be an input at all
  (propagated-input)"): Add tests.
---
 doc/guix.texi |3 ++-
 guix/scripts/lint.scm |   63 +++--
 tests/lint.scm|   34 ++
 3 files changed, 81 insertions(+), 19 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 33d62b8..55ae89e 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12367,7 +12367,8 @@ following check list to determine which dependency goes 
where.
 @item
 We currently package Python 2 with @code{setuptools} and @code{pip}
 installed like Python 3.4 has per default.  Thus you don't need to
-specify either of these as an input.
+specify either of these as an input.  @command{guix lint} will warn you
+if you do.
 
 @item
 Python dependencies required at run time go into
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index b3ec6d6..042c679 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès 
 ;;; Copyright © 2015, 2016 Mathieu Lirzin 
 ;;; Copyright © 2016 Danny Milosavljevic 
+;;; Copyright © 2016 Hartmut Goebel 
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -59,6 +60,7 @@
   #:export (guix-lint
 check-description-style
 check-inputs-should-be-native
+check-inputs-should-not-be-an-input-at-all
 check-patch-file-names
 check-synopsis-style
 check-derivation
@@ -213,34 +215,55 @@ by two spaces; possible infraction~p at ~{~a~^, ~}")
   (format #f (_ "invalid description: ~s") description)
   'description
 
+(define (warn-if-package-has-input linted inputs-to-check input-names message)
+  ;; Emit a warning MESSAGE if some of the inputs named in INPUT-NAMES are
+  ;; contained in INPUTS-TO-CHECK, which are assumed to be inputs of package
+  ;; LINTED.
+  (match inputs-to-check
+(((labels packages . outputs) ...)
+ (for-each (lambda (package output)
+ (when (package? package)
+   (let ((input (string-append
+ (package-name package)
+ (if (> (length output) 0)
+ (string-append ":" (car output))
+ ""
+ (when (member input input-names)
+   (emit-warning linted
+ (format #f (_ message) input)
+ 'inputs-to-check)
+   packages outputs
+
 (define (check-inputs-should-be-native package)
   ;; Emit a warning if some inputs of PACKAGE are likely to belong to its
   ;; native inputs.
-  (let ((linted package)
+  (let ((message "'~a' should probably be a native input")
 (inputs (package-inputs package))
-(native-inputs
+(input-names
   '("pkg-config"
 "extra-cmake-modules"
 "glib:bin"
 "intltool"
 "itstool"
 "qttools")))
-(match inputs
-  (((labels packages . outputs) ...)
-   (for-each (lambda (package output)
-   (when (package? package)
- (let ((input (string-append
-   (package-name package)
-   (if (> (length output) 0)
-   (string-append ":" (car output))
-   ""
-   (when (member input native-inputs)
- (emit-warning linted
-   (format #f (_ "'~a' should probably \
-be a native input")
-   input)
-   'inputs)
- packages outputs)
+