From patchwork Fri Jan 11 09:42:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Wurmus X-Patchwork-Id: 719 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 63BC216A5F; Fri, 11 Jan 2019 09:43:07 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id C74A316A1E for ; Fri, 11 Jan 2019 09:43:06 +0000 (GMT) Received: from localhost ([127.0.0.1]:46402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghtLG-000662-Dc for patchwork@mira.cbaines.net; Fri, 11 Jan 2019 04:43:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghtLE-000657-0c for guix-patches@gnu.org; Fri, 11 Jan 2019 04:43:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghtLC-0001m2-P1 for guix-patches@gnu.org; Fri, 11 Jan 2019 04:43:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:55345) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghtLC-0001lu-LK for guix-patches@gnu.org; Fri, 11 Jan 2019 04:43:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ghtLC-0006Pr-IU for guix-patches@gnu.org; Fri, 11 Jan 2019 04:43:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#34040] [PATCH 1/2] refresh: Suggest input changes when updating. References: <8736pzpnhg.fsf@elephly.net> In-Reply-To: <8736pzpnhg.fsf@elephly.net> Resent-From: Ricardo Wurmus Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 11 Jan 2019 09:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34040 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 34040@debbugs.gnu.org Received: via spool by 34040-submit@debbugs.gnu.org id=B34040.154719976324630 (code B ref 34040); Fri, 11 Jan 2019 09:43:02 +0000 Received: (at 34040) by debbugs.gnu.org; 11 Jan 2019 09:42:43 +0000 Received: from localhost ([127.0.0.1]:54625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ghtKs-0006PB-Jn for submit@debbugs.gnu.org; Fri, 11 Jan 2019 04:42:43 -0500 Received: from sender-of-o53.zoho.com ([135.84.80.218]:21723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ghtKo-0006Oo-5U for 34040@debbugs.gnu.org; Fri, 11 Jan 2019 04:42:38 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1547199736; cv=none; d=zoho.com; s=zohoarc; b=d34/9e8ZQnhwi8vVKe9kKndjOCMLq6vE9u3qBnE5I36dDSY5Q4ZM86fgAKsCib8bprQEOupTB7mA16vB/HZuuyAGRRH5XyPnuwWM7cXeumtJb1NN3if4j3SnRGlYFXHwxwkP/isOI+XwLrDkHHoZHCJeLZLj2SAY9t9qbrQyhYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1547199736; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To:ARC-Authentication-Results; bh=5L/4qXbuW6yemPsYvk4JFDcTaw1u6o798XFxXRLqSM8=; b=SGGBwTNQlAHNClpqeUrB3uxpP9Xf+9aFYXKab1P0Iwm2OHqa5EY1k2YEGE+QTv+6MiXgoclIB66INl9aw7bJ8f4+95BapaUVLN/e8yQXL6z9ktSBqiALO/TCRV7c/oAsuZ+Ss1wK+MoLn4OXg7xPH+PEaeyckiom3rwfcFDMkUU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1547199736; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; l=7189; bh=5L/4qXbuW6yemPsYvk4JFDcTaw1u6o798XFxXRLqSM8=; b=K9UwRVqSh3ymAffjRw/feQfIVje3X5fZyp8VmlrhxTRNdUA8hCoXR1o0nxSQz9I0 Uv6idWXf6MatXR9xup9odm2lO0FM5sCCiKMr2e6Uuhxy0936lHTg+h3o9oqGWo5wRG6 Ga3yHkTWtrXDrQjVTFG0qpRJ+mznkWw3jtiJUhno= Received: from localhost (141.80.247.176 [141.80.247.176]) by mx.zohomail.com with SMTPS id 1547199735468630.8512313450167; Fri, 11 Jan 2019 01:42:15 -0800 (PST) From: Ricardo Wurmus Message-ID: <20190111094208.28327-1-rekado@elephly.net> Date: Fri, 11 Jan 2019 10:42:07 +0100 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ricardo Wurmus Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/upstream.scm ()[input-changes]: New field. (): New record. (upstream-input-change?, upstream-input-change-name, upstream-input-change-type, upstream-input-change-action, changed-inputs): New procedures. (package-update): Pass along input changes. * guix/script/refresh.scm (update-package): Process input changes. --- guix/scripts/refresh.scm | 23 +++++++++- guix/upstream.scm | 90 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 104 insertions(+), 9 deletions(-) diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 003c915da..15cf385fb 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2016 Ben Woodcroft ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2018 Efraim Flashner +;;; Copyright © 2019 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -224,7 +225,7 @@ KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys; allowed values: 'interactive' (default), 'always', and 'never'. When WARN? is true, warn about packages that have no matching updater." (if (lookup-updater package updaters) - (let-values (((version tarball) + (let-values (((version tarball changes) (package-update store package updaters #:key-download key-download)) ((loc) @@ -238,6 +239,26 @@ warn about packages that have no matching updater." (location->string loc) (package-name package) (package-version package) version) + (for-each + (lambda (change) + (format (current-error-port) + (match (list (upstream-input-change-action change) + (upstream-input-change-type change)) + (('add 'regular) + (G_ "~a: consider adding this input: ~a~%")) + (('add 'native) + (G_ "~a: consider adding this native input: ~a~%")) + (('add 'propagated) + (G_ "~a: consider adding this propagated input: ~a~%")) + (('remove 'regular) + (G_ "~a: consider removing this input: ~a~%")) + (('remove 'native) + (G_ "~a: consider removing this native input: ~a~%")) + (('remove 'propagated) + (G_ "~a: consider removing this propagated input: ~a~%"))) + (package-name package) + (upstream-input-change-name change))) + (changes)) (let ((hash (call-with-input-file tarball port-sha256))) (update-package-source package version hash))) diff --git a/guix/upstream.scm b/guix/upstream.scm index 9e1056f7a..880cb9094 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès ;;; Copyright © 2015 Alex Kost +;;; Copyright © 2019 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. ;;; @@ -45,6 +46,7 @@ upstream-source-urls upstream-source-signature-urls upstream-source-archive-types + upstream-source-input-changes url-prefix-predicate coalesce-sources @@ -56,6 +58,12 @@ upstream-updater-predicate upstream-updater-latest + upstream-input-change? + upstream-input-change-name + upstream-input-change-type + upstream-input-change-action + changed-inputs + %updaters lookup-updater @@ -82,7 +90,73 @@ (version upstream-source-version) ;string (urls upstream-source-urls) ;list of strings (signature-urls upstream-source-signature-urls ;#f | list of strings - (default #f))) + (default #f)) + (input-changes upstream-source-input-changes + (default '()) (thunked))) + +;; Representation of an upstream input change. +(define-record-type* + upstream-input-change make-upstream-input-change + upstream-input-change? + (name upstream-input-change-name) ;string + (type upstream-input-change-type) ;symbol: regular | native | propagated + (action upstream-input-change-action)) ;symbol: add | remove + +(define (changed-inputs package package-sexp) + "Return a list of input changes for PACKAGE based on the newly imported +S-expression PACKAGE-SEXP." + (match package-sexp + ((and expr ('package fields ...)) + (let* ((input->name (match-lambda ((name pkg . out) name))) + (new-regular + (match expr + ((path *** ('inputs + ('quasiquote ((label ('unquote sym)) ...)))) label) + (_ '()))) + (new-native + (match expr + ((path *** ('native-inputs + ('quasiquote ((label ('unquote sym)) ...)))) label) + (_ '()))) + (new-propagated + (match expr + ((path *** ('propagated-inputs + ('quasiquote ((label ('unquote sym)) ...)))) label) + (_ '()))) + (current-regular + (map input->name (package-inputs package))) + (current-native + (map input->name (package-native-inputs package))) + (current-propagated + (map input->name (package-propagated-inputs package)))) + (append-map + (match-lambda + ((action type names) + (map (lambda (name) + (upstream-input-change + (name name) + (type type) + (action action))) + names))) + `((add regular + ,(lset-difference equal? + new-regular current-regular)) + (remove regular + ,(lset-difference equal? + current-regular new-regular)) + (add native + ,(lset-difference equal? + new-native current-native)) + (remove native + ,(lset-difference equal? + current-native new-native)) + (add propagated + ,(lset-difference equal? + new-propagated current-propagated)) + (remove propagated + ,(lset-difference equal? + current-propagated new-propagated)))))) + (_ '()))) (define (url-prefix-predicate prefix) "Return a predicate that returns true when passed a package where one of its @@ -268,12 +342,12 @@ values: the item from LST1 and the item from LST2 that match PRED." (define* (package-update store package updaters #:key (key-download 'interactive)) - "Return the new version and the file name of the new version tarball for -PACKAGE, or #f and #f when PACKAGE is up-to-date. KEY-DOWNLOAD specifies a -download policy for missing OpenPGP keys; allowed values: 'always', 'never', -and 'interactive' (default)." + "Return the new version, the file name of the new version tarball and input +changes for PACKAGE, or #f and #f when PACKAGE is up-to-date. KEY-DOWNLOAD +specifies a download policy for missing OpenPGP keys; allowed values: +'always', 'never', and 'interactive' (default)." (match (package-latest-release* package updaters) - (($ _ version urls signature-urls) + (($ _ version urls signature-urls changes) (let*-values (((name) (package-name package)) ((archive-type) @@ -299,9 +373,9 @@ and 'interactive' (default)." (or signature-urls (circular-list #f))))) (let ((tarball (download-tarball store url signature-url #:key-download key-download))) - (values version tarball)))) + (values version tarball changes)))) (#f - (values #f #f)))) + (values #f #f #f)))) (define (update-package-source package version hash) "Modify the source file that defines PACKAGE to refer to VERSION,