Skip to content

Commit b525ae5

Browse files
committed
Use temporary pathname for release tarball in INSTALL
This reduces the chance of clashes when independent Lisp processes are installing things. Inspired by #138
1 parent 21aa87c commit b525ae5

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

quicklisp/dist.lisp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -767,16 +767,16 @@ the given NAME."
767767

768768
(defmethod install ((release release))
769769
(let ((archive (ensure-local-archive-file release))
770-
(tar (qmerge "tmp/release-install.tar"))
771770
(output (relative-to (dist release)
772771
(make-pathname :directory
773772
(list :relative "software"))))
774773
(tracking (install-metadata-file release)))
775-
(ensure-directories-exist tar)
776-
(ensure-directories-exist output)
777-
(ensure-directories-exist tracking)
778-
(gunzip archive tar)
779-
(unpack-tarball tar :directory output)
774+
(with-temporary-file (tar "release-install.tar")
775+
(ensure-directories-exist tar)
776+
(ensure-directories-exist output)
777+
(ensure-directories-exist tracking)
778+
(gunzip archive tar)
779+
(unpack-tarball tar :directory output))
780780
(ensure-directories-exist tracking)
781781
(with-open-file (stream tracking
782782
:direction :output

quicklisp/package.lisp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#:file-size
1717
#:safely-read
1818
#:safely-read-file
19-
#:make-versions-url))
19+
#:make-versions-url
20+
#:with-temporary-file))
2021

2122
(defpackage #:ql-setup
2223
(:documentation

quicklisp/utils.lisp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,24 @@ http://foo/bar-versions.txt."
122122
(subseq url 0 suffix-pos)
123123
"-versions"
124124
extension))))
125+
126+
(defun call-with-temporary-file (fun template-pathname)
127+
(assert (null (pathname-directory template-pathname)))
128+
(let* ((relative-file (merge-pathnames template-pathname
129+
#p"tmp/"))
130+
(absolute-file (ql-setup:qmerge relative-file))
131+
(randomized-file (make-pathname :name (format nil "~A-~36,5,'0R"
132+
(pathname-name template-pathname)
133+
(random #xFFFFFF))
134+
:defaults absolute-file)))
135+
(unwind-protect
136+
(funcall fun randomized-file)
137+
(delete-file-if-exists randomized-file))))
138+
139+
;;; TODO: Use this where (qmerge "tmp/...") is used, when possible
140+
(defmacro with-temporary-file ((var template) &body body)
141+
"Evaluate BODY with VAR bound to a temporary pathname created by
142+
adding random data to the pathname-name of TEMPLATE, which should be a
143+
pathname without a directory component. After evaluation, the
144+
temporary pathname is deleted if it exists."
145+
`(call-with-temporary-file (lambda (,var) ,@body) ,template))

0 commit comments

Comments
 (0)