summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-11-28 15:05:55 +0100
committerLudovic Courtès <ludo@gnu.org>2017-11-28 15:05:55 +0100
commiteef01cfe8eac8dee8ecf727e4ca459ae065e15ea (patch)
tree0ad04efcbcd00d8c0366f5a6674c096051a5bbec /guix
parent1da3d2a3a1b53bdd71774194f4afc13f35bb18e3 (diff)
lint: 'patch-file-names' checks for file name length.
Reported at <https://bugs.gnu.org/27943> by Danny Milosavljevic <dannym@scratchpost.org>. * guix/scripts/lint.scm (%distro-directory): New variable. (check-patch-file-names): Add check for the file name length. * tests/lint.scm ("patches: file name too long"): New test.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/lint.scm28
1 files changed, 25 insertions, 3 deletions
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 8840b1acb5..7300e55de2 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -587,24 +587,46 @@ from ~a")
(package-home-page package))
'home-page)))))
+(define %distro-directory
+ (dirname (search-path %load-path "gnu.scm")))
+
(define (check-patch-file-names package)
"Emit a warning if the patches requires by PACKAGE are badly named or if the
patch could not be found."
(guard (c ((message-condition? c) ;raised by 'search-patch'
(emit-warning package (condition-message c)
'patch-file-names)))
+ (define patches
+ (or (and=> (package-source package) origin-patches)
+ '()))
+
(unless (every (match-lambda ;patch starts with package name?
((? string? patch)
(and=> (string-contains (basename patch)
(package-name package))
zero?))
(_ #f)) ;must be an <origin> or something like that.
- (or (and=> (package-source package) origin-patches)
- '()))
+ patches)
(emit-warning
package
(G_ "file names of patches should start with the package name")
- 'patch-file-names))))
+ 'patch-file-names))
+
+ ;; Check whether we're reaching tar's maximum file name length.
+ (let ((prefix (string-length %distro-directory))
+ (margin (string-length "guix-0.13.0-10-123456789/"))
+ (max 99))
+ (for-each (match-lambda
+ ((? string? patch)
+ (when (> (+ margin (- (string-length patch) prefix))
+ max)
+ (emit-warning
+ package
+ (format #f (G_ "~a: file name is too long")
+ (basename patch))
+ 'patch-file-names)))
+ (_ #f))
+ patches))))
(define (escape-quotes str)
"Replace any quote character in STR by an escaped quote character."