Finding the system of a package

88 views Asked by At

I am in the design phase of building a deployment tool for CL projects.

I imagine the typical workflow to be like so:

  1. (ql:quickload :yolo)
  2. (yolo:configure)
  3. Developer adds remote machine user and host, etc...
  4. Developer goes to bed. Turns off the PC
  5. In the morning: hack hack hack
  6. Time to deploy. Developer commits changes and goes to the REPL and types (yolo:deploy)

What I want is for my library to know which system the developer wants deployed based on the current package. (*package*)

My question: Is it possible to find the system that loaded a particular package? Naturally I am talking about ASDF.

Bonus question: Is such a tool even needed? Perhaps there is a better workflow. I am also planning to make the library an executable, but then the default project can be obtain by the current directory.

2

There are 2 answers

0
Svante On BEST ANSWER

First, read about packages, systems, libraries etc. here.

I do not think that it makes much sense to infer the intended system. You need at least one additional parameter anyway (the target where to deploy).

A few ideas:

I imagine that a deployment tool would deploy a system. It would then perhaps sensibly be defined as an extension for ASDF.

For example, you might devise such an extension so that you can specify deployment configuration in the defsystem form like this:

(defsystem #:foo
  :defsystem-depends-on (#:your-awesome-asdf-deploy)
  ;; ...
  :deploy-targets (:test (:host "test.example.org"
                          :user "foo"
                          :env (:backend-url "https://test.foo.org/api"
                                :dev t))
                   :prod (:host "prod.example.org"
                          :user "bar"
                          :env (:backend-url "https://foo.org/api"
                                :dev nil))))

This information could then be used in a new op deploy-op, that you might invoke like:

(asdf:oos 'asdf-deploy:deploy-op 'foo :target :test)
0
Faré On

There is no builtin way to answer your question, but if, right after you load asdf, you hook into (defmethod perform :after ((o load-op) (s system)) ...) a function that diffs the list of new entries from the list of all packages, then you could build an index of which systems create which packages.