diff mbox series

[bug#60358,v3,1/2] gnu: Add gnulib.

Message ID 6d918b9fb87e379766c1187c6ea7bd76d9842d6e.camel@planete-kraus.eu
State New
Headers show
Series [bug#60358,v3,1/2] gnu: Add gnulib. | expand

Commit Message

Vivien Kraus Dec. 27, 2022, 4:23 p.m. UTC
* 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 | 58 ++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)


base-commit: 77d4bff94c6918eb0c0ccd20ee610e6dfc823aec

Comments

Liliana Marie Prikler Dec. 29, 2022, 8:02 p.m. UTC | #1
Am Dienstag, dem 27.12.2022 um 17:23 +0100 schrieb Vivien Kraus:
> * 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 | 58
> ++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
> 
> diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-
> tools.scm
> index 6c1350c44f..5b4fc71429 100644
> --- a/gnu/packages/build-tools.scm
> +++ b/gnu/packages/build-tools.scm
> @@ -38,6 +38,7 @@ (define-module (gnu packages build-tools)
>    #: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 +49,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 +806,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 gl-version gl-commit gl-hash)
You should probably use keyword arguments here.  Also, don't bother
prefixing things, the shadowing rules in Guix are well-defined.
> +  "Return as a package the exact gnulib checkout."
> +  (package
> +    (name "gnulib")
> +    (version (git-version gl-version "1" gl-commit))
Allow the user to specify revision, defaulting to "1".
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://git.savannah.gnu.org/git/gnulib.git")
> +             (commit gl-commit)))
> +       (file-name (git-file-name name version))
> +       (sha256 (base32 gl-hash))))
While it's more typing effort, move base32 outside for that compile-
time expansion.
> +    (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
> +                                 "/share/gnulib/"
> +                                 #$gl-commit)))))
See [*] below.
> +      #:tests? #f)) ;; Tests are syntax and indentation checks for
> the
> +    ;; maintainer.
IMHO, we should still run tests unless they significantly complicate
packaging. 
> +    (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 (string-append "share/gnulib/" gl-
> commit))))))
[*] Rather than installing the library to an always different location
and using an environment variable to bind it, I'd suggest using a fixed
location, such as #$output/src/gnulib, so that consuming packages can
use --gnulib-srcdir=#$(search-input-directory %build-inputs
"src/gnulib")
> +    (license (list license:lgpl2.0+ license:gpl3+))))
> +

Furthermore, quite a number of gnulib appears to have been
automatically generated.  Can we do a proper bootstrap? :)

Cheers
Vivien Kraus Dec. 30, 2022, 11:45 a.m. UTC | #2
Hello,

Le jeudi 29 décembre 2022 à 21:02 +0100, Liliana Marie Prikler a
écrit :
> Furthermore, quite a number of gnulib appears to have been
> automatically generated.  Can we do a proper bootstrap? :)

Could you give an example? I think I remember that gnulib sources are
taken from glibc, is it what you mean?

Best regards,

Vivien
Liliana Marie Prikler Dec. 30, 2022, 7:35 p.m. UTC | #3
Am Freitag, dem 30.12.2022 um 12:45 +0100 schrieb Vivien Kraus:
> Hello,
> 
> Le jeudi 29 décembre 2022 à 21:02 +0100, Liliana Marie Prikler a
> écrit :
> > Furthermore, quite a number of gnulib appears to have been
> > automatically generated.  Can we do a proper bootstrap? :)
> 
> Could you give an example? I think I remember that gnulib sources are
> taken from glibc, is it what you mean?
grep -iR "do not edit" $(./pre-inst-env guix build -S gnulib)

Some of the matches are emitters, but many of them are emitted
comments.

Cheers
diff mbox series

Patch

diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 6c1350c44f..5b4fc71429 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -38,6 +38,7 @@  (define-module (gnu packages build-tools)
   #: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 +49,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 +806,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 gl-version gl-commit gl-hash)
+  "Return as a package the exact gnulib checkout."
+  (package
+    (name "gnulib")
+    (version (git-version gl-version "1" gl-commit))
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.savannah.gnu.org/git/gnulib.git")
+             (commit gl-commit)))
+       (file-name (git-file-name name version))
+       (sha256 (base32 gl-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
+                                 "/share/gnulib/"
+                                 #$gl-commit)))))
+      #:tests? #f)) ;; Tests are syntax and indentation checks for the
+    ;; maintainer.
+    (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 (string-append "share/gnulib/" gl-commit))))))
+    (license (list license:lgpl2.0+ license:gpl3+))))
+
+(define-public gnulib
+  (gnulib-checkout
+   "2022-12-27"
+   "fde75446490e18d2539817ca418ab8adf73b02d3"
+   "0fjbdhwi9025wyq39rwc2j6aazfmagx056kkbvxx6bs97i80dcim"))