+ (lambda _
+ ;; Don't change the ownership of any file at this time.
+ (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
+
+# Note: this /hurd/ gets substituted
+settrans --create /servers/socket/1 /hurd/pflocal
+
+# parse multiboot arguments
+for i in \"$@\"; do
+ case $i in
+ (--system=*)
+ system=${i#--system=}
+ ;;
+ esac
+done
+
+echo Starting ${system}/rc...
+exec ${system}/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" "config/ttys")
+ (("/libexec/")
+ (string-append out "/libexec/")))
+ (substitute* '("utils/uptime.sh")
+ (("/bin/w")
+ (string-append out "/bin/w")))
+ ;; Upon first boot the /hurd symlink does not exist; it is
+ ;; created during activation: Hard-code the .../hurd store file
+ ;; name.
+ (substitute* '("boot/boot.c"
+ "daemons/console-run.c"
+ "startup/startup.c")
+ (("/hurd/")
+ (string-append out "/hurd/")))
+ (substitute* '("libdiskfs/boot-start.c"
+ "libdiskfs/opts-std-startup.c")
+ (("_HURD_STARTUP")
+ (string-append "\"" out "/hurd/startup\"")))
+ (substitute* '("daemons/runsystem.sh"
+ "utils/fakeroot.sh"
+ "utils/remap.sh"
+ "sutils/MAKEDEV.sh"
+ "sutils/losetup.sh")
+ (("^PATH=.*")
+ (string-append "PATH=" out "/bin"
+ ":" out "/sbin"
+ ":" coreutils "/bin"
+ ":" grep "/bin"
+ ":" sed "/bin"
+ ":" util-linux "/sbin\n"))
+ (("/sbin/") (string-append out "/sbin/"))
+ (("/libexec/") (string-append out "/libexec/"))
+ (("/hurd/") (string-append out "/hurd/")))
+ #t)))
+ (add-after 'patch-shebangs 'patch-libexec-shebangs
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; XXX: Since the 'patch-shebangs' phase doesn't traverse
+ ;; /libexec, do it here.
+ (let* ((out (assoc-ref outputs "out"))
+ (bash (assoc-ref inputs "bash-minimal"))
+ (path (list (string-append bash "/bin"))))
+ (for-each (lambda (file)
+ (patch-shebang file path))
+ (find-files (string-append out "/libexec")))
+ #t)))
+ (add-after 'install 'install-goodies
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ ;; Install additional goodies.
+ ;; TODO: Build & install *.msgids for rpctrace.
+ (let* ((out (assoc-ref outputs "out"))
+ (datadir (string-append out "/share/hurd")))
+ ;; Install the fancy UTF-8 motd.
+ (mkdir-p (string-append out "/etc"))
+ (copy-file "console/motd.UTF8"
+ (string-append out "/etc/motd"))
+
+ ;; Install the BDF font for use by the console client.
+ (copy-file (assoc-ref inputs "unifont")
+ "unifont.gz")
+ (invoke "gunzip" "unifont.gz")
+ (mkdir-p datadir)
+ (copy-file "unifont"
+ (string-append datadir "/vga-system.bdf"))
+ #t))))