From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:43206) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jS5Pp-0005LL-K7 for guix-patches@gnu.org; Fri, 24 Apr 2020 16:59:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jS5Pa-0002lP-D7 for guix-patches@gnu.org; Fri, 24 Apr 2020 16:59:17 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jS5Pa-0002k1-18 for guix-patches@gnu.org; Fri, 24 Apr 2020 16:59:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jS5PZ-00016d-VR for guix-patches@gnu.org; Fri, 24 Apr 2020 16:59:01 -0400 Subject: [bug#39258] [PATCH v3 2/3] guix: Search package metadata cache. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20200327162654.18785-1-arunisaac@systemreboot.net> <20200327162654.18785-3-arunisaac@systemreboot.net> Date: Fri, 24 Apr 2020 22:58:30 +0200 In-Reply-To: <20200327162654.18785-3-arunisaac@systemreboot.net> (Arun Isaac's message of "Fri, 27 Mar 2020 21:56:53 +0530") Message-ID: <874kt8ha89.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Arun Isaac Cc: mail@ambrevar.xyz, 39258@debbugs.gnu.org, zimon.toutoune@gmail.com Arun Isaac skribis: > * gnu/packages.scm (search-packages): New function. > * guix/packages.scm (): New record type. [...] > +(define (search-packages profile regexps) > + "Return a list of pairs: objects corresponding to > +packages whose name, synopsis, description, or output matches at least o= ne of > +REGEXPS sorted by relevance, and its non-zero relevance score." > + (define cache-file > + (string-append profile %package-metadata-cache-file)) Here we=E2=80=99re missing something that checks if the cache is authoritat= ive and falls back to the old method if it=E2=80=99s not, akin to what =E2=80=98fold-available-packages=E2=80=99 does. > + (define cache > + (catch 'system-error > + (lambda () > + (map (match-lambda > + (#(name version dependencies outputs systems > + synopsis description home-page (file line column)) > + (make-package-metadata > + name version dependencies outputs systems > + synopsis description home-page > + (location file line column)))) > + (load-compiled cache-file))) I realize the other cache also has that problem, but it would be nice to add a version tag to the cache. Basically emit something like: (package-metadata-cache (version 0) VECTOR =E2=80=A6) instead of just: (VECTOR =E2=80=A6) > +(define-record-type* > + package-metadata make-package-metadata > + package-metadata? > + this-package-metadata > + (name package-metadata-name) > + (version package-metadata-version) > + (dependencies package-metadata-dependencies) > + (outputs package-metadata-outputs) > + (supported-systems package-metadata-supported-systems) > + (synopsis package-metadata-synopsis) > + (description package-metadata-description) > + ;; TODO: Add license > + ;; (license package-metadata-license) > + (home-page package-metadata-home-page) > + (location package-metadata-location)) I=E2=80=99m not comfortable with this data structure duplication, especially right in (guix packages, but I=E2=80=99m not sure it=E2=80=99s avoidable. =E2=80=98fold-available-packages=E2=80=99 avoids it by passing all the fiel= ds as arguments to the fold procedure, I=E2=80=99m not sure if it=E2=80=99s appli= cable here. Thanks, Ludo=E2=80=99.