From 96728c54df365cc48f14a514b63616ff7a6d052b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 30 Oct 2021 23:30:50 +0200 Subject: home: import: Factorize triplicated 'version-spec' procedure. * guix/scripts/package.scm (manifest-entry-version-prefix): New procedure, moved from... (export-manifest)[version-spec]: ... here. Adjust caller. * tests/home-import.scm (version-spec): Remove. (eval-test-with-home-environment): Use 'manifest-entry-version-prefix' instead. * guix/scripts/home/import.scm (import-manifest): Likewise. --- tests/home-import.scm | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'tests/home-import.scm') diff --git a/tests/home-import.scm b/tests/home-import.scm index 40d9547e8b..dc413d8516 100644 --- a/tests/home-import.scm +++ b/tests/home-import.scm @@ -24,6 +24,8 @@ #:use-module (ice-9 match) #:use-module ((guix profiles) #:hide (manifest->code)) #:use-module ((guix build syscalls) #:select (mkdtemp!)) + #:use-module ((guix scripts package) + #:select (manifest-entry-version-prefix)) #:use-module (gnu packages) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) @@ -81,33 +83,13 @@ corresponding file." ((file . content) (create-file file content))) files-alist)) -;; Copied from (guix profiles) -(define (version-spec entry) - (let ((name (manifest-entry-name entry))) - (match (map package-version (find-packages-by-name name)) - ((_) - ;; A single version of NAME is available, so do not specify the - ;; version number, even if the available version doesn't match ENTRY. - "") - (versions - ;; If ENTRY uses the latest version, don't specify any version. - ;; Otherwise return the shortest unique version prefix. Note that - ;; this is based on the currently available packages, which could - ;; differ from the packages available in the revision that was used - ;; to build MANIFEST. - (let ((current (manifest-entry-version entry))) - (if (every (cut version>? current <>) - (delete current versions)) - "" - (version-unique-prefix (manifest-entry-version entry) - versions))))))) - (define (eval-test-with-home-environment files-alist manifest matcher) (create-temporary-home files-alist) (setenv "HOME" %temporary-home-directory) (mkdir-p %temporary-home-directory) (let* ((home-environment (manifest->code manifest %destination-directory - #:entry-package-version version-spec + #:entry-package-version + manifest-entry-version-prefix #:home-environment? #t)) (result (matcher home-environment))) (delete-file-recursively %temporary-home-directory) -- cgit 1.4.1