summaryrefslogtreecommitdiff
path: root/gnu/build
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/build')
-rw-r--r--gnu/build/cross-toolchain.scm9
-rw-r--r--gnu/build/install.scm18
-rw-r--r--gnu/build/linux-boot.scm35
-rw-r--r--gnu/build/vm.scm51
4 files changed, 90 insertions, 23 deletions
diff --git a/gnu/build/cross-toolchain.scm b/gnu/build/cross-toolchain.scm
index 6bdbdd5411..9746be3e50 100644
--- a/gnu/build/cross-toolchain.scm
+++ b/gnu/build/cross-toolchain.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2016 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
@@ -38,8 +38,11 @@
(define %gcc-include-paths
;; Environment variables for header search paths.
- ;; Note: See <http://bugs.gnu.org/30756> for why not 'C_INCLUDE_PATH' & co.
- '("CPATH"))
+ ;; Note: See <http://bugs.gnu.org/22186> for why not 'CPATH'.
+ '("C_INCLUDE_PATH"
+ "CPLUS_INCLUDE_PATH"
+ "OBJC_INCLUDE_PATH"
+ "OBJCPLUS_INCLUDE_PATH"))
(define %gcc-cross-include-paths
;; Search path for target headers when cross-compiling.
diff --git a/gnu/build/install.scm b/gnu/build/install.scm
index b18654f1cc..87aa5d68da 100644
--- a/gnu/build/install.scm
+++ b/gnu/build/install.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -76,6 +76,13 @@ the context of the caller. If the directive matches those defaults then,
(('directory name uid gid mode)
(loop `(directory ,name ,uid ,gid))
(chmod (string-append target name) mode))
+ (('file name)
+ (call-with-output-file (string-append target name)
+ (const #t)))
+ (('file name (? string? content))
+ (call-with-output-file (string-append target name)
+ (lambda (port)
+ (display content port))))
((new '-> old)
(let try ()
(catch 'system-error
@@ -126,11 +133,14 @@ STORE."
(directory "/home" 0 0)))
-(define (populate-root-file-system system target)
+(define* (populate-root-file-system system target
+ #:key (extras '()))
"Make the essential non-store files and directories on TARGET. This
-includes /etc, /var, /run, /bin/sh, etc., and all the symlinks to SYSTEM."
+includes /etc, /var, /run, /bin/sh, etc., and all the symlinks to SYSTEM.
+EXTRAS is a list of directives appended to the built-in directives to populate
+TARGET."
(for-each (cut evaluate-populate-directive <> target)
- (directives (%store-directory)))
+ (append (directives (%store-directory)) extras))
;; Add system generation 1.
(let ((generation-1 (string-append target
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 05e833c0c6..c6f9df5f29 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
;;;
@@ -40,6 +40,7 @@
find-long-option
find-long-options
make-essential-device-nodes
+ make-hurd-device-nodes
make-static-device-nodes
configure-qemu-networking
@@ -223,7 +224,7 @@ one specific hardware device. These we have to create."
(call-with-input-file devname-name
read-static-device-nodes))))
-(define* (make-essential-device-nodes #:key (root "/"))
+(define* (make-essential-device-nodes #:optional (root "/"))
"Make essential device nodes under ROOT/dev."
;; The hand-made devtmpfs/udev!
@@ -323,6 +324,36 @@ one specific hardware device. These we have to create."
;; File systems in user space (FUSE).
(mknod (scope "dev/fuse") 'char-special #o666 (device-number 10 229)))
+(define* (make-hurd-device-nodes #:optional (root "/"))
+ "Make some of the nodes needed on GNU/Hurd."
+ (define (scope dir)
+ (string-append root
+ (if (string-suffix? "/" root)
+ ""
+ "/")
+ dir))
+
+ (mkdir (scope "dev"))
+ (for-each (lambda (file)
+ (call-with-output-file (scope file)
+ (lambda (port)
+ (chmod port #o666))))
+ '("dev/null"
+ "dev/zero"
+ "dev/full"
+ "dev/random"
+ "dev/urandom"))
+ ;; Don't create /dev/console, /dev/vcs, etc.: they are created by
+ ;; console-run on first boot.
+
+ (mkdir (scope "servers"))
+ (mkdir (scope "servers/socket"))
+ ;; Don't create /servers/socket/1 & co: runsystem does that on first boot.
+
+ ;; TODO: Set the 'gnu.translator' extended attribute for passive translator
+ ;; settings?
+ )
+
(define %host-qemu-ipv4-address
(inet-pton AF_INET "10.0.2.10"))
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 1a888b1a51..433b5a7e8d 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -34,6 +34,7 @@
#:use-module (guix records)
#:use-module ((guix combinators) #:select (fold2))
#:use-module (ice-9 format)
+ #:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
#:use-module (ice-9 popen)
@@ -234,6 +235,8 @@ deduplicates files common to CLOSURE and the rest of PREFIX."
(device partition-device (default #f))
(size partition-size)
(file-system partition-file-system (default "ext4"))
+ (file-system-options partition-file-system-options ;passed to 'mkfs.FS'
+ (default '()))
(label partition-label (default #f))
(uuid partition-uuid (default #f))
(flags partition-flags (default '()))
@@ -308,7 +311,7 @@ actual /dev name based on DEVICE."
(define MS_BIND 4096) ; <sys/mounts.h> again!
(define* (create-ext-file-system partition type
- #:key label uuid)
+ #:key label uuid (options '()))
"Create an ext-family file system of TYPE on PARTITION. If LABEL is true,
use that as the volume name. If UUID is true, use it as the partition UUID."
(format #t "creating ~a partition... ~@[label: ~s~] ~@[uuid: ~s~]\n"
@@ -320,26 +323,29 @@ use that as the volume name. If UUID is true, use it as the partition UUID."
'())
,@(if uuid
`("-U" ,(uuid->string uuid))
- '()))))
+ '())
+ ,@options)))
(define* (create-fat-file-system partition
- #:key label uuid)
+ #:key label uuid (options '()))
"Create a FAT file system on PARTITION. The number of File Allocation Tables
will be determined based on file system size. If LABEL is true, use that as the
volume name."
;; FIXME: UUID is ignored!
(format #t "creating FAT partition...\n")
(apply invoke "mkfs.fat" partition
- (if label `("-n" ,label) '())))
+ (append (if label `("-n" ,label) '()) options)))
(define* (format-partition partition type
- #:key label uuid)
+ #:key label uuid (options '()))
"Create a file system TYPE on PARTITION. If LABEL is true, use that as the
-volume name."
+volume name. Options is a list of command-line options passed to 'mkfs.FS'."
(cond ((string-prefix? "ext" type)
- (create-ext-file-system partition type #:label label #:uuid uuid))
+ (create-ext-file-system partition type #:label label #:uuid uuid
+ #:options options))
((or (string-prefix? "fat" type) (string= "vfat" type))
- (create-fat-file-system partition #:label label #:uuid uuid))
+ (create-fat-file-system partition #:label label #:uuid uuid
+ #:options options))
(else (error "Unsupported file system."))))
(define (initialize-partition partition)
@@ -349,7 +355,8 @@ it, run its initializer, and unmount it."
(format-partition (partition-device partition)
(partition-file-system partition)
#:label (partition-label partition)
- #:uuid (partition-uuid partition))
+ #:uuid (partition-uuid partition)
+ #:options (partition-file-system-options partition))
(mkdir-p target)
(mount (partition-device partition) target
(partition-file-system partition))
@@ -363,14 +370,20 @@ it, run its initializer, and unmount it."
copy-closures?
(register-closures? #t)
system-directory
- (deduplicate? #t))
+ (deduplicate? #t)
+ (make-device-nodes
+ make-essential-device-nodes)
+ (extra-directives '()))
"Return a procedure to initialize a root partition.
If REGISTER-CLOSURES? is true, register all of CLOSURES in the partition's
store. If DEDUPLICATE? is true, then also deduplicate files common to
CLOSURES and the rest of the store when registering the closures. If
COPY-CLOSURES? is true, copy all of CLOSURES to the partition.
-SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
+SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation.
+
+EXTRA-DIRECTIVES is an optional list of directives to populate the root file
+system that is passed to 'populate-root-file-system'."
(lambda (target)
(define target-store
(string-append target (%store-directory)))
@@ -381,7 +394,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
target))
;; Populate /dev.
- (make-essential-device-nodes #:root target)
+ (make-device-nodes target)
;; Optionally, register the inputs in the image's store.
(when register-closures?
@@ -403,12 +416,22 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
;; Add the non-store directories and files.
(display "populating...\n")
- (populate-root-file-system system-directory target)
+ (populate-root-file-system system-directory target
+ #:extras extra-directives)
;; 'register-closure' resets timestamps and everything, so no need to do it
;; once more in that case.
(unless register-closures?
- (reset-timestamps target))))
+ ;; 'reset-timestamps' also resets file permissions; do that everywhere
+ ;; except on /dev so that /dev/null remains writable, etc.
+ (for-each (lambda (directory)
+ (reset-timestamps (string-append target "/" directory)))
+ (scandir target
+ (match-lambda
+ ((or "." ".." "dev") #f)
+ (_ #t))))
+ (reset-timestamps (string-append target "/dev")
+ #:preserve-permissions? #t))))
(define (register-bootcfg-root target bootcfg)
"On file system TARGET, register BOOTCFG as a GC root."