unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#60145] [PATCH 0/2] Add u-boot-documentation and patman
@ 2022-12-17  4:15 Maxim Cournoyer
  2022-12-17  4:35 ` [bug#60145] [PATCH 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-17  4:15 UTC (permalink / raw)
  To: 60145; +Cc: Maxim Cournoyer

This adds the u-boot documentation as an info manual and package a tool it
used in the U-Boot community to work with patch.  I'm testing it, perhaps it
could be used in Guix, if it's modular enough to be plugged with etc/teams.scm
and guix lint :-).

Thanks,

Maxim Cournoyer (2):
  gnu: Add u-boot-documentation.
  gnu: Add patman.

 gnu/local.mk                                  |  2 +
 gnu/packages/bootloaders.scm                  | 79 ++++++++++++++++++-
 .../patches/u-boot-infodocs-target.patch      | 61 ++++++++++++++
 .../patches/u-boot-patman-fix-help.patch      | 40 ++++++++++
 4 files changed, 181 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-infodocs-target.patch
 create mode 100644 gnu/packages/patches/u-boot-patman-fix-help.patch


base-commit: 90a2b8c64a0155a1cd663ee5408dc6bb09d64123
-- 
2.38.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH 1/2] gnu: Add u-boot-documentation.
  2022-12-17  4:15 [bug#60145] [PATCH 0/2] Add u-boot-documentation and patman Maxim Cournoyer
@ 2022-12-17  4:35 ` Maxim Cournoyer
  2022-12-17  4:35   ` [bug#60145] [PATCH 2/2] gnu: Add patman Maxim Cournoyer
  2022-12-19 17:23 ` [bug#60145] [PATCH v4 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-17  4:35 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* gnu/packages/patches/u-boot-infodocs-target.patch: New patch.
* gnu/local.mk: (dist_patch_DATA): Register it.
* gnu/packages/bootloaders.scm (u-boot): Apply it.
(u-boot-documentation): New variable.
---

 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 47 +++++++++++++-
 .../patches/u-boot-infodocs-target.patch      | 61 +++++++++++++++++++
 3 files changed, 108 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-infodocs-target.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 5b8944f568..8ae21641d7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1923,6 +1923,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/tuxpaint-stamps-path.patch		\
   %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-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 3c96453e5c..f52b2130ac 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -62,6 +63,7 @@ (define-module (gnu packages bootloaders)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages valgrind)
@@ -637,7 +639,8 @@ (define u-boot
                (list %u-boot-rockchip-inno-usb-patch
                      %u-boot-allow-disabling-openssl-patch
                      %u-boot-sifive-prevent-relocating-initrd-fdt
-                     %u-boot-rk3399-enable-emmc-phy-patch))
+                     %u-boot-rk3399-enable-emmc-phy-patch
+                     (search-patch "u-boot-infodocs-target.patch")))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
@@ -667,6 +670,48 @@ (define u-boot
 also initializes the boards (RAM etc).")
     (license license:gpl2+)))
 
+;;; This is very similar to the linux-libre-documentation package, since it
+;;; reuses the same Makefile-based build system.
+(define-public u-boot-documentation
+  (package
+    (inherit u-boot)
+    (name "u-boot-documentation")
+    (arguments
+     (list
+      #:make-flags #~(list "HOSTCC=gcc"
+                           ;; Avoid treating Sphinx warnings as errors.
+                           "SPHINXOPTS=")
+      #:tests? #f
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'configure)
+                   (replace 'build
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (substitute* "doc/Makefile"
+                         ;; Remove problematic environment check script.
+                         ((".*scripts/sphinx-pre-install.*") ""))
+                       (apply invoke "make" "infodocs" make-flags)))
+                   (replace 'install
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (let* ((info-dir (string-append #$output "/share/info"))
+                              (info (string-append info-dir
+                                                   "/DasUBoot.info.gz")))
+                         (with-directory-excursion "doc/output"
+                           (apply invoke "make" "-C" "texinfo" "install-info"
+                                  (string-append "infodir=" info-dir)
+                                  make-flags))
+                         ;; Create a symlink, for convenience.
+                         (symlink info (string-append info-dir
+                                                      "/uboot.info.gz"))))))))
+    (native-inputs
+     (modify-inputs (package-native-inputs u-boot)
+       (append fontconfig
+               python-sphinx
+               texinfo
+               which)))
+    (synopsis "U-Boot documentation")
+    (description "This package provides the documentation for U-Boot, as an
+Info manual.")))
+
 (define-public u-boot-tools
   (package
     (inherit u-boot)
diff --git a/gnu/packages/patches/u-boot-infodocs-target.patch b/gnu/packages/patches/u-boot-infodocs-target.patch
new file mode 100644
index 0000000000..ba32f1913a
--- /dev/null
+++ b/gnu/packages/patches/u-boot-infodocs-target.patch
@@ -0,0 +1,61 @@
+Submitted upstream on Dec 16th, 2022.
+
+diff --git a/Makefile b/Makefile
+index de5746399a..597a8886c3 100644
+--- a/Makefile
++++ b/Makefile
+@@ -2372,7 +2372,7 @@ tcheck:
+ # Documentation targets
+ # ---------------------------------------------------------------------------
+ DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
+-	       linkcheckdocs dochelp refcheckdocs
++	       linkcheckdocs dochelp refcheckdocs texinfodocs infodocs
+ PHONY += $(DOC_TARGETS)
+ $(DOC_TARGETS): scripts_basic FORCE
+ 	$(Q)$(MAKE) $(build)=doc $@
+diff --git a/doc/Makefile b/doc/Makefile
+index f5de65e927..62effd0fec 100644
+--- a/doc/Makefile
++++ b/doc/Makefile
+@@ -69,6 +69,15 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
+ htmldocs:
+ 	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
+ 
++texinfodocs:
++	@$(srctree)/scripts/sphinx-pre-install --version-check
++	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texinfo,$(var)))
++
++# Note: the 'info' Make target is generated by sphinx itself when
++# running the texinfodocs target defined above.
++infodocs: texinfodocs
++	$(MAKE) -C $(BUILDDIR)/texinfo info
++
+ linkcheckdocs:
+ 	@$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
+ 
+@@ -109,6 +118,8 @@ cleandocs:
+ dochelp:
+ 	@echo  ' U-Boot documentation in different formats from ReST:'
+ 	@echo  '  htmldocs        - HTML'
++	@echo  '  texinfodocs     - Texinfo'
++	@echo  '  infodocs        - Info'
+ 	@echo  '  latexdocs       - LaTeX'
+ 	@echo  '  pdfdocs         - PDF'
+ 	@echo  '  epubdocs        - EPUB'
+diff --git a/doc/media/Makefile b/doc/media/Makefile
+index b9b43a34c3..9b32258696 100644
+--- a/doc/media/Makefile
++++ b/doc/media/Makefile
+@@ -22,10 +22,11 @@ $(BUILDDIR)/linker_lists.h.rst: ${API}/linker_lists.h ${PARSER} $(SRC_DIR)/linke
+ 
+ # Media build rules
+ 
+-.PHONY: all html epub xml latex
++.PHONY: all html texinfo epub xml latex
+ 
+ all: $(IMGDOT) $(BUILDDIR) ${TARGETS}
+ html: all
++texinfo: all
+ epub: all
+ xml: all
+ latex: $(IMGPDF) all

base-commit: 90a2b8c64a0155a1cd663ee5408dc6bb09d64123
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH 2/2] gnu: Add patman.
  2022-12-17  4:35 ` [bug#60145] [PATCH 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
@ 2022-12-17  4:35   ` Maxim Cournoyer
  0 siblings, 0 replies; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-17  4:35 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* gnu/packages/bootloaders.scm (patman): New variable.
* gnu/packages/patches/u-boot-patman-fix-help.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Register it.
---

 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 34 +++++++++++++++-
 .../patches/u-boot-patman-fix-help.patch      | 40 +++++++++++++++++++
 3 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-patman-fix-help.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 8ae21641d7..456d955616 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1924,6 +1924,7 @@ 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-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 f52b2130ac..335b5a56d8 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,8 @@ (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")))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
@@ -822,6 +826,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..15b1aa3b55
--- /dev/null
+++ b/gnu/packages/patches/u-boot-patman-fix-help.patch
@@ -0,0 +1,40 @@
+Submitted upstream on Dec 16th, 2022.
+
+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'])
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH v4 1/2] gnu: Add u-boot-documentation.
  2022-12-17  4:15 [bug#60145] [PATCH 0/2] Add u-boot-documentation and patman Maxim Cournoyer
  2022-12-17  4:35 ` [bug#60145] [PATCH 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
@ 2022-12-19 17:23 ` Maxim Cournoyer
  2022-12-19 17:23   ` [bug#60145] [PATCH v4 2/2] gnu: Add patman Maxim Cournoyer
  2022-12-19 22:42 ` [bug#60145] [PATCH v5 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
  2022-12-20 13:21 ` [bug#60145] [PATCH v6 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
  3 siblings, 1 reply; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 17:23 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* gnu/packages/patches/u-boot-infodocs-target.patch: New patch.
* gnu/local.mk: (dist_patch_DATA): Register it.
* gnu/packages/bootloaders.scm (u-boot): Apply it.
(u-boot-documentation): New variable.

---

(no changes since v3)

Changes in v3:
- Update U-Boot documentation patch
- Remove now extraneous convenience symlink

Changes in v2:
- Update U-Boot documentation patch

 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 41 ++++++++-
 .../patches/u-boot-infodocs-target.patch      | 84 +++++++++++++++++++
 3 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-infodocs-target.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 56634e090c..01fcc9d7d3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1924,6 +1924,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/tuxpaint-stamps-path.patch		\
   %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-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 3c96453e5c..32970f86f1 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -62,6 +63,7 @@ (define-module (gnu packages bootloaders)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages valgrind)
@@ -637,7 +639,8 @@ (define u-boot
                (list %u-boot-rockchip-inno-usb-patch
                      %u-boot-allow-disabling-openssl-patch
                      %u-boot-sifive-prevent-relocating-initrd-fdt
-                     %u-boot-rk3399-enable-emmc-phy-patch))
+                     %u-boot-rk3399-enable-emmc-phy-patch
+                     (search-patch "u-boot-infodocs-target.patch")))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
@@ -667,6 +670,42 @@ (define u-boot
 also initializes the boards (RAM etc).")
     (license license:gpl2+)))
 
+;;; This is very similar to the linux-libre-documentation package, since it
+;;; reuses the same Makefile-based build system.
+(define-public u-boot-documentation
+  (package
+    (inherit u-boot)
+    (name "u-boot-documentation")
+    (arguments
+     (list
+      #:make-flags #~(list "HOSTCC=gcc"
+                           ;; Avoid treating Sphinx warnings as errors.
+                           "SPHINXOPTS=")
+      #:tests? #f
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'configure)
+                   (replace 'build
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (apply invoke "make" "infodocs" make-flags)))
+                   (replace 'install
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (let* ((info-dir (string-append #$output "/share/info"))
+                              (info (string-append info-dir
+                                                   "/DasUBoot.info.gz")))
+                         (with-directory-excursion "doc/output"
+                           (apply invoke "make" "-C" "texinfo" "install-info"
+                                  (string-append "infodir=" info-dir)
+                                  make-flags))))))))
+    (native-inputs
+     (modify-inputs (package-native-inputs u-boot)
+       (append fontconfig
+               python-sphinx
+               texinfo
+               which)))
+    (synopsis "U-Boot documentation")
+    (description "This package provides the documentation for U-Boot, as an
+Info manual.")))
+
 (define-public u-boot-tools
   (package
     (inherit u-boot)
diff --git a/gnu/packages/patches/u-boot-infodocs-target.patch b/gnu/packages/patches/u-boot-infodocs-target.patch
new file mode 100644
index 0000000000..2c81807f39
--- /dev/null
+++ b/gnu/packages/patches/u-boot-infodocs-target.patch
@@ -0,0 +1,84 @@
+Upstream status: https://patchwork.ozlabs.org/project/uboot/patch/20221217025137.2514-1-maxim.cournoyer@savoirfairelinux.com/
+
+diff --git a/Makefile b/Makefile
+index de5746399a..597a8886c3 100644
+--- a/Makefile
++++ b/Makefile
+@@ -2372,7 +2372,7 @@ tcheck:
+ # Documentation targets
+ # ---------------------------------------------------------------------------
+ DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
+-	       linkcheckdocs dochelp refcheckdocs
++	       linkcheckdocs dochelp refcheckdocs texinfodocs infodocs
+ PHONY += $(DOC_TARGETS)
+ $(DOC_TARGETS): scripts_basic FORCE
+ 	$(Q)$(MAKE) $(build)=doc $@
+diff --git a/doc/Makefile b/doc/Makefile
+index f5de65e927..d0904a9f99 100644
+--- a/doc/Makefile
++++ b/doc/Makefile
+@@ -69,6 +69,14 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
+ htmldocs:
+ 	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
+ 
++texinfodocs:
++	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texinfo,$(var)))
++
++# Note: the 'info' Make target is generated by sphinx itself when
++# running the texinfodocs target defined above.
++infodocs: texinfodocs
++	$(MAKE) -C $(BUILDDIR)/texinfo info
++
+ linkcheckdocs:
+ 	@$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
+ 
+@@ -109,6 +117,8 @@ cleandocs:
+ dochelp:
+ 	@echo  ' U-Boot documentation in different formats from ReST:'
+ 	@echo  '  htmldocs        - HTML'
++	@echo  '  texinfodocs     - Texinfo'
++	@echo  '  infodocs        - Info'
+ 	@echo  '  latexdocs       - LaTeX'
+ 	@echo  '  pdfdocs         - PDF'
+ 	@echo  '  epubdocs        - EPUB'
+diff --git a/doc/conf.py b/doc/conf.py
+index 62c8d31270..3db70f80c1 100644
+--- a/doc/conf.py
++++ b/doc/conf.py
+@@ -449,7 +449,7 @@ for fn in os.listdir('.'):
+ # One entry per manual page. List of tuples
+ # (source start file, name, description, authors, manual section).
+ man_pages = [
+-    (master_doc, 'dasuboot', 'The U-Boot Documentation',
++    (master_doc, 'u-boot', 'The U-Boot Documentation',
+      [author], 1)
+ ]
+ 
+@@ -463,8 +463,8 @@ man_pages = [
+ # (source start file, target name, title, author,
+ #  dir menu entry, description, category)
+ texinfo_documents = [
+-    (master_doc, 'DasUBoot', 'The U-Boot Documentation',
+-     author, 'DasUBoot', 'One line description of project.',
++    (master_doc, 'u-boot', 'The U-Boot Documentation',
++     author, 'U-Boot', 'Boot loader for embedded systems',
+      'Miscellaneous'),
+ ]
+ 
+diff --git a/doc/media/Makefile b/doc/media/Makefile
+index b9b43a34c3..9b32258696 100644
+--- a/doc/media/Makefile
++++ b/doc/media/Makefile
+@@ -22,10 +22,11 @@ $(BUILDDIR)/linker_lists.h.rst: ${API}/linker_lists.h ${PARSER} $(SRC_DIR)/linke
+ 
+ # Media build rules
+ 
+-.PHONY: all html epub xml latex
++.PHONY: all html texinfo epub xml latex
+ 
+ all: $(IMGDOT) $(BUILDDIR) ${TARGETS}
+ html: all
++texinfo: all
+ epub: all
+ xml: all
+ latex: $(IMGPDF) all

base-commit: f28ca2447c5e2eef1ba6a3a11587380a665b0e26
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH v4 2/2] gnu: Add patman.
  2022-12-19 17:23 ` [bug#60145] [PATCH v4 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
@ 2022-12-19 17:23   ` Maxim Cournoyer
  0 siblings, 0 replies; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 17:23 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* 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 <wd@denx.de>
+     others: Mike Frysinger <vapier@gentoo.org>, Fred Bloggs <f.bloggs@napier.net>
+ 
++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 <maxim.cournoyer@savoirfairelinux.com>
+ #
+ 
+ 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 <maxim.cournoyer@savoirfairelinux.com>
++#
++
++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





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH v5 1/2] gnu: Add u-boot-documentation.
  2022-12-17  4:15 [bug#60145] [PATCH 0/2] Add u-boot-documentation and patman Maxim Cournoyer
  2022-12-17  4:35 ` [bug#60145] [PATCH 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
  2022-12-19 17:23 ` [bug#60145] [PATCH v4 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
@ 2022-12-19 22:42 ` Maxim Cournoyer
  2022-12-19 22:42   ` [bug#60145] [PATCH v5 2/2] gnu: Add patman Maxim Cournoyer
  2022-12-20 13:21 ` [bug#60145] [PATCH v6 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
  3 siblings, 1 reply; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:42 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* gnu/packages/patches/u-boot-infodocs-target.patch: New patch.
* gnu/local.mk: (dist_patch_DATA): Register it.
* gnu/packages/bootloaders.scm (u-boot): Apply it.
(u-boot-documentation): New variable.

---

Changes in v5:
- Update URL in patch

Changes in v3:
- Update U-Boot documentation patch
- Remove now extraneous convenience symlink

Changes in v2:
- Update U-Boot documentation patch

 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 41 ++++++++-
 .../patches/u-boot-infodocs-target.patch      | 84 +++++++++++++++++++
 3 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-infodocs-target.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 56634e090c..01fcc9d7d3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1924,6 +1924,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/tuxpaint-stamps-path.patch		\
   %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-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 3c96453e5c..32970f86f1 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -62,6 +63,7 @@ (define-module (gnu packages bootloaders)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages valgrind)
@@ -637,7 +639,8 @@ (define u-boot
                (list %u-boot-rockchip-inno-usb-patch
                      %u-boot-allow-disabling-openssl-patch
                      %u-boot-sifive-prevent-relocating-initrd-fdt
-                     %u-boot-rk3399-enable-emmc-phy-patch))
+                     %u-boot-rk3399-enable-emmc-phy-patch
+                     (search-patch "u-boot-infodocs-target.patch")))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
@@ -667,6 +670,42 @@ (define u-boot
 also initializes the boards (RAM etc).")
     (license license:gpl2+)))
 
+;;; This is very similar to the linux-libre-documentation package, since it
+;;; reuses the same Makefile-based build system.
+(define-public u-boot-documentation
+  (package
+    (inherit u-boot)
+    (name "u-boot-documentation")
+    (arguments
+     (list
+      #:make-flags #~(list "HOSTCC=gcc"
+                           ;; Avoid treating Sphinx warnings as errors.
+                           "SPHINXOPTS=")
+      #:tests? #f
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'configure)
+                   (replace 'build
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (apply invoke "make" "infodocs" make-flags)))
+                   (replace 'install
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (let* ((info-dir (string-append #$output "/share/info"))
+                              (info (string-append info-dir
+                                                   "/DasUBoot.info.gz")))
+                         (with-directory-excursion "doc/output"
+                           (apply invoke "make" "-C" "texinfo" "install-info"
+                                  (string-append "infodir=" info-dir)
+                                  make-flags))))))))
+    (native-inputs
+     (modify-inputs (package-native-inputs u-boot)
+       (append fontconfig
+               python-sphinx
+               texinfo
+               which)))
+    (synopsis "U-Boot documentation")
+    (description "This package provides the documentation for U-Boot, as an
+Info manual.")))
+
 (define-public u-boot-tools
   (package
     (inherit u-boot)
diff --git a/gnu/packages/patches/u-boot-infodocs-target.patch b/gnu/packages/patches/u-boot-infodocs-target.patch
new file mode 100644
index 0000000000..5b21a99de3
--- /dev/null
+++ b/gnu/packages/patches/u-boot-infodocs-target.patch
@@ -0,0 +1,84 @@
+Upstream status: https://patchwork.ozlabs.org/project/uboot/list/?series=333259
+
+diff --git a/Makefile b/Makefile
+index de5746399a..597a8886c3 100644
+--- a/Makefile
++++ b/Makefile
+@@ -2372,7 +2372,7 @@ tcheck:
+ # Documentation targets
+ # ---------------------------------------------------------------------------
+ DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
+-	       linkcheckdocs dochelp refcheckdocs
++	       linkcheckdocs dochelp refcheckdocs texinfodocs infodocs
+ PHONY += $(DOC_TARGETS)
+ $(DOC_TARGETS): scripts_basic FORCE
+ 	$(Q)$(MAKE) $(build)=doc $@
+diff --git a/doc/Makefile b/doc/Makefile
+index f5de65e927..d0904a9f99 100644
+--- a/doc/Makefile
++++ b/doc/Makefile
+@@ -69,6 +69,14 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
+ htmldocs:
+ 	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
+ 
++texinfodocs:
++	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texinfo,$(var)))
++
++# Note: the 'info' Make target is generated by sphinx itself when
++# running the texinfodocs target defined above.
++infodocs: texinfodocs
++	$(MAKE) -C $(BUILDDIR)/texinfo info
++
+ linkcheckdocs:
+ 	@$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
+ 
+@@ -109,6 +117,8 @@ cleandocs:
+ dochelp:
+ 	@echo  ' U-Boot documentation in different formats from ReST:'
+ 	@echo  '  htmldocs        - HTML'
++	@echo  '  texinfodocs     - Texinfo'
++	@echo  '  infodocs        - Info'
+ 	@echo  '  latexdocs       - LaTeX'
+ 	@echo  '  pdfdocs         - PDF'
+ 	@echo  '  epubdocs        - EPUB'
+diff --git a/doc/conf.py b/doc/conf.py
+index 62c8d31270..3db70f80c1 100644
+--- a/doc/conf.py
++++ b/doc/conf.py
+@@ -449,7 +449,7 @@ for fn in os.listdir('.'):
+ # One entry per manual page. List of tuples
+ # (source start file, name, description, authors, manual section).
+ man_pages = [
+-    (master_doc, 'dasuboot', 'The U-Boot Documentation',
++    (master_doc, 'u-boot', 'The U-Boot Documentation',
+      [author], 1)
+ ]
+ 
+@@ -463,8 +463,8 @@ man_pages = [
+ # (source start file, target name, title, author,
+ #  dir menu entry, description, category)
+ texinfo_documents = [
+-    (master_doc, 'DasUBoot', 'The U-Boot Documentation',
+-     author, 'DasUBoot', 'One line description of project.',
++    (master_doc, 'u-boot', 'The U-Boot Documentation',
++     author, 'U-Boot', 'Boot loader for embedded systems',
+      'Miscellaneous'),
+ ]
+ 
+diff --git a/doc/media/Makefile b/doc/media/Makefile
+index b9b43a34c3..9b32258696 100644
+--- a/doc/media/Makefile
++++ b/doc/media/Makefile
+@@ -22,10 +22,11 @@ $(BUILDDIR)/linker_lists.h.rst: ${API}/linker_lists.h ${PARSER} $(SRC_DIR)/linke
+ 
+ # Media build rules
+ 
+-.PHONY: all html epub xml latex
++.PHONY: all html texinfo epub xml latex
+ 
+ all: $(IMGDOT) $(BUILDDIR) ${TARGETS}
+ html: all
++texinfo: all
+ epub: all
+ xml: all
+ latex: $(IMGPDF) all

base-commit: f28ca2447c5e2eef1ba6a3a11587380a665b0e26
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH v5 2/2] gnu: Add patman.
  2022-12-19 22:42 ` [bug#60145] [PATCH v5 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
@ 2022-12-19 22:42   ` Maxim Cournoyer
  0 siblings, 0 replies; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-19 22:42 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* gnu/packages/bootloaders.scm (patman): New variable.
* gnu/packages/patches/u-boot-patman-fix-help.patch: New patch.
* gnu/packages/patches/u-boot-patman-get-maintainer.patch: Likewise.
* gnu/packages/patches/u-boot-patman-local-conf.patch: Likewise.
* gnu/local.mk (dist_patch_DATA): Register them.

---

Changes in v5:
- Add new u-boot-patman-get-maintainer.patch.

Changes in v4:
- Use the series URL for the patches upstream submission status
- Add new u-boot-patman-local-conf.patch

 gnu/local.mk                                  |   3 +
 gnu/packages/bootloaders.scm                  |  36 ++-
 .../patches/u-boot-patman-fix-help.patch      |  40 +++
 .../u-boot-patman-get-maintainer.patch        | 285 ++++++++++++++++++
 .../patches/u-boot-patman-local-conf.patch    | 176 +++++++++++
 5 files changed, 539 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-patman-fix-help.patch
 create mode 100644 gnu/packages/patches/u-boot-patman-get-maintainer.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..a704cf6002 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1925,6 +1925,9 @@ 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-get-maintainer.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..4cfb16860e 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,10 @@ (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")
+                     (search-patch "u-boot-patman-get-maintainer.patch")))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
@@ -816,6 +822,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-get-maintainer.patch b/gnu/packages/patches/u-boot-patman-get-maintainer.patch
new file mode 100644
index 0000000000..1ff03efea3
--- /dev/null
+++ b/gnu/packages/patches/u-boot-patman-get-maintainer.patch
@@ -0,0 +1,285 @@
+Upstream status: https://patchwork.ozlabs.org/project/uboot/list/?series=333427
+
+diff --git a/tools/patman/control.py b/tools/patman/control.py
+index bf426cf7bc..38e98dab84 100644
+--- a/tools/patman/control.py
++++ b/tools/patman/control.py
+@@ -94,8 +94,8 @@ def check_patches(series, patch_files, run_checkpatch, verbose, use_tree):
+ 
+ 
+ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
+-                  ignore_bad_tags, add_maintainers, limit, dry_run, in_reply_to,
+-                  thread, smtp_server):
++                  ignore_bad_tags, add_maintainers, get_maintainer_script, limit,
++                  dry_run, in_reply_to, thread, smtp_server):
+     """Email patches to the recipients
+ 
+     This emails out the patches and cover letter using 'git send-email'. Each
+@@ -123,6 +123,8 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
+         ignore_bad_tags (bool): True to just print a warning for unknown tags,
+             False to halt with an error
+         add_maintainers (bool): Run the get_maintainer.pl script for each patch
++        get_maintainer_script (str): The script used to retrieve which
++            maintainers to cc
+         limit (int): Limit on the number of people that can be cc'd on a single
+             patch or the cover letter (None if no limit)
+         dry_run (bool): Don't actually email the patches, just print out what
+@@ -134,7 +136,7 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go,
+         smtp_server (str): SMTP server to use to send patches (None for default)
+     """
+     cc_file = series.MakeCcFile(process_tags, cover_fname, not ignore_bad_tags,
+-                                add_maintainers, limit)
++                                add_maintainers, limit, get_maintainer_script)
+ 
+     # Email the patches out (giving the user time to check / cancel)
+     cmd = ''
+@@ -174,8 +176,8 @@ def send(args):
+     email_patches(
+         col, series, cover_fname, patch_files, args.process_tags,
+         its_a_go, args.ignore_bad_tags, args.add_maintainers,
+-        args.limit, args.dry_run, args.in_reply_to, args.thread,
+-        args.smtp_server)
++        args.get_maintainer_script, args.limit, args.dry_run,
++        args.in_reply_to, args.thread, args.smtp_server)
+ 
+ def patchwork_status(branch, count, start, end, dest_branch, force,
+                      show_comments, url):
+diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
+index 7b92bc67be..6fa6e6a75e 100644
+--- a/tools/patman/func_test.py
++++ b/tools/patman/func_test.py
+@@ -200,6 +200,8 @@ class TestFunctional(unittest.TestCase):
+         text = self._get_text('test01.txt')
+         series = patchstream.get_metadata_for_test(text)
+         cover_fname, args = self._create_patches_for_test(series)
++        get_maintainer_script = (pathlib.Path(__file__).parent.parent.parent
++                                 / 'get_maintainer.pl') + ' --norolestats'
+         with capture_sys_output() as out:
+             patchstream.fix_patches(series, args)
+             if cover_fname and series.get('cover'):
+@@ -207,7 +209,7 @@ class TestFunctional(unittest.TestCase):
+             series.DoChecks()
+             cc_file = series.MakeCcFile(process_tags, cover_fname,
+                                         not ignore_bad_tags, add_maintainers,
+-                                        None)
++                                        None, get_maintainer_script)
+             cmd = gitutil.email_patches(
+                 series, cover_fname, args, dry_run, not ignore_bad_tags,
+                 cc_file, in_reply_to=in_reply_to, thread=None)
+diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py
+index e1d15ff6ab..eb06423c19 100644
+--- a/tools/patman/get_maintainer.py
++++ b/tools/patman/get_maintainer.py
+@@ -1,48 +1,61 @@
+ # SPDX-License-Identifier: GPL-2.0+
+ # Copyright (c) 2012 The Chromium OS Authors.
++# Copyright (c) 2022 Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
+ #
+ 
+ import os
++import shlex
++import shutil
+ 
+ from patman import command
++from patman import gitutil
+ 
+-def find_get_maintainer(try_list):
+-    """Look for the get_maintainer.pl script.
+ 
+-    Args:
+-        try_list: List of directories to try for the get_maintainer.pl script
++def find_get_maintainer(script_file_name):
++    """Try to find where `script_file_name` is.
+ 
+-    Returns:
+-        If the script is found we'll return a path to it; else None.
++    It searches in PATH and falls back to a path relative to the top
++    of the current git repository.
+     """
+-    # Look in the list
+-    for path in try_list:
+-        fname = os.path.join(path, 'get_maintainer.pl')
+-        if os.path.isfile(fname):
+-            return fname
++    get_maintainer = shutil.which(script_file_name)
++    if get_maintainer:
++        return get_maintainer
++
++    git_relative_script = os.path.join(gitutil.get_top_level(),
++                                       script_file_name)
++    if os.path.exist(git_relative_script):
++        return git_relative_script
+ 
+-    return None
+ 
+-def get_maintainer(dir_list, fname, verbose=False):
+-    """Run get_maintainer.pl on a file if we find it.
++def get_maintainer(script_file_name, fname, verbose=False):
++    """Run `script_file_name` on a file.
+ 
+-    We look for get_maintainer.pl in the 'scripts' directory at the top of
+-    git.  If we find it we'll run it.  If we don't find get_maintainer.pl
+-    then we fail silently.
++    `script_file_name` should be a get_maintainer.pl-like script that
++    takes a patch file name as an input and return the email addresses
++    of the associated maintainers to standard output, one per line.
++
++    If `script_file_name` does not exist we fail silently.
+ 
+     Args:
+-        dir_list: List of directories to try for the get_maintainer.pl script
+-        fname: Path to the patch file to run get_maintainer.pl on.
++        script_file_name: The file name of the get_maintainer.pl script
++            (or compatible).
++        fname: File name of the patch to process with get_maintainer.pl.
+ 
+     Returns:
+         A list of email addresses to CC to.
+     """
+-    get_maintainer = find_get_maintainer(dir_list)
++    # Expand `script_file_name` into a file name and its arguments, if
++    # any.
++    cmd_args = shlex.split(script_file_name)
++    file_name = cmd_args[0]
++    arguments = cmd_args[1:]
++
++    get_maintainer = find_get_maintainer(file_name)
+     if not get_maintainer:
+         if verbose:
+             print("WARNING: Couldn't find get_maintainer.pl")
+         return []
+ 
+-    stdout = command.output(get_maintainer, '--norolestats', fname)
++    stdout = command.output(get_maintainer, *arguments, fname)
+     lines = stdout.splitlines()
+-    return [ x.replace('"', '') for x in lines ]
++    return [x.replace('"', '') for x in lines]
+diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
+index ceaf2ce150..a72ba4f42d 100644
+--- a/tools/patman/gitutil.py
++++ b/tools/patman/gitutil.py
+@@ -417,8 +417,8 @@ def check_suppress_cc_config():
+     return True
+ 
+ def email_patches(series, cover_fname, args, dry_run, warn_on_error, cc_fname,
+-        self_only=False, alias=None, in_reply_to=None, thread=False,
+-        smtp_server=None):
++                  self_only=False, alias=None, in_reply_to=None, thread=False,
++                  smtp_server=None, get_maintainer_script=None):
+     """Email a patch series.
+ 
+     Args:
+@@ -435,6 +435,7 @@ def email_patches(series, cover_fname, args, dry_run, warn_on_error, cc_fname,
+         thread: True to add --thread to git send-email (make
+             all patches reply to cover-letter or first patch in series)
+         smtp_server: SMTP server to use to send patches
++        get_maintainer_script: File name of script to get maintainers emails
+ 
+     Returns:
+         Git command that was/would be run
+diff --git a/tools/patman/main.py b/tools/patman/main.py
+index fb5ad60b20..c39c0424f9 100755
+--- a/tools/patman/main.py
++++ b/tools/patman/main.py
+@@ -64,6 +64,12 @@ send.add_argument('-l', '--limit-cc', dest='limit', type=int, default=None,
+ send.add_argument('-m', '--no-maintainers', action='store_false',
+        dest='add_maintainers', default=True,
+        help="Don't cc the file maintainers automatically")
++send.add_argument(
++    '--get-maintainer-script', dest='get_maintainer_script', type=str,
++    action='store',
++    default=os.path.join(gitutil.get_top_level(), 'scripts',
++                         'get_maintainer.pl') + ' --norolestats',
++    help='File name of the get_maintainer.pl (or compatible) script.')
+ send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
+        default=False, help="Do a dry run (create but don't email patches)")
+ send.add_argument('-r', '--in-reply-to', type=str, action='store',
+diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
+index 7828899879..5a3554f961 100644
+--- a/tools/patman/patman.rst
++++ b/tools/patman/patman.rst
+@@ -1,6 +1,7 @@
+ .. SPDX-License-Identifier: GPL-2.0+
+ .. Copyright (c) 2011 The Chromium OS Authors
+ .. Simon Glass <sjg@chromium.org>
++.. Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
+ .. v1, v2, 19-Oct-11
+ .. revised v3 24-Nov-11
+ .. revised v4 Independence Day 2020, with Patchwork integration
+@@ -68,8 +69,23 @@ this once::
+ 
+     git config sendemail.aliasesfile doc/git-mailrc
+ 
+-For both Linux and U-Boot the 'scripts/get_maintainer.pl' handles figuring
+-out where to send patches pretty well.
++For both Linux and U-Boot the 'scripts/get_maintainer.pl' handles
++figuring out where to send patches pretty well. For other projects,
++you may want to specify a different script to be run, for example via
++a project-specific `.patman` file::
++
++    # .patman configuration file at the root of some project
++
++    [settings]
++    get_maintainer_script: etc/teams.scm get-maintainer
++
++The `get_maintainer_script` option corresponds to the
++`--get-maintainer-script` argument of the `send` command.  It is
++looked relatively to the root of the current git repository, as well
++as on PATH.  It can also be provided arguments, as shown above.  The
++contract is that the script should accept a patch file name and return
++a list of email addresses, one per line, like `get_maintainer.pl`
++does.
+ 
+ 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.
+@@ -85,11 +101,11 @@ To add your own, create a file `~/.patman` like this::
+     wolfgang: Wolfgang Denk <wd@denx.de>
+     others: Mike Frysinger <vapier@gentoo.org>, Fred Bloggs <f.bloggs@napier.net>
+ 
+-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.
++As hinted above, 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.
+ 
+diff --git a/tools/patman/series.py b/tools/patman/series.py
+index 3075378ac1..2eeeef71dc 100644
+--- a/tools/patman/series.py
++++ b/tools/patman/series.py
+@@ -235,7 +235,7 @@ class Series(dict):
+             print(col.build(col.RED, str))
+ 
+     def MakeCcFile(self, process_tags, cover_fname, warn_on_error,
+-                   add_maintainers, limit):
++                   add_maintainers, limit, get_maintainer_script):
+         """Make a cc file for us to use for per-commit Cc automation
+ 
+         Also stores in self._generated_cc to make ShowActions() faster.
+@@ -249,6 +249,8 @@ class Series(dict):
+                 True/False to call the get_maintainers to CC maintainers
+                 List of maintainers to include (for testing)
+             limit: Limit the length of the Cc list (None if no limit)
++            get_maintainer_script: The file name of the get_maintainer.pl
++                script (or compatible).
+         Return:
+             Filename of temp file created
+         """
+@@ -267,8 +269,9 @@ class Series(dict):
+             if type(add_maintainers) == type(cc):
+                 cc += add_maintainers
+             elif add_maintainers:
+-                dir_list = [os.path.join(gitutil.get_top_level(), 'scripts')]
+-                cc += get_maintainer.get_maintainer(dir_list, commit.patch)
++
++                cc += get_maintainer.get_maintainer(get_maintainer_script,
++                                                    commit.patch)
+             for x in set(cc) & set(settings.bounces):
+                 print(col.build(col.YELLOW, 'Skipping "%s"' % x))
+             cc = list(set(cc) - set(settings.bounces))
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 <wd@denx.de>
+     others: Mike Frysinger <vapier@gentoo.org>, Fred Bloggs <f.bloggs@napier.net>
+ 
++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 <maxim.cournoyer@savoirfairelinux.com>
+ #
+ 
+ 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 <maxim.cournoyer@savoirfairelinux.com>
++#
++
++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





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH v6 1/2] gnu: Add u-boot-documentation.
  2022-12-17  4:15 [bug#60145] [PATCH 0/2] Add u-boot-documentation and patman Maxim Cournoyer
                   ` (2 preceding siblings ...)
  2022-12-19 22:42 ` [bug#60145] [PATCH v5 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
@ 2022-12-20 13:21 ` Maxim Cournoyer
  2022-12-20 13:21   ` [bug#60145] [PATCH v6 2/2] gnu: Add patman Maxim Cournoyer
  3 siblings, 1 reply; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-20 13:21 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* gnu/packages/patches/u-boot-infodocs-target.patch: New patch.
* gnu/local.mk: (dist_patch_DATA): Register it.
* gnu/packages/bootloaders.scm (u-boot): Apply it.
(u-boot-documentation): New variable.

---

(no changes since v5)

Changes in v5:
- Update URL in patch

Changes in v3:
- Update U-Boot documentation patch
- Remove now extraneous convenience symlink

Changes in v2:
- Update U-Boot documentation patch

 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 41 ++++++++-
 .../patches/u-boot-infodocs-target.patch      | 84 +++++++++++++++++++
 3 files changed, 125 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-infodocs-target.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 56634e090c..01fcc9d7d3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1924,6 +1924,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/tuxpaint-stamps-path.patch		\
   %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-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 3c96453e5c..32970f86f1 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -62,6 +63,7 @@ (define-module (gnu packages bootloaders)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages swig)
   #:use-module (gnu packages valgrind)
@@ -637,7 +639,8 @@ (define u-boot
                (list %u-boot-rockchip-inno-usb-patch
                      %u-boot-allow-disabling-openssl-patch
                      %u-boot-sifive-prevent-relocating-initrd-fdt
-                     %u-boot-rk3399-enable-emmc-phy-patch))
+                     %u-boot-rk3399-enable-emmc-phy-patch
+                     (search-patch "u-boot-infodocs-target.patch")))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
@@ -667,6 +670,42 @@ (define u-boot
 also initializes the boards (RAM etc).")
     (license license:gpl2+)))
 
+;;; This is very similar to the linux-libre-documentation package, since it
+;;; reuses the same Makefile-based build system.
+(define-public u-boot-documentation
+  (package
+    (inherit u-boot)
+    (name "u-boot-documentation")
+    (arguments
+     (list
+      #:make-flags #~(list "HOSTCC=gcc"
+                           ;; Avoid treating Sphinx warnings as errors.
+                           "SPHINXOPTS=")
+      #:tests? #f
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'configure)
+                   (replace 'build
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (apply invoke "make" "infodocs" make-flags)))
+                   (replace 'install
+                     (lambda* (#:key make-flags #:allow-other-keys)
+                       (let* ((info-dir (string-append #$output "/share/info"))
+                              (info (string-append info-dir
+                                                   "/DasUBoot.info.gz")))
+                         (with-directory-excursion "doc/output"
+                           (apply invoke "make" "-C" "texinfo" "install-info"
+                                  (string-append "infodir=" info-dir)
+                                  make-flags))))))))
+    (native-inputs
+     (modify-inputs (package-native-inputs u-boot)
+       (append fontconfig
+               python-sphinx
+               texinfo
+               which)))
+    (synopsis "U-Boot documentation")
+    (description "This package provides the documentation for U-Boot, as an
+Info manual.")))
+
 (define-public u-boot-tools
   (package
     (inherit u-boot)
diff --git a/gnu/packages/patches/u-boot-infodocs-target.patch b/gnu/packages/patches/u-boot-infodocs-target.patch
new file mode 100644
index 0000000000..5b21a99de3
--- /dev/null
+++ b/gnu/packages/patches/u-boot-infodocs-target.patch
@@ -0,0 +1,84 @@
+Upstream status: https://patchwork.ozlabs.org/project/uboot/list/?series=333259
+
+diff --git a/Makefile b/Makefile
+index de5746399a..597a8886c3 100644
+--- a/Makefile
++++ b/Makefile
+@@ -2372,7 +2372,7 @@ tcheck:
+ # Documentation targets
+ # ---------------------------------------------------------------------------
+ DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
+-	       linkcheckdocs dochelp refcheckdocs
++	       linkcheckdocs dochelp refcheckdocs texinfodocs infodocs
+ PHONY += $(DOC_TARGETS)
+ $(DOC_TARGETS): scripts_basic FORCE
+ 	$(Q)$(MAKE) $(build)=doc $@
+diff --git a/doc/Makefile b/doc/Makefile
+index f5de65e927..d0904a9f99 100644
+--- a/doc/Makefile
++++ b/doc/Makefile
+@@ -69,6 +69,14 @@ quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
+ htmldocs:
+ 	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
+ 
++texinfodocs:
++	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texinfo,$(var)))
++
++# Note: the 'info' Make target is generated by sphinx itself when
++# running the texinfodocs target defined above.
++infodocs: texinfodocs
++	$(MAKE) -C $(BUILDDIR)/texinfo info
++
+ linkcheckdocs:
+ 	@$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
+ 
+@@ -109,6 +117,8 @@ cleandocs:
+ dochelp:
+ 	@echo  ' U-Boot documentation in different formats from ReST:'
+ 	@echo  '  htmldocs        - HTML'
++	@echo  '  texinfodocs     - Texinfo'
++	@echo  '  infodocs        - Info'
+ 	@echo  '  latexdocs       - LaTeX'
+ 	@echo  '  pdfdocs         - PDF'
+ 	@echo  '  epubdocs        - EPUB'
+diff --git a/doc/conf.py b/doc/conf.py
+index 62c8d31270..3db70f80c1 100644
+--- a/doc/conf.py
++++ b/doc/conf.py
+@@ -449,7 +449,7 @@ for fn in os.listdir('.'):
+ # One entry per manual page. List of tuples
+ # (source start file, name, description, authors, manual section).
+ man_pages = [
+-    (master_doc, 'dasuboot', 'The U-Boot Documentation',
++    (master_doc, 'u-boot', 'The U-Boot Documentation',
+      [author], 1)
+ ]
+ 
+@@ -463,8 +463,8 @@ man_pages = [
+ # (source start file, target name, title, author,
+ #  dir menu entry, description, category)
+ texinfo_documents = [
+-    (master_doc, 'DasUBoot', 'The U-Boot Documentation',
+-     author, 'DasUBoot', 'One line description of project.',
++    (master_doc, 'u-boot', 'The U-Boot Documentation',
++     author, 'U-Boot', 'Boot loader for embedded systems',
+      'Miscellaneous'),
+ ]
+ 
+diff --git a/doc/media/Makefile b/doc/media/Makefile
+index b9b43a34c3..9b32258696 100644
+--- a/doc/media/Makefile
++++ b/doc/media/Makefile
+@@ -22,10 +22,11 @@ $(BUILDDIR)/linker_lists.h.rst: ${API}/linker_lists.h ${PARSER} $(SRC_DIR)/linke
+ 
+ # Media build rules
+ 
+-.PHONY: all html epub xml latex
++.PHONY: all html texinfo epub xml latex
+ 
+ all: $(IMGDOT) $(BUILDDIR) ${TARGETS}
+ html: all
++texinfo: all
+ epub: all
+ xml: all
+ latex: $(IMGPDF) all

base-commit: f28ca2447c5e2eef1ba6a3a11587380a665b0e26
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [bug#60145] [PATCH v6 2/2] gnu: Add patman.
  2022-12-20 13:21 ` [bug#60145] [PATCH v6 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
@ 2022-12-20 13:21   ` Maxim Cournoyer
  2022-12-28 21:06     ` bug#60145: " Maxim Cournoyer
  0 siblings, 1 reply; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-20 13:21 UTC (permalink / raw)
  To: 60145; +Cc: vagrant, Maxim Cournoyer

* gnu/packages/bootloaders.scm (patman): New variable.
* gnu/packages/patches/u-boot-patman-fix-help.patch: New patch.
* gnu/packages/patches/u-boot-patman-get-maintainer.patch: Likewise.
* gnu/packages/patches/u-boot-patman-local-conf.patch: Likewise.
* gnu/local.mk (dist_patch_DATA): Register them.

---

Changes in v6:
- Update u-boot-patman-get-maintainer.patch.

Changes in v5:
- Add new u-boot-patman-get-maintainer.patch.

Changes in v4:
- Use the series URL for the patches upstream submission status
- Add new u-boot-patman-local-conf.patch

 gnu/local.mk                                  |   3 +
 gnu/packages/bootloaders.scm                  |  36 +++-
 .../patches/u-boot-patman-fix-help.patch      |  40 ++++
 .../u-boot-patman-get-maintainer.patch        | 104 +++++++++++
 .../patches/u-boot-patman-local-conf.patch    | 176 ++++++++++++++++++
 5 files changed, 358 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/u-boot-patman-fix-help.patch
 create mode 100644 gnu/packages/patches/u-boot-patman-get-maintainer.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..a704cf6002 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1925,6 +1925,9 @@ 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-get-maintainer.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..4cfb16860e 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,10 @@ (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")
+                     (search-patch "u-boot-patman-get-maintainer.patch")))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
@@ -816,6 +822,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-get-maintainer.patch b/gnu/packages/patches/u-boot-patman-get-maintainer.patch
new file mode 100644
index 0000000000..4377f8394e
--- /dev/null
+++ b/gnu/packages/patches/u-boot-patman-get-maintainer.patch
@@ -0,0 +1,104 @@
+Upstream status: https://patchwork.ozlabs.org/project/uboot/list/?series=333427
+
+diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
+index 7828899879..95b6c9c3f0 100644
+--- a/tools/patman/patman.rst
++++ b/tools/patman/patman.rst
+@@ -88,7 +88,7 @@ To add your own, create a file `~/.patman` like this::
+ 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
++project-specific way. The values of this "local" configuration file
+ take precedence over those of the "global" one.
+ 
+ Aliases are recursive.
+diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py
+index 9c14b4aaa3..c768a2fc64 100644
+--- a/tools/patman/test_settings.py
++++ b/tools/patman/test_settings.py
+@@ -6,38 +6,62 @@
+ import argparse
+ import contextlib
+ import os
+-import subprocess
++import sys
+ import tempfile
+ 
+ from patman import settings
++from patman import tools
+ 
+ 
+ @contextlib.contextmanager
+ def empty_git_repository():
+     with tempfile.TemporaryDirectory() as tmpdir:
+         os.chdir(tmpdir)
+-        subprocess.check_call(['git', 'init'])
++        tools.run('git', 'init', raise_on_error=True)
+         yield tmpdir
+ 
+ 
++@contextlib.contextmanager
++def cleared_command_line_args():
++    old_value = sys.argv[:]
++    sys.argv = [sys.argv[0]]
++    try:
++        yield
++    finally:
++        sys.argv = old_value
++
++
+ 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'
++    # Clearing the command line arguments is required, otherwise
++    # arguments passed to the test running such as in 'pytest -k
++    # filter' would be processed by _UpdateDefaults and fail.
++    with cleared_command_line_args():
++        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')
++                subparsers = parser.add_subparsers(dest='cmd')
++                send = subparsers.add_parser('send')
++                send.add_argument('--no-check', action='store_false',
++                                  dest='check_patch', default=True)
++
++                # Test "global" config is used.
++                settings.Setup(parser, 'unknown', global_config.name)
++                args, _ = parser.parse_known_args([])
++                assert args.project == 'u-boot'
++                send_args, _ = send.parse_known_args([])
++                assert send_args.check_patch
++
++                # Test local config can shadow it.
++                with open('.patman', 'w', buffering=1) as f:
++                    f.write('[settings]\n'
++                            'project: guix-patches\n'
++                            'check_patch: False\n')
++                settings.Setup(parser, 'unknown', global_config.name)
++                args, _ = parser.parse_known_args([])
++                assert args.project == 'guix-patches'
++                send_args, _ = send.parse_known_args([])
++                assert not send_args.check_patch
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 <wd@denx.de>
+     others: Mike Frysinger <vapier@gentoo.org>, Fred Bloggs <f.bloggs@napier.net>
+ 
++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 <maxim.cournoyer@savoirfairelinux.com>
+ #
+ 
+ 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 <maxim.cournoyer@savoirfairelinux.com>
++#
++
++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





^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#60145: [PATCH v6 2/2] gnu: Add patman.
  2022-12-20 13:21   ` [bug#60145] [PATCH v6 2/2] gnu: Add patman Maxim Cournoyer
@ 2022-12-28 21:06     ` Maxim Cournoyer
  0 siblings, 0 replies; 10+ messages in thread
From: Maxim Cournoyer @ 2022-12-28 21:06 UTC (permalink / raw)
  To: 60145-done; +Cc: vagrant

Hello,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

> * gnu/packages/bootloaders.scm (patman): New variable.
> * gnu/packages/patches/u-boot-patman-fix-help.patch: New patch.
> * gnu/packages/patches/u-boot-patman-get-maintainer.patch: Likewise.
> * gnu/packages/patches/u-boot-patman-local-conf.patch: Likewise.
> * gnu/local.mk (dist_patch_DATA): Register them.

I just pushed this series; closing.

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-12-28 21:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-17  4:15 [bug#60145] [PATCH 0/2] Add u-boot-documentation and patman Maxim Cournoyer
2022-12-17  4:35 ` [bug#60145] [PATCH 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
2022-12-17  4:35   ` [bug#60145] [PATCH 2/2] gnu: Add patman Maxim Cournoyer
2022-12-19 17:23 ` [bug#60145] [PATCH v4 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
2022-12-19 17:23   ` [bug#60145] [PATCH v4 2/2] gnu: Add patman Maxim Cournoyer
2022-12-19 22:42 ` [bug#60145] [PATCH v5 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
2022-12-19 22:42   ` [bug#60145] [PATCH v5 2/2] gnu: Add patman Maxim Cournoyer
2022-12-20 13:21 ` [bug#60145] [PATCH v6 1/2] gnu: Add u-boot-documentation Maxim Cournoyer
2022-12-20 13:21   ` [bug#60145] [PATCH v6 2/2] gnu: Add patman Maxim Cournoyer
2022-12-28 21:06     ` bug#60145: " Maxim Cournoyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).