From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oNPYHI6eoGNoGQAAbAwnHQ (envelope-from ) for ; Mon, 19 Dec 2022 18:25:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id qDjBHI6eoGOaowAAauVa8A (envelope-from ) for ; Mon, 19 Dec 2022 18:25:34 +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 502FE1E4C3 for ; Mon, 19 Dec 2022 18:25:33 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7Jsu-0004Lj-Bc; Mon, 19 Dec 2022 12:25:04 -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 1p7Jss-0004L1-Aq for guix-patches@gnu.org; Mon, 19 Dec 2022 12:25:02 -0500 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 1p7Jss-0003Qh-0O for guix-patches@gnu.org; Mon, 19 Dec 2022 12:25:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7Jsr-0005B2-Sm for guix-patches@gnu.org; Mon, 19 Dec 2022 12:25:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60145] [PATCH v4 2/2] gnu: Add patman. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 19 Dec 2022 17:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60145 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60145@debbugs.gnu.org Cc: vagrant@debian.org, Maxim Cournoyer Received: via spool by 60145-submit@debbugs.gnu.org id=B60145.167147066919890 (code B ref 60145); Mon, 19 Dec 2022 17:25:01 +0000 Received: (at 60145) by debbugs.gnu.org; 19 Dec 2022 17:24:29 +0000 Received: from localhost ([127.0.0.1]:39331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7JsK-0005Ak-9K for submit@debbugs.gnu.org; Mon, 19 Dec 2022 12:24:29 -0500 Received: from mail-vs1-f43.google.com ([209.85.217.43]:42988) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7JsH-0005AZ-5I for 60145@debbugs.gnu.org; Mon, 19 Dec 2022 12:24:26 -0500 Received: by mail-vs1-f43.google.com with SMTP id m2so9371605vsv.9 for <60145@debbugs.gnu.org>; Mon, 19 Dec 2022 09:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P/Y+E8j9zurJFwH/G96UgQFVcoOFwJxG8YKqYS17RBs=; b=kDo65n/63mMOmPxrOidrB1OfWUwzYmDLEmNESpLvhOJvDu53yJmRhsrfYbtV6Acdul CCIjhxsxBk3gBBJ1Ot6fa7lxpvTNFuOZFFAIiucAjB3x5BlYpAjixVCAcms0Bziz7NzX XRk/HniRAOJVa5sgdwoFutYh0Io6tNGjSh+FywB0hYVpmQHR4u94HOJhd76TxBqYNJ70 NREUH1/Yl1dWogK4QRfQiGT8J9Cdq/Nbbyn8GGbd/qfmD9OeiDTsP3JeKd/yN/kiQ1Ir UBPEsFIAfwIS4/1C+Av6P6ybc5hKpHy4bVnIIiIfDL6QTXCHQiwxZdjFBEm2ldAjxeWn UeeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P/Y+E8j9zurJFwH/G96UgQFVcoOFwJxG8YKqYS17RBs=; b=PaLlgqZ3/2DjnGXUbrFE9A1LMIC46aWQzHRbWLOQ3jd0njE+ZDH6ftGRxzBIrHclRw lHFM5h7NMZvPFAIIC5hrOQ5/d2aevD+GjmYWvsKAwhQfi3sQOVNyYSRd8qPQoITQBS3D 18+7hYPrnFdIF44xKAs2X+hhSN9QcryKpqAqNpPjCrO+bHAJxBb51DIrBHYQBknrexBl PV/ZWP5TbUGN/5hyNQ8CczdMeRgBsZonlWTw/Rh8aOXCY7Df1LHNQU0w3pBzdEm5YRah JVx1ummgM00XicZOHb34naZcrOUi9ENC+p4Ua7zrKBhZyZJHsGZ/ShkYu5IL32vsypXq 2Y1A== X-Gm-Message-State: AFqh2koEtW6KGhrGVIuVjJPRQFrKGd5CK9ruaUz5a/G9JXeK+G8wj5DS ZrkulIo3+DfovvQg7JvNwUxw5p2hoWmjLQ== X-Google-Smtp-Source: AMrXdXtQqi5EDeevCcM437yCnSMXXTLBU8xNG4byY6KupESh9HGrkSyhgLZposFGZkN7BI6YIPImDQ== X-Received: by 2002:a05:6102:34f7:b0:3b0:7212:f98e with SMTP id bi23-20020a05610234f700b003b07212f98emr3191681vsb.27.1671470659200; Mon, 19 Dec 2022 09:24:19 -0800 (PST) Received: from localhost.localdomain (dsl-10-133-202.b2b2c.ca. [72.10.133.202]) by smtp.gmail.com with ESMTPSA id l6-20020a05620a28c600b00702311aea78sm5083298qkp.82.2022.12.19.09.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 09:24:18 -0800 (PST) From: Maxim Cournoyer Date: Mon, 19 Dec 2022 12:23:32 -0500 Message-Id: <20221219172332.31222-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219172332.31222-1-maxim.cournoyer@gmail.com> References: <20221219172332.31222-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="kDo65n/6"; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1671470734; a=rsa-sha256; cv=none; b=mG+ZHDlsVhM+W6gPaYKt6ETOqYbf/UZRUZOy2986nsJ/Ky9xkfCPCTJnohBR+Y+30t8uSp +wg+y1BBCKJI+s8cy75tWh54vcfLw/ECx3mjFaZDEhpf9CbxL06AYVuuLf7XDnxXyLKuSV lPpzr7R/rJ9YdkD1RHouTIvaDz1Qdy/5hrEo0k+e6SbgX/8jwxkL1kPXKy8L4oZynj+It3 aM3JqKjmiqdFnRY5PKmY4xXzKUYWagEHQi2vWbwuzRXSix/+7XqOhqwVnsRXFwah/ulbUU hdChJ1G+vX8G5uZq6Qfxef9eNvz6yztd4dSEUfJMzk71SPKCmPeE4O6xyr+h4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1671470734; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=P/Y+E8j9zurJFwH/G96UgQFVcoOFwJxG8YKqYS17RBs=; b=A0lSPWA/lT1DxeoJrOk+O34nH8TBT22OW+eQKtuuN2LALcPCOU6MMnBXH0L+UeKlEcoloc 8g29HNLfZlRN2dcVOzO0stUAhyU5DOUvBQUcUMU+S1oVLIz0snbjBy5TeKOwwOARIQKrPA jA8OyqcHZ8KVcZuMtSM6qihb34jRs816w534BSmFaOCf12QHIFhqrC4X94Z+CRJJg5lq1j CZH1CeTHa+BjNqWtNkJoPYYQE8ZF9RC64MxQvP60V2RsRMnUp0FUyg0B8VIwZJV+I7Pu1Z 3joQZnV5TK5lp361IAOVao/vG0su34CEbAxPZxds69MoH/bMqBklbHg/Xt7lsQ== X-Migadu-Spam: Yes X-Spam: Yes X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b="kDo65n/6"; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) X-Migadu-Spam-Score: 6.21 X-Spam-Score: 6.21 X-Migadu-Queue-Id: 502FE1E4C3 X-TUID: 39z7IRLa1mMo * gnu/packages/bootloaders.scm (patman): New variable. * gnu/packages/patches/u-boot-patman-fix-help.patch: New patch. * gnu/packages/patches/u-boot-patman-local-conf.patch: Likewise. * gnu/local.mk (dist_patch_DATA): Register them. --- Changes in v4: - Use the series URL for the patches upstream submission status - Add new u-boot-patman-local-conf.patch gnu/local.mk | 2 + gnu/packages/bootloaders.scm | 35 +++- .../patches/u-boot-patman-fix-help.patch | 40 ++++ .../patches/u-boot-patman-local-conf.patch | 176 ++++++++++++++++++ 4 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/u-boot-patman-fix-help.patch create mode 100644 gnu/packages/patches/u-boot-patman-local-conf.patch diff --git a/gnu/local.mk b/gnu/local.mk index 01fcc9d7d3..48de38e770 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1925,6 +1925,8 @@ dist_patch_DATA = \ %D%/packages/patches/twinkle-bcg729.patch \ %D%/packages/patches/u-boot-allow-disabling-openssl.patch \ %D%/packages/patches/u-boot-infodocs-target.patch \ + %D%/packages/patches/u-boot-patman-fix-help.patch \ + %D%/packages/patches/u-boot-patman-local-conf.patch \ %D%/packages/patches/u-boot-nintendo-nes-serial.patch \ %D%/packages/patches/u-boot-rockchip-inno-usb.patch \ %D%/packages/patches/u-boot-sifive-prevent-reloc-initrd-fdt.patch \ diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index 32970f86f1..db7505df4f 100644 --- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -69,7 +69,10 @@ (define-module (gnu packages bootloaders) #:use-module (gnu packages valgrind) #:use-module (gnu packages virtualization) #:use-module (gnu packages xorg) + #:use-module (gnu packages python-web) + #:use-module (gnu packages python-xyz) #:use-module (guix build-system gnu) + #:use-module (guix build-system pyproject) #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix gexp) @@ -640,7 +643,9 @@ (define u-boot %u-boot-allow-disabling-openssl-patch %u-boot-sifive-prevent-relocating-initrd-fdt %u-boot-rk3399-enable-emmc-phy-patch - (search-patch "u-boot-infodocs-target.patch"))) + (search-patch "u-boot-infodocs-target.patch") + (search-patch "u-boot-patman-fix-help.patch") + (search-patch "u-boot-patman-local-conf.patch"))) (method url-fetch) (uri (string-append "https://ftp.denx.de/pub/u-boot/" @@ -816,6 +821,34 @@ (define-public u-boot-tools " This package provides board-independent tools " "of U-Boot.")))) +;;; This is packaged separately, as it can be used in other contexts than for +;;; U-Boot development. +(define-public patman + (package + (inherit u-boot) + (name "patman") + (build-system pyproject-build-system) + (arguments + ;; The test suite strongly relies on the git metadata being available (23 + ;; failed, 14 passed). + (list + #:tests? #f + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda _ + (chdir "tools/patman")))))) + (inputs (list python-pygit2 python-requests)) + (synopsis "Patch automation tool") + (description "Patman is a patch automation script which: +@itemize +@item Creates patches directly from your branch +@item Cleans them up by removing unwanted tags +@item Inserts a cover letter with change lists +@item Runs the patches through automated checks +@item Optionally emails them out to selected people. +@end itemize"))) + (define*-public (make-u-boot-package board triplet #:key defconfig diff --git a/gnu/packages/patches/u-boot-patman-fix-help.patch b/gnu/packages/patches/u-boot-patman-fix-help.patch new file mode 100644 index 0000000000..89bac06c2f --- /dev/null +++ b/gnu/packages/patches/u-boot-patman-fix-help.patch @@ -0,0 +1,40 @@ +Upstream status: https://patchwork.ozlabs.org/project/uboot/list/?series=333156 + +diff --git a/tools/patman/main.py b/tools/patman/main.py +index 5a7756a221..bf300c6e64 100755 +--- a/tools/patman/main.py ++++ b/tools/patman/main.py +@@ -7,6 +7,7 @@ + """See README for more information""" + + from argparse import ArgumentParser ++import importlib.resources + import os + import re + import shutil +@@ -163,11 +164,8 @@ elif args.cmd == 'send': + fd.close() + + elif args.full_help: +- tools.print_full_help( +- os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), +- 'README.rst') +- ) +- ++ with importlib.resources.path('patman', 'README.rst') as readme: ++ tools.print_full_help(str(readme)) + else: + # If we are not processing tags, no need to warning about bad ones + if not args.process_tags: +diff --git a/tools/patman/setup.py b/tools/patman/setup.py +index 43fdc00ce6..ce9bb4aa63 100644 +--- a/tools/patman/setup.py ++++ b/tools/patman/setup.py +@@ -7,6 +7,6 @@ setup(name='patman', + scripts=['patman'], + packages=['patman'], + package_dir={'patman': ''}, +- package_data={'patman': ['README']}, ++ package_data={'patman': ['README.rst']}, + classifiers=['Environment :: Console', + 'Topic :: Software Development']) diff --git a/gnu/packages/patches/u-boot-patman-local-conf.patch b/gnu/packages/patches/u-boot-patman-local-conf.patch new file mode 100644 index 0000000000..3400982356 --- /dev/null +++ b/gnu/packages/patches/u-boot-patman-local-conf.patch @@ -0,0 +1,176 @@ +Upstream status: https://patchwork.ozlabs.org/project/uboot/list/?series=333354 + +diff --git a/tools/patman/main.py b/tools/patman/main.py +index bf300c6e64..3616b28f27 100755 +--- a/tools/patman/main.py ++++ b/tools/patman/main.py +@@ -116,7 +116,7 @@ status.add_argument('-f', '--force', action='store_true', + argv = sys.argv[1:] + args, rest = parser.parse_known_args(argv) + if hasattr(args, 'project'): +- settings.Setup(gitutil, parser, args.project, '') ++ settings.Setup(parser, args.project) + args, rest = parser.parse_known_args(argv) + + # If we have a command, it is safe to parse all arguments +diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst +index 8c5c9cc2cc..7828899879 100644 +--- a/tools/patman/patman.rst ++++ b/tools/patman/patman.rst +@@ -74,7 +74,7 @@ out where to send patches pretty well. + During the first run patman creates a config file for you by taking the default + user name and email address from the global .gitconfig file. + +-To add your own, create a file ~/.patman like this:: ++To add your own, create a file `~/.patman` like this:: + + # patman alias file + +@@ -85,6 +85,12 @@ To add your own, create a file ~/.patman like this:: + wolfgang: Wolfgang Denk + others: Mike Frysinger , Fred Bloggs + ++Patman will also look for a `.patman` configuration file at the root ++of the current project git repository, which makes it possible to ++override the `project` settings variable or anything else in a ++project-specific way. The values of this "local" configuration file ++take precedence over those of the "global" one. ++ + Aliases are recursive. + + The checkpatch.pl in the U-Boot tools/ subdirectory will be located and +diff --git a/tools/patman/settings.py b/tools/patman/settings.py +index 903d6fcb0b..e8e2908f1f 100644 +--- a/tools/patman/settings.py ++++ b/tools/patman/settings.py +@@ -1,5 +1,6 @@ + # SPDX-License-Identifier: GPL-2.0+ + # Copyright (c) 2011 The Chromium OS Authors. ++# Copyright (c) 2022 Maxim Cournoyer + # + + try: +@@ -11,8 +12,7 @@ import argparse + import os + import re + +-from patman import command +-from patman import tools ++from patman import gitutil + + """Default settings per-project. + +@@ -190,7 +190,8 @@ def ReadGitAliases(fname): + + fd.close() + +-def CreatePatmanConfigFile(gitutil, config_fname): ++ ++def CreatePatmanConfigFile(config_fname): + """Creates a config file under $(HOME)/.patman if it can't find one. + + Args: +@@ -328,26 +329,46 @@ def GetItems(config, section): + except: + raise + +-def Setup(gitutil, parser, project_name, config_fname=''): ++def Setup(parser, project_name, config_fname=None): + """Set up the settings module by reading config files. + ++ Unless `config_fname` is specified, a `.patman` config file local ++ to the git repository is consulted, followed by the global ++ `$HOME/.patman`. If none exists, the later is created. Values ++ defined in the local config file take precedence over those ++ defined in the global one. ++ + Args: +- parser: The parser to update ++ parser: The parser to update. + project_name: Name of project that we're working on; we'll look + for sections named "project_section" as well. +- config_fname: Config filename to read ('' for default) ++ config_fname: Config filename to read. An error is raised if it ++ does not exist. + """ + # First read the git alias file if available + _ReadAliasFile('doc/git-mailrc') + config = _ProjectConfigParser(project_name) +- if config_fname == '': ++ ++ if config_fname and not os.path.exists(config_fname): ++ raise Exception(f'provided {config_fname} does not exist') ++ ++ if not config_fname: + config_fname = '%s/.patman' % os.getenv('HOME') ++ has_config = os.path.exists(config_fname) ++ ++ git_local_config_fname = os.path.join(gitutil.get_top_level(), '.patman') ++ has_git_local_config = os.path.exists(git_local_config_fname) + +- if not os.path.exists(config_fname): +- print("No config file found ~/.patman\nCreating one...\n") +- CreatePatmanConfigFile(gitutil, config_fname) ++ # Read the git local config last, so that its values override ++ # those of the global config, if any. ++ if has_config: ++ config.read(config_fname) ++ if has_git_local_config: ++ config.read(git_local_config_fname) + +- config.read(config_fname) ++ if not (has_config or has_git_local_config): ++ print("No config file found.\nCreating ~/.patman...\n") ++ CreatePatmanConfigFile(config_fname) + + for name, value in GetItems(config, 'alias'): + alias[name] = value.split(',') +diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py +new file mode 100644 +index 0000000000..9c14b4aaa3 +--- /dev/null ++++ b/tools/patman/test_settings.py +@@ -0,0 +1,43 @@ ++# SPDX-License-Identifier: GPL-2.0+ ++# ++# Copyright (c) 2022 Maxim Cournoyer ++# ++ ++import argparse ++import contextlib ++import os ++import subprocess ++import tempfile ++ ++from patman import settings ++ ++ ++@contextlib.contextmanager ++def empty_git_repository(): ++ with tempfile.TemporaryDirectory() as tmpdir: ++ os.chdir(tmpdir) ++ subprocess.check_call(['git', 'init']) ++ yield tmpdir ++ ++ ++def test_git_local_config(): ++ with empty_git_repository(): ++ with tempfile.NamedTemporaryFile() as global_config: ++ global_config.write(b'[settings]\n' ++ b'project=u-boot\n') ++ global_config.flush() ++ parser = argparse.ArgumentParser() ++ parser.add_argument('-p', '--project', default='unknown') ++ ++ # Test "global" config is used. ++ settings.Setup(parser, 'unknown', global_config.name) ++ args, _ = parser.parse_known_args() ++ assert args.project == 'u-boot' ++ ++ # Test local config can shadow it. ++ with open('.patman', 'w', buffering=1) as f: ++ f.write('[settings]\n' ++ 'project=guix-patches\n') ++ settings.Setup(parser, 'unknown', global_config.name) ++ args, _ = parser.parse_known_args([]) ++ assert args.project == 'guix-patches' -- 2.38.1