gnu: texlive-latex-amsmath: Declare a source file-name.
[jackhill/guix/guix.git] / build-aux / build-self.scm
index 8fb9af2..4c85c09 100644 (file)
@@ -44,6 +44,9 @@
 ;; could be renamed or shuffled around in modules over time.  Conversely,
 ;; 'find-best-packages-by-name' is expected to always have the same semantics.
 
+(define guix
+  (first (find-best-packages-by-name "guix" #f)))
+
 (define libgcrypt
   (first (find-best-packages-by-name "libgcrypt" #f)))
 
@@ -120,13 +123,30 @@ person's version identifier."
   ;; XXX: Replace with a Git commit id.
   (date->string (current-date 0) "~Y~m~d.~H"))
 
+(define (matching-guile-2.2)
+  "Return a Guile 2.2 with the same version as the current one or immediately
+older than then current one.  This is so that we do not build ABI-incompatible
+objects.  See <https://bugs.gnu.org/29570>."
+  (let loop ((packages (find-packages-by-name "guile" "2.2"))
+             (best     #f))
+    (match packages
+      (()
+       best)
+      ((head tail ...)
+       (if (string=? (package-version head) (version))
+           head
+           (if best
+               (if (version>? (package-version head) (version))
+                   (loop tail best)
+                   (loop tail head))
+               (loop tail head)))))))
+
 (define (guile-for-build)
   "Return a derivation for Guile 2.0 or 2.2, whichever matches the currently
 running Guile."
   (package->derivation (cond-expand
                          (guile-2.2
-                          (canonical-package
-                           (specification->package "guile@2.2")))
+                          (canonical-package (matching-guile-2.2)))
                          (else
                           (canonical-package
                            (specification->package "guile@2.0"))))))
@@ -148,8 +168,6 @@ files."
     (if (defined? '%localstatedir) %localstatedir (dirname %state-directory)))
   (define sysconfdir
     (if (defined? '%sysconfdir) %sysconfdir (dirname %config-directory)))
-  (define sbindir
-    (if (defined? '%sbindir) %sbindir (dirname %guix-register-program)))
 
   (define builder
     #~(begin
@@ -205,7 +223,7 @@ files."
                     #:storedir #$storedir
                     #:localstatedir #$localstatedir
                     #:sysconfdir #$sysconfdir
-                    #:sbindir #$sbindir
+                    #:sbindir (string-append #$guix "/sbin")
 
                     #:package-name #$%guix-package-name
                     #:package-version #$version
@@ -224,14 +242,33 @@ files."
                                      (current-error-port)
                                      (%make-void-port "w")))))
 
+  (unless guile-git
+    ;; XXX: Guix before February 2017 lacks a 'guile-git' package altogether.
+    ;; If we try to upgrade anyway, the logic in (guix scripts pull) will not
+    ;; build (guix git), which will leave us with an unusable 'guix pull'.  To
+    ;; avoid that, fail early.
+    (format (current-error-port)
+            "\
+Your installation is too old and lacks a '~a' package.
+Please upgrade to an intermediate version first, for instance with:
+
+  guix pull --url=https://git.savannah.gnu.org/cgit/guix.git/snapshot/v0.13.0.tar.gz
+\n"
+            (match (effective-version)
+              ("2.0" "guile2.0-git")
+              (_     "guile-git")))
+    (exit 1))
+
   (mlet %store-monad ((guile (guile-for-build)))
     (gexp->derivation "guix-latest" builder
                       #:modules '((guix build pull)
                                   (guix build utils)
+                                  (guix build compile)
 
                                   ;; Closure of (guix modules).
                                   (guix modules)
                                   (guix memoization)
+                                  (guix profiling)
                                   (guix sets))
 
                       ;; Arrange so that our own (guix build …) modules are