[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
30/35: gnu: hurd: Create minimal "runsystem" script to invoke "rc".
From: |
guix-commits |
Subject: |
30/35: gnu: hurd: Create minimal "runsystem" script to invoke "rc". |
Date: |
Thu, 28 May 2020 13:03:34 -0400 (EDT) |
janneke pushed a commit to branch wip-hurd-vm
in repository guix.
commit d3e4ca1c0dcff51350d4ff678b5859fe57996790
Author: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
AuthorDate: Wed May 6 08:22:41 2020 +0200
gnu: hurd: Create minimal "runsystem" script to invoke "rc".
* gnu/packages/hurd.scm (hurd-rc-script): Update to handle "runsystem"
tasks.
(hurd)[arguments]: Add 'create-runsystem' phase. Do not substitute
now unused init.c, runsystem.hurd.
---
gnu/packages/hurd.scm | 125 ++++++++++++++++++++++++++++++++++++--------------
1 file changed, 90 insertions(+), 35 deletions(-)
diff --git a/gnu/packages/hurd.scm b/gnu/packages/hurd.scm
index 278568b..9f3e945 100644
--- a/gnu/packages/hurd.scm
+++ b/gnu/packages/hurd.scm
@@ -331,8 +331,8 @@ boot, since this cannot be done from GNU/Linux."
(use-modules (guix build utils)
(ice-9 match))
- ;; "@HURD@" is a placeholder.
- (setenv "PATH" "@HURD@/bin")
+ ;; "@HURD@" and "@COREUTILS@" are a placeholders.
+ (setenv "PATH" "@HURD@/bin:@HURD@/sbin:@COREUTILS@/bin")
(define (translated? node)
;; Return true if a translator is installed on NODE.
@@ -342,6 +342,15 @@ boot, since this cannot be done from GNU/Linux."
(lambda ()
(zero? (system* "showtrans" "-s" node)))))))
+ (format #t "Setting / writable...\n")
+ (unless (zero? (system* "fsysopts" "/" "--update" "--writable"))
+ (format #t "FAILED...Good luck!\n"))
+
+ (format #t "settrans pflocal...\n")
+ (mkdir-p "/servers/socket")
+ (unless (zero? (system* "settrans" "-c" "/servers/socket/1"
"/hurd/pflocal"))
+ (format #t "FAILED...Good luck!\n"))
+
(for-each (match-lambda
((node command)
(unless (translated? node)
@@ -349,10 +358,55 @@ boot, since this cannot be done from GNU/Linux."
(apply invoke "settrans" "-c" node command))))
'#$translators)
- ;; Start the oh-so-fancy console client.
- (mkdir-p "/var/run") ;for the PID file
- (invoke "console" "--daemonize" "-c" "/dev/vcs"
- "-d" "vga" "-d" "pc_kbd" "-d" "generic_speaker"))))
+ (format #t "Creating essential device nodes...\n")
+ (with-directory-excursion "/dev"
+ (invoke "MAKEDEV" "--devdir=/dev" "std")
+ (invoke "MAKEDEV" "--devdir=/dev" "vcs")
+ (invoke "MAKEDEV" "--devdir=/dev" "tty1""tty2" "tty3" "tty4"
"tty5" "tty6")
+ (invoke "MAKEDEV" "--devdir=/dev" "ptyp0" "ptyp1" "ptyp2")
+ (invoke "MAKEDEV" "--devdir=/dev" "std")
+ (invoke "MAKEDEV" "--devdir=/dev" "console"))
+
+ ;; Setting current system
+ (unless (file-exists? "/run/current-system/profile")
+ (format #t "Setting current system...\n")
+ (mkdir-p "/run/current-system")
+ (let ((profiles (find-files "/gnu/store"
+ (lambda (name stat)
+ (and (string-suffix? "-profile" name)
+ (eq? 'directory (stat:type
stat))))
+ #:directories? #t)))
+ (when (> (length profiles) 1)
+ (format #t "Too many profiles found...choosing first!\n"))
+ (if (null? profiles)
+ (format #t "No profiles found...Good luck!\n")
+ (symlink (car profiles) "/run/current-system/profile"))))
+
+ ;; Start console?
+ (system* "/run/current-system/profile/bin/bash" "-c" "echo
1>/dev/console")
+
+ (format #t "Starting pager...\n")
+ (unless (zero? (system* "/hurd/mach-defpager"))
+ (format #t "FAILED...Good luck!\n"))
+
+ ;; XXX Activate the system
+ (format #t "Activating system...\n")
+ ;; XXX (primitive-load "/boot/activation")
+ (invoke "/run/current-system/profile/bin/bash" "/boot/activation")
+ ;; Hand over to the Shepherd
+ (let ((shepherd.conf
+ (if (file-exists? "/etc/shepherd.conf")
+ "/etc/shepherd.conf"
+ (let ((files (find-files "/gnu/store"
".*-shepherd.conf")))
+ (and (pair? files) (car files))))))
+ (unless shepherd.conf
+ (format #t "No shepherd.conf found, dropping to a shell...\n")
+ (invoke "/run/current-system/profile/bin/bash")
+ (reboot))
+ (false-if-exception (delete-file "/var/run/shepherd/socket"))
+ (format #t "Starting the Shepherd... ~a\n" shepherd.conf)
+ (execl "/run/current-system/profile/bin/shepherd" "shepherd"
+ "--config" shepherd.conf)))))
;; FIXME: We want the program to use the cross-compiled Guile when
;; cross-compiling. But why do we need to be explicit here?
@@ -425,19 +479,38 @@ boot, since this cannot be done from GNU/Linux."
(substitute* '("daemons/Makefile" "utils/Makefile")
(("-o root -m 4755") ""))
#t))
+ (add-after 'unpack 'create-runsystem
+ (lambda _
+ ;; XXX Work towards having startup.c invoke the Guile rc
+ (delete-file "daemons/runsystem.sh")
+ (with-output-to-file "daemons/runsystem.sh"
+ (lambda _
+ (display "#! /bin/bash
+
+# XXX Guile needs pipe support for its finalizer thread, to start.
+# Remove this script when Linux and the Hurd have xattr patches.
+PATH=@PATH@
+
+fsck --yes --force /
+fsysopts / --writable
+settrans -c /servers/socket/1 /hurd/pflocal
+echo Starting /libexec/rc ...
+exec /libexec/rc
+")))
+ ))
+
(add-before 'build 'set-file-names
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(bash (assoc-ref inputs "bash-minimal"))
(coreutils (assoc-ref inputs "coreutils"))
(sed (assoc-ref inputs "sed"))
- (grep (assoc-ref inputs "grep"))
(util-linux (assoc-ref inputs "util-linux")))
(substitute* '("daemons/runttys.c" "daemons/getty.c"
"utils/login.c")
(("/bin/login")
(string-append out "/bin/login"))
(("/bin/bash") (string-append bash "/bin/bash")))
- (substitute* '("startup/startup.c" "init/init.c" "config/ttys")
+ (substitute* '("startup/startup.c" "config/ttys")
(("/libexec/")
(string-append out "/libexec/")))
(substitute* '("utils/uptime.sh")
@@ -446,36 +519,17 @@ boot, since this cannot be done from GNU/Linux."
(substitute* "daemons/console-run.c"
(("/hurd/")
(string-append out "/hurd/")))
-
(substitute* '("daemons/runsystem.sh"
- "daemons/runsystem.hurd.sh"
"sutils/MAKEDEV.sh")
(("^PATH=.*")
- (string-append "PATH=" out "/bin:" out "/sbin:"
- coreutils "/bin:"
- sed "/bin:" grep "/bin:"
- util-linux "/bin\n"))
- (("^SHELL=.*")
- (string-append "SHELL=" bash "/bin/bash\n"))
+ (string-append "PATH=" out "/bin"
+ ":" out "/sbin"
+ ":" coreutils "/bin"
+ ":" sed "/bin"
+ ":" util-linux "/sbin\n"))
(("/sbin/") (string-append out "/sbin/"))
(("/libexec/") (string-append out "/libexec/"))
(("/hurd/") (string-append out "/hurd/")))
-
- (substitute* "daemons/runsystem.sh"
- (("export PATH")
- (string-append "export PATH\n"
- "\
-fsysopts / --writable
-
-# MAKEDEV relies on pipes so this needs to be set up.
-settrans -c /servers/socket/1 /hurd/pflocal
-
-(cd /dev; MAKEDEV -D /dev std vcs tty{1,2,3,4,5,6})\n")))
-
- (substitute* "daemons/runsystem.hurd.sh"
- (("export PATH")
- "export PATH
-fsysopts / --writable\n"))
#t)))
(add-after 'patch-shebangs 'patch-libexec-shebangs
(lambda* (#:key inputs outputs #:allow-other-keys)
@@ -511,11 +565,13 @@ fsysopts / --writable\n"))
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(file (string-append out "/libexec/rc"))
- (rc (assoc-ref inputs "hurd-rc")))
+ (rc (assoc-ref inputs "hurd-rc"))
+ (coreutils (assoc-ref inputs "coreutils")))
(delete-file file)
(copy-file rc file)
(substitute* file
- (("@HURD@") out))
+ (("@HURD@") out)
+ (("@COREUTILS@") coreutils))
#t))))
#:configure-flags (list (string-append "LDFLAGS=-Wl,-rpath="
%output "/lib")
@@ -544,7 +600,6 @@ fsysopts / --writable\n"))
("bash-minimal" ,bash-minimal)
("coreutils" ,coreutils)
("sed" ,sed)
- ("grep" ,grep)
("util-linux" ,util-linux)))
(native-inputs
`(("autoconf" ,autoconf)
- 04/35: vm: 'qemu-image' preserves the cross-compilation target of the OS., (continued)
- 04/35: vm: 'qemu-image' preserves the cross-compilation target of the OS., guix-commits, 2020/05/28
- 10/35: bootloader: grub: Do not run grub-install when creating a disk-image., guix-commits, 2020/05/28
- 12/35: image: Add bootloader installation support., guix-commits, 2020/05/28
- 19/35: image: Support extra-directives, add hurd-directives., guix-commits, 2020/05/28
- 20/35: system: hurd: Add hurd-default-essential-services., guix-commits, 2020/05/28
- 22/35: bootloader: Extend `<menu-entry>' for multiboot., guix-commits, 2020/05/28
- 27/35: services: hurd: Add `hurd-etc-service'., guix-commits, 2020/05/28
- 11/35: bootloader: grub: Use inheritance to define grub-minimal-bootloader., guix-commits, 2020/05/28
- 24/35: bootloader: grub: Add support for multiboot., guix-commits, 2020/05/28
- 28/35: system: Add `hurd-activation'., guix-commits, 2020/05/28
- 30/35: gnu: hurd: Create minimal "runsystem" script to invoke "rc".,
guix-commits <=
- 33/35: system: hurd: Populate services., guix-commits, 2020/05/28
- 34/35: system: hurd: Remove 'cross-hurd-image' hack., guix-commits, 2020/05/28
- 35/35: system: bare-hurd.tmpl: Add openssh client and service., guix-commits, 2020/05/28