gnupdate: Add `--dry-run' option.

* maintainers/scripts/gnu/gnupdate.scm (%options): Add `dry-run'.
  (main): Handle `--dry-run'.

svn path=/nixpkgs/trunk/; revision=21716
This commit is contained in:
Ludovic Courtès 2010-05-10 21:26:53 +00:00
parent 5dd1036a04
commit 5583d516d2
1 changed files with 13 additions and 4 deletions

View File

@ -658,9 +658,13 @@
(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 " -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 '(#\d "dry-run") #f #f
(lambda (opt name arg result)
(alist-cons 'dry-run #t result)))
(option '(#\x "xml") #t #f (option '(#\x "xml") #t #f
(lambda (opt name arg result) (lambda (opt name arg result)
@ -695,8 +699,13 @@
old-version old-hash old-version old-hash
new-version new-hash new-version new-hash
location) location)
(update-nix-expression (location-file location) (if (assoc-ref opts 'dry-run)
old-version old-hash (format #t "`~a' would be updated from ~a to ~a (~a -> ~a)~%"
new-version new-hash)) name old-version new-version
old-hash new-hash)
(update-nix-expression (location-file location)
old-version old-hash
new-version new-hash)))
(_ #f))) (_ #f)))
updates))) updates)
#t))