playing with the Guix sources, I wrote following Guile script in order to
check available updates for a profile.

Is it suitable for this purpose or I need to include additional checks
on my script? 


(define-module (px tools updater)
  #:use-module (guix profiles)
  #:use-module (guix utils)
  #:use-module (srfi srfi-1)
  #:export (check-entry
            check-manifest
            check-profile))

(define (check-entry entry manifest)
  "Recursive update check for a manifest entry"
  (let* ((pattern (manifest-pattern
                    (name (manifest-entry-name entry))
                    (output (manifest-entry-output entry))))
         (previous (manifest-lookup manifest pattern))
         (newer? (and previous
                      (version>? (manifest-entry-version entry)
                                 (manifest-entry-version previous)))))
    (fold (lambda (child-entry result)
            (or result
                (check-entry child-entry manifest)))
      newer? (manifest-entry-dependencies entry))))


(define (check-manifest manifest)
  "Check if any update available for a manifest"
  (fold (lambda (entry previous)
          (or previous (check-entry entry manifest)))
    #f (manifest-entries manifest)))


(define* (check-profile #:optional (profile %current-profile))
  "Check if any update is available for a profile"
  (let ((manifest (profile-manifest profile)))
    (check-manifest manifest)))


-- 
Regards
Reza Alizadeh Majd
PantherX Team

Reply via email to