Subject: [bug#60358] [PATCH v5 1/5] gnu: Add gnulib.

From: Vivien Kraus <[email-masked]>
Date: Tue, 27 Dec 2022 17:23:30 +0100

* gnu/packages/build-tools.scm (gnulib): New variable.
(gnulib-checkout): New function. It returns a package with a specific commit
of gnulib.
---
 gnu/packages/build-tools.scm | 59 ++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 6c1350c44f..bde4ee0973 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -32,12 +32,14 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages build-tools)
+  #:use-module (ice-9 optargs)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (guix gexp)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix git)
   #:use-module (guix build-system cmake)
   #:use-module (gnu packages)
   #:use-module (gnu packages adns)
@@ -48,11 +50,13 @@ (define-module (gnu packages build-tools)
   #:use-module (gnu packages cpp)
   #:use-module (gnu packages elf)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages lisp)
   #:use-module (gnu packages logging)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages ninja)
   #:use-module (gnu packages package-management)
   #:use-module (gnu packages pcre)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pretty-print)
   #:use-module (gnu packages protobuf)
@@ -803,3 +807,58 @@ (define-public genie
 same settings to multiple projects.  It supports generating projects using GNU
 Makefiles, JSON Compilation Database, and experimentally Ninja.")
       (license license:bsd-3))))
+
+(define*-public (gnulib-checkout #:key
+                                 version
+                                 (revision "1")
+                                 commit
+                                 hash)
+  "Return as a package the exact gnulib checkout."
+  (package
+    (name "gnulib")
+    (version (git-version version revision commit))
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.savannah.gnu.org/git/gnulib.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256 hash)))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'configure)
+          (replace 'install
+            (lambda _
+              (install-file "gnulib-tool"
+                            (string-append #$output "/bin"))
+              (copy-recursively "." (string-append #$output "/src/gnulib/")))))
+      #:tests? #f)) ;; Tests are syntax and indentation checks for the
+    ;; maintainer. And they are failing.
+    (inputs ;; Shebangs for some auxiliary build files.
+     (list python perl clisp))
+    (home-page "https://www.gnu.org/software/gnulib/")
+    (synopsis "Source files to share among distributions")
+    (description
+     "Gnulib is a central location for common infrastructure needed by GNU
+packages.  It provides a wide variety of functionality, e.g., portability
+across many systems, working with Unicode strings, cryptographic computation,
+and much more.  The code is intended to be shared at the level of source
+files, rather than being a standalone library that is distributed, built, and
+installed.  The included @command{gnulib-tool} script helps with using Gnulib
+code in other packages.  Gnulib also includes copies of licensing and
+maintenance-related files, for convenience.")
+    (native-search-paths
+     (list (search-path-specification
+            (variable "GNULIB_SRCDIR")
+            (files (list "src/gnulib")))))
+    (license (list license:lgpl2.0+ license:gpl3+))))
+
+(define-public gnulib
+  (gnulib-checkout
+   #:version "2022-12-28"
+   #:commit "14a7b0ce5462c90ce86d97bf952185ec2500d341"
+   #:hash (base32 "0fz25ccdlxf4xp37rjsl1fslc4g0x12qpvadz4qw0cq18dvx5kbx")))

base-commit: e84f17ea939013f25a0dd1276659e27bc4c2198f
-- 
2.38.1