From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egcyo-0007cF-AV for guix-patches@gnu.org; Tue, 30 Jan 2018 15:59:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egcxi-00017n-MG for guix-patches@gnu.org; Tue, 30 Jan 2018 15:58:10 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:41966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egcxi-000170-7n for guix-patches@gnu.org; Tue, 30 Jan 2018 15:57:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1egcxh-0005YX-SN for guix-patches@gnu.org; Tue, 30 Jan 2018 15:57:01 -0500 Subject: [bug#30216] [WIP v5] services: agetty: Make tty optional. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20180124131219.14202-1-dannym@scratchpost.org> <20180124133147.15060-1-dannym@scratchpost.org> Date: Tue, 30 Jan 2018 21:56:37 +0100 In-Reply-To: <20180124133147.15060-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Wed, 24 Jan 2018 14:31:47 +0100") Message-ID: <87r2q7vzei.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Danny Milosavljevic Cc: 30216@debbugs.gnu.org Hi, Danny Milosavljevic skribis: > * gnu/system/install.scm (agetty-default-service): Delete variable. > (beaglebone-black-installation-os): Do not specify tty. > (a20-olinuxino-lime-installation-os): Do not specify tty. > (a20-olinuxino-lime2-emmc-installation-os): Do not specify tty. > (a20-olinuxino-micro-installation-os): Do not specify tty. > (banana-pi-m2-ultra-installation-os): Do not specify tty. > (nintendo-nes-classic-edition-installation-os): Do not specify tty. > (embedded-installation-os): Move agetty-service instantiation to... > * gnu/services/base.scm (%base-services): ...here. > (default-tty): New variable. > (agetty-shepherd-service): Make tty optional, default to the above. Neat, it looks better than hardcoding a default tty for each of these machines. :-) > +(define (default-tty) Could you add a docstring, like, IIUC: =E2=80=9CReturn a gexp that determin= es a reasonable default serial port to use as the tty. This is primarily useful for headless systems such as ARM SoCs.=E2=80=9D In the manual, for the agetty service, it would be good to document the =E2=80=98agetty.tty=E2=80=99 kernel command-line option. Perhaps =E2=80=98default-serial-port=E2=80=99 is more appropriate in fact? > + #~(begin > + ;; console=3Ddevice,options > + ;; device: can be tty0, ttyS0, lp0, ttyUSB0 (serial). > + ;; options: BBBBPNF. P n|o|e, N number of bits, > + ;; F flow control (r RTS) > + (use-modules (rnrs io ports)) > + (let* ((command (call-with-input-file "/proc/cmdline" get-string-a= ll)) > + (not-comma (char-set-complement (char-set #\,))) > + (items (string-tokenize command)) > + (items-by-key (lambda (key target-prefix) > + (let ((keylen (string-length key))) > + (map (lambda (a) > + (string-append target-prefix > + (string-drop a keyle= n))) > + (filter (lambda (b) > + (string-prefix? key b)) ite= ms))))) > + (agetty-ttys (items-by-key "agetty.tty=3D" "")) Rather use =E2=80=98linux-command-line=E2=80=99 from (gnu build linux-boot). =E2=80=98find-long-option=E2=80=99 in the same module does almost what you = want, but if you really want to support repeated =E2=80=9Cagetty.tty=E2=80=9D options, y= ou=E2=80=99ll have to make a new =E2=80=98find-long-options=E2=80=99 (plural) variant. > + (console-ttys (filter (lambda (tty) > + (not (or > + (string-prefix? tty "tty0") > + (string-prefix? tty "tty1") > + (string-prefix? tty "tty2") > + (string-prefix? tty "tty3") > + (string-prefix? tty "tty4") > + (string-prefix? tty "tty5") > + (string-prefix? tty "tty6") > + (string-prefix? tty "tty7") > + (string-prefix? tty "tty8") > + (string-prefix? tty "tty9"))= )) > + (items-by-key "console=3Dtty" "tty"))) I think this would work: (let* ((consoles (find-long-option "console" (linux-command-line))) (console-ttys (remove (lambda (console) (string-prefix? "tty" console)) (string-tokenize consoles not-comma)))) =E2=80=A6) > + (ttys (or agetty-ttys (map (lambda (console-spec) > + ;; Extract device name. > + (car (string-tokenize console-= spec > + not-comm= a))) > + console-ttys)))) > + (if (null? ttys) > + "XXX" ; would crash entire boot process: (error "agetty: No de= fault tty found.") > + (car ttys))))) Maybe default to /dev/ttyS0? Could you send an updated patch? Thanks, Ludo=E2=80=99.