Ludovic Courtès writes: Hi! > "Jan (janneke) Nieuwenhuizen" skribis: > >> * gnu/build/hurd-boot.scm (make-hurd-device-nodes): Do not create >> dev/{null,zero,full,random,urandom} mount points. >> (setup-translator, xattr-translator, >> showtrans-translator?, translated?, set-hurd-device-translators): New >> procedures. >> (boot-hurd-system): Use them instead of running MAKEDEV. > > This is mostly about moving the logic from the MAKEDEV script to this > file, right? Sounds nice. Yes. Glad you like the idea too. >> +(define (xattr-translator? file-name) >> + "Return true if FILE-NAME has an extended @code{gnu.translator} attribute >> +set." >> + (false-if-exception >> + (not (string-null? (getxattr file-name "gnu.translator"))))) > > I’d call it ‘passive-translator-xattr?’. > In general, I’d avoid ‘false-if-exception’ as much as possible because > it can hide real issues. So here, you could catch 'system-error and > check for ENODATA. If you need it in several places, you can define a > ‘false-if-ENODATA’ macro Nice. Ah, I remember having file-exists? checks or no check at all and then found it only worked on first boot, not with a persistent image. Minor detail. So I got out my axe and..."it worked" :-/ >> +(define (showtrans-translator? file-name) >> + "Return true if @file{showtrans} finds a translator installed on FILE-NAME." > > Should be ‘passive-translator-installed?’ no? (IIRC ‘showtrans’ only > shows passive translator settings by default.) Yes, thanks. >> + (with-output-to-port (%make-void-port "w") >> + (lambda _ >> + (with-error-to-port (%make-void-port "w") >> + (lambda _ >> + (zero? (system* "showtrans" "--silent" file-name))))))) >> + >> +(define (translated? file-name) >> + "Return true if a translator is installed on FILE-NAME." >> + (if (string-contains %host-type "linux-gnu") >> + (xattr-translator? file-name) >> + (showtrans-translator? file-name))) > > It’s counter-intuitive that hurd-boot.scm is used from GNU/Linux. > Should we move the shared bits in (gnu build hurd) or similar? Maybe...I don't know. hurd-boot defines functions that are needed to create a bootable hurd -- some can be called from GNU/Linux. Similarly, "linux-boot" defines "make-essential-device-nodes", which could be called from GNU/Hurd when we cross build a linux VM. Well, having one weird situation is a bad argument to propagate the madness. I guess it makes sense to move utility functions like passive-translator-xattr, passive-translator-installed?, and translated? could be moved to (gnu build hurd). Haven't made this change yet, let me know you want; or feel free to make the change yourself :-) >> +(define* (setup-translator file-name command #:optional (mode #o600)) >> + "Setup translator COMMAND on FILE-NAME." > > ‘set-translator’? :-) => set-translator! :-) >> + (false-if-exception (mkdir-p (scope "dev/vcs/1"))) >> + (false-if-exception (mkdir-p (scope "dev/vcs/2"))) >> + (false-if-exception (mkdir-p (scope "dev/vcs/3"))) >> + (false-if-exception (rename-file "/dev/console" "/dev/console-")) >> + (for-each scope-setup-translator devices) >> + >> + (false-if-exception (symlink "/dev/random" "/dev/urandom")) >> + (false-if-exception (mkdir-p "/dev/fd")) >> + (false-if-exception (symlink "/dev/fd/0" "/dev/stdin")) >> + (false-if-exception (symlink "/dev/fd/1" "/dev/stdout")) >> + (false-if-exception (symlink "/dev/fd/2" "/dev/stderr"))) > > ‘false-if-EEXIST’? Done for symlink; for mkdir, using (define (mkdir* dir) (let ((dir (scope dir))) (unless (file-exists? dir) (mkdir-p dir)))) New patch attached. Greetings, Janneke