Hi,

Here's fix of the rkdeveloptool package which fails to build due to GCC 
complaining about the truncation error.

See https://github.com/rockchip-linux/rkdeveloptool/pull/62.

----
Petr
From 50e6bbcf7f648a7793ecf6b1ddd9a4148fc776b8 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phod...@protonmail.com>
Date: Mon, 21 Feb 2022 13:25:16 +0100
Subject: [PATCH 1/2] gnu: rkdeveloptool: Fix build.

* gnu/packages/hardware.scm (rkdeveloptool): Update to newer commit 46bb4c.
  [source]: Apply patch to fix GCC format truncation error.
  [arguments]: Add phase after install to install udev rules.
* gnu/local.mk: Add patch.
* gnu/packages/patches/rkdeveloptool-fix-format-truncation.patch: New file.

diff --git a/gnu/local.mk b/gnu/local.mk
index dcee1611b2..3e84188937 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1754,6 +1754,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/remake-impure-dirs.patch			\
   %D%/packages/patches/restic-0.9.6-fix-tests-for-go1.15.patch	\
   %D%/packages/patches/retroarch-LIBRETRO_DIRECTORY.patch	\
+  %D%/packages/patches/rkdeveloptool-fix-format-truncation.patch \
   %D%/packages/patches/rnp-add-version.cmake.patch		\
   %D%/packages/patches/rnp-disable-ruby-rnp-tests.patch		\
   %D%/packages/patches/rnp-unbundle-googletest.patch		\
diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index a3ce90f75e..e4aceab54b 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -770,29 +770,40 @@ (define-public wavemon
     (license license:gpl3+)))
 
 (define-public rkdeveloptool
-  (let ((commit "6e92ebcf8b1812da02663494a68972f956e490d3")
-        (revision "0"))
+  (let ((commit "46bb4c073624226c3f05b37b9ecc50bbcf543f5a")
+        (revision "1"))
     (package
       (name "rkdeveloptool")
-      (version (git-version "1.3" revision commit))
+      (version (git-version "1.32" revision commit))
       (source
        (origin
          (method git-fetch)
          (uri (git-reference
                (url "https://github.com/rockchip-linux/rkdeveloptool";)
                (commit commit)))
+         ;; https://github.com/rockchip-linux/rkdeveloptool/pull/62
+         (patches (search-patches "rkdeveloptool-fix-format-truncation.patch"))
          (file-name (git-file-name name version))
          (sha256
-          (base32 "0zwrkqfxd671iy69v3q0844gfdpm1yk51i9qh2rqc969bd8glxga"))))
+          (base32 "0kb2ylsrqqrdf4np66yxmk96kdc5g8nvjx13gifpm5rshv5770bq"))))
       (build-system gnu-build-system)
+	  (arguments
+	  `(#:phases
+	   (modify-phases %standard-phases
+	    (add-after 'install 'install-udev-rules
+		 (lambda* (#:key outputs #:allow-other-keys)
+		  (let ((udev (string-append (assoc-ref outputs "out")
+		  "/lib/udev/rules.d")))
+		  (mkdir-p udev)
+		  (install-file "99-rk-rockusb.rules" udev)))))))
       (native-inputs
        (list autoconf automake pkg-config))
       (inputs
        (list libusb))
       (home-page "https://github.com/rockchip-linux/rkdeveloptool";)
-      (synopsis "Read from and write to RockChicp devices over USB")
+      (synopsis "Read/write to rockchip devices over USB")
       (description
-       "Rkdeveloptool can read from and write to RockChip devices over USB, such
+       "Rkdeveloptool can read from and write to rockchip devices over USB, such
 as the Pinebook Pro.")
       (license license:gpl2+))))
 
diff --git a/gnu/packages/patches/rkdeveloptool-fix-format-truncation.patch b/gnu/packages/patches/rkdeveloptool-fix-format-truncation.patch
new file mode 100644
index 0000000000..fd9a193e76
--- /dev/null
+++ b/gnu/packages/patches/rkdeveloptool-fix-format-truncation.patch
@@ -0,0 +1,22 @@
+From bc9e5f03d71b3dd4360721f4df3524c1dcba9bc8 Mon Sep 17 00:00:00 2001
+From: Petr Hodina <phod...@protonmail.com>
+Date: Mon, 21 Feb 2022 13:00:53 +0100
+Subject: [PATCH] Fix format truncation for GCC >7.1.
+
+
+diff --git a/main.cpp b/main.cpp
+index 72bd94b..800db0b 100644
+--- a/main.cpp
++++ b/main.cpp
+@@ -1490,7 +1490,7 @@ static bool saveEntry(FILE* outFile, char* path, rk_entry_type type,
+ static inline uint32_t convertChipType(const char* chip) {
+ 	char buffer[5];
+ 	memset(buffer, 0, sizeof(buffer));
+-	snprintf(buffer, sizeof(buffer), "%s", chip);
++	memcpy(buffer, chip, 4);
+ 	return buffer[0] << 24 | buffer[1] << 16 | buffer[2] << 8 | buffer[3];
+ }
+ 
+-- 
+2.34.0
+
-- 
2.34.0

From 1ed30235dbaae9f95c34826051eb88f9d6def032 Mon Sep 17 00:00:00 2001
From: Petr Hodina <phod...@protonmail.com>
Date: Mon, 21 Feb 2022 13:33:41 +0100
Subject: [PATCH 2/2] gnu: Add rkdeveloptool-pine64.

* gnu/packages/hardware.scm (rkdeveloptool-pine64): New variable.

diff --git a/gnu/packages/hardware.scm b/gnu/packages/hardware.scm
index e4aceab54b..ceb63081b2 100644
--- a/gnu/packages/hardware.scm
+++ b/gnu/packages/hardware.scm
@@ -807,6 +807,41 @@ (define-public rkdeveloptool
 as the Pinebook Pro.")
       (license license:gpl2+))))
 
+(define-public rkdeveloptool-pine64
+  (package
+    (name "rkdeveloptool-pine64")
+    (version "1.1.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url
+                     "https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool";)
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0nh9592mllygycnxbw91vg58wwais7w3w62rl9gcvc4m3i909b1z"))))
+    (build-system meson-build-system)
+    (arguments
+     `(#:tests? #f ;no test suite
+       #:phases
+       (modify-phases %standard-phases
+         ;; attempts to place the file into the udev pkg read-only path
+         (add-after 'unpack 'fix-udev-path
+           (lambda* _
+             (substitute* "meson.build"
+               (("udev_rules_dir,") (string-append "'" %output
+                                                   "/lib/udev/rules.d',"))))))))
+    (native-inputs (list pkg-config))
+    (inputs (list eudev libusb))
+    (synopsis "Read from and write to RockChicp devices over USB")
+    (description
+     "Rkdeveloptool is a fastboot-like CLI tool to read from and
+write to RockChip devices over USB.  Supports PineNote and Quartz64 as well
+as other Pine64 RK devices.")
+    (home-page "https://gitlab.com/pine64-org/quartz-bsp/rkdeveloptool";)
+    (license license:gpl2+)))
+
 (define-public libqb
   (package
     (name "libqb")
-- 
2.34.0

Reply via email to