[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
13/13: squash! Create database when it doesn't already exist.
From: |
guix-commits |
Subject: |
13/13: squash! Create database when it doesn't already exist. |
Date: |
Sun, 21 May 2023 17:40:24 -0400 (EDT) |
civodul pushed a commit to branch wip-guix-index
in repository guix.
commit 5fc794ac94dbafdbeeeba739e5e15a0c4bb849b3
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun May 21 23:16:34 2023 +0200
squash! Create database when it doesn't already exist.
---
guix/scripts/index.scm | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/guix/scripts/index.scm b/guix/scripts/index.scm
index 9ba2cccc87..6a6316534a 100644
--- a/guix/scripts/index.scm
+++ b/guix/scripts/index.scm
@@ -455,7 +455,9 @@ user or system."
(if (and system (> (stat:mtime system) (stat:mtime user)))
system-database-file
user-database-file)
- system-database-file)))))
+ (if system
+ system-database-file
+ user-database-file))))))
(define (show-help)
(display (G_ "Usage: guix index [OPTIONS...] [search FILE...]
@@ -581,14 +583,20 @@ See --database for customization.\n"))
(database ((assoc-ref args 'database)
(eq? action 'index)))
(method (assoc-ref args 'method)))
+ (define (populate-database database)
+ (mkdir-p (dirname database))
+ ;; Migrate/initialize db to schema at version application-version
+ (migrate-schema-to-version database)
+ ;; Finally index packages
+ (if (eq? method 'manifests)
+ (index-packages-from-manifests-with-db database)
+ (index-packages-from-store-with-db database)))
+
(match action
('search
(unless (file-exists? database)
- (report-error (G_ "file database '~a' does not exist~%")
- database)
- (display-hint (G_ "Run @command{guix index} to create it. This
-will browse available packages on your system, which may take time."))
- (exit 1))
+ (info (G_ "indexing files from ~a...~%") (%store-prefix))
+ (populate-database database))
(let* ((file (assoc-ref args 'argument))
(matches (matching-packages-with-db database file)))
(print-matching-results matches)
@@ -596,10 +604,4 @@ will browse available packages on your system, which may
take time."))
(leave (G_ "file '~a' not be found in indexed packages~%")
file))))
('index
- (mkdir-p (dirname database))
- ;; Migrate/initialize db to schema at version application-version
- (migrate-schema-to-version database)
- ;; Finally index packages
- (if (eq? method 'manifests)
- (index-packages-from-manifests-with-db database)
- (index-packages-from-store-with-db database)))))))
+ (populate-database database))))))
- branch wip-guix-index created (now 5fc794ac94), guix-commits, 2023/05/21
- 06/13: squash! "with-method" -> "method", guix-commits, 2023/05/21
- 03/13: squash! Update test., guix-commits, 2023/05/21
- 05/13: squash! Improve error reporting and i18n., guix-commits, 2023/05/21
- 08/13: squash! Remove debugging statements., guix-commits, 2023/05/21
- 01/13: store: Tolerate non-existent GC root directories., guix-commits, 2023/05/21
- 07/13: squash! Don't insert directory if it's already present., guix-commits, 2023/05/21
- 10/13: squash! Do not insert the same directory more than once., guix-commits, 2023/05/21
- 11/13: squash! Keep store prefix in database., guix-commits, 2023/05/21
- 13/13: squash! Create database when it doesn't already exist.,
guix-commits <=
- 09/13: squash! Choose system-wide database if it's more recent., guix-commits, 2023/05/21
- 12/13: squash! Add one variant of each package (name/version pair)., guix-commits, 2023/05/21
- 02/13: DRAFT Add 'guix index'., guix-commits, 2023/05/21
- 04/13: squash! "--db-path" -> "--database"., guix-commits, 2023/05/21