From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id m+NROjv6s2OUsAAAbAwnHQ (envelope-from ) for ; Tue, 03 Jan 2023 10:49:48 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id uK5uOTv6s2PShQAAauVa8A (envelope-from ) for ; Tue, 03 Jan 2023 10:49:47 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 541C2444EE for ; Tue, 3 Jan 2023 10:49:47 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCdv5-000256-Uh; Tue, 03 Jan 2023 04:49:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCdv4-00024w-Oj for guix-devel@gnu.org; Tue, 03 Jan 2023 04:49:18 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCdv3-0000FA-1Y; Tue, 03 Jan 2023 04:49:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=5gckt52O+rz8eU0UVV5QGAp1XOZZda14BZbKyhGiZsM=; b=UO5BpsTtE7Qv1XMxLtDw +ZG1b5KCzAxXTjppwSX7n5DNT9UliXohfesi1QtZAUweqiGtAMdcklHMZgomzbvWNjutwOXSUJUT0 vqJffpShG5D9obEen0UUwRK9KIewMQglKCAmTRbjUqSNcb2bhX1lHumOaG2xjtNoXNkXCnS571na2 EKAboZt0ev3NLKDanrd48bcqfFjSYFzjnN4mZH/sQcCjbStzLQvUSCj8zif/NECofYWKijbR4aS9d niL+2+J3iNV+Z7k1B/IWNyq9TnMqa2ddj+AObgNycbXckPHskH+5tFF9Yi+i4/dsiwKlv0Q4y+8+K WCmAP0ExFMiRnw==; Received: from [193.50.110.60] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCduo-0004t2-Qn; Tue, 03 Jan 2023 04:49:15 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Ricardo Wurmus Cc: Hartmut Goebel , guix-devel@gnu.org Subject: Re: All updaters are broken References: <874jtb7icl.fsf@elephly.net> <875ydp5ctv.fsf@elephly.net> <871qod5b4v.fsf@elephly.net> <87wn644u9y.fsf@elephly.net> <12f602da-16fb-0c19-1fe2-8e4c9a921868@crazy-compilers.com> <87k0243rg8.fsf@elephly.net> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quartidi 14 =?utf-8?Q?Niv=C3=B4se?= an 231 de la =?utf-8?Q?R=C3=A9volution=2C?= jour du =?utf-8?Q?Gr=C3=A8s?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 03 Jan 2023 10:49:00 +0100 In-Reply-To: <87k0243rg8.fsf@elephly.net> (Ricardo Wurmus's message of "Tue, 03 Jan 2023 10:16:41 +0100") Message-ID: <87pmbw7xtf.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672739387; a=rsa-sha256; cv=none; b=dnGUzFApFJP71iIQ2qifWXejgBT/875P2vQH7QHhaOekDvh837NFPbNG1+Pqq0wabeXWjc 7n3i0f6/Re7GdtWSwEw75KwtD/GugtRdCFNML6DVZQ/n4z1mQM6xZcEh0LNedZd1PmzvGG D0Y2GnxdFvaMBOa1FncZRlC2oePwv/h6TXhtZ9xBwQcny5wn/hz3jO+ohjUIIFX8vMGfw2 22N5J64iXIPbRFDlSGbS+js4rDRhwnT/VF1q92/RHsa0pxD+B48ZG7g3dLGtGHZSzkrvVw QnJ9wKmKJpFxKc7IrPeV3Jv4jMljBhMb2GaWMJvtEreFfLzVzSo2pDDQqPR/GQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=UO5BpsTt; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672739387; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=N7rKg9yqexIXOsGZd7x7PUyskkEN72UQ1QAA/YvTE+o=; b=iRpUYA/PvaH1hXzkCirD1C9yyimguotm1pbkC/l4v5qepbQtkDcReK12F+Ra49cvgXCilE oNGYEjk7lczSl1b++g6kPNCalMm0+d5pgZ+qfZVw++LbauL5/9Pv+W+jOTTTcZz3dUOwbi v706m+KiNO3irHB0QSeUTDv3jdR9Ym90CacvqcF2sgP5K2/Xj78sQvb6BONEiLoe5c0/di P+ex5bBarKPr6srCz9KUO6hsLyXm3nGdFyCwFcV6PTIgEZ4CvVjO+FMt20fS2ZvC5nZ1ml DzO3EO9OBTcX0NqPLBS/J0G5Jl4WqOACAAAbi+mOIl2AYW+K0T26OSlYXqQOfA== X-Spam-Score: -3.05 X-Migadu-Queue-Id: 541C2444EE Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=UO5BpsTt; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -3.05 X-TUID: ZKVHaZzshJPb --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello! Ricardo Wurmus skribis: > Okay. Here=E2=80=99s something simpler using =E2=80=9Cpartition=E2=80=9D: > > commit 96fb123832b262a3453fe1b7646758da235a343e > Author: Ricardo Wurmus > Date: Tue Jan 3 10:14:52 2023 +0100 > > WIP > > diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm > index e0b94ce48d..bbda2df35a 100644 > --- a/guix/scripts/refresh.scm > +++ b/guix/scripts/refresh.scm > @@ -183,9 +183,9 @@ (define (show-help) > (newline) > (show-bug-report-information)) >=20=20 > -(define (options->update-specs opts) > - "Return the list of packages requested by OPTS, honoring options like > -'--recursive'." > +(define (options->packages+update-specs opts) > + "Return the list of packages and update-specs requested by OPTS, honor= ing > +options like '--recursive'." > (define core-package? > (let* ((input->package (match-lambda > ((name (? package? package) _ ...) package) > @@ -220,7 +220,7 @@ (define (keep-newest package lst) > (_ > (cons package lst))))) >=20=20 > - (define args-packages > + (define args-packages+update-specs > ;; Packages explicitly passed as command-line arguments. > (match (filter-map (match-lambda > (('argument . spec) > @@ -244,17 +244,18 @@ (define args-packages > (some ;user-specified packag= es > some))) >=20=20 > - (define packages > + (define packages+update-specs > (match (assoc-ref opts 'manifest) > - (#f args-packages) > + (#f args-packages+update-specs) > ((? string? file) (packages-from-manifest file)))) I tried something different and perhaps simpler: making sure =E2=80=98options->update-specs=E2=80=99 always returns a list of , as the name implies, and does the right thing with manifests, -r, and -e. (Part of the patch moves the definition before its first use.) WDYT? This is on top of , which also clarified a couple of things. After that I=E2=80=99d like to thing about tests for the CLI. Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 65c3ce9c16..9438df870d 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -183,9 +183,31 @@ (define (show-help) (newline) (show-bug-report-information)) + +;;; +;;; Utilities. +;;; + +(define-record-type + (%update-spec package version) + update? + (package update-spec-package) + (version update-spec-version)) + +(define* (update-spec package #:optional version) + (%update-spec package version)) + +(define (update-specification->update-spec spec) + "Given SPEC, a package name like \"guile@2.0=2.0.8\", return a +record with two fields: the package to upgrade, and the target version." + (match (string-rindex spec #\=) + (#f (update-spec (specification->package spec) #f)) + (idx (update-spec (specification->package (substring spec 0 idx)) + (substring spec (1+ idx)))))) + (define (options->update-specs opts) - "Return the list of packages requested by OPTS, honoring options like -'--recursive'." + "Return the list of records requested by OPTS, honoring +options like '--recursive'." (define core-package? (let* ((input->package (match-lambda ((name (? package? package) _ ...) package) @@ -220,60 +242,43 @@ (define (keep-newest package lst) (_ (cons package lst))))) - (define args-packages - ;; Packages explicitly passed as command-line arguments. - (match (filter-map (match-lambda + (define update-specs + ;; Update specs explicitly passed as command-line arguments. + (match (append-map (match-lambda (('argument . spec) ;; Take either the specified version or the ;; latest one. - (update-specification->update-spec spec)) + (list (update-specification->update-spec spec))) (('expression . exp) - (read/eval-package-expression exp)) - (_ #f)) + (list (update-spec (read/eval-package-expression exp)))) + (('manifest . manifest) + (map update-spec (packages-from-manifest manifest))) + (_ + '())) opts) (() ;default to all packages (let ((select? (match (assoc-ref opts 'select) ('core core-package?) ('non-core (negate core-package?)) (_ (const #t))))) - (fold-packages (lambda (package result) - (if (select? package) - (keep-newest package result) - result)) - '()))) + (map update-spec + (fold-packages (lambda (package result) + (if (select? package) + (keep-newest package result) + result)) + '())))) (some ;user-specified packages some))) - (define packages - (match (assoc-ref opts 'manifest) - (#f args-packages) - ((? string? file) (packages-from-manifest file)))) - (if (assoc-ref opts 'recursive?) - (mlet %store-monad ((edges (node-edges %bag-node-type - (all-packages)))) - (return (node-transitive-edges packages edges))) + (mlet* %store-monad ((edges (node-edges %bag-node-type (all-packages))) + (packages -> (node-transitive-edges + (map update-spec-package update-specs) + edges))) + ;; FIXME: We're losing the 'version' field of each update spec. + (return (map update-spec packages))) (with-monad %store-monad - (return packages)))) - - -;;; -;;; Utilities. -;;; - -(define-record-type - (update-spec package version) - update? - (package update-spec-package) - (version update-spec-version)) - -(define (update-specification->update-spec spec) - "Given SPEC, a package name like \"guile@2.0=2.0.8\", return a -record with two fields: the package to upgrade, and the target version." - (match (string-rindex spec #\=) - (#f (update-spec (specification->package spec) #f)) - (idx (update-spec (specification->package (substring spec 0 idx)) - (substring spec (1+ idx)))))) + (return update-specs)))) ;;; --=-=-=--