-
Notifications
You must be signed in to change notification settings - Fork 3
/
self-upgrade.lisp
38 lines (33 loc) · 1.82 KB
/
self-upgrade.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
;;; Shell command-line interface for XCVB
#+xcvb
(module (:depends-on ("commands")))
(in-package :xcvb)
(declaim (optimize (speed 1) (safety 3) (compilation-speed 0) (debug 3)))
(defun reduce-xcvb-version (version)
(subseq version 0
(position-if-not (lambda (x) (or (digit-char-p x) (eql x #\.))) version)))
(defun ensure-required-xcvb-version (required-xcvb-version)
(when required-xcvb-version
(let ((reduced-required-version (reduce-xcvb-version required-xcvb-version))
(reduced-current-version (reduce-xcvb-version (or *xcvb-version* (get-xcvb-version)))))
(unless (asdf:version-satisfies reduced-current-version reduced-required-version)
(log-format 1 "This is XCVB ~A but version ~A was required"
*xcvb-version* required-xcvb-version)
(flet ((abend (fmt &rest args)
(errexit 18 "Can't recompile XCVB ~A or newer: ~?."
required-xcvb-version fmt args)))
(unless (get-xcvb-directory)
(abend "cannot find source directory for XCVB"))
(log-format 5 "Found XCVB source in ~A" (get-xcvb-directory))
(let* ((source-version (get-xcvb-version))
(reduced-source-version (reduce-xcvb-version source-version)))
(unless source-version
(abend "no version found in XCVB source code."))
(unless (asdf:version-satisfies reduced-source-version reduced-required-version)
(abend "found insufficient source XCVB version ~A" source-version))
(unless (build-xcvb *xcvb-program*)
(abend "failed to build XCVB ~A" source-version))
(exit
(nth-value 2
(run-program (cons *xcvb-program* *arguments*)
:output :interactive :ignore-error-status t)))))))))