From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id UI15F/GkRWdDYwEAe85BDQ:P1 (envelope-from ) for ; Tue, 26 Nov 2024 10:37:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id UI15F/GkRWdDYwEAe85BDQ (envelope-from ) for ; Tue, 26 Nov 2024 11:37:37 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=lk07KNhv; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=DlOjfn24; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1732617457; a=rsa-sha256; cv=none; b=EehSTpM90R4TN9+E0kKGLHWMiQW/MuGuqnw5psi6tshjIVPy23I295TuZVRX2hBEX7PY0l Xjr5PP50STNoCoPbPp0+yBhrfNdwIuDQg5Vntj/zSPFAjy4+q1YkDIdT6Vkv/gtAjimCik NnEzEGU/tZr61S7s5s+i4uzRi8Lzn4Um/O8fK8cNB/TeCL1mr97HzgszWXz+TOstxCKMOC cUI9vjitJaoNyrXndAvzEjXzllSCWscTTSbnSj0REf7ly2CM80PYWucYfDXa4UDIBESqky h8Clpss2ekHlCJ9SejozFSjOUzNreUv/auhpYqwiOV8bofGy37hUENqBBqAu0g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=lk07KNhv; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=DlOjfn24; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1732617457; 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: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=k3k/sg0/wgle55A25LQqmWpOUX+fPsiNJz/UedSG5CU=; b=ifOXFRAq+JdRXL4QXcOTrsnwBkZSYIjIrvDQCq9a2GfAh7OBi1oG8+gi9CLQ9pfEJc80XZ 3XWHRCrtchYrAgQnH3niTKalR9HYgWLj8GH9JwFQKWQ2uhNeuepc382bh58pUyYzAEWPcf ZV/97hZ47xn4Edos9Z6LAtVHUEl1T3BXokOKMD9bR3Q2KhgOE+5dHKRTFpy/x6orWY3BSQ 6hbpRwLYuG2c0qY5Ish3Ynt74bizjaVefEeDGUxLFQZiKehTWmcLlIjMNxJJD4RaxV/DSb 0di+BmnSp85Kxs7CyUQFz3+E9dono1lUFQRuTEwM+4usiECbZxwY1jsou+86cQ== 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 137997CFD8 for ; Tue, 26 Nov 2024 11:37:36 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFswY-0005Jl-90; Tue, 26 Nov 2024 05:37:18 -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 1tFswO-0005Im-Aq for guix-patches@gnu.org; Tue, 26 Nov 2024 05:37:08 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFswM-0000pe-9o; Tue, 26 Nov 2024 05:37:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=k3k/sg0/wgle55A25LQqmWpOUX+fPsiNJz/UedSG5CU=; b=lk07KNhvhYxTNhe9921yKHSff3fkUMz04Fu7+AfhUCjpSVYQb5nVL9gvLQ2teU74HS5hiHvEFk9xmuGDwaTV95z73mfdzc5jKsCedeRxDRP4mVDWnV28Fnvh3/Wcf/aoefcps+gmdY6N9td3MAgxwCOdgmuovRJL2dWND19AEWagOZqPiUEssIjmLPECP5RHKtFNxWRPI9uQd0Z/BeeQh12+33Y7rLFbJaL+pNL+v+hdt3LCT4YU+bjKBMA2eqDwC/xGEP5BEfqK0EPABzDh8jtZuIXtRxQ1kK8RgtQonjP7o5Jn9br4UhlGRXelWEwmauVRVs3A29ZYE3l4lzRnjQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tFswK-0002eQ-P8; Tue, 26 Nov 2024 05:37:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74542] [PATCH 06/11] guix build: Add =?UTF-8?Q?=E2=80=98--dependents=E2=80=99.?= Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, maxim.cournoyer@gmail.com, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 26 Nov 2024 10:37:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74542 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74542@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic Court?s , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic Court?s , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 74542-submit@debbugs.gnu.org id=B74542.173261740610088 (code B ref 74542); Tue, 26 Nov 2024 10:37:04 +0000 Received: (at 74542) by debbugs.gnu.org; 26 Nov 2024 10:36:46 +0000 Received: from localhost ([127.0.0.1]:46204 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tFsw1-0002cY-PR for submit@debbugs.gnu.org; Tue, 26 Nov 2024 05:36:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tFsvo-0002af-5U for 74542@debbugs.gnu.org; Tue, 26 Nov 2024 05:36:32 -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 1tFstc-00006m-AL; Tue, 26 Nov 2024 05:34:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=k3k/sg0/wgle55A25LQqmWpOUX+fPsiNJz/UedSG5CU=; b=DlOjfn24XgIyfLJWx6ac HrRsYWG9mWedyNOuDuFJ8PMaWheLketKnPOtaQSxjBD+GuDXXqGgUCm/ywxdG6H4C9C6ja4kl4i/R bIr0x7U7kq8U6FnNDfByIodYT5oueGADRp8iqO5BJaJhd4mKWYB0GR2GNjvgMvJIo1uEWHLgaf5y2 UcoEmIQQnLYCzED0KxinjKuI3wEo9VBZwVAfgBBkkCm9AdXELxMUhRYPaOkBqdj0B5je/vgymblFP pVSqDd7PDEZ/7fOP061U1iOynwqnSG+0ZRO5qepfn95ZR7UsreKt1UAMZCtHsrGCrpBsnKz9lwdm/ j6bP+/nYaQKGnA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Tue, 26 Nov 2024 11:33:45 +0100 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 137997CFD8 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -1.99 X-Spam-Score: -1.99 X-TUID: FfK6Yn+1GJ5n * guix/scripts/build.scm (show-help, %options): Add ‘--dependents’. (dependents): New procedure. (options->things-to-build): Add ‘store’ parameter; honor ‘dependents’ option. [for-type]: Handle ‘dependents’ type. (options->derivations): Update call to ‘options->things-to-build’. * tests/guix-build.sh: Add test. * doc/guix.texi (Additional Build Options): Document ‘--dependents’. (Invoking guix refresh): Cross-reference it. * doc/contributing.texi (Submitting Patches): Mention it. Change-Id: I00b6d5831e1f1d35dc8b84a82605391d5a8f417c --- doc/contributing.texi | 4 ++- doc/guix.texi | 27 ++++++++++++++++++++ guix/scripts/build.scm | 56 ++++++++++++++++++++++++++++++++++++++++-- tests/guix-build.sh | 6 +++++ 4 files changed, 90 insertions(+), 3 deletions(-) diff --git a/doc/contributing.texi b/doc/contributing.texi index b063169189..5a778466d7 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -1914,7 +1914,9 @@ Submitting Patches @item Make sure the package builds on your platform, using @command{guix build -@var{package}}. +@var{package}}. Also build at least its direct dependents with +@command{guix build --dependents=1 @var{package}} +(@pxref{build-dependents, @command{guix build}}). @item We recommend you also try building the package on other supported diff --git a/doc/guix.texi b/doc/guix.texi index a9d0d044ae..5734cf306b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13639,6 +13639,31 @@ Additional Build Options natively. @end quotation +@cindex dependents of a package, building them +@cindex building the dependents of a package +@anchor{build-dependents} +@item --dependents[=@var{depth}] +@itemx -T [@var{depth}] +Build the dependents of the following package. By default, build all +the direct and indirect dependents; when @var{depth} is provided, limit +to dependents at that distance: 1 for direct dependents, 2 for +dependents of dependents, and so on. + +For example, the command below builds @emph{all} the dependents of libgit2: + +@example +guix build --dependents libgit2 +@end example + +To build all the packages that directly depend on NumPy, run: + +@example +guix build -T1 python-numpy +@end example + +The list of dependents is computed in the same way as with @command{guix +refresh --list-dependent} (@pxref{Invoking guix refresh}). + @item --source @itemx -S Build the source derivations of the packages, rather than the packages @@ -15142,6 +15167,8 @@ Invoking guix refresh @command{guix graph}}, for information on how to visualize the list of dependents of a package. +@xref{build-dependents, @command{guix build --dependents}}, for a +convenient way to build all the dependents of a package. @end table Be aware that the @option{--list-dependent} option only diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 326d04f1f8..565bfd48e9 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -33,6 +33,9 @@ (define-module (guix scripts build) #:use-module (guix profiles) #:use-module (guix diagnostics) #:autoload (guix http-client) (http-fetch http-get-error?) + #:autoload (guix scripts graph) (%bag-node-type) + #:autoload (guix graph) (node-back-edges) + #:autoload (guix sets) (setq set-contains? set-insert) #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (srfi srfi-1) @@ -440,6 +443,9 @@ (define (show-help) (display (G_ " -D, --development build the inputs of the following package")) (display (G_ " + -T, --dependents[=N] build dependents of the following package, up to + depth N")) + (display (G_ " -S, --source build the packages' source derivations")) (display (G_ " --sources[=TYPE] build source derivations; TYPE may optionally be one @@ -527,6 +533,11 @@ (define %options (option '(#\D "development") #f #f (lambda (opt name arg result) (alist-cons 'development? #t result))) + (option '(#\T "dependents") #f #t + (lambda (opt name arg result) + (alist-cons 'dependents + (or (and=> arg string->number*) +inf.0) + result))) (option '(#\n "dry-run") #f #f (lambda (opt name arg result) (alist-cons 'dry-run? #t result))) @@ -551,7 +562,39 @@ (define %options %standard-cross-build-options %standard-native-build-options))) -(define (options->things-to-build opts) +(define (dependents store packages max-depth) + "List all the things that would need to be rebuilt if PACKAGES are changed." + ;; Using %BAG-NODE-TYPE is more accurate than using %PACKAGE-NODE-TYPE + ;; because it includes implicit dependencies. + (define (get-dependents packages edges) + (let loop ((packages packages) + (result '()) + (depth 0) + (visited (setq))) + (if (> depth max-depth) + (values result visited) + (match packages + (() + (values result visited)) + ((head . tail) + (if (set-contains? visited head) + (loop tail result depth visited) + (let ((next (edges head))) + (call-with-values + (lambda () + (loop next + (cons head result) + (+ depth 1) + (set-insert head visited))) + (lambda (result visited) + (loop tail result depth visited)))))))))) + + (with-store store + (run-with-store store + (mlet %store-monad ((edges (node-back-edges %bag-node-type (all-packages)))) + (return (get-dependents packages edges)))))) + +(define (options->things-to-build store opts) "Read the arguments from OPTS and return a list of high-level objects to build---packages, gexps, derivations, and so on." (define (validate-type x) @@ -600,6 +643,13 @@ (define-public my-package (match type ('regular (list obj)) + (('dependents . depth) + (if (package? obj) + (begin + (info (G_ "computing dependents of package ~a...~%") + (package-full-name obj)) + (dependents store (list obj) depth)) + (list obj))) ('development (if (package? obj) (map manifest-entry-item @@ -661,6 +711,8 @@ (define-public my-package (loop tail 'regular (cons drv result))) (('development? . #t) (loop tail 'development result)) + (('dependents . depth) + (loop tail `(dependents . ,depth) result)) (_ (loop tail type result))))))) @@ -687,7 +739,7 @@ (define (options->derivations store opts) (systems systems))) (define things-to-build - (map transform (options->things-to-build opts))) + (map transform (options->things-to-build store opts))) (define warn-if-unsupported (let ((target (assoc-ref opts 'target))) diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 3637bcdeb3..42e2ecafb1 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -196,6 +196,12 @@ test `guix build -D hello -d \ | grep -e 'glibc.*\.drv$' -e 'gcc.*\.drv$' -e 'binutils.*\.drv$' \ | wc -l` -ge 3 +# Building the dependents. +test `guix build -T1 libgit2 -T1 libssh -d \ + | grep -e 'guile-git.*\.drv$' -e 'guile-ssh.*\.drv$' \ + -e 'libgit2.*\.drv$' -e 'libssh.*\.drv$' \ + | wc -l` -eq 4 + # Unbound variable in thunked field. cat > "$module_dir/foo.scm" <