From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ek95x-0002LL-PJ for guix-patches@gnu.org; Fri, 09 Feb 2018 08:52:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ek95u-0005DI-MO for guix-patches@gnu.org; Fri, 09 Feb 2018 08:52:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:55120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ek95u-0005Cs-IQ for guix-patches@gnu.org; Fri, 09 Feb 2018 08:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ek95u-0002Qc-8r for guix-patches@gnu.org; Fri, 09 Feb 2018 08:52:02 -0500 Subject: [bug#30355] [PATCH] services: agetty: Make tty optional and add agetty instance to base services. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20180205081553.5930-1-dannym@scratchpost.org> Date: Fri, 09 Feb 2018 14:51:12 +0100 In-Reply-To: <20180205081553.5930-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Mon, 5 Feb 2018 09:15:53 +0100") Message-ID: <87d11e1dbj.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: 30355@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-serial-port): New variable. > (agetty-shepherd-service): Make tty optional, default to the above. > * doc/guix.texi (agetty-configuration): Update "tty" documentation. I would prefer the install.scm part to be a separate patch, if that=E2=80= =99s not too much of a burden for you. I have a few minor comments: > @item @code{tty} > The name of the console this agetty runs on, as a string---e.g., > -@code{"ttyS0"}. This argument is mandatory. > +@code{"ttyS0"}. This argument is optional, it will default to > +a reasonable default serial port used by Linux. s/Linux/the kernel Linux/ (to avoid ambiguities=E2=80=A6) > +For this, if there is a value for an option "agetty.tty" in the Linux > +command line, agetty will extract the device name of the serial port > +from it and use that. > + > +If not and if there is a value for an option "console" with a tty in > +the Linux command line, agetty will extract the device name of the > +serial port from it and use that. @code{agetty.tty}, @code{console}, etc. Write =E2=80=9Ckernel command line=E2=80=9D instead of =E2=80=9CLinux comma= nd line=E2=80=9D. > +In both cases, agetty will leave the other serial device settings > +(baud rate etc) alone - in the hope that Linux pinned them to the > +correct values. s/etc/etc./ s/alone - in the hope/alone---in the hope/ (The three hyphens map to an em dash in the output.) > +(define (default-serial-port) > + "Return a gexp that determines a reasonable default serial port > +to use as the tty. This is primarily useful for headless systems." > + #~(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 (gnu build linux-boot)) > + (let* ((not-comma (char-set-complement (char-set #\,))) > + (command (linux-command-line)) > + (agetty-specs (find-long-options "agetty.tty" command)) > + (console-specs (filter (lambda (spec) > + (not (or > + (string-prefix? "tty0" spec) > + (string-prefix? "tty1" spec) > + (string-prefix? "tty2" spec) > + (string-prefix? "tty3" spec) > + (string-prefix? "tty4" spec) > + (string-prefix? "tty5" spec) > + (string-prefix? "tty6" spec) > + (string-prefix? "tty7" spec) > + (string-prefix? "tty8" spec) > + (string-prefix? "tty9" spec)= ))) > + (filter > + (lambda (spec) > + (string-prefix? "tty" spec)) > + (find-long-options "console" comman= d)))) Please make that a single =E2=80=98filter=E2=80=99 or =E2=80=98remove=E2=80= =99 call, for clarity. > + (specs (append agetty-specs console-specs)) > + (spec (if (null? specs) > + #f > + (car specs)))) > + (and spec > + ;; Extract device name. > + (car (string-tokenize spec not-comma)))))) Rather: (match (append agetty-specs console-specs) (() #f) ((spec _ ...) (string-tokenize spec not-comma))) The rest LGTM. OK to push with these changes! Thanks, Ludo=E2=80=99.