From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id uLYgKjiESWMKewEAbAwnHQ (envelope-from ) for ; Fri, 14 Oct 2022 17:46:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id uMgdKjiESWP5gwAAauVa8A (envelope-from ) for ; Fri, 14 Oct 2022 17:46:00 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 52961135A5 for ; Fri, 14 Oct 2022 17:46:00 +0200 (CEST) Received: from localhost ([::1]:54556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ojMsp-0001Ef-GH for larch@yhetil.org; Fri, 14 Oct 2022 11:45:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojMrv-00019o-CD for bug-guix@gnu.org; Fri, 14 Oct 2022 11:45:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39309) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ojMru-0004BB-9q for bug-guix@gnu.org; Fri, 14 Oct 2022 11:45:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ojMrt-0007Sp-U0 for bug-guix@gnu.org; Fri, 14 Oct 2022 11:45:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#58375: Installer does not show what is being downloaded Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 14 Oct 2022 15:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58375 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: Josselin Poiret , 55360@debbugs.gnu.org, 58375@debbugs.gnu.org Received: via spool by 58375-submit@debbugs.gnu.org id=B58375.166576228128632 (code B ref 58375); Fri, 14 Oct 2022 15:45:01 +0000 Received: (at 58375) by debbugs.gnu.org; 14 Oct 2022 15:44:41 +0000 Received: from localhost ([127.0.0.1]:38383 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojMrY-0007Ri-Lv for submit@debbugs.gnu.org; Fri, 14 Oct 2022 11:44:41 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55044) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ojMrW-0007RP-CH; Fri, 14 Oct 2022 11:44:38 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojMrN-000454-5M; Fri, 14 Oct 2022 11:44:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=fkR9vMg9G4UMYdCbRM4yvWrJz0zSsN7OSxK0cD4/fhs=; b=UGF+J25hLZR5BdXdCDdA 3u8YwVy2cACadWNQ0VE3HIC5vdzS86JeDg9vG2kIe5meQcMbfKYmz6qRNg3cNpfh/g90cv5aGdpVS Yl8+E/80Yy08fVfJZYt/1J4E7m+uzSTK7vQmVAVN8rp0R3Med2u8NYSS3JIFtntTTiucUVNLy+xKh 2M2QZypOdtlwTeYjxjkg1oRMRT6pGQkibEqMvv9IUgDjUDyiW37ZQDAMID+OSFcRjYndN1FodNcTZ aXcH9HuFugADGFZhyhBkst/rpusa/qbfav4B9y+CkI3hSn5yVwaA2gjwxG4UalO6qqB5G/YMwX8iF bb3zTVHEBjaTeg==; Received: from 2a02-8429-81d2-3d01-94c9-8097-ea5c-2775.rev.sfr.net ([2a02:8429:81d2:3d01:94c9:8097:ea5c:2775]:48042 helo=meije) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ojMrM-0004z1-GB; Fri, 14 Oct 2022 11:44:28 -0400 From: Mathieu Othacehe References: <87pmkko21t.fsf@gnu.org> <87y1wqw5tx.fsf@gnu.org> <87lepk5hnh.fsf_-_@gnu.org> <87zgdzq2oe.fsf@gnu.org> Date: Fri, 14 Oct 2022 17:44:24 +0200 In-Reply-To: <87zgdzq2oe.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Thu, 13 Oct 2022 15:21:53 +0200") Message-ID: <871qrabeav.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665762360; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=fkR9vMg9G4UMYdCbRM4yvWrJz0zSsN7OSxK0cD4/fhs=; b=Mw9IOP8ILSRmHmyo57fuwioN+YzdzeID5NPzjrC7F/ihzvV/uc65b9JTDFDdo1ndBsUJ13 Z++PueNAcpctXzraopTMSlfQGwxBccQgbVUJ72PvNtuOj56cOC4nJWjVxNj5EChNx3rlPG WSOcT4jXykuAsUssvlQDxxbCGuZ71ySth0PHaBmwEiQtI03MetF3GMAqqj0Gn9HCN1Uh0/ G0CUZy/IEyhhi0IUwLrjvebIKGB7XrxFSw/6oZgvqiKXcJ2NNfjh+LxOWJSH+pVIoxS3a6 ee+2U2IU9uPbP5NpQZDo4XPlFtZ0sjaLwYhRlMDUi9+SKR5m0L7kzIV/Hcr0RQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665762360; a=rsa-sha256; cv=none; b=tnPjHZgsJnKylY9Yjt46pfXNI1cU1xr1XH0obgzCmgw5O3hx5mLriQoDwEIMrvaqVwK1bL xNFwarsxwhOWDhecOwtA517cwdiFhPo4jO81qVhzwNbexie3vxDhCc0twQV8BySyY/58gl ClatlF+QB5w0T/4PhJlLZ32/h5tWbX1Q4IiIhXFTgBcK34nXnwatxbcuIvc8HKesfsNLyr TqwOtJbogYGmje0BR5GiHmaV/PzIgEHu2cjUoivQFHdUiHyD02AmvWeVeQnW2S1xBsnbjM dLM81SMrnFei7wMK7glxmfQTRc+wkbcC85HM1+4GpjjV+NU0UetR+LR5+2yZpg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=UGF+J25h; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.69 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=UGF+J25h; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 52961135A5 X-Spam-Score: -3.69 X-Migadu-Scanner: scn0.migadu.com X-TUID: QZm26pAeUuOy --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hey, > If we really want to capture the output of =E2=80=98guix system init=E2= =80=99, then we > need to open a pseudo-terminal with =E2=80=98openpty=E2=80=99 & co. inste= ad of =E2=80=98pipe=E2=80=99 in > =E2=80=98run-external-command-with-handler=E2=80=99. That may be relativ= ely easy > actually. So I implemented your proposal. It seems to be working quite well. As discussed on #guix, we could avoid to dump the download bars to the syslog if the "guix system init" command succeeds. However, it seems quite tricky in the current implementation where the syslog dumping is actually a hook (%syslog-line-hook). Fixing this issue, I also realized that when the "guix system init" command fails, the user is only offered to resume the installation or restart it. In cases where "guix system init" failed because of a network issue, or because a partition was too small, restarting/resuming seems like the right thing to do. However, when the installer failed because "guix system init" crashed or segfaulted, restarting/resuming won't probably help, and dumping the crash is probably the best way to get help. That's why I added in a second patch, a new button "Report the failure" to the "run-install-failed-page". Thanks, Mathieu --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-installer-Run-the-guix-system-init-command-in-a-PTY.patch >From c6286404e9c4c0dc302c3d398a8f27b050cf4ce0 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 14 Oct 2022 17:28:27 +0200 Subject: [PATCH 1/2] installer: Run the "guix system init" command in a PTY. Fixes: * gnu/installer/utils.scm (run-external-command-with-handler/tty): New procedure. (run-external-command-with-line-hooks, run-command): Add a TTY? argument. * gnu/installer/final.scm (install-system): Call run-command with TTY? argument set to #true. --- gnu/installer/final.scm | 2 +- gnu/installer/utils.scm | 50 +++++++++++++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm index 3f6dacc490..044f79372b 100644 --- a/gnu/installer/final.scm +++ b/gnu/installer/final.scm @@ -211,7 +211,7 @@ (define (assert-exit x) (setenv "PATH" "/run/current-system/profile/bin/") - (set! ret (run-command install-command))) + (set! ret (run-command install-command #:tty? #t))) (lambda () ;; Restart guix-daemon so that it does no keep the MNT namespace ;; alive. diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm index 5fd2e2d425..061493e6a7 100644 --- a/gnu/installer/utils.scm +++ b/gnu/installer/utils.scm @@ -20,6 +20,7 @@ (define-module (gnu installer utils) #:use-module (gnu services herd) #:use-module (guix utils) + #:use-module ((guix build syscalls) #:select (openpty login-tty)) #:use-module (guix build utils) #:use-module (guix i18n) #:use-module (srfi srfi-1) @@ -45,6 +46,7 @@ (define-module (gnu installer utils) nearest-exact-integer read-percentage run-external-command-with-handler + run-external-command-with-handler/tty run-external-command-with-line-hooks run-command run-command-in-installer @@ -124,10 +126,37 @@ (define dummy-pipe (close-port input) (close-pipe dummy-pipe))) -(define (run-external-command-with-line-hooks line-hooks command) +(define (run-external-command-with-handler/tty handler command) + "Run command specified by the list COMMAND in a child operating in a +pseudoterminal with output handler HANDLER. HANDLER is a procedure taking an +input port, to which the command will write its standard output and error. +Returns the integer status value of the child process as returned by waitpid." + (define-values (controller inferior) + (openpty)) + + (match (primitive-fork) + (0 + (catch #t + (lambda () + (close-fdes controller) + (login-tty inferior) + (apply execlp (car command) command)) + (lambda _ + (primitive-exit 127)))) + (pid + (close-fdes inferior) + (let* ((port (fdopen controller "r0")) + (result (false-if-exception + (handler port)))) + (close-port port) + (cdr (waitpid pid)))))) + +(define* (run-external-command-with-line-hooks line-hooks command + #:key (tty? #false)) "Run command specified by the list COMMAND in a child, processing each -output line with the procedures in LINE-HOOKS. Returns the integer status -value of the child process as returned by waitpid." +output line with the procedures in LINE-HOOKS. If TTY is set to #true, the +COMMAND will be run in a pseudoterminal. Returns the integer status value of +the child process as returned by waitpid." (define (handler input) (and (and=> (get-line input) @@ -136,14 +165,17 @@ (define (handler input) #f (begin (for-each (lambda (f) (f line)) (append line-hooks - %default-installer-line-hooks)) + %default-installer-line-hooks)) #t)))) (handler input))) - (run-external-command-with-handler handler command)) + (if tty? + (run-external-command-with-handler/tty handler command) + (run-external-command-with-handler handler command))) -(define* (run-command command) +(define* (run-command command #:key (tty? #f)) "Run COMMAND, a list of strings. Return true if COMMAND exited -successfully, #f otherwise." +successfully, #f otherwise. If TTY is set to #true, the COMMAND will be run +in a pseudoterminal." (define (pause) (format #t (G_ "Press Enter to continue.~%")) (send-to-clients '(pause)) @@ -154,8 +186,8 @@ (define (pause) (installer-log-line "running command ~s" command) (define result (run-external-command-with-line-hooks - (list %display-line-hook) - command)) + (list %display-line-hook) command + #:tty? tty?)) (define exit-val (status:exit-val result)) (define term-sig (status:term-sig result)) (define stop-sig (status:stop-sig result)) -- 2.37.3 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-installer-Propose-the-user-to-report-a-guix-system-i.patch >From 159b82a013cad8c3c698031cce9ee07956153da3 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 14 Oct 2022 17:33:28 +0200 Subject: [PATCH 2/2] installer: Propose the user to report a "guix system init" failure. * gnu/installer/newt/final.scm (run-install-failed-page): Add a "Report the failure" button. --- gnu/installer/newt/final.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm index 7c3f73ee82..6e55be5067 100644 --- a/gnu/installer/newt/final.scm +++ b/gnu/installer/newt/final.scm @@ -80,16 +80,21 @@ (define (run-install-success-page) (define (run-install-failed-page) (match (current-clients) (() - (match (choice-window + (match (ternary-window (G_ "Installation failed") (G_ "Resume") (G_ "Restart the installer") + (G_ "Report the failure") (G_ "The final system installation step failed. You can resume from \ a specific step, or restart the installer.")) (1 (abort-to-prompt 'installer-step 'abort)) (2 ;; Keep going, the installer will be restarted later on. - #t))) + #t) + (3 (raise + (condition + (&message + (message "User abort."))))))) (_ (send-to-clients '(installation-failure)) #t))) -- 2.37.3 --=-=-=--