Commit e5cdddc6 authored by Eric Timmons's avatar Eric Timmons
Browse files

Integrate cl-tar as option to extract tar archives and make it the default

parent e00f650c
......@@ -7,6 +7,7 @@
(:use #:cl
#:clpm/archives/defs
#:clpm/archives/chipz
#:clpm/archives/cl-tar
#:clpm/archives/tar)
(:reexport #:clpm/archives/defs))
......
;;;; Support for extracting archives using the cl-tar project.
;;;;
;;;; This software is part of CLPM. See README.org for more information. See
;;;; LICENSE for license information.
(uiop:define-package #:clpm/archives/cl-tar
(:use #:cl
#:clpm/archives/defs)
(:import-from #:tar)
(:import-from #:tar-extract))
(in-package #:clpm/archives/cl-tar)
(defclass cl-tar-client ()
()
(:documentation
"Describes an archive extractor that uses the cl-tar project."))
(register-tar-client :cl-tar 'cl-tar-client)
(defmethod tar-client-available-p ((client cl-tar-client))
"Always available."
t)
(defmethod unarchive-tar ((client cl-tar-client) archive-stream destination-pathname
&key strip-components)
"Ensures ~destination-pathname~ exists and then uses CL-TAR to extract the
contents. Dereferences links on Windows and skips all block and character
devices."
(assert (uiop:directory-pathname-p destination-pathname))
(ensure-directories-exist destination-pathname)
(tar:with-open-archive (a archive-stream)
(tar-extract:extract-archive a
:directory destination-pathname
:strip-components strip-components
:if-exists :replace
:if-newer-exists :replace
:no-same-owner t
:symbolic-links (if (uiop:os-windows-p)
:dereference
t)
:hard-links (if (uiop:os-windows-p)
:dereference
t)
:fifos (if (uiop:os-windows-p)
:skip
t)
:character-devices :skip
:block-devices :skip)))
......@@ -71,7 +71,7 @@ Instantiate all registered tar clients, then remove the ones where
(let* ((client-key (config-value :archives :tar :type))
(available-clients (available-tar-clients))
(client (if (eql :auto client-key)
(cdr (first available-clients))
(assoc-value available-clients :cl-tar)
(assoc-value available-clients client-key))))
(unless client
(error "Unable to find a tar client."))
......
......@@ -25,7 +25,7 @@
((:archives :tar)
:type hash-table)
((:archives :tar :type)
:type (member :auto :tar)
:type (member :auto :cl-tar :tar)
:default :auto
:documentation
"The tar implementation to use.")
......@@ -233,6 +233,9 @@
:documentation
"The default logging level of the application.")
((:cl-tar)
:type hash-table)
((:tar)
:type hash-table)
((:tar :path)
......
......@@ -76,7 +76,8 @@ The current configuration can be printed by running =clpm config info=.
This table contains configuration for dealing with archives in tar format.
+ =:type= :: A keyword specifying which tar implementation use. Defaults to
=:auto=.
=:auto=. =:cl-tar= specifies that the CL-TAR project should be
used. =:tar= specifies that an external tar executable should be used.
* =(:bundle)=
This table contains all configuration for operating with bundles.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment