[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#30355] [PATCH] services: agetty: Make tty optional and add agetty i
From: |
Ludovic Courtès |
Subject: |
[bug#30355] [PATCH] services: agetty: Make tty optional and add agetty instance to base services. |
Date: |
Fri, 09 Feb 2018 23:00:27 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Danny Milosavljevic <address@hidden> skribis:
>> Please make that a single ‘filter’ or ‘remove’ call, for clarity.
>
> OK!
>
>> Rather:
>>
>> (match (append agetty-specs console-specs)
>> (() #f)
>> ((spec _ ...)
>> (string-tokenize spec not-comma)))
>
> Crashes boot process with form error ().
>
> I can't get "match" to work at all in this location.
>
> It works fine when I start guile on a normally running system, but
> in this initrd guile thing, (use-modules (ice-9 match)) doesn't help
> either. What does help is (@ (ice-9 match) match). Why?
>
> (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=device,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)
> (and (string-prefix? "tty" 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)))))
> (find-long-options "console" command)))
> (specs (append agetty-specs console-specs)))
> (use-modules (ice-9 match))
> (match specs
> (() #f) ; form error here
> ((spec _ ...) ; underscore is undefined
> ;; Extract device name from first spec.
> (match (string-tokenize spec not-comma)
> ((device-name _ ...) ; underscore is undefined
> device-name)))))))
Try moving the ‘use-modules’ form at the top so you have:
(use-modules (gnu build linux-boot) (ice-9 match))
The inner ‘use-modules’ you had cannot work because the expander doesn’t
“see” it when compiling, and thus the ‘match’ macro is missing at
expansion time (thus the compiler assumes that code is calling a ‘match’
procedure that’ll be define at run time.) However it can work when you
interpret it instead of compiling because the compiler will have
expansion and execution intermingled.
HTH,
Ludo’.