From patchwork Thu May 18 15:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 50115 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 C24BC17A88; Thu, 18 May 2023 16:18:16 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D008E17A9A for ; Thu, 18 May 2023 16:18:15 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzfNV-0003Vg-Kp; Thu, 18 May 2023 11:17:17 -0400 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 1pzfNN-0003KR-WE for guix-patches@gnu.org; Thu, 18 May 2023 11:17:11 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzfNL-0001yl-Bk; Thu, 18 May 2023 11:17:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pzfNI-0005UK-SV; Thu, 18 May 2023 11:17:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63571] [PATCH 09/14] upstream: Remove and related code. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Thu, 18 May 2023 15:17:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63571 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63571@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 63571-submit@debbugs.gnu.org id=B63571.168442301621018 (code B ref 63571); Thu, 18 May 2023 15:17:04 +0000 Received: (at 63571) by debbugs.gnu.org; 18 May 2023 15:16:56 +0000 Received: from localhost ([127.0.0.1]:54128 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfN9-0005Sq-8H for submit@debbugs.gnu.org; Thu, 18 May 2023 11:16:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55664) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzfN0-0005Qb-0s for 63571@debbugs.gnu.org; Thu, 18 May 2023 11:16:47 -0400 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 1pzfMu-0001vo-RC; Thu, 18 May 2023 11:16:40 -0400 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=pDY1XX+UFrepPdlVcRDrBmOfjRRGXt4CMRppEK82J8w=; b=Z26vjalJbwBOD0v+5Ncq ICNwINulN4J/iq5XDdoR9kUFp1QGF/LTX4HrwCKzyMimHrqAhXuX8AWINFjd2IrzLtj2sPdTaujK7 YES2RTvC5gE/xaU/QsvgpZKtUeejR8oLcZmgYEtDTQZKuCgmdvV0buTBCDVmgxIixJO3EuhxO+0Qf xM62IioXQ+Zrg953i7LwKmeMQfb6b/dJh0m9qVuu0oUaWL1tNZ9wMbjRVC5mY5gRxhT+YD+u7jNra SZ5UYY6iTwt5M7Zp7sGOlwg/g4q7wu/meQGIjzN+zi4G1ySbrPrSxInjZdCcbyXHUN2/T92bLJBg5 HGpmiLc6vegT7A==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzfMu-0007G6-ES; Thu, 18 May 2023 11:16:40 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 18 May 2023 17:16:17 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/upstream.scm (): Remove. (changed-inputs): Remove. * tests/upstream.scm (test-package, test-new-package) ("changed-inputs returns no changes") ("changed-inputs returns changes to plain input list") ("changed-inputs returns changes to all plain input lists"): Remove. --- guix/upstream.scm | 64 ------------------------ tests/upstream.scm | 120 --------------------------------------------- 2 files changed, 184 deletions(-) diff --git a/guix/upstream.scm b/guix/upstream.scm index 1a90a342ff..54e6c3b89c 100644 --- a/guix/upstream.scm +++ b/guix/upstream.scm @@ -82,12 +82,6 @@ (define-module (guix upstream) upstream-updater-predicate upstream-updater-import - upstream-input-change? - upstream-input-change-name - upstream-input-change-type - upstream-input-change-action - changed-inputs - %updaters lookup-updater @@ -151,64 +145,6 @@ (define upstream-source-regular-inputs (input-type-filter 'regular)) (define upstream-source-native-inputs (input-type-filter 'native)) (define upstream-source-propagated-inputs (input-type-filter 'propagated)) -;; 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 source) - "Return a list of input changes for PACKAGE compared to the 'inputs' field -of SOURCE, an record." - (define input->name - (match-lambda - ((label (? package? pkg) . out) (package-name pkg)) - (_ #f))) - - (if (upstream-source-inputs source) - (let* ((new-regular (map upstream-input-downstream-name - (upstream-source-regular-inputs source))) - (new-native (map upstream-input-downstream-name - (upstream-source-native-inputs source))) - (new-propagated (map upstream-input-downstream-name - (upstream-source-propagated-inputs source))) - (current-regular - (filter-map input->name (package-inputs package))) - (current-native - (filter-map input->name (package-native-inputs package))) - (current-propagated - (filter-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-predicate matching-url?) "Return a predicate that returns true when passed a package whose source is an with the URL-FETCH method, and one of its URLs passes diff --git a/tests/upstream.scm b/tests/upstream.scm index 0792ebd5d0..b82579228a 100644 --- a/tests/upstream.scm +++ b/tests/upstream.scm @@ -54,124 +54,4 @@ (define-module (test-upstream) (signature-urls '("ftp://example.org/foo-1.tar.xz.sig")))))) -(define test-package - (package - (name "test") - (version "2.10") - (source (origin - (method url-fetch) - (uri (string-append "mirror://gnu/hello/hello-" version - ".tar.gz")) - (sha256 - (base32 - "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))) - (build-system gnu-build-system) - (inputs - `(("hello" ,hello))) - (native-inputs - `(("sed" ,sed) - ("tar" ,tar))) - (propagated-inputs - `(("grep" ,grep))) - (home-page "http://localhost") - (synopsis "test") - (description "test") - (license license:gpl3+))) - -(test-equal "changed-inputs returns no changes" - '() - (changed-inputs test-package - (upstream-source - (package "test") - (version "1") - (urls '()) - (inputs - (let ((->input - (lambda (type) - (match-lambda - ((label _) - (upstream-input - (name label) - (downstream-name label) - (type type))))))) - (append (map (->input 'regular) - (package-inputs test-package)) - (map (->input 'native) - (package-native-inputs test-package)) - (map (->input 'propagated) - (package-propagated-inputs - test-package)))))))) - -(define test-new-package - (package - (inherit test-package) - (inputs - (list hello)) - (native-inputs - (list sed tar)) - (propagated-inputs - (list grep)))) - -(test-assert "changed-inputs returns changes to plain input list" - (let ((changes (changed-inputs - (package - (inherit test-new-package) - (inputs (list hello sed)) - (native-inputs '()) - (propagated-inputs '())) - (upstream-source - (package "test") - (version "1") - (urls '()) - (inputs (list (upstream-input - (name "hello") - (downstream-name name)))))))) - (match changes - ;; Exactly one change - (((? upstream-input-change? item)) - (and (equal? (upstream-input-change-type item) - 'regular) - (equal? (upstream-input-change-action item) - 'remove) - (string=? (upstream-input-change-name item) - "sed"))) - (else (pk else #false))))) - -(test-assert "changed-inputs returns changes to all plain input lists" - (let ((changes (changed-inputs - (package - (inherit test-new-package) - (inputs '()) - (native-inputs '()) - (propagated-inputs '())) - (upstream-source - (package "test") - (version "1") - (urls '()) - (inputs (list (upstream-input - (name "hello") - (downstream-name name) - (type 'regular)) - (upstream-input - (name "sed") - (downstream-name name) - (type 'native)) - (upstream-input - (name "tar") - (downstream-name name) - (type 'native)) - (upstream-input - (name "grep") - (downstream-name name) - (type 'propagated)))))))) - (match changes - (((? upstream-input-change? items) ...) - (and (equal? (map upstream-input-change-type items) - '(regular native native propagated)) - (equal? (map upstream-input-change-action items) - '(add add add add)) - (equal? (map upstream-input-change-name items) - '("hello" "sed" "tar" "grep")))) - (else (pk else #false))))) - (test-end)