[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
13/20: squash! Create database when it doesn't already exist.
From: |
guix-commits |
Subject: |
13/20: squash! Create database when it doesn't already exist. |
Date: |
Sun, 4 Jun 2023 17:34:41 -0400 (EDT) |
civodul pushed a commit to branch wip-guix-index
in repository guix.
commit fe7bfe34be7837ae37b129fa2413ec7b90293778
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 861a4e42e7), guix-commits, 2023/06/04
- 04/20: squash! "--db-path" -> "--database"., guix-commits, 2023/06/04
- 07/20: squash! Don't insert directory if it's already present., guix-commits, 2023/06/04
- 08/20: squash! Remove debugging statements., guix-commits, 2023/06/04
- 12/20: squash! Add one variant of each package (name/version pair)., guix-commits, 2023/06/04
- 13/20: squash! Create database when it doesn't already exist.,
guix-commits <=
- 16/20: squash! Simplify '--help'., guix-commits, 2023/06/04
- 18/20: squash! Optimize 'insert-package'., guix-commits, 2023/06/04
- 19/20: squash! Show output name except for "out"; remove '-d'., guix-commits, 2023/06/04
- 02/20: DRAFT Add 'guix index'., guix-commits, 2023/06/04
- 03/20: squash! Update test., guix-commits, 2023/06/04
- 05/20: squash! Improve error reporting and i18n., guix-commits, 2023/06/04
- 01/20: store: Tolerate non-existent GC root directories., guix-commits, 2023/06/04
- 06/20: squash! "with-method" -> "method", guix-commits, 2023/06/04
- 09/20: squash! Choose system-wide database if it's more recent., guix-commits, 2023/06/04
- 11/20: squash! Keep store prefix in database., guix-commits, 2023/06/04