services: shepherd: Parameterize 'shepherd-service-back-edges'.

* gnu/services/shepherd.scm (shepherd-service-back-edges): Add
  #:provision and #:requirement parameter.  Honor them.
This commit is contained in:
Ludovic Courtès 2016-08-31 15:16:36 +02:00
parent f20a7b8696
commit 6673bddc9a
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 10 additions and 4 deletions

View File

@ -268,11 +268,17 @@ procedure that takes a service and returns the list of symbols it provides."
((_ . service) service) ((_ . service) service)
(#f #f))))) (#f #f)))))
(define (shepherd-service-back-edges services) (define* (shepherd-service-back-edges services
#:key
(provision shepherd-service-provision)
(requirement shepherd-service-requirement))
"Return a procedure that, when given a <shepherd-service> from SERVICES, "Return a procedure that, when given a <shepherd-service> from SERVICES,
returns the list of <shepherd-service> that depend on it." returns the list of <shepherd-service> that depend on it.
Use PROVISION and REQUIREMENT as one-argument procedures that return the
symbols provided/required by a service."
(define provision->service (define provision->service
(shepherd-service-lookup-procedure services)) (shepherd-service-lookup-procedure services provision))
(define edges (define edges
(fold (lambda (service edges) (fold (lambda (service edges)
@ -280,7 +286,7 @@ returns the list of <shepherd-service> that depend on it."
(vhash-consq (provision->service requirement) service (vhash-consq (provision->service requirement) service
edges)) edges))
edges edges
(shepherd-service-requirement service))) (requirement service)))
vlist-null vlist-null
services)) services))