unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#54581] Add emacs-sqlite3-api package
@ 2022-03-26 14:09 Roman Scherer
  2022-03-26 21:17 ` Maxime Devos
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Roman Scherer @ 2022-03-26 14:09 UTC (permalink / raw)
  To: 54581


[-- Attachment #1.1: Type: text/plain, Size: 227 bytes --]


Hello Guix,

this patch adds the emacs-sqlite3-api package to Guix. It is a dynamic
module for GNU Emacs 25+ that provides direct access to the core SQLite3
C API from Emacs Lisp.

Could you please review it?

Thanks, Roman.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: emacs-sqlite3-api --]
[-- Type: text/x-patch, Size: 3130 bytes --]

From 9136e4ad504528763315dcb2148c4da0ca1dbe74 Mon Sep 17 00:00:00 2001
From: r0man <roman@burningswell.com>
Date: Sat, 26 Mar 2022 14:59:01 +0100
Subject: [PATCH] Add emacs-sqlite3-api package

This patch adds the emacs-sqlite3-api package to Guix. It is a dynamic module
for GNU Emacs 25+ that provides direct access to the core SQLite3 C API from
Emacs Lisp.
---
 gnu/packages/emacs-xyz.scm | 47 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 42fc13f4c2..422739a744 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -5731,6 +5731,53 @@ (define-public emacs-sqlite
 It is not intended as a user interface.")
       (license license:gpl3+))))
 
+(define-public emacs-sqlite3-api
+  (let ((version "0.0.1")
+        (revision "0")
+        (commit "88dfeae8f9612cb3564a7393aa8a5c867aacbaf8"))
+    (package
+      (name "emacs-sqlite3-api")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/pekingduck/emacs-sqlite3-api")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0sj1fsgcgfzz6dfpmp8r5gmdwpbdzpk5g5lm8j7c3nqj6wqgg7g6"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:modules ((guix build emacs-build-system)
+                    (guix build emacs-utils)
+                    (guix build utils))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'patch-module-load
+             (lambda* (#:key outputs #:allow-other-keys)
+               (chmod "sqlite3.el" #o644)
+               (emacs-substitute-sexps "sqlite3.el"
+                 ("(require 'sqlite3-api nil t)"
+                  `(module-load ,(string-append (assoc-ref outputs "out")
+                                                "/lib/sqlite3-api.so"))))))
+           (add-before 'install 'build-emacs-module
+             ;; Run make.
+             (lambda* (#:key (make-flags '()) outputs #:allow-other-keys)
+               ;; Compile the shared object file.
+               (apply invoke "make" "CC=gcc" make-flags)
+               ;; Move the file into /lib.
+               (install-file "sqlite3-api.so"
+                             (string-append (assoc-ref outputs "out")
+                                            "/lib")))))
+         #:tests? #f))
+      (inputs (list sqlite))
+      (home-page "https://github.com/pekingduck/emacs-sqlite3-api")
+      (synopsis "SQLite3 API for GNU Emacs 25+")
+      (description "SQLite3 is a dynamic module for GNU Emacs 25+ that provides
+direct access to the core SQLite3 C API from Emacs Lisp.")
+      (license license:gpl3+))))
+
 (define-public emacs-sr-speedbar
   (let ((commit "77a83fb50f763a465c021eca7343243f465b4a47")
         (revision "0"))
-- 
2.34.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-26 14:09 [bug#54581] Add emacs-sqlite3-api package Roman Scherer
@ 2022-03-26 21:17 ` Maxime Devos
  2022-03-26 21:20 ` Maxime Devos
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-03-26 21:17 UTC (permalink / raw)
  To: Roman Scherer, 54581

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Roman Scherer schreef op za 26-03-2022 om 15:09 [+0100]:
> +               ;; Compile the shared object file.
> +               (apply invoke "make" "CC=gcc" make-flags)

This is broken when cross-compiling.  Use (string-append "CC=" ,(cc-
for-target)) instead of "CC=gcc".

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-26 14:09 [bug#54581] Add emacs-sqlite3-api package Roman Scherer
  2022-03-26 21:17 ` Maxime Devos
@ 2022-03-26 21:20 ` Maxime Devos
  2022-03-26 21:21 ` Maxime Devos
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-03-26 21:20 UTC (permalink / raw)
  To: Roman Scherer, 54581

[-- Attachment #1: Type: text/plain, Size: 561 bytes --]

Roman Scherer schreef op za 26-03-2022 om 15:09 [+0100]:
> +      (description "SQLite3 is a dynamic module for GNU Emacs 25+
> that provides
> +direct access to the core SQLite3 C API from Emacs Lisp.")

While this package integrates SQLite3 into Emacs, SQLite itself is not
part of Emacs, so I would reformulate this a bit.  The description is
also a bit short, ‘(guix)Synopses and Descriptions’ recommends longer
descriptions.  Additionally, the only Emacs in Guix, emacs@27.2, is
25+, so no need to write 25+ here.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-26 14:09 [bug#54581] Add emacs-sqlite3-api package Roman Scherer
  2022-03-26 21:17 ` Maxime Devos
  2022-03-26 21:20 ` Maxime Devos
@ 2022-03-26 21:21 ` Maxime Devos
  2022-03-26 21:23 ` Maxime Devos
  2022-03-26 21:25 ` Maxime Devos
  4 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-03-26 21:21 UTC (permalink / raw)
  To: Roman Scherer, 54581

[-- Attachment #1: Type: text/plain, Size: 139 bytes --]

Roman Scherer schreef op za 26-03-2022 om 15:09 [+0100]:
> +         #:tests? #f))

I see some tests in the 'tests' directory.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-26 14:09 [bug#54581] Add emacs-sqlite3-api package Roman Scherer
                   ` (2 preceding siblings ...)
  2022-03-26 21:21 ` Maxime Devos
@ 2022-03-26 21:23 ` Maxime Devos
  2022-03-26 21:25 ` Maxime Devos
  4 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-03-26 21:23 UTC (permalink / raw)
  To: Roman Scherer, 54581

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

Roman Scherer schreef op za 26-03-2022 om 15:09 [+0100]:
> +             (lambda* (#:key (make-flags '()) outputs #:allow-other-
> keys)

'make-flags' is never set, so I would remove it and simplify the invoke
to

  (invoke "make" ... (string-append "CC=" ,(cc-for-target)))

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-26 14:09 [bug#54581] Add emacs-sqlite3-api package Roman Scherer
                   ` (3 preceding siblings ...)
  2022-03-26 21:23 ` Maxime Devos
@ 2022-03-26 21:25 ` Maxime Devos
  2022-03-27 17:55   ` Roman Scherer
  4 siblings, 1 reply; 20+ messages in thread
From: Maxime Devos @ 2022-03-26 21:25 UTC (permalink / raw)
  To: Roman Scherer, 54581

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

Roman Scherer schreef op za 26-03-2022 om 15:09 [+0100]:
> +         #:phases
> +         (modify-phases %standard-phases

Could consts.c be built from source?

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-26 21:25 ` Maxime Devos
@ 2022-03-27 17:55   ` Roman Scherer
  2022-03-27 19:19     ` Maxime Devos
                       ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Roman Scherer @ 2022-03-27 17:55 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 54581


[-- Attachment #1.1: Type: text/plain, Size: 1676 bytes --]


Hi Maxime,

thanks for the review. I attached 2 patches.

0001-Add-emacs-sqlite3-api-package.patch

In this one I addressed your following comments:

- I changed the synopsis and the description
- Removed the make flags
- I'm using cc-for-target now
- Enabled tests

The tests are passing, and I tested it manually by evaluating the Emacs
Lisp code snippets in [1]. Everything seems to work fine.

0001-Add-emacs-sqlite3-api-package-generate-constants.patch

In this patch I did the same as above, and I generated the consts.c file
by running make in the "tools" directory. The tests are passing fine,
but when I manually test it by evaluating the Elisp snippets in [1] I
get an error that the sqlite-open-readwrite and sqlite-open-create are
not defined in Emacs. The .so file is loaded by Emacs but somehow it
does not work.

I looked at the diff between the consts.c committed in the repository
and the generated one, but I could not see any changes related to those
functions. I'm still a bit lost about this and could need some help.

But I also wonder if generating the consts.c file is actually better
than just using the checked in consts.c file. The command to generate
the file fetches a web page from the Sqlite website and builds the
consts.c file with this information. And I think this is kind of a
brittle approach. How would this approach would even work with Software
heritage?

I think my preference would be to go without generating the consts.c
file, the patch works, it uses the same file the maintainer of the
packages is using, and I believe it is less brittle. :)

What do you think?

[1] https://github.com/pekingduck/emacs-sqlite3-api#introduction


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Add-emacs-sqlite3-api-package.patch --]
[-- Type: text/x-patch, Size: 3361 bytes --]

From b1568732c8aa95aa8f6cd914a903be2f807c252d Mon Sep 17 00:00:00 2001
From: r0man <roman@burningswell.com>
Date: Sat, 26 Mar 2022 14:59:01 +0100
Subject: [PATCH] Add emacs-sqlite3-api package

This patch adds the emacs-sqlite3-api package to Guix.

The package provides a dynamic module for Emacs that allows direct access to
the SQLite C interface.  It only exposes a subset of the full SQLite C
interface, but should satisfy most user's needs.
---
 gnu/packages/emacs-xyz.scm | 48 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 42fc13f4c2..dad0fe62e8 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -5731,6 +5731,54 @@ (define-public emacs-sqlite
 It is not intended as a user interface.")
       (license license:gpl3+))))
 
+(define-public emacs-sqlite3-api
+  (let ((version "0.15")
+        (revision "0")
+        (commit "7cb4b660fe30deb8a4229f3abb18bd99ca9c971c"))
+    (package
+      (name "emacs-sqlite3-api")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/pekingduck/emacs-sqlite3-api")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1b7if1dp6i5kqwhq25gna89xbca66i4mmgx1a5yn12kncfdgs6d7"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:modules ((guix build emacs-build-system)
+                    (guix build emacs-utils)
+                    (guix build utils))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'patch-module-load
+             (lambda* (#:key outputs #:allow-other-keys)
+               (chmod "sqlite3.el" #o644)
+               (emacs-substitute-sexps "sqlite3.el"
+                 ("(require 'sqlite3-api nil t)"
+                  `(module-load ,(string-append (assoc-ref outputs "out")
+                                                "/lib/sqlite3-api.so"))))))
+           (add-before 'check 'build-emacs-module
+             (lambda* (#:key (make-flags '()) outputs #:allow-other-keys)
+               ;; Compile the shared object file.
+               (invoke "make" (string-append "CC=" ,(cc-for-target)))
+               ;; Move the shared object file into /lib.
+               (install-file "sqlite3-api.so"
+                             (string-append (assoc-ref outputs "out")
+                                            "/lib")))))
+         #:tests? #t
+         #:test-command '("make" "test" "EMACS=emacs")))
+      (inputs (list sqlite))
+      (home-page "https://github.com/pekingduck/emacs-sqlite3-api")
+      (synopsis "SQLite dynamic module for Emacs Lisp")
+      (description "This package provides a dynamic module for Emacs that allows
+direct access to the SQLite C interface.  It only exposes a subset of the full
+SQLite C interface, but should satisfy most user's needs.")
+      (license license:gpl3+))))
+
 (define-public emacs-sr-speedbar
   (let ((commit "77a83fb50f763a465c021eca7343243f465b4a47")
         (revision "0"))
-- 
2.34.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0001-Add-emacs-sqlite3-api-package-generate-constants.patch --]
[-- Type: text/x-patch, Size: 3512 bytes --]

From f2726c3c87d890dfb547e7e9de880c5c57954ccf Mon Sep 17 00:00:00 2001
From: r0man <roman@burningswell.com>
Date: Sat, 26 Mar 2022 14:59:01 +0100
Subject: [PATCH] Add emacs-sqlite3-api package

This patch adds the emacs-sqlite3-api package to Guix.

The package provides a dynamic module for Emacs that allows direct access to
the SQLite C interface.  It only exposes a subset of the full SQLite C
interface, but should satisfy most user's needs.
---
 gnu/packages/emacs-xyz.scm | 51 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 42fc13f4c2..87595db74c 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -5731,6 +5731,57 @@ (define-public emacs-sqlite
 It is not intended as a user interface.")
       (license license:gpl3+))))
 
+(define-public emacs-sqlite3-api
+  (let ((version "0.15")
+        (revision "0")
+        (commit "7cb4b660fe30deb8a4229f3abb18bd99ca9c971c"))
+    (package
+      (name "emacs-sqlite3-api")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/pekingduck/emacs-sqlite3-api")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1b7if1dp6i5kqwhq25gna89xbca66i4mmgx1a5yn12kncfdgs6d7"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:modules ((guix build emacs-build-system)
+                    (guix build emacs-utils)
+                    (guix build utils))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'patch-module-load
+             (lambda* (#:key outputs #:allow-other-keys)
+               (chmod "sqlite3.el" #o644)
+               (emacs-substitute-sexps "sqlite3.el"
+                 ("(require 'sqlite3-api nil t)"
+                  `(module-load ,(string-append (assoc-ref outputs "out")
+                                                "/lib/sqlite3-api.so"))))))
+           (add-before 'check 'build-emacs-module
+             (lambda* (#:key (make-flags '()) outputs #:allow-other-keys)
+               ;; Generate the consts.c file.
+               (invoke "make" "--directory=tools")
+               ;; Compile the shared object file.
+               (invoke "make" (string-append "CC=" ,(cc-for-target)))
+               ;; Move the shared object file into /lib.
+               (install-file "sqlite3-api.so"
+                             (string-append (assoc-ref outputs "out")
+                                            "/lib")))))
+         #:tests? #t
+         #:test-command '("make" "test" "EMACS=emacs")))
+      (inputs (list sqlite))
+      (native-inputs (list curl pandoc python))
+      (home-page "https://github.com/pekingduck/emacs-sqlite3-api")
+      (synopsis "SQLite dynamic module for Emacs Lisp")
+      (description "This package provides a dynamic module for Emacs that allows
+direct access to the SQLite C interface.  It only exposes a subset of the full
+SQLite C interface, but should satisfy most user's needs.")
+      (license license:gpl3+))))
+
 (define-public emacs-sr-speedbar
   (let ((commit "77a83fb50f763a465c021eca7343243f465b4a47")
         (revision "0"))
-- 
2.34.0


[-- Attachment #1.4: Type: text/plain, Size: 305 bytes --]


Maxime Devos <maximedevos@telenet.be> writes:

> [[PGP Signed Part:Undecided]]
> Roman Scherer schreef op za 26-03-2022 om 15:09 [+0100]:
>> +         #:phases
>> +         (modify-phases %standard-phases
>
> Could consts.c be built from source?
>
> [[End of PGP Signed Part]]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-27 17:55   ` Roman Scherer
@ 2022-03-27 19:19     ` Maxime Devos
  2022-03-27 19:20     ` Maxime Devos
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-03-27 19:19 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

Roman Scherer schreef op zo 27-03-2022 om 19:55 [+0200]:
> +           (add-before 'check 'build-emacs-module
> +             (lambda* (#:key (make-flags '()) outputs #:allow-other-
> keys)

'make-flags' can be removed here.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-27 17:55   ` Roman Scherer
  2022-03-27 19:19     ` Maxime Devos
@ 2022-03-27 19:20     ` Maxime Devos
  2022-03-27 19:34     ` Maxime Devos
  2022-03-27 19:45     ` Maxime Devos
  3 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-03-27 19:20 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

Roman Scherer schreef op zo 27-03-2022 om 19:55 [+0200]:
> +         #:tests? #t

To allow (*) cross-compilation, this needs to be #:tests? ,(%current-
target-system).

(*) cross-compilation won't work yet because Emacs is not yet cross-
compilable.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-27 17:55   ` Roman Scherer
  2022-03-27 19:19     ` Maxime Devos
  2022-03-27 19:20     ` Maxime Devos
@ 2022-03-27 19:34     ` Maxime Devos
  2022-03-27 19:45     ` Maxime Devos
  3 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-03-27 19:34 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]

Roman Scherer schreef op zo 27-03-2022 om 19:55 [+0200]:
> But I also wonder if generating the consts.c file is actually better
> than just using the checked in consts.c file. The command to generate
> the file fetches a web page from the Sqlite website and builds the
> consts.c file with this information. And I think this is kind of a
> brittle approach. How would this approach would even work with
> Software
> heritage?

As-is, it won't even build, because the build container does not have
network access.  Something you could try, is adding an origin to the
'inputs':

(package
  (name "emacs-sqlite...")
  (inputs `(("web-page" ,(origin [...]
https://sqlite.org/c3ref/constlist.html [...])))))

and do some appropriate substitutions.  Problem is that this page is
not stable ...

To resolve this, you could modify gen-consts.py to not use the web page
to filter things out, basically, delete:

useful_codes = []
with open(sys.argv[1]) as f:
  for l in f.readlines():
    useful_codes.append(l.rstrip())

and

  #print("{0}".format(fields[1]))
  if not fields[1] in useful_codes:
    #print("{0} excluded".format(fields[1]))
    continue

and strip out the curl stuff from gen-consts.sh.

If you do this, don't forget to remove the non-deterministic NOW=$(date
...).

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-27 17:55   ` Roman Scherer
                       ` (2 preceding siblings ...)
  2022-03-27 19:34     ` Maxime Devos
@ 2022-03-27 19:45     ` Maxime Devos
  2022-04-01  9:07       ` Roman Scherer
  3 siblings, 1 reply; 20+ messages in thread
From: Maxime Devos @ 2022-03-27 19:45 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 936 bytes --]

Roman Scherer schreef op zo 27-03-2022 om 19:55 [+0200]:
> I think my preference would be to go without generating the consts.c
> file, the patch works, it uses the same file the maintainer of the
> packages is using, and I believe it is less brittle. :)

I don't expect any practical problems but technically it isn't source
code, and rather a binary (or, as GPL words it, ‘object code’), at
least according to the GPL's definition:

  The "source code" for a work means the preferred form of the work
  for making modifications to it.  "Object code" means any non-source
  form of a work.

, and Guix builds things from source. I don't think constants.c is in
preferred form, rather it seems to be sqlite.h

Maybe it's not much of a problem here though, I donk't know.

I don't see the relevancy of what files the maintainer is using.  What
does maintainerhood have to do with anything?

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-03-27 19:45     ` Maxime Devos
@ 2022-04-01  9:07       ` Roman Scherer
  2022-04-01  9:57         ` Maxime Devos
  2022-04-01  9:59         ` Maxime Devos
  0 siblings, 2 replies; 20+ messages in thread
From: Roman Scherer @ 2022-04-01  9:07 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 54581


[-- Attachment #1.1: Type: text/plain, Size: 2398 bytes --]


Hi Maxime,

here's a new patch as per your suggestion. I'm removing the code that
downloads from the internet, and the call to date for the NOW variable.

I also remove the SQLITE_STATIC and SQLITE_TRANSIENT sections in the
generated constants.c file, they cause a warning and would have been
remove by the original script.

I changed the #:tests? keyword to (%current-target-system), but I
noticed the tests of the package are now not run anymore when I build
the package. Is this expected?

I tried to specify a target when building the package, but this gives me
the following error:

./pre-inst-env guix build emacs-sqlite3-api --target=x86_64
guix build: error: /home/roman/workspace/guix/gnu/packages/emacs-xyz.scm:5738:4: emacs-sqlite3-api@0.15-0.7cb4b66: build system `emacs' does not support cross builds

Do you know how I can trigger the tests when building this package from
the command line, or even better from within Emacs?

Maxime Devos <maximedevos@telenet.be> writes:

> [[PGP Signed Part:Undecided]]
> Roman Scherer schreef op zo 27-03-2022 om 19:55 [+0200]:
>> I think my preference would be to go without generating the consts.c
>> file, the patch works, it uses the same file the maintainer of the
>> packages is using, and I believe it is less brittle. :)
>
> I don't expect any practical problems but technically it isn't source
> code, and rather a binary (or, as GPL words it, ‘object code’), at
> least according to the GPL's definition:
>
>   The "source code" for a work means the preferred form of the work
>   for making modifications to it.  "Object code" means any non-source
>   form of a work.
>
> , and Guix builds things from source. I don't think constants.c is in
> preferred form, rather it seems to be sqlite.h
>
> Maybe it's not much of a problem here though, I donk't know.
>
> I don't see the relevancy of what files the maintainer is using.  What
> does maintainerhood have to do with anything?

Well, I was looking at the last time the consts.c has been modified by
the maintainer and it was 2 years ago.

I was thinking it would be more stable to use the code that ships with
the repository, rather than building something from the internet which
hasn't been updated for 2 years.

But if this file is considered object code, ok.

> Greetings,
> Maxime.
>
> [[End of PGP Signed Part]]


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Add-emacs-sqlite3-api-package.patch --]
[-- Type: text/x-patch, Size: 4686 bytes --]

From 16a89de32c9ef7458e852169e62eb08f008a6a2b Mon Sep 17 00:00:00 2001
From: r0man <roman@burningswell.com>
Date: Sat, 26 Mar 2022 14:59:01 +0100
Subject: [PATCH] Add emacs-sqlite3-api package

This patch adds the emacs-sqlite3-api package to Guix.

The package provides a dynamic module for Emacs that allows direct access to
the SQLite C interface.  It only exposes a subset of the full SQLite C
interface, but should satisfy most user's needs.

The original source code uses a file called constants.c, which is checked into
the repository, but can be generated by running make in the tools directory of
the source.

However, the procedure to generate this file downloads a list of constants
from the SQLite website. We are patching the scripts to generate those
constants, to not download anything from the internet to have a stable build
process.
---
 gnu/packages/emacs-xyz.scm | 61 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 42fc13f4c2..b4eacce952 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -5731,6 +5731,67 @@ (define-public emacs-sqlite
 It is not intended as a user interface.")
       (license license:gpl3+))))
 
+(define-public emacs-sqlite3-api
+  (let ((version "0.15")
+        (revision "0")
+        (commit "7cb4b660fe30deb8a4229f3abb18bd99ca9c971c"))
+    (package
+      (name "emacs-sqlite3-api")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/pekingduck/emacs-sqlite3-api")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1b7if1dp6i5kqwhq25gna89xbca66i4mmgx1a5yn12kncfdgs6d7"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:modules ((guix build emacs-build-system)
+                    (guix build emacs-utils)
+                    (guix build utils))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'patch-module-load
+             (lambda* (#:key outputs #:allow-other-keys)
+               (chmod "sqlite3.el" #o644)
+               (emacs-substitute-sexps "sqlite3.el"
+                 ("(require 'sqlite3-api nil t)"
+                  `(module-load ,(string-append (assoc-ref outputs "out")
+                                                "/lib/sqlite3-api.so"))))))
+           (add-before 'check 'build-emacs-module
+             (lambda* (#:key outputs #:allow-other-keys)
+               ;; Remove code that fetches constants from the SQLite website
+               ;; and the call to generate a timestamp.
+               (invoke "sed" "--in-place" "3,4d;24,28d;31d" "tools/gen-consts.sh")
+               ;; Remove filter logic from the script that generates the constants.
+               (invoke "sed" "--in-place" "7,11d;18,22d" "tools/gen-consts.py")
+               ;; Generate the consts.c file.
+               (invoke "make" "--directory=tools")
+               ;; Remove the SQLITE_STATIC and SQLITE_TRANSIENT
+               ;; constants. They cause a compilation warning and would have
+               ;; been removed by the original script.
+               (invoke "sed" "--in-place" "/ifdef SQLITE_STATIC/,+2d" "consts.c")
+               (invoke "sed" "--in-place" "/ifdef SQLITE_TRANSIENT/,+2d" "consts.c")
+               ;; Compile the shared object file.
+               (invoke "make" (string-append "CC=" ,(cc-for-target)))
+               ;; Move the shared object file into /lib.
+               (install-file "sqlite3-api.so"
+                             (string-append (assoc-ref outputs "out")
+                                            "/lib")))))
+         #:tests? ,(%current-target-system)
+         #:test-command '("make" "test" "EMACS=emacs")))
+      (inputs (list sqlite))
+      (native-inputs (list python sed))
+      (home-page "https://github.com/pekingduck/emacs-sqlite3-api")
+      (synopsis "SQLite dynamic module for Emacs Lisp")
+      (description "This package provides a dynamic module for Emacs that allows
+direct access to the SQLite C interface.  It only exposes a subset of the full
+SQLite C interface, but should satisfy most user's needs.")
+      (license license:gpl3+))))
+
 (define-public emacs-sr-speedbar
   (let ((commit "77a83fb50f763a465c021eca7343243f465b4a47")
         (revision "0"))
-- 
2.34.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-04-01  9:07       ` Roman Scherer
@ 2022-04-01  9:57         ` Maxime Devos
  2022-04-01 10:11           ` Roman Scherer
  2022-04-01  9:59         ` Maxime Devos
  1 sibling, 1 reply; 20+ messages in thread
From: Maxime Devos @ 2022-04-01  9:57 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 426 bytes --]

Roman Scherer schreef op vr 01-04-2022 om 11:07 [+0200]:
> I changed the #:tests? keyword to (%current-target-system), but I
> noticed the tests of the package are now not run anymore when I build
> the package. Is this expected?

You need the inverse condition:

  #:tests? ,(not (%current-target-system))

otherwise, tests are only run when cross-compiling, and not when
building natively.

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-04-01  9:07       ` Roman Scherer
  2022-04-01  9:57         ` Maxime Devos
@ 2022-04-01  9:59         ` Maxime Devos
  2022-04-01 10:13           ` Roman Scherer
  1 sibling, 1 reply; 20+ messages in thread
From: Maxime Devos @ 2022-04-01  9:59 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

Roman Scherer schreef op vr 01-04-2022 om 11:07 [+0200]:
> ./pre-inst-env guix build emacs-sqlite3-api --target=x86_64
> guix build: error: /home/roman/workspace/guix/gnu/packages/emacs-
> xyz.scm:5738:4: emacs-sqlite3-api@0.15-0.7cb4b66: build system
> `emacs' does not support cross builds

FWIW x86_64 is not a valid triple, you need something like

   --target=aarch64-linux-gnu

or
   --target=x86_64-linux-gnu

or
   --target=i686-pc-gnu # or was it i586?

though that won't work either because emacs-build-system doesn't
support cross-compilation yet.

Geetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-04-01  9:57         ` Maxime Devos
@ 2022-04-01 10:11           ` Roman Scherer
  2022-05-05  7:46             ` Roman Scherer
  2022-09-18 12:44             ` bug#54581: " Nicolas Goaziou
  0 siblings, 2 replies; 20+ messages in thread
From: Roman Scherer @ 2022-04-01 10:11 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 54581


[-- Attachment #1.1: Type: text/plain, Size: 68 bytes --]


Ok, thank you. The attached patch uses the inverse condition now.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Add-emacs-sqlite3-api-package.patch --]
[-- Type: text/x-patch, Size: 4713 bytes --]

From 2f6a85911d6e6542c5ccbbecaf753605008ed7ea Mon Sep 17 00:00:00 2001
From: r0man <roman@burningswell.com>
Date: Sat, 26 Mar 2022 14:59:01 +0100
Subject: [PATCH] Add emacs-sqlite3-api package

This patch adds the emacs-sqlite3-api package to Guix.

The package provides a dynamic module for Emacs that allows direct access to
the SQLite C interface.  It only exposes a subset of the full SQLite C
interface, but should satisfy most user's needs.

The original source code uses a file called constants.c, which is checked into
the repository, but can be generated by running make in the tools directory of
the source.

However, the procedure to generate this file downloads a list of constants
from the SQLite website. We are patching the scripts to generate those
constants, to not download anything from the internet to have a stable build
process.
---
 gnu/packages/emacs-xyz.scm | 61 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 42fc13f4c2..b3575e9297 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -5731,6 +5731,67 @@ (define-public emacs-sqlite
 It is not intended as a user interface.")
       (license license:gpl3+))))
 
+(define-public emacs-sqlite3-api
+  (let ((version "0.15")
+        (revision "0")
+        (commit "7cb4b660fe30deb8a4229f3abb18bd99ca9c971c"))
+    (package
+      (name "emacs-sqlite3-api")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/pekingduck/emacs-sqlite3-api")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "1b7if1dp6i5kqwhq25gna89xbca66i4mmgx1a5yn12kncfdgs6d7"))))
+      (build-system emacs-build-system)
+      (arguments
+       `(#:modules ((guix build emacs-build-system)
+                    (guix build emacs-utils)
+                    (guix build utils))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'patch-module-load
+             (lambda* (#:key outputs #:allow-other-keys)
+               (chmod "sqlite3.el" #o644)
+               (emacs-substitute-sexps "sqlite3.el"
+                 ("(require 'sqlite3-api nil t)"
+                  `(module-load ,(string-append (assoc-ref outputs "out")
+                                                "/lib/sqlite3-api.so"))))))
+           (add-before 'check 'build-emacs-module
+             (lambda* (#:key outputs #:allow-other-keys)
+               ;; Remove code that fetches constants from the SQLite website
+               ;; and the call to generate a timestamp.
+               (invoke "sed" "--in-place" "3,4d;24,28d;31d" "tools/gen-consts.sh")
+               ;; Remove filter logic from the script that generates the constants.
+               (invoke "sed" "--in-place" "7,11d;18,22d" "tools/gen-consts.py")
+               ;; Generate the consts.c file.
+               (invoke "make" "--directory=tools")
+               ;; Remove the SQLITE_STATIC and SQLITE_TRANSIENT
+               ;; constants. They cause a compilation warning and would have
+               ;; been removed by the original script.
+               (invoke "sed" "--in-place" "/ifdef SQLITE_STATIC/,+2d" "consts.c")
+               (invoke "sed" "--in-place" "/ifdef SQLITE_TRANSIENT/,+2d" "consts.c")
+               ;; Compile the shared object file.
+               (invoke "make" (string-append "CC=" ,(cc-for-target)))
+               ;; Move the shared object file into /lib.
+               (install-file "sqlite3-api.so"
+                             (string-append (assoc-ref outputs "out")
+                                            "/lib")))))
+         #:tests? ,(not (%current-target-system))
+         #:test-command '("make" "test" "EMACS=emacs")))
+      (inputs (list sqlite))
+      (native-inputs (list python sed))
+      (home-page "https://github.com/pekingduck/emacs-sqlite3-api")
+      (synopsis "Dynamic module for Emacs to access the SQLite C interface")
+      (description "This package provides a dynamic module for Emacs that allows
+direct access to the SQLite C interface.  It only exposes a subset of the full
+SQLite C interface, but should satisfy most user's needs.")
+      (license license:gpl3+))))
+
 (define-public emacs-sr-speedbar
   (let ((commit "77a83fb50f763a465c021eca7343243f465b4a47")
         (revision "0"))
-- 
2.34.0


[-- Attachment #1.3: Type: text/plain, Size: 544 bytes --]


Maxime Devos <maximedevos@telenet.be> writes:

> [[PGP Signed Part:Undecided]]
> Roman Scherer schreef op vr 01-04-2022 om 11:07 [+0200]:
>> I changed the #:tests? keyword to (%current-target-system), but I
>> noticed the tests of the package are now not run anymore when I build
>> the package. Is this expected?
>
> You need the inverse condition:
>
>   #:tests? ,(not (%current-target-system))
>
> otherwise, tests are only run when cross-compiling, and not when
> building natively.
>
> Greetings,
> Maxime.
>
> [[End of PGP Signed Part]]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-04-01  9:59         ` Maxime Devos
@ 2022-04-01 10:13           ` Roman Scherer
  0 siblings, 0 replies; 20+ messages in thread
From: Roman Scherer @ 2022-04-01 10:13 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]


Ok, understood. Thanks for the explanation.

Maxime Devos <maximedevos@telenet.be> writes:

> [[PGP Signed Part:Undecided]]
> Roman Scherer schreef op vr 01-04-2022 om 11:07 [+0200]:
>> ./pre-inst-env guix build emacs-sqlite3-api --target=x86_64
>> guix build: error: /home/roman/workspace/guix/gnu/packages/emacs-
>> xyz.scm:5738:4: emacs-sqlite3-api@0.15-0.7cb4b66: build system
>> `emacs' does not support cross builds
>
> FWIW x86_64 is not a valid triple, you need something like
>
>    --target=aarch64-linux-gnu
>
> or
>    --target=x86_64-linux-gnu
>
> or
>    --target=i686-pc-gnu # or was it i586?
>
> though that won't work either because emacs-build-system doesn't
> support cross-compilation yet.
>
> Geetings,
> Maxime.
>
> [[End of PGP Signed Part]]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-04-01 10:11           ` Roman Scherer
@ 2022-05-05  7:46             ` Roman Scherer
  2022-05-05 10:51               ` Maxime Devos
  2022-09-18 12:44             ` bug#54581: " Nicolas Goaziou
  1 sibling, 1 reply; 20+ messages in thread
From: Roman Scherer @ 2022-05-05  7:46 UTC (permalink / raw)
  To: Maxime Devos; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]


Hi Maxime,

is there anything I can do to move this forward?

Roman

Roman Scherer <roman.scherer@burningswell.com> writes:

> [[PGP Signed Part:Undecided]]
>
> Ok, thank you. The attached patch uses the inverse condition now.
>
> [2. text/x-patch; 0001-Add-emacs-sqlite3-api-package.patch]...
>
>
> Maxime Devos <maximedevos@telenet.be> writes:
>
>> [[PGP Signed Part:Undecided]]
>> Roman Scherer schreef op vr 01-04-2022 om 11:07 [+0200]:
>>> I changed the #:tests? keyword to (%current-target-system), but I
>>> noticed the tests of the package are now not run anymore when I build
>>> the package. Is this expected?
>>
>> You need the inverse condition:
>>
>>   #:tests? ,(not (%current-target-system))
>>
>> otherwise, tests are only run when cross-compiling, and not when
>> building natively.
>>
>> Greetings,
>> Maxime.
>>
>> [[End of PGP Signed Part]]
>
> [[End of PGP Signed Part]]

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 528 bytes --]

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

* [bug#54581] Add emacs-sqlite3-api package
  2022-05-05  7:46             ` Roman Scherer
@ 2022-05-05 10:51               ` Maxime Devos
  0 siblings, 0 replies; 20+ messages in thread
From: Maxime Devos @ 2022-05-05 10:51 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

Roman Scherer schreef op do 05-05-2022 om 09:46 [+0200]:
> 
> Hi Maxime,
> 
> is there anything I can do to move this forward?
> 
> Roman

I am currently not reviewing packages much, so for now, you will have
to wait for another reviewer (or committer if the package definition is
good).

Greetings,
Maxime.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

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

* bug#54581: Add emacs-sqlite3-api package
  2022-04-01 10:11           ` Roman Scherer
  2022-05-05  7:46             ` Roman Scherer
@ 2022-09-18 12:44             ` Nicolas Goaziou
  2022-09-19  6:46               ` [bug#54581] " Roman Scherer
  1 sibling, 1 reply; 20+ messages in thread
From: Nicolas Goaziou @ 2022-09-18 12:44 UTC (permalink / raw)
  To: Roman Scherer; +Cc: 54581-done, Maxime Devos

Hello,

Roman Scherer <roman.scherer@burningswell.com> writes:

> Ok, thank you. The attached patch uses the inverse condition now.

Thank you. I updated the package to latest 0.16, rewrote the arguments
with G-expressions, and applied it all.

Regards,
-- 
Nicolas Goaziou




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

* [bug#54581] Add emacs-sqlite3-api package
  2022-09-18 12:44             ` bug#54581: " Nicolas Goaziou
@ 2022-09-19  6:46               ` Roman Scherer
  0 siblings, 0 replies; 20+ messages in thread
From: Roman Scherer @ 2022-09-19  6:46 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: 54581-done, Maxime Devos

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

Thank you Nicolas

On Sun, Sep 18, 2022, 14:44 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Hello,
>
> Roman Scherer <roman.scherer@burningswell.com> writes:
>
> > Ok, thank you. The attached patch uses the inverse condition now.
>
> Thank you. I updated the package to latest 0.16, rewrote the arguments
> with G-expressions, and applied it all.
>
> Regards,
> --
> Nicolas Goaziou
>

[-- Attachment #2: Type: text/html, Size: 790 bytes --]

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

end of thread, other threads:[~2022-09-19  6:57 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-26 14:09 [bug#54581] Add emacs-sqlite3-api package Roman Scherer
2022-03-26 21:17 ` Maxime Devos
2022-03-26 21:20 ` Maxime Devos
2022-03-26 21:21 ` Maxime Devos
2022-03-26 21:23 ` Maxime Devos
2022-03-26 21:25 ` Maxime Devos
2022-03-27 17:55   ` Roman Scherer
2022-03-27 19:19     ` Maxime Devos
2022-03-27 19:20     ` Maxime Devos
2022-03-27 19:34     ` Maxime Devos
2022-03-27 19:45     ` Maxime Devos
2022-04-01  9:07       ` Roman Scherer
2022-04-01  9:57         ` Maxime Devos
2022-04-01 10:11           ` Roman Scherer
2022-05-05  7:46             ` Roman Scherer
2022-05-05 10:51               ` Maxime Devos
2022-09-18 12:44             ` bug#54581: " Nicolas Goaziou
2022-09-19  6:46               ` [bug#54581] " Roman Scherer
2022-04-01  9:59         ` Maxime Devos
2022-04-01 10:13           ` Roman Scherer

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).