Browse Source

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.
install-doc-overhaul
Ludovic Courtès 3 years ago
parent
commit
76832d3420
No known key found for this signature in database GPG Key ID: 90B11993D9AEBB5
  1. 6
      guix/build/download-nar.scm
  2. 10
      guix/build/download.scm
  3. 4
      guix/build/make-bootstrap.scm
  4. 21
      guix/build/union.scm
  5. 8
      guix/ftp-client.scm
  6. 2
      guix/http-client.scm
  7. 4
      guix/inferior.scm
  8. 6
      guix/scripts/substitute.scm
  9. 6
      guix/self.scm
  10. 12
      guix/ssh.scm
  11. 2
      guix/store.scm
  12. 4
      guix/ui.scm
  13. 6
      tests/publish.scm

6
guix/build/download-nar.scm

@ -1,5 +1,5 @@
;;; 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.
;;;
@ -93,8 +93,8 @@ ITEM."
"Download and extract the normalized archive for ITEM. Return #t on
success, #f otherwise."
;; Let progress reports go through.
(setvbuf (current-error-port) _IONBF)
(setvbuf (current-output-port) _IONBF)
(setvbuf (current-error-port) 'none)
(setvbuf (current-output-port) 'none)
(let loop ((urls (urls-for-item item)))
(match urls

10
guix/build/download.scm

@ -357,7 +357,7 @@ ETIMEDOUT error is raised."
(connect* s (addrinfo:addr ai) timeout)
;; Buffer input and output on this port.
(setvbuf s _IOFBF)
(setvbuf s 'block)
;; If we're using a proxy, make a note of that.
(when http-proxy (set-http-proxy-port?! s #t))
s)
@ -401,7 +401,7 @@ VERIFY-CERTIFICATE? is true, verify HTTPS server certificates."
(with-https-proxy
(let ((s (open-socket-for-uri uri #:timeout timeout)))
;; Buffer input and output on this port.
(setvbuf s _IOFBF %http-receive-buffer-size)
(setvbuf s 'block %http-receive-buffer-size)
(if https?
(tls-wrap s (uri-host uri)
@ -777,11 +777,11 @@ otherwise simply ignore them."
hashes))
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.
(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)))
(match uri

4
guix/build/make-bootstrap.scm

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; 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.
;;;
@ -67,7 +67,7 @@ when producing a bootstrap libc."
util).*\\.so(\\..*)?|lib(machuser|hurduser).so.*|(libc(rt|)|libpthread)\
_nonshared\\.a)$")
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-output-port) 'line)
(let* ((libdir (string-append output "/lib")))
(mkdir-p libdir)
(for-each (lambda (file)

21
guix/build/union.scm

@ -1,5 +1,5 @@
;;; 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 © 2017 Huang Ying <huang.ying.caritas@gmail.com>
;;;
@ -39,6 +39,19 @@
;;;
;;; 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)
(let ((dir (opendir dirname)))
(let loop ((files '()))
@ -179,10 +192,10 @@ returns #f, skip the faulty file altogether."
(reverse dirs-with-file))))
table)))
(setvbuf (current-output-port) _IOLBF)
(setvbuf (current-error-port) _IOLBF)
(setvbuf (current-output-port) 'line)
(setvbuf (current-error-port) 'line)
(when (file-port? log-port)
(setvbuf log-port _IOLBF))
(setvbuf log-port 'line))
(union-of-directories output (delete-duplicates inputs)))

8
guix/ftp-client.scm

@ -1,5 +1,5 @@
;;; 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.
;;;
@ -154,7 +154,7 @@ TIMEOUT, an ETIMEDOUT error is raised."
(catch 'system-error
(lambda ()
(connect* s (addrinfo:addr ai) timeout)
(setvbuf s _IOLBF)
(setvbuf s 'line)
(let-values (((code message) (%ftp-listen s)))
(if (eqv? code 220)
(begin
@ -237,7 +237,7 @@ TIMEOUT, an ETIMEDOUT error is raised."
(s (socket (addrinfo:fam ai) (addrinfo:socktype ai)
(addrinfo:protocol ai))))
(connect* s (address-with-port (addrinfo:addr ai) port) timeout)
(setvbuf s _IOLBF)
(setvbuf s 'line)
(dynamic-wind
(lambda () #t)
@ -293,7 +293,7 @@ must be closed before CONN can be used for other purposes."
(throw 'ftp-error conn "LIST" code message))))
(connect* s (address-with-port (addrinfo:addr ai) port) timeout)
(setvbuf s _IOLBF)
(setvbuf s 'line)
(%ftp-command (string-append "RETR " file)
150 (ftp-connection-socket conn))

2
guix/http-client.scm

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

4
guix/inferior.scm

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

6
guix/scripts/substitute.scm

@ -1,5 +1,5 @@
;;; 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 © 2018 Kyle Meyer <kyle@kyleam.com>
;;;
@ -219,7 +219,7 @@ provide."
(set! port (guix:open-connection-for-uri
uri #:verify-certificate? #f))
(unless (or buffered? (not (file-port? port)))
(setvbuf port _IONBF)))
(setvbuf port 'none)))
(http-fetch uri #:text? #f #:port port
#:verify-certificate? #f))))))
(else
@ -567,7 +567,7 @@ initial connection on which HTTP requests are sent."
verify-certificate?))))
;; For HTTPS, P is not a file port and does not support 'setvbuf'.
(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.
;; XXX: Do our own caching to work around inefficiencies when

6
guix/self.scm

@ -1,5 +1,5 @@
;;; 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.
;;;
@ -904,8 +904,8 @@ containing MODULE-FILES and possibly other files as well."
#:report-load report-load
#:report-compilation report-compilation)))
(setvbuf (current-output-port) _IONBF)
(setvbuf (current-error-port) _IONBF)
(setvbuf (current-output-port) 'none)
(setvbuf (current-error-port) 'none)
(set! %load-path (cons #+module-tree %load-path))
(set! %load-path

12
guix/ssh.scm

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

2
guix/store.scm

@ -608,7 +608,7 @@ to OUT, using chunks of BUFFER-SIZE bytes."
(define %newlines
;; 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.
(char-set #\newline #\return))

4
guix/ui.scm

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

6
tests/publish.scm

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; 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.
;;;
@ -63,12 +63,12 @@
(let ((socket (open-socket-for-uri uri)))
;; Make sure to use an unbuffered port so that we can then peek at the
;; underlying file descriptor via 'call-with-gzip-input-port'.
(setvbuf socket _IONBF)
(setvbuf socket 'none)
(call-with-values
(lambda ()
(http-get uri #:port socket #:streaming? #t))
(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))))

Loading…
Cancel
Save