From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id UP4zI3zCn2ZXJgEAe85BDQ:P1 (envelope-from ) for ; Tue, 23 Jul 2024 14:47:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id UP4zI3zCn2ZXJgEAe85BDQ (envelope-from ) for ; Tue, 23 Jul 2024 16:47:24 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="XpvuV8s/"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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=1721746044; 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=A5bA6Uh7vp5gIdVyhWIiFXJPauiJQfh5ciwFRTF0PxA=; b=WIh/XGUCwuTmmQUBKuwoZSVJi//Po9aFTsWRRxc5qq0EdqBPtj6SjET0WYh+7CfM3ST49O 0hilUkUfYXSIk9w6S3kQMaspThTLxjJvn+iurWsaKoIv3oJFdmDJBt6Dbl8RKSQA3pB92I g1psUcVmD+SjLVXcWFr9qXFZPvMVzerwahzATxQ+Fozy1nxXjdtcwdkA+dCjRVIUc2TwHP jvzyfM9fb+E/AvG5eVlLKu6i5r++V319VZ2bHiD2R/Y7i/uJ7YfLnHt+wcz1d3LQ38Z2OL fuKrbG5k+ecQBtPa73y8KOrKJEFbT3eMfg6SKvPJogrZRCOz8VWBRNQNEcqoLw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1721746044; a=rsa-sha256; cv=none; b=JrRJqBX1UubLO58Mu4bqnmJStkZdb6IZR4zAP/U9AXdMKJBzJEK2BYe5oVm4tTUJMiF2hj spySEpTSwLzMZgM526Py5S3M08NqKjF477oucFumTb0glmN3x+i3dU8naRKlp/BtAgx+IK tX8Io5Bm0mABRqA0wlR9XV4MskMB8CjkgRiG58lq57ynSjIPx2JzVsFpmYJjGAd4Sl9KIK q7lRiPGbRJ0cIT23EuJrW6lKk/jJccdooLGxS+NdyLdc2S3s+f74gjzh0s/hVC124ZJFKM 3PK6PvbObhcikrka3LL2M1OPfNilNpkA2Xm1u0bBHwFDaJik+TSJEQYpE4QtAg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="XpvuV8s/"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" 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 30B48752D9 for ; Tue, 23 Jul 2024 16:47:24 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWGnA-0006DO-6d; Tue, 23 Jul 2024 10:47:04 -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 1sWGn8-0006D8-OL for guix-patches@gnu.org; Tue, 23 Jul 2024 10:47:02 -0400 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 1sWGn8-0004nY-Fb; Tue, 23 Jul 2024 10:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sWGn8-0006UN-0J; Tue, 23 Jul 2024 10:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66592] [PATCH v4] scripts: archive: Check compatibility of command line options. References: In-Reply-To: Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 23 Jul 2024 14:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66592 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66592@debbugs.gnu.org Cc: Simon Tournier , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 66592-submit@debbugs.gnu.org id=B66592.172174598624901 (code B ref 66592); Tue, 23 Jul 2024 14:47:01 +0000 Received: (at 66592) by debbugs.gnu.org; 23 Jul 2024 14:46:26 +0000 Received: from localhost ([127.0.0.1]:60489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWGmY-0006TY-7A for submit@debbugs.gnu.org; Tue, 23 Jul 2024 10:46:26 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:39570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWGmS-0006TN-Fq for 66592@debbugs.gnu.org; Tue, 23 Jul 2024 10:46:24 -0400 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3684e2d0d8bso215876f8f.2 for <66592@debbugs.gnu.org>; Tue, 23 Jul 2024 07:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721745915; x=1722350715; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=A5bA6Uh7vp5gIdVyhWIiFXJPauiJQfh5ciwFRTF0PxA=; b=XpvuV8s/ONe5jEsmCgkXAe1JePLiwolK8ctZJjEjxoFB0MYz2nHyopHoY/b14qivYB XASaEN537OhMA/nr6vKr2kVWRClUdbB91kGvoh9iWVBAecJoDKhSI70KAseE7P6os2PL xg50tvtRLtKnVPOxzf49uFswALBU7nS32vR6ZfefpXWClRUTO+zLIICMNp4CI0sGZfps YHDMv1pqTsQ/UaMcRRo5pBQV5L2SE59PTQ8xlJE9Bqw6bxv3VA222+pVF9OiC07Gopqv RUDQvtapUe/+gsTYOR4TJk5OagRb5RptaGnvQKzRSlY5vbW3kxeVj0rLZIHUFCtjTRAS Fm3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721745915; x=1722350715; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A5bA6Uh7vp5gIdVyhWIiFXJPauiJQfh5ciwFRTF0PxA=; b=TflOJHZl8pfI9xLVe2hh/ZL597KifJRP1Qe55Bde/r7d0o03r6NJSzkhJBlk9fiuML QysD7qUDoy4/8hsA/alyAaBfsfYXWuuTy65bQrlQEQKrJVkvFlNDMqWOUODoskt9NsfF kqDtczX4IQa3IyrbfPQGkf4dXnBUHhzpNQaEObfzZVK7e5NodJ8izxpDHNh5u8TTGq8V o5WR4+O9tjgtTLJHhvSR8Dk3RXuVqatvqg5AkWbVfeDFiVL0TRBPqGm12IxUtH/3mLMj YNE4RLyOgfPYqE195d1wiAStO1aLuGQZ9AkbYzo60E+CQY8FARS7XZMwZUub6N8HdvWA nL6w== X-Gm-Message-State: AOJu0YxYaLoL5ESH2s+Q+TdxxChsiyaGEvjtiqMTIqGUowyUOjddmeyX oTBeZGKc8XHHVczVgqqEM1HzFX+RfIgeM0FmXvh5/7u89hTfqyhVK9VSrg== X-Google-Smtp-Source: AGHT+IH5+ifCzb0KiVBhgJqZHLsBa3BvhCwzIJ6BrhaIdeQxbxdgFK2Xq7xay3PK25c0+UBo/9BJRQ== X-Received: by 2002:a5d:6d89:0:b0:367:811f:814c with SMTP id ffacd0b85a97d-369b6777155mr4816394f8f.4.1721745914909; Tue, 23 Jul 2024 07:45:14 -0700 (PDT) Received: from lili.. (2a02-8429-6820-f501-e58e-8032-398d-7493.rev.sfr.net. [2a02:8429:6820:f501:e58e:8032:398d:7493]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368785c58e7sm11887329f8f.0.2024.07.23.07.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 07:45:14 -0700 (PDT) From: Simon Tournier Date: Tue, 23 Jul 2024 16:45:09 +0200 Message-ID: <9fcbba89f5128ce639bcf10d0d6dd1cccec817a9.1721745865.git.zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.41.0 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-Spam-Score: -0.81 X-Spam-Score: -0.81 X-Migadu-Queue-Id: 30B48752D9 X-Migadu-Scanner: mx11.migadu.com X-TUID: GccDqRmC5njF Fixes . Reported by Perry, Daniel J . * guix/scripts/archive.scm (guix-archive)[compatible-option]: New procedure. and use it. * tests/guix-archive.sh: Test it. --- guix/scripts/archive.scm | 19 ++++++++++++++++++- tests/guix-archive.sh | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm index 2b5a55a23f..29e4d3f7ba 100644 --- a/guix/scripts/archive.scm +++ b/guix/scripts/archive.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2020 Tobias Geerinckx-Rice +;;; Copyright © 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -375,8 +376,24 @@ (define-command (guix-archive . args) (loop (read-line port) (cons line result))))) + (define* (compatible-option options #:key actions) + "Return the OPTIONS if it is compatible with the list of ACTIONS, else exit +with message." + (let ((some-actions (filter (lambda (action) + (assoc-ref options action)) + actions))) + (match some-actions + ((action) + options) + ((action other-actions ...) + (leave (G_ "the options ~{'~s' ~}are exclusive~%") some-actions)) + (_ + options)))) + (with-error-handling - (let ((opts (parse-command-line args %options (list %default-options)))) + (let* ((opts (parse-command-line args %options (list %default-options))) + (opts (compatible-option opts + #:actions (list 'authorize 'export 'import)))) (parameterize ((%graft? (assoc-ref opts 'graft?))) (cond ((assoc-ref opts 'generate-key) => diff --git a/tests/guix-archive.sh b/tests/guix-archive.sh index 0866b5a4d8..08c07684ad 100644 --- a/tests/guix-archive.sh +++ b/tests/guix-archive.sh @@ -79,4 +79,9 @@ guix archive -t < "$archive" | grep "^r /share/guile.*/boot-9\.scm" echo foo | guix archive --authorize && false +# Check incompatible command-line options +guix archive --authorize --export --import && false +guix archive --export guile-bootstrap --authorize > "$archive" && false +guix archive --authorize --import < "$archive" && false + exit 0 base-commit: d007b64356764f49677c78d82643f1125b5353b7 -- 2.41.0