Remove most uses of the _IO*F constants.

These constants, for use with 'setvbuf', were deprecated in Guile 2.2
and disappeared in Guile 3.0.  Here we keep these constants in
build-side code where removing them is not feasible.

* guix/build/download-nar.scm (download-nar): Adjust 'setvbuf' calls to
the Guile 2.2+ API.
* guix/build/download.scm (open-socket-for-uri): Likewise.
(open-connection-for-uri, url-fetch): Likewise.
* guix/build/make-bootstrap.scm (make-stripped-libc): Likewise.
* guix/build/union.scm (setvbuf) [guile-2.0]: New conditional wrapper.
(union-build): Adjust to new API.
* guix/ftp-client.scm (ftp-open, ftp-list, ftp-retr): Likewise.
* guix/http-client.scm (http-fetch): Likewise.
* guix/inferior.scm (proxy): Likewise.
* guix/scripts/substitute.scm (fetch, http-multiple-get): Likewise.
* guix/self.scm (compiled-modules): Likewise.
* guix/ssh.scm (remote-daemon-channel, store-import-channel)
(store-export-channel): Likewise.
* guix/ui.scm (initialize-guix): Likewise.
* tests/publish.scm (http-get-port): Likewise.
* guix/store.scm (%newlines): Adjust comment.
This commit is contained in:
Ludovic Courtès 2019-01-07 10:57:18 +01:00
parent c3d9bca48a
commit 76832d3420
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
13 changed files with 52 additions and 39 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017, 2019 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -93,8 +93,8 @@ ITEM."
"Download and extract the normalized archive for ITEM. Return #t on "Download and extract the normalized archive for ITEM. Return #t on
success, #f otherwise." success, #f otherwise."
;; Let progress reports go through. ;; Let progress reports go through.
(setvbuf (current-error-port) _IONBF) (setvbuf (current-error-port) 'none)
(setvbuf (current-output-port) _IONBF) (setvbuf (current-output-port) 'none)
(let loop ((urls (urls-for-item item))) (let loop ((urls (urls-for-item item)))
(match urls (match urls

View File

@ -357,7 +357,7 @@ ETIMEDOUT error is raised."
(connect* s (addrinfo:addr ai) timeout) (connect* s (addrinfo:addr ai) timeout)
;; Buffer input and output on this port. ;; Buffer input and output on this port.
(setvbuf s _IOFBF) (setvbuf s 'block)
;; If we're using a proxy, make a note of that. ;; If we're using a proxy, make a note of that.
(when http-proxy (set-http-proxy-port?! s #t)) (when http-proxy (set-http-proxy-port?! s #t))
s) s)
@ -401,7 +401,7 @@ VERIFY-CERTIFICATE? is true, verify HTTPS server certificates."
(with-https-proxy (with-https-proxy
(let ((s (open-socket-for-uri uri #:timeout timeout))) (let ((s (open-socket-for-uri uri #:timeout timeout)))
;; Buffer input and output on this port. ;; Buffer input and output on this port.
(setvbuf s _IOFBF %http-receive-buffer-size) (setvbuf s 'block %http-receive-buffer-size)
(if https? (if https?
(tls-wrap s (uri-host uri) (tls-wrap s (uri-host uri)
@ -777,11 +777,11 @@ otherwise simply ignore them."
hashes)) hashes))
content-addressed-mirrors)) content-addressed-mirrors))
;; Make this unbuffered so 'progress-report/file' works as expected. _IOLBF ;; Make this unbuffered so 'progress-report/file' works as expected. 'line
;; means '\n', not '\r', so it's not appropriate here. ;; means '\n', not '\r', so it's not appropriate here.
(setvbuf (current-output-port) _IONBF) (setvbuf (current-output-port) 'none)
(setvbuf (current-error-port) _IOLBF) (setvbuf (current-error-port) 'line)
(let try ((uri (append uri content-addressed-uris))) (let try ((uri (append uri content-addressed-uris)))
(match uri (match uri

View File

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com> ;;; Copyright © 2015, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015, 2019 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -67,7 +67,7 @@ when producing a bootstrap libc."
util).*\\.so(\\..*)?|lib(machuser|hurduser).so.*|(libc(rt|)|libpthread)\ util).*\\.so(\\..*)?|lib(machuser|hurduser).so.*|(libc(rt|)|libpthread)\
_nonshared\\.a)$") _nonshared\\.a)$")
(setvbuf (current-output-port) _IOLBF) (setvbuf (current-output-port) 'line)
(let* ((libdir (string-append output "/lib"))) (let* ((libdir (string-append output "/lib")))
(mkdir-p libdir) (mkdir-p libdir)
(for-each (lambda (file) (for-each (lambda (file)

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2017 Huang Ying <huang.ying.caritas@gmail.com> ;;; Copyright © 2017 Huang Ying <huang.ying.caritas@gmail.com>
;;; ;;;
@ -39,6 +39,19 @@
;;; ;;;
;;; Code: ;;; Code:
;; This code can be used with the bootstrap Guile, which is Guile 2.0, so
;; provide a compatibility layer.
(cond-expand
((and guile-2 (not guile-2.2))
(define (setvbuf port mode . rest)
(apply (@ (guile) setvbuf) port
(match mode
('line _IOLBF)
('block _IOFBF)
('none _IONBF))
rest)))
(else #f))
(define (files-in-directory dirname) (define (files-in-directory dirname)
(let ((dir (opendir dirname))) (let ((dir (opendir dirname)))
(let loop ((files '())) (let loop ((files '()))
@ -179,10 +192,10 @@ returns #f, skip the faulty file altogether."
(reverse dirs-with-file)))) (reverse dirs-with-file))))
table))) table)))
(setvbuf (current-output-port) _IOLBF) (setvbuf (current-output-port) 'line)
(setvbuf (current-error-port) _IOLBF) (setvbuf (current-error-port) 'line)
(when (file-port? log-port) (when (file-port? log-port)
(setvbuf log-port _IOLBF)) (setvbuf log-port 'line))
(union-of-directories output (delete-duplicates inputs))) (union-of-directories output (delete-duplicates inputs)))

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -154,7 +154,7 @@ TIMEOUT, an ETIMEDOUT error is raised."
(catch 'system-error (catch 'system-error
(lambda () (lambda ()
(connect* s (addrinfo:addr ai) timeout) (connect* s (addrinfo:addr ai) timeout)
(setvbuf s _IOLBF) (setvbuf s 'line)
(let-values (((code message) (%ftp-listen s))) (let-values (((code message) (%ftp-listen s)))
(if (eqv? code 220) (if (eqv? code 220)
(begin (begin
@ -237,7 +237,7 @@ TIMEOUT, an ETIMEDOUT error is raised."
(s (socket (addrinfo:fam ai) (addrinfo:socktype ai) (s (socket (addrinfo:fam ai) (addrinfo:socktype ai)
(addrinfo:protocol ai)))) (addrinfo:protocol ai))))
(connect* s (address-with-port (addrinfo:addr ai) port) timeout) (connect* s (address-with-port (addrinfo:addr ai) port) timeout)
(setvbuf s _IOLBF) (setvbuf s 'line)
(dynamic-wind (dynamic-wind
(lambda () #t) (lambda () #t)
@ -293,7 +293,7 @@ must be closed before CONN can be used for other purposes."
(throw 'ftp-error conn "LIST" code message)))) (throw 'ftp-error conn "LIST" code message))))
(connect* s (address-with-port (addrinfo:addr ai) port) timeout) (connect* s (address-with-port (addrinfo:addr ai) port) timeout)
(setvbuf s _IOLBF) (setvbuf s 'line)
(%ftp-command (string-append "RETR " file) (%ftp-command (string-append "RETR " file)
150 (ftp-connection-socket conn)) 150 (ftp-connection-socket conn))

View File

@ -97,7 +97,7 @@ Raise an '&http-get-error' condition if downloading fails."
headers)) headers))
(_ headers)))) (_ headers))))
(unless (or buffered? (not (file-port? port))) (unless (or buffered? (not (file-port? port)))
(setvbuf port _IONBF)) (setvbuf port 'none))
(let*-values (((resp data) (let*-values (((resp data)
(http-get uri #:streaming? #t #:port port (http-get uri #:streaming? #t #:port port
#:keep-alive? #t #:keep-alive? #t

View File

@ -389,8 +389,8 @@ input/output ports.)"
;; Use buffered ports so that 'get-bytevector-some' returns up to the ;; Use buffered ports so that 'get-bytevector-some' returns up to the
;; whole buffer like read(2) would--see <https://bugs.gnu.org/30066>. ;; whole buffer like read(2) would--see <https://bugs.gnu.org/30066>.
(setvbuf client _IOFBF 65536) (setvbuf client 'block 65536)
(setvbuf backend _IOFBF 65536) (setvbuf backend 'block 65536)
(let loop () (let loop ()
(match (select* (list client backend) '() '()) (match (select* (list client backend) '() '())

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com> ;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com>
;;; ;;;
@ -219,7 +219,7 @@ provide."
(set! port (guix:open-connection-for-uri (set! port (guix:open-connection-for-uri
uri #:verify-certificate? #f)) uri #:verify-certificate? #f))
(unless (or buffered? (not (file-port? port))) (unless (or buffered? (not (file-port? port)))
(setvbuf port _IONBF))) (setvbuf port 'none)))
(http-fetch uri #:text? #f #:port port (http-fetch uri #:text? #f #:port port
#:verify-certificate? #f)))))) #:verify-certificate? #f))))))
(else (else
@ -567,7 +567,7 @@ initial connection on which HTTP requests are sent."
verify-certificate?)))) verify-certificate?))))
;; For HTTPS, P is not a file port and does not support 'setvbuf'. ;; For HTTPS, P is not a file port and does not support 'setvbuf'.
(when (file-port? p) (when (file-port? p)
(setvbuf p _IOFBF (expt 2 16))) (setvbuf p 'block (expt 2 16)))
;; Send REQUESTS, up to a certain number, in a row. ;; Send REQUESTS, up to a certain number, in a row.
;; XXX: Do our own caching to work around inefficiencies when ;; XXX: Do our own caching to work around inefficiencies when

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -904,8 +904,8 @@ containing MODULE-FILES and possibly other files as well."
#:report-load report-load #:report-load report-load
#:report-compilation report-compilation))) #:report-compilation report-compilation)))
(setvbuf (current-output-port) _IONBF) (setvbuf (current-output-port) 'none)
(setvbuf (current-error-port) _IONBF) (setvbuf (current-error-port) 'none)
(set! %load-path (cons #+module-tree %load-path)) (set! %load-path (cons #+module-tree %load-path))
(set! %load-path (set! %load-path

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -140,12 +140,12 @@ right away."
(match (select read write except) (match (select read write except)
((read write except) ((read write except)
(select read write except 0)))))) (select read write except 0))))))
(setvbuf stdout _IONBF) (setvbuf stdout 'none)
;; Use buffered ports so that 'get-bytevector-some' returns up to the ;; Use buffered ports so that 'get-bytevector-some' returns up to the
;; whole buffer like read(2) would--see <https://bugs.gnu.org/30066>. ;; whole buffer like read(2) would--see <https://bugs.gnu.org/30066>.
(setvbuf stdin _IOFBF 65536) (setvbuf stdin 'block 65536)
(setvbuf sock _IOFBF 65536) (setvbuf sock 'block 65536)
(connect sock AF_UNIX ,socket-name) (connect sock AF_UNIX ,socket-name)
@ -218,7 +218,7 @@ can be written."
(consume-input (current-input-port)) (consume-input (current-input-port))
(list 'protocol-error (nix-protocol-error-message c)))) (list 'protocol-error (nix-protocol-error-message c))))
(with-store store (with-store store
(setvbuf (current-input-port) _IONBF) (setvbuf (current-input-port) 'none)
(import-paths store (current-input-port)) (import-paths store (current-input-port))
'(success)))) '(success))))
(lambda args (lambda args
@ -269,7 +269,7 @@ be read. When RECURSIVE? is true, the closure of FILES is exported."
(write '(exporting)) ;we're ready (write '(exporting)) ;we're ready
(force-output) (force-output)
(setvbuf (current-output-port) _IONBF) (setvbuf (current-output-port) 'none)
(export-paths store files (current-output-port) (export-paths store files (current-output-port)
#:recursive? ,recursive?)))))) #:recursive? ,recursive?))))))

View File

@ -608,7 +608,7 @@ to OUT, using chunks of BUFFER-SIZE bytes."
(define %newlines (define %newlines
;; Newline characters triggering a flush of 'current-build-output-port'. ;; Newline characters triggering a flush of 'current-build-output-port'.
;; Unlike Guile's _IOLBF, we flush upon #\return so that progress reports ;; Unlike Guile's 'line, we flush upon #\return so that progress reports
;; that use that trick are correctly displayed. ;; that use that trick are correctly displayed.
(char-set #\newline #\return)) (char-set #\newline #\return))

View File

@ -454,8 +454,8 @@ See the \"Application Setup\" section in the manual, for more info.\n")))))
;; notified via an EPIPE later. ;; notified via an EPIPE later.
(sigaction SIGPIPE SIG_IGN) (sigaction SIGPIPE SIG_IGN)
(setvbuf (current-output-port) _IOLBF) (setvbuf (current-output-port) 'line)
(setvbuf (current-error-port) _IOLBF)) (setvbuf (current-error-port) 'line))
(define* (show-version-and-exit #:optional (command (car (command-line)))) (define* (show-version-and-exit #:optional (command (car (command-line))))
"Display version information for COMMAND and `(exit 0)'." "Display version information for COMMAND and `(exit 0)'."

View File

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -63,12 +63,12 @@
(let ((socket (open-socket-for-uri uri))) (let ((socket (open-socket-for-uri uri)))
;; Make sure to use an unbuffered port so that we can then peek at the ;; Make sure to use an unbuffered port so that we can then peek at the
;; underlying file descriptor via 'call-with-gzip-input-port'. ;; underlying file descriptor via 'call-with-gzip-input-port'.
(setvbuf socket _IONBF) (setvbuf socket 'none)
(call-with-values (call-with-values
(lambda () (lambda ()
(http-get uri #:port socket #:streaming? #t)) (http-get uri #:port socket #:streaming? #t))
(lambda (response port) (lambda (response port)
;; Don't (setvbuf port _IONBF) because of <http://bugs.gnu.org/19610> ;; Don't (setvbuf port 'none) because of <http://bugs.gnu.org/19610>
;; (PORT might be a custom binary input port). ;; (PORT might be a custom binary input port).
port)))) port))))