gnupdate: Add `--attribute' option.
* maintainers/scripts/gnu/gnupdate (open-nixpkgs): Add optional ATTRIBUTE parameter; honor it. (%options)["-A"]: New option. (gnupdate)[nixpkgs->snix]: Add ATTRIBUTE parameter and pass it down to `open-nixpkgs'. [selected-gnu-packages]: New procedure. Adjust callers accordingly. svn path=/nixpkgs/trunk/; revision=30107
This commit is contained in:
parent
908f43b020
commit
2492fba29f
@ -308,12 +308,17 @@ replaced by the result of their application to DERIVATIONS, a vhash."
|
|||||||
;; DERIVATION lacks an "src" attribute.
|
;; DERIVATION lacks an "src" attribute.
|
||||||
(and=> (derivation-source derivation) source-output-path))
|
(and=> (derivation-source derivation) source-output-path))
|
||||||
|
|
||||||
(define (open-nixpkgs nixpkgs)
|
(define* (open-nixpkgs nixpkgs #:optional attribute)
|
||||||
|
;; Return an input pipe to the XML representation of Nixpkgs. When
|
||||||
|
;; ATTRIBUTE is true, only that attribute is considered.
|
||||||
(let ((script (string-append nixpkgs
|
(let ((script (string-append nixpkgs
|
||||||
"/maintainers/scripts/eval-release.nix")))
|
"/maintainers/scripts/eval-release.nix")))
|
||||||
(open-pipe* OPEN_READ "nix-instantiate"
|
(apply open-pipe* OPEN_READ
|
||||||
"--strict" "--eval-only" "--xml"
|
"nix-instantiate" "--strict" "--eval-only" "--xml"
|
||||||
script)))
|
`(,@(if attribute
|
||||||
|
`("-A" ,attribute)
|
||||||
|
'())
|
||||||
|
,script))))
|
||||||
|
|
||||||
(define (pipe-failed? pipe)
|
(define (pipe-failed? pipe)
|
||||||
"Close pipe and return its status if it failed."
|
"Close pipe and return its status if it failed."
|
||||||
@ -963,12 +968,18 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
|
|||||||
(format #t "~%")
|
(format #t "~%")
|
||||||
(format #t " -x, --xml=FILE Read XML output of `nix-instantiate'~%")
|
(format #t " -x, --xml=FILE Read XML output of `nix-instantiate'~%")
|
||||||
(format #t " from FILE.~%")
|
(format #t " from FILE.~%")
|
||||||
|
(format #t " -A, --attribute=ATTR~%")
|
||||||
|
(format #t " Update only the package pointed to by attribute~%")
|
||||||
|
(format #t " ATTR.~%")
|
||||||
(format #t " -s, --select=SET Update only packages from SET, which may~%")
|
(format #t " -s, --select=SET Update only packages from SET, which may~%")
|
||||||
(format #t " be either `all', `stdenv', or `non-stdenv'.~%")
|
(format #t " be either `all', `stdenv', or `non-stdenv'.~%")
|
||||||
(format #t " -d, --dry-run Don't actually update Nix expressions~%")
|
(format #t " -d, --dry-run Don't actually update Nix expressions~%")
|
||||||
(format #t " -h, --help Give this help list.~%~%")
|
(format #t " -h, --help Give this help list.~%~%")
|
||||||
(format #t "Report bugs to <ludo@gnu.org>~%")
|
(format #t "Report bugs to <ludo@gnu.org>~%")
|
||||||
(exit 0)))
|
(exit 0)))
|
||||||
|
(option '(#\A "attribute") #t #f
|
||||||
|
(lambda (opt name arg result)
|
||||||
|
(alist-cons 'attribute arg result)))
|
||||||
(option '(#\s "select") #t #f
|
(option '(#\s "select") #t #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(cond ((string-ci=? arg "stdenv")
|
(cond ((string-ci=? arg "stdenv")
|
||||||
@ -994,13 +1005,14 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
|
|||||||
(define (gnupdate . args)
|
(define (gnupdate . args)
|
||||||
;; Assume Nixpkgs is under $NIXPKGS or ~/src/nixpkgs.
|
;; Assume Nixpkgs is under $NIXPKGS or ~/src/nixpkgs.
|
||||||
|
|
||||||
(define (nixpkgs->snix xml-file)
|
(define (nixpkgs->snix xml-file attribute)
|
||||||
(format (current-error-port) "evaluating Nixpkgs...~%")
|
(format (current-error-port) "evaluating Nixpkgs...~%")
|
||||||
(let* ((home (getenv "HOME"))
|
(let* ((home (getenv "HOME"))
|
||||||
(xml (if xml-file
|
(xml (if xml-file
|
||||||
(open-input-file xml-file)
|
(open-input-file xml-file)
|
||||||
(open-nixpkgs (or (getenv "NIXPKGS")
|
(open-nixpkgs (or (getenv "NIXPKGS")
|
||||||
(string-append home "/src/nixpkgs")))))
|
(string-append home "/src/nixpkgs"))
|
||||||
|
attribute)))
|
||||||
(snix (xml->snix xml)))
|
(snix (xml->snix xml)))
|
||||||
(if (not xml-file)
|
(if (not xml-file)
|
||||||
(let ((status (pipe-failed? xml)))
|
(let ((status (pipe-failed? xml)))
|
||||||
@ -1009,7 +1021,34 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
|
|||||||
(format (current-error-port) "`nix-instantiate' failed: ~A~%"
|
(format (current-error-port) "`nix-instantiate' failed: ~A~%"
|
||||||
status)
|
status)
|
||||||
(exit 1)))))
|
(exit 1)))))
|
||||||
snix))
|
|
||||||
|
;; If we asked for a specific attribute, rewrap the thing in an
|
||||||
|
;; attribute set to match the expectations of `packages-to-update' & co.
|
||||||
|
(if attribute
|
||||||
|
(match snix
|
||||||
|
(('snix loc ('derivation args ...))
|
||||||
|
`(snix ,loc
|
||||||
|
(attribute-set
|
||||||
|
((attribute #f ,attribute
|
||||||
|
(derivation ,@args)))))))
|
||||||
|
snix)))
|
||||||
|
|
||||||
|
(define (selected-gnu-packages packages stdenv selection)
|
||||||
|
;; Return the subset of PACKAGES that are/aren't in STDENV, according to
|
||||||
|
;; SELECTION. To do that reliably, we check whether their "src"
|
||||||
|
;; derivation is a requisite of STDENV.
|
||||||
|
(define gnu
|
||||||
|
(gnu-packages packages))
|
||||||
|
|
||||||
|
(case selection
|
||||||
|
((stdenv)
|
||||||
|
gnu)
|
||||||
|
((non-stdenv)
|
||||||
|
(filter (lambda (p)
|
||||||
|
(not (member (package-source-output-path p)
|
||||||
|
(force stdenv))))
|
||||||
|
gnu))
|
||||||
|
(else gnu)))
|
||||||
|
|
||||||
(let* ((opts (args-fold (cdr args) %options
|
(let* ((opts (args-fold (cdr args) %options
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
@ -1017,7 +1056,8 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
|
|||||||
(lambda (operand result)
|
(lambda (operand result)
|
||||||
(error "extraneous argument `~A'" operand))
|
(error "extraneous argument `~A'" operand))
|
||||||
'()))
|
'()))
|
||||||
(snix (nixpkgs->snix (assoc-ref opts 'xml-file)))
|
(snix (nixpkgs->snix (assq-ref opts 'xml-file)
|
||||||
|
(assq-ref opts 'attribute)))
|
||||||
(packages (match snix
|
(packages (match snix
|
||||||
(('snix _ ('attribute-set attributes))
|
(('snix _ ('attribute-set attributes))
|
||||||
attributes)
|
attributes)
|
||||||
@ -1026,23 +1066,12 @@ pairs. Example: (\"mit-scheme-9.0.1\" . \"/gnu/mit-scheme/stable.pkg/9.0.1\").
|
|||||||
;; The source tarballs that make up stdenv.
|
;; The source tarballs that make up stdenv.
|
||||||
(filter-map derivation-source-output-path
|
(filter-map derivation-source-output-path
|
||||||
(package-requisites (stdenv-package packages)))))
|
(package-requisites (stdenv-package packages)))))
|
||||||
(gnu (gnu-packages packages))
|
(attribute (assq-ref opts 'attribute))
|
||||||
(gnu* (case (assoc-ref opts 'filter)
|
(selection (assq-ref opts 'filter))
|
||||||
;; Filter out packages that are/aren't in `stdenv'. To
|
(to-update (if attribute
|
||||||
;; do that reliably, we check whether their "src"
|
packages ; already a subset
|
||||||
;; derivation is a requisite of stdenv.
|
(selected-gnu-packages packages stdenv selection)))
|
||||||
((stdenv)
|
(updates (packages-to-update to-update)))
|
||||||
(filter (lambda (p)
|
|
||||||
(member (package-source-output-path p)
|
|
||||||
(force stdenv)))
|
|
||||||
gnu))
|
|
||||||
((non-stdenv)
|
|
||||||
(filter (lambda (p)
|
|
||||||
(not (member (package-source-output-path p)
|
|
||||||
(force stdenv))))
|
|
||||||
gnu))
|
|
||||||
(else gnu)))
|
|
||||||
(updates (packages-to-update gnu*)))
|
|
||||||
|
|
||||||
(format #t "~%~A packages to update...~%" (length updates))
|
(format #t "~%~A packages to update...~%" (length updates))
|
||||||
(for-each (lambda (update)
|
(for-each (lambda (update)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user