system: Clean /tmp and /var/run during early boot.

* gnu/system.scm (operating-system-boot-script): Clean out /tmp and
  /var/run before activating the system.
This commit is contained in:
Mark H Weaver 2015-02-24 23:54:29 -05:00
parent 1b922590d7
commit 5e738ac224

View file

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -695,6 +696,20 @@ (define (operating-system-boot-script os)
(dmd-conf (dmd-configuration-file services))) (dmd-conf (dmd-configuration-file services)))
(gexp->file "boot" (gexp->file "boot"
#~(begin #~(begin
(use-modules (guix build utils))
;; Clean out /tmp and /var/run.
;;
;; XXX This needs to happen before service activations, so
;; it has to be here, but this also implicitly assumes
;; that /tmp and /var/run are on the root partition.
(false-if-exception (delete-file-recursively "/tmp"))
(false-if-exception (delete-file-recursively "/var/run"))
(false-if-exception (mkdir "/tmp"))
(false-if-exception (chmod "/tmp" #o1777))
(false-if-exception (mkdir "/var/run"))
(false-if-exception (chmod "/var/run" #o755))
;; Activate the system. ;; Activate the system.
;; TODO: Use 'load-compiled'. ;; TODO: Use 'load-compiled'.
(primitive-load #$activate) (primitive-load #$activate)