guix package: Fix version and output for 'guix package -i /gnu/store/…'.

* guix/utils.scm (package-name->name+version): Add optional 'delimiter'
parameter.
* guix/scripts/package.scm (store-item->manifest-entry): Pass #\- as the
delimiter for 'package-name->name+version'.  Use "out" instead of #f for
the 'output' field.
* tests/guix-package.sh: Add test.
This commit is contained in:
Ludovic Courtès 2017-01-11 11:55:51 +01:00
parent 69323016d3
commit aa042770da
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
3 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2013, 2015 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2013, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com> ;;; Copyright © 2014, 2016 Alex Kost <alezost@gmail.com>
@ -577,11 +577,12 @@ upgrading, #f otherwise."
(define (store-item->manifest-entry item) (define (store-item->manifest-entry item)
"Return a manifest entry for ITEM, a \"/gnu/store/...\" file name." "Return a manifest entry for ITEM, a \"/gnu/store/...\" file name."
(let-values (((name version) (let-values (((name version)
(package-name->name+version (store-path-package-name item)))) (package-name->name+version (store-path-package-name item)
#\-)))
(manifest-entry (manifest-entry
(name name) (name name)
(version version) (version version)
(output #f) (output "out") ;XXX: wild guess
(item item)))) (item item))))
(define (options->installable opts manifest transaction) (define (options->installable opts manifest transaction)

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013, 2014, 2015 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2013, 2014, 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net> ;;; Copyright © 2014 Ian Denhardt <ian@zenhack.net>
@ -500,11 +500,13 @@ returned by `config.guess'."
;; cross-building to. ;; cross-building to.
(make-parameter #f)) (make-parameter #f))
(define (package-name->name+version spec) (define* (package-name->name+version spec
#:optional (delimiter #\@))
"Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\" "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"
and \"0.9.1b\". When the version part is unavailable, SPEC and #f are and \"0.9.1b\". When the version part is unavailable, SPEC and #f are
returned. Both parts must not contain any '@'." returned. Both parts must not contain any '@'. Optionally, DELIMITER can be
(match (string-rindex spec #\@) a character other than '@'."
(match (string-rindex spec delimiter)
(#f (values spec #f)) (#f (values spec #f))
(idx (values (substring spec 0 idx) (idx (values (substring spec 0 idx)
(substring spec (1+ idx)))))) (substring spec (1+ idx))))))

View File

@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU # GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> # Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> # Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
# #
# This file is part of GNU Guix. # This file is part of GNU Guix.
@ -39,6 +39,14 @@ trap 'rm -f "$profile" "$profile-"[0-9]* "$tmpfile"; rm -rf "$module_dir" t-home
if guix package --bootstrap -e +; if guix package --bootstrap -e +;
then false; else true; fi then false; else true; fi
# Install a store item and make sure the version and output in the manifest
# are correct.
guix package --bootstrap -p "$profile" -i `guix build guile-bootstrap`
test "`guix package -A guile-bootstrap | cut -f 1-2`" \
= "`guix package -p "$profile" -I | cut -f 1-2`"
test "`guix package -p "$profile" -I | cut -f 3`" = "out"
rm "$profile"
guix package --bootstrap -p "$profile" -i guile-bootstrap guix package --bootstrap -p "$profile" -i guile-bootstrap
test -L "$profile" && test -L "$profile-1-link" test -L "$profile" && test -L "$profile-1-link"
test -f "$profile/bin/guile" test -f "$profile/bin/guile"