source: trunk/source/cocoa-ide/ide-self-update.lisp @ 9480

Last change on this file since 9480 was 9480, checked in by mikel, 12 years ago

adding infrastructure for svn updates

File size: 3.9 KB
Line 
1;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: cl-user -*-
2;;;; ***********************************************************************
3;;;; FILE IDENTIFICATION
4;;;;
5;;;; Name:          svn-self.lisp
6;;;; Version:       0.1
7;;;; Project:       Cocoa IDE
8;;;; Purpose:       Cocoa UI for updating the Cocoa IDE from the source repo
9;;;;
10;;;; ***********************************************************************
11
12(in-package :ccl)
13
14;;; IDE: decide how and whether to handle cvs self-updates.
15;;; see the cvs/svn code in update-ccl in compile-ccl.lisp
16
17;;; How to self-update the IDE from the svn repo
18;;; 1. Find the ccl directory that corresponds to the running image
19;;; 2. find the .svn directory
20;;; 3. read the .svn/entries file to determine whether we need to
21;;;    authenticate
22;;; 4. make sure we have auth tokens if we need them
23;;; 5. record the svn version before we start (so we can roll back
24;;;    if things go horribly wrong)
25;;; 6. run svn status to check for potential merge conflicts before starting
26;;;    the update
27;;; 7. construct the svn command:
28;;;    a. cd to the proper CCL directory
29;;;    b. run svn update
30;;; 8. check the outcome of the update:
31;;;    a. if okay, run queue a full-rebuild, and a rebuild of the IDE
32;;;       (need to make some infrastructure for queuing these activities
33;;;        and running them on next launch)
34;;;    b. if not okay, warn the user, and offer to roll back to the
35;;;       previously-recorded version (need to make some infrastructure for
36;;;       running a rollback)
37
38;;; LISP-COMMAND-PATHNAME
39;;; ---------------------
40;;; returns the pathname of the running Lisp kernel binary
41;;; (pathname-directory (lisp-command-pathname)) should give the CCL
42;;; directory for that lisp
43
44(defun lisp-command-pathname () 
45  (pathname (car ccl::*command-line-argument-list*)))
46
47(defun effective-ccl-directory ()
48    (make-pathname :directory (pathname-directory (lisp-command-pathname))))
49
50;;; LISP-SUBVERSION-DATA-PATHNAME
51;;; ---------------------
52;;; returns the pathname of the subversion metadata for the running
53;;; Lisp. This function infers where the Subversion data should be; it
54;;; does not check to see whether it's really there
55
56;;; TODO: there is a good chance this path will be of a form like this:
57;;; #P"/usr/local/ccl/trunk/darwinx8664/ccl/Clozure CL.app/Contents/MacOS/dx86cl64"
58;;; need a way to be sure we find the proper CCL directory for the app bundle
59
60(defun lisp-subversion-data-pathname ()
61  (merge-pathnames ".svn/"
62                   (make-pathname :directory (pathname-directory (ccl::lisp-command-pathname)))))
63
64;;; VALIDATE-SVN-DATA-PATHNAME p
65;;; ---------------------
66;;; returns TRUE if P is really an existing directory that appears to
67;;; contain valid Subversion metadata; FALSE otherwise
68
69(defun validate-svn-data-pathname (p)
70  (and (probe-file p)
71       (directoryp p)
72       (string= ".svn" (first (last (pathname-directory p))))
73       ;; if we reached this point, it's an existing directory
74       ;; named ".svn". now, does it have Subversion metadata files
75       ;; in it?
76       (let ((subversion-metafiles '("dir-prop-base" "entries" "format"
77                                     "prop-base/" "props/" "text-base/")))
78         (every (lambda (f) (probe-file (merge-pathnames f p))) 
79                subversion-metafiles))))
80
81;;; given a valid-looking .svn directory, we should be able to use
82;;; the svn executable to get the repository URL. we call:
83;;;  svn info
84;;; and get a big block of info text. one line of the output
85;;; is of the form:
86;;;  URL: yatta-yatta
87;;; where yatta-yatta is the repository URL of the checked out directory
88;;; Another piece of information we want opos up here, too: the
89;;; current revision, on a line of the form:
90;;; Revision: foobar
91
92(defun parse-svn-info (info-string)
93  info-string)
94
95(defun get-svn-info (p)
96  (parse-svn-info
97   (with-output-to-string (out)
98     (run-program "svn" `("info" ,(namestring p)) :output out))))
Note: See TracBrowser for help on using the repository browser.