* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
@ 2021-04-19 18:48 david larsson
2021-05-13 12:41 ` Marius Bakke
0 siblings, 1 reply; 9+ messages in thread
From: david larsson @ 2021-04-19 18:48 UTC (permalink / raw)
To: 47898
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
Hi!
This patch adds the option to separate xpath results from xmllint by a
null delimiter when using the --xpath0 option-flag. It is something
that's been asked for for a long time by users on stackoverflow and
merge-attempts have been made to upstream without success.
Examples:
- https://gitlab.gnome.org/GNOME/libxml2/-/issues/227
- https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/8
Best regards,
David
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-libxml2-Add-patch-for-xpath0-option-to-xmllint.patch --]
[-- Type: text/x-diff; name=0001-gnu-libxml2-Add-patch-for-xpath0-option-to-xmllint.patch, Size: 6647 bytes --]
From 714a6a26da55f7e06c94d3d2bb2965b9d2f832da Mon Sep 17 00:00:00 2001
From: David Larsson <david.larsson@selfhosted.xyz>
Date: Mon, 19 Apr 2021 20:39:23 +0200
Subject: [PATCH] gnu: libxml2: Add patch for xpath0 option to xmllint.
* gnu/packages/patches/libxml2-Add-option-xpath0.patch: New file...
* gnu/packages/xml.scm (libxml2) [source]: ...add it.
---
.../patches/libxml2-Add-option-xpath0.patch | 139 ++++++++++++++++++
gnu/packages/xml.scm | 3 +-
2 files changed, 141 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/libxml2-Add-option-xpath0.patch
diff --git a/gnu/packages/patches/libxml2-Add-option-xpath0.patch b/gnu/packages/patches/libxml2-Add-option-xpath0.patch
new file mode 100644
index 0000000000..3337374a8c
--- /dev/null
+++ b/gnu/packages/patches/libxml2-Add-option-xpath0.patch
@@ -0,0 +1,139 @@
+From e1df743329bdfd94fbfdea18303c5c6c6fe13403 Mon Sep 17 00:00:00 2001
+From: methuselah-0 <david.larsson@selfhosted.xyz>
+Date: Thu, 1 Apr 2021 08:33:56 +0200
+Subject: [PATCH] Add option --xpath0
+
+---
+ doc/xmllint.xml | 16 ++++++++++++++++
+ xmllint.c | 32 +++++++++++++++++++++++---------
+ 2 files changed, 39 insertions(+), 9 deletions(-)
+
+diff --git a/doc/xmllint.xml b/doc/xmllint.xml
+index 1008179b..fcdc237e 100644
+--- a/doc/xmllint.xml
++++ b/doc/xmllint.xml
+@@ -70,6 +70,7 @@
+ <arg choice="plain"><option>--debug</option></arg>
+ <arg choice="plain"><option>--shell</option></arg>
+ <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
++ <arg choice="plain"><option>--xpath0 "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
+ <arg choice="plain"><option>--debugent</option></arg>
+ <arg choice="plain"><option>--copy</option></arg>
+ <arg choice="plain"><option>--recover</option></arg>
+@@ -537,6 +538,21 @@
+ node set is serialized in full in the output. In case
+ of an empty node set the "XPath set is empty" result
+ will be shown and an error exit code will be returned.
++ Results are separated by the newline character.
++ </para>
++ </listitem>
++ </varlistentry>
++
++ <varlistentry>
++ <term><option>--xpath0 "<replaceable class="option">XPath_expression</replaceable>"</option></term>
++ <listitem>
++ <para>
++ Run an XPath expression given as argument and print the
++ result. In case of a nodeset result, each node in the
++ node set is serialized in full in the output. In case
++ of an empty node set the "XPath set is empty" result
++ will be shown and an error exit code will be returned.
++ Results are separated by the null character.
+ </para>
+ </listitem>
+ </varlistentry>
+diff --git a/xmllint.c b/xmllint.c
+index 6ca1bf54..a60e1f4f 100644
+--- a/xmllint.c
++++ b/xmllint.c
+@@ -194,6 +194,7 @@ static int sax1 = 0;
+ #endif /* LIBXML_SAX1_ENABLED */
+ #ifdef LIBXML_XPATH_ENABLED
+ static const char *xpathquery = NULL;
++static const char *xpathsep = "\n";
+ #endif
+ static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES;
+ static int sax = 0;
+@@ -2095,7 +2096,7 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
+ for (i = 0;i < cur->nodesetval->nodeNr;i++) {
+ node = cur->nodesetval->nodeTab[i];
+ xmlNodeDumpOutput(buf, NULL, node, 0, 0, NULL);
+- xmlOutputBufferWrite(buf, 1, "\n");
++ xmlOutputBufferWrite(buf, 1, xpathsep);
+ }
+ xmlOutputBufferClose(buf);
+ #else
+@@ -2104,27 +2105,27 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
+ break;
+ }
+ case XPATH_BOOLEAN:
+- if (cur->boolval) printf("true\n");
+- else printf("false\n");
++ if (cur->boolval) printf("true%s", xpathsep);
++ else printf("false%s", xpathsep);
+ break;
+ case XPATH_NUMBER:
+ switch (xmlXPathIsInf(cur->floatval)) {
+ case 1:
+- printf("Infinity\n");
++ printf("Infinity%s", xpathsep);
+ break;
+ case -1:
+- printf("-Infinity\n");
++ printf("-Infinity%s", xpathsep);
+ break;
+ default:
+ if (xmlXPathIsNaN(cur->floatval)) {
+- printf("NaN\n");
++ printf("NaN%s", xpathsep);
+ } else {
+- printf("%0g\n", cur->floatval);
++ printf("%0g%s", cur->floatval, xpathsep);
+ }
+ }
+ break;
+ case XPATH_STRING:
+- printf("%s\n", (const char *) cur->stringval);
++ printf("%s%s", (const char *) cur->stringval, xpathsep);
+ break;
+ case XPATH_UNDEFINED:
+ fprintf(stderr, "XPath Object is uninitialized\n");
+@@ -3098,7 +3099,8 @@ static void usage(FILE *f, const char *name) {
+ fprintf(f, "\t--sax: do not build a tree but work just at the SAX level\n");
+ fprintf(f, "\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n");
+ #ifdef LIBXML_XPATH_ENABLED
+- fprintf(f, "\t--xpath expr: evaluate the XPath expression, imply --noout\n");
++ fprintf(f, "\t--xpath expr: evaluate the XPath expression, results are separated by \\n, imply --noout\n");
++ fprintf(f, "\t--xpath0 expr: evaluate the XPath expression, results are separated by \\0, imply --noout\n");
+ #endif
+
+ fprintf(f, "\nLibxml project home page: http://xmlsoft.org/\n");
+@@ -3480,6 +3482,13 @@ main(int argc, char **argv) {
+ i++;
+ noout++;
+ xpathquery = argv[i];
++ xpathsep = "\n";
++ } else if ((!strcmp(argv[i], "-xpath0")) ||
++ (!strcmp(argv[i], "--xpath0"))) {
++ i++;
++ noout++;
++ xpathquery = argv[i];
++ xpathsep = "\0";
+ #endif
+ } else if ((!strcmp(argv[i], "-oldxml10")) ||
+ (!strcmp(argv[i], "--oldxml10"))) {
+@@ -3712,6 +3721,11 @@ main(int argc, char **argv) {
+ i++;
+ continue;
+ }
++ if ((!strcmp(argv[i], "-xpath0")) ||
++ (!strcmp(argv[i], "--xpath0"))) {
++ i++;
++ continue;
++ }
+ #endif
+ if ((timing) && (repeat))
+ startTimer();
+--
+2.30.2
+
diff --git a/gnu/packages/xml.scm b/gnu/packages/xml.scm
index ad5f35ef1e..d6a9b46e1d 100644
--- a/gnu/packages/xml.scm
+++ b/gnu/packages/xml.scm
@@ -177,7 +177,8 @@ hierarchical form with variable field lengths.")
version ".tar.gz"))
(sha256
(base32
- "07xynh8hcxb2yb1fs051xrgszjvj37wnxvxgsj10rzmqzy9y3zma"))))
+ "07xynh8hcxb2yb1fs051xrgszjvj37wnxvxgsj10rzmqzy9y3zma"))
+ (patches (list (search-patch "libxml2-Add-option-xpath0.patch")))))
(build-system gnu-build-system)
(outputs '("out" "static" "doc"))
(arguments
--
2.30.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
2021-04-19 18:48 [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2 david larsson
@ 2021-05-13 12:41 ` Marius Bakke
2021-05-13 13:21 ` david larsson
0 siblings, 1 reply; 9+ messages in thread
From: Marius Bakke @ 2021-05-13 12:41 UTC (permalink / raw)
To: david larsson, 47898
[-- Attachment #1: Type: text/plain, Size: 958 bytes --]
david larsson <david.larsson@selfhosted.xyz> skriver:
> Hi!
> This patch adds the option to separate xpath results from xmllint by a
> null delimiter when using the --xpath0 option-flag. It is something
> that's been asked for for a long time by users on stackoverflow and
> merge-attempts have been made to upstream without success.
>
> Examples:
> - https://gitlab.gnome.org/GNOME/libxml2/-/issues/227
> - https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/8
I'm reluctant to take a patch that has been rejected upstream,
especially for a core package such as libxml2. Porting can be
time-consuming which delays security updates, and we'll have situations
where something "works on Guix" but not elsewhere (or vice versa).
Will adding it as a separate package be sufficient? We could call it
"xmllint-xpath0" or similar and make it clear that it's just libxml2
with a patched xmllint in the description.
Thoughts?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
2021-05-13 12:41 ` Marius Bakke
@ 2021-05-13 13:21 ` david larsson
2021-05-13 13:29 ` Marius Bakke
0 siblings, 1 reply; 9+ messages in thread
From: david larsson @ 2021-05-13 13:21 UTC (permalink / raw)
To: Marius Bakke; +Cc: 47898
On 2021-05-13 14:41, Marius Bakke wrote:
> david larsson <david.larsson@selfhosted.xyz> skriver:
>
>> Hi!
>> This patch adds the option to separate xpath results from xmllint by a
>> null delimiter when using the --xpath0 option-flag. It is something
>> that's been asked for for a long time by users on stackoverflow and
>> merge-attempts have been made to upstream without success.
>>
>> Examples:
>> - https://gitlab.gnome.org/GNOME/libxml2/-/issues/227
>> - https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/8
>
> I'm reluctant to take a patch that has been rejected upstream,
> especially for a core package such as libxml2. Porting can be
> time-consuming which delays security updates, and we'll have situations
> where something "works on Guix" but not elsewhere (or vice versa).
I understand.
>
> Will adding it as a separate package be sufficient? We could call it
> "xmllint-xpath0" or similar and make it clear that it's just libxml2
> with a patched xmllint in the description.
>
> Thoughts?
Yes, that would be nice. How about calling it libxml2-xpath0 instead?
That would maintain libxml2 in the name, letting users know it's just a
version of the original package and should show up when searching for
libxml2. If calling it xmllint-xpath0, I feel that the package should
remove other outputs than just the xmllint binary file, which is perhaps
a good idea though?
Either option is fine for me.
Best regards,
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
2021-05-13 13:21 ` david larsson
@ 2021-05-13 13:29 ` Marius Bakke
[not found] ` <80bc8f6c73d5aa423cf906d59bbcd43e@selfhosted.xyz>
0 siblings, 1 reply; 9+ messages in thread
From: Marius Bakke @ 2021-05-13 13:29 UTC (permalink / raw)
To: david larsson; +Cc: 47898
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
david larsson <david.larsson@selfhosted.xyz> skriver:
> On 2021-05-13 14:41, Marius Bakke wrote:
>> david larsson <david.larsson@selfhosted.xyz> skriver:
>>
>> Will adding it as a separate package be sufficient? We could call it
>> "xmllint-xpath0" or similar and make it clear that it's just libxml2
>> with a patched xmllint in the description.
>>
>> Thoughts?
>
> Yes, that would be nice. How about calling it libxml2-xpath0 instead?
> That would maintain libxml2 in the name, letting users know it's just a
> version of the original package and should show up when searching for
> libxml2. If calling it xmllint-xpath0, I feel that the package should
> remove other outputs than just the xmllint binary file, which is perhaps
> a good idea though?
libxml2-xpath0 is probably better indeed, I don't have a strong opinion.
Can you send an updated patch? :-)
Thanks,
Marius
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
[not found] ` <80bc8f6c73d5aa423cf906d59bbcd43e@selfhosted.xyz>
@ 2021-05-15 12:53 ` david larsson
2021-05-15 16:12 ` Marius Bakke
0 siblings, 1 reply; 9+ messages in thread
From: david larsson @ 2021-05-15 12:53 UTC (permalink / raw)
To: 47898
[-- Attachment #1: Type: text/plain, Size: 183 bytes --]
> libxml2-xpath0 is probably better indeed, I don't have a strong
> opinion.
> Can you send an updated patch? :-)
>
> Thanks,
> Marius
Updated patch attached!
Best regards,
David
[-- Attachment #2: 0001-gnu-libxml2-xpath0-New-package-with-patch-for-xpath0.patch --]
[-- Type: text/x-diff, Size: 8998 bytes --]
From f3f3ff5e1553363a3c46335d418eed314646d38e Mon Sep 17 00:00:00 2001
From: David Larsson <david.larsson@selfhosted.xyz>
Date: Sat, 15 May 2021 11:35:11 +0200
Subject: [PATCH] gnu: libxml2-xpath0: New package with patch for xpath0 option
to xmllint.
gnu/packages/patches/libxml2-Add-option-xpath0.patch: New file...
gnu/packages/xml.scm (libxml2-xpath0) [source]: ...apply it.
---
.../patches/libxml2-Add-option-xpath0.patch | 139 ++++++++++++++++++
gnu/packages/xml.scm | 52 +++++++
2 files changed, 191 insertions(+)
create mode 100644 gnu/packages/patches/libxml2-Add-option-xpath0.patch
diff --git a/gnu/packages/patches/libxml2-Add-option-xpath0.patch b/gnu/packages/patches/libxml2-Add-option-xpath0.patch
new file mode 100644
index 0000000000..3337374a8c
--- /dev/null
+++ b/gnu/packages/patches/libxml2-Add-option-xpath0.patch
@@ -0,0 +1,139 @@
+From e1df743329bdfd94fbfdea18303c5c6c6fe13403 Mon Sep 17 00:00:00 2001
+From: methuselah-0 <david.larsson@selfhosted.xyz>
+Date: Thu, 1 Apr 2021 08:33:56 +0200
+Subject: [PATCH] Add option --xpath0
+
+---
+ doc/xmllint.xml | 16 ++++++++++++++++
+ xmllint.c | 32 +++++++++++++++++++++++---------
+ 2 files changed, 39 insertions(+), 9 deletions(-)
+
+diff --git a/doc/xmllint.xml b/doc/xmllint.xml
+index 1008179b..fcdc237e 100644
+--- a/doc/xmllint.xml
++++ b/doc/xmllint.xml
+@@ -70,6 +70,7 @@
+ <arg choice="plain"><option>--debug</option></arg>
+ <arg choice="plain"><option>--shell</option></arg>
+ <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
++ <arg choice="plain"><option>--xpath0 "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
+ <arg choice="plain"><option>--debugent</option></arg>
+ <arg choice="plain"><option>--copy</option></arg>
+ <arg choice="plain"><option>--recover</option></arg>
+@@ -537,6 +538,21 @@
+ node set is serialized in full in the output. In case
+ of an empty node set the "XPath set is empty" result
+ will be shown and an error exit code will be returned.
++ Results are separated by the newline character.
++ </para>
++ </listitem>
++ </varlistentry>
++
++ <varlistentry>
++ <term><option>--xpath0 "<replaceable class="option">XPath_expression</replaceable>"</option></term>
++ <listitem>
++ <para>
++ Run an XPath expression given as argument and print the
++ result. In case of a nodeset result, each node in the
++ node set is serialized in full in the output. In case
++ of an empty node set the "XPath set is empty" result
++ will be shown and an error exit code will be returned.
++ Results are separated by the null character.
+ </para>
+ </listitem>
+ </varlistentry>
+diff --git a/xmllint.c b/xmllint.c
+index 6ca1bf54..a60e1f4f 100644
+--- a/xmllint.c
++++ b/xmllint.c
+@@ -194,6 +194,7 @@ static int sax1 = 0;
+ #endif /* LIBXML_SAX1_ENABLED */
+ #ifdef LIBXML_XPATH_ENABLED
+ static const char *xpathquery = NULL;
++static const char *xpathsep = "\n";
+ #endif
+ static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES;
+ static int sax = 0;
+@@ -2095,7 +2096,7 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
+ for (i = 0;i < cur->nodesetval->nodeNr;i++) {
+ node = cur->nodesetval->nodeTab[i];
+ xmlNodeDumpOutput(buf, NULL, node, 0, 0, NULL);
+- xmlOutputBufferWrite(buf, 1, "\n");
++ xmlOutputBufferWrite(buf, 1, xpathsep);
+ }
+ xmlOutputBufferClose(buf);
+ #else
+@@ -2104,27 +2105,27 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
+ break;
+ }
+ case XPATH_BOOLEAN:
+- if (cur->boolval) printf("true\n");
+- else printf("false\n");
++ if (cur->boolval) printf("true%s", xpathsep);
++ else printf("false%s", xpathsep);
+ break;
+ case XPATH_NUMBER:
+ switch (xmlXPathIsInf(cur->floatval)) {
+ case 1:
+- printf("Infinity\n");
++ printf("Infinity%s", xpathsep);
+ break;
+ case -1:
+- printf("-Infinity\n");
++ printf("-Infinity%s", xpathsep);
+ break;
+ default:
+ if (xmlXPathIsNaN(cur->floatval)) {
+- printf("NaN\n");
++ printf("NaN%s", xpathsep);
+ } else {
+- printf("%0g\n", cur->floatval);
++ printf("%0g%s", cur->floatval, xpathsep);
+ }
+ }
+ break;
+ case XPATH_STRING:
+- printf("%s\n", (const char *) cur->stringval);
++ printf("%s%s", (const char *) cur->stringval, xpathsep);
+ break;
+ case XPATH_UNDEFINED:
+ fprintf(stderr, "XPath Object is uninitialized\n");
+@@ -3098,7 +3099,8 @@ static void usage(FILE *f, const char *name) {
+ fprintf(f, "\t--sax: do not build a tree but work just at the SAX level\n");
+ fprintf(f, "\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n");
+ #ifdef LIBXML_XPATH_ENABLED
+- fprintf(f, "\t--xpath expr: evaluate the XPath expression, imply --noout\n");
++ fprintf(f, "\t--xpath expr: evaluate the XPath expression, results are separated by \\n, imply --noout\n");
++ fprintf(f, "\t--xpath0 expr: evaluate the XPath expression, results are separated by \\0, imply --noout\n");
+ #endif
+
+ fprintf(f, "\nLibxml project home page: http://xmlsoft.org/\n");
+@@ -3480,6 +3482,13 @@ main(int argc, char **argv) {
+ i++;
+ noout++;
+ xpathquery = argv[i];
++ xpathsep = "\n";
++ } else if ((!strcmp(argv[i], "-xpath0")) ||
++ (!strcmp(argv[i], "--xpath0"))) {
++ i++;
++ noout++;
++ xpathquery = argv[i];
++ xpathsep = "\0";
+ #endif
+ } else if ((!strcmp(argv[i], "-oldxml10")) ||
+ (!strcmp(argv[i], "--oldxml10"))) {
+@@ -3712,6 +3721,11 @@ main(int argc, char **argv) {
+ i++;
+ continue;
+ }
++ if ((!strcmp(argv[i], "-xpath0")) ||
++ (!strcmp(argv[i], "--xpath0"))) {
++ i++;
++ continue;
++ }
+ #endif
+ if ((timing) && (repeat))
+ startTimer();
+--
+2.30.2
+
diff --git a/gnu/packages/xml.scm b/gnu/packages/xml.scm
index 931698a575..12cad65154 100644
--- a/gnu/packages/xml.scm
+++ b/gnu/packages/xml.scm
@@ -167,6 +167,58 @@ binary extension of XML for the purpose of storing and manipulating data in a
hierarchical form with variable field lengths.")
(license license:lgpl2.1)))
+(define-public libxml2-xpath0
+ (package
+ (name "libxml2-xpath0")
+ (version "2.9.10")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "ftp://xmlsoft.org/libxml2/libxml2-"
+ version ".tar.gz"))
+ (sha256
+ (base32
+ "07xynh8hcxb2yb1fs051xrgszjvj37wnxvxgsj10rzmqzy9y3zma"))
+ (patches (list (search-patch "libxml2-Add-option-xpath0.patch")))))
+ (build-system gnu-build-system)
+ (outputs '("out" "static"))
+ (arguments
+ `(#:phases (modify-phases %standard-phases
+ (add-after 'install 'move-static-libs
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((src (string-append (assoc-ref outputs "out") "/lib"))
+ (dst (string-append (assoc-ref outputs "static")
+ "/lib")))
+ (mkdir-p dst)
+ (for-each (lambda (ar)
+ (rename-file ar (string-append dst "/"
+ (basename ar))))
+ (find-files src "\\.a$"))
+
+ ;; Remove reference to the static library from the .la
+ ;; file such that Libtool does the right thing when both
+ ;; the shared and static variants are available.
+ (substitute* (string-append src "/libxml2.la")
+ (("^old_library='libxml2.a'") "old_library=''"))
+ #t))))))
+ (home-page "http://www.xmlsoft.org/")
+ (synopsis "C parser for XML")
+ (inputs `(("xz" ,xz)))
+ (propagated-inputs `(("zlib" ,zlib))) ; libxml2.la says '-lz'.
+ (native-inputs `(("perl" ,perl)))
+ ;; $XML_CATALOG_FILES lists 'catalog.xml' files found in under the 'xml'
+ ;; sub-directory of any given package.
+ (native-search-paths (list (search-path-specification
+ (variable "XML_CATALOG_FILES")
+ (separator " ")
+ (files '("xml"))
+ (file-pattern "^catalog\\.xml$")
+ (file-type 'regular))))
+ (search-paths native-search-paths)
+ (description
+ "Libxml2 is the XML C parser and toolkit developed for the Gnome
+project (but it is usable outside of the Gnome platform).")
+ (license license:x11)))
+
(define-public libxml2
(package
(name "libxml2")
--
2.31.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
2021-05-15 12:53 ` david larsson
@ 2021-05-15 16:12 ` Marius Bakke
2021-05-15 17:12 ` david larsson
2021-05-15 19:21 ` david larsson
0 siblings, 2 replies; 9+ messages in thread
From: Marius Bakke @ 2021-05-15 16:12 UTC (permalink / raw)
To: david larsson, 47898
[-- Attachment #1: Type: text/plain, Size: 1988 bytes --]
david larsson <david.larsson@selfhosted.xyz> skriver:
>> libxml2-xpath0 is probably better indeed, I don't have a strong
>> opinion.
>> Can you send an updated patch? :-)
>>
>> Thanks,
>> Marius
>
> Updated patch attached!
Thanks!
[...]
> gnu/packages/patches/libxml2-Add-option-xpath0.patch: New file...
> gnu/packages/xml.scm (libxml2-xpath0) [source]: ...apply it.
> ---
> .../patches/libxml2-Add-option-xpath0.patch | 139 ++++++++++++++++++
> gnu/packages/xml.scm | 52 +++++++
> 2 files changed, 191 insertions(+)
> create mode 100644 gnu/packages/patches/libxml2-Add-option-xpath0.patch
Please also register this patch in gnu/local.mk. Can you also add your
copyright at the top of xml.scm?
[...]
> +(define-public libxml2-xpath0
> + (package
> + (name "libxml2-xpath0")
> + (version "2.9.10")
> + (source (origin
> + (method url-fetch)
> + (uri (string-append "ftp://xmlsoft.org/libxml2/libxml2-"
> + version ".tar.gz"))
> + (sha256
> + (base32
> + "07xynh8hcxb2yb1fs051xrgszjvj37wnxvxgsj10rzmqzy9y3zma"))
> + (patches (list (search-patch "libxml2-Add-option-xpath0.patch")))))
You can inherit another record in Scheme to avoid duplicating all the
fields. Then the package can be shortened to:
(define-public libxml2-xpath0
(package/inherit libxml2
(name "libxml2-xpath0")
(source (origin
(inherit (package-source libxml2))
(patches (append (search-patches "libxml2-Add-option-xpath0.patch")
(origin-patches (package-source libxml2))))))
(description
"...")))
We should fill out that description to mention how it differs from the
regular libxml2. Can you give it a try? I can make the other changes
on your behalf, but not sure what to write.
Thanks,
Marius
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
2021-05-15 16:12 ` Marius Bakke
@ 2021-05-15 17:12 ` david larsson
2021-05-15 19:21 ` david larsson
1 sibling, 0 replies; 9+ messages in thread
From: david larsson @ 2021-05-15 17:12 UTC (permalink / raw)
To: Marius Bakke; +Cc: 47898
On 2021-05-15 18:12, Marius Bakke wrote:
> david larsson <david.larsson@selfhosted.xyz> skriver:
>
>>> libxml2-xpath0 is probably better indeed, I don't have a strong
>>> opinion.
>>> Can you send an updated patch? :-)
>>>
>>> Thanks,
>>> Marius
>>
>> Updated patch attached!
>
> Thanks!
>
> [...]
>
>> gnu/packages/patches/libxml2-Add-option-xpath0.patch: New file...
>> gnu/packages/xml.scm (libxml2-xpath0) [source]: ...apply it.
>> ---
>> .../patches/libxml2-Add-option-xpath0.patch | 139
>> ++++++++++++++++++
>> gnu/packages/xml.scm | 52 +++++++
>> 2 files changed, 191 insertions(+)
>> create mode 100644
>> gnu/packages/patches/libxml2-Add-option-xpath0.patch
>
> Please also register this patch in gnu/local.mk. Can you also add your
> copyright at the top of xml.scm?
>
> [...]
>
>> +(define-public libxml2-xpath0
>> + (package
>> + (name "libxml2-xpath0")
>> + (version "2.9.10")
>> + (source (origin
>> + (method url-fetch)
>> + (uri (string-append "ftp://xmlsoft.org/libxml2/libxml2-"
>> + version ".tar.gz"))
>> + (sha256
>> + (base32
>> +
>> "07xynh8hcxb2yb1fs051xrgszjvj37wnxvxgsj10rzmqzy9y3zma"))
>> + (patches (list (search-patch
>> "libxml2-Add-option-xpath0.patch")))))
>
> You can inherit another record in Scheme to avoid duplicating all the
> fields. Then the package can be shortened to:
>
> (define-public libxml2-xpath0
> (package/inherit libxml2
> (name "libxml2-xpath0")
> (source (origin
> (inherit (package-source libxml2))
> (patches (append (search-patches
> "libxml2-Add-option-xpath0.patch")
> (origin-patches (package-source
> libxml2))))))
> (description
> "...")))
>
> We should fill out that description to mention how it differs from the
> regular libxml2. Can you give it a try? I can make the other changes
> on your behalf, but not sure what to write.
>
> Thanks,
> Marius
I can fix all of it and send an updated patch again.
Best regards,
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
2021-05-15 16:12 ` Marius Bakke
2021-05-15 17:12 ` david larsson
@ 2021-05-15 19:21 ` david larsson
2021-05-18 20:25 ` bug#47898: " Marius Bakke
1 sibling, 1 reply; 9+ messages in thread
From: david larsson @ 2021-05-15 19:21 UTC (permalink / raw)
To: Marius Bakke; +Cc: 47898
[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]
> Please also register this patch in gnu/local.mk. Can you also add your
> copyright at the top of xml.scm?
Done!
>
> [...]
>
>> +(define-public libxml2-xpath0
>> + (package
>> + (name "libxml2-xpath0")
>> + (version "2.9.10")
>> + (source (origin
>> + (method url-fetch)
>> + (uri (string-append "ftp://xmlsoft.org/libxml2/libxml2-"
>> + version ".tar.gz"))
>> + (sha256
>> + (base32
>> +
>> "07xynh8hcxb2yb1fs051xrgszjvj37wnxvxgsj10rzmqzy9y3zma"))
>> + (patches (list (search-patch
>> "libxml2-Add-option-xpath0.patch")))))
>
> You can inherit another record in Scheme to avoid duplicating all the
> fields. Then the package can be shortened to:
>
> (define-public libxml2-xpath0
> (package/inherit libxml2
> (name "libxml2-xpath0")
> (source (origin
> (inherit (package-source libxml2))
> (patches (append (search-patches
> "libxml2-Add-option-xpath0.patch")
> (origin-patches (package-source
> libxml2))))))
> (description
> "...")))
>
> We should fill out that description to mention how it differs from the
> regular libxml2. Can you give it a try? I can make the other changes
> on your behalf, but not sure what to write.
>
> Thanks,
> Marius
Hi, new patch attached. There's a lint warning though:
"libxml2-xpath0@2.9.10: no updater for libxml2-xpath0". I don't know
what it means, maybe it should be fixed before committing?
Best regards,
David
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-libxml2-xpath0-New-package-with-patch-for-xpath0.patch --]
[-- Type: text/x-diff; name=0001-gnu-libxml2-xpath0-New-package-with-patch-for-xpath0.patch, Size: 7970 bytes --]
From 70c7a419f060256795737a7dc7122bfbcd456ae6 Mon Sep 17 00:00:00 2001
From: David Larsson <david.larsson@selfhosted.xyz>
Date: Sat, 15 May 2021 20:52:50 +0200
Subject: [PATCH] gnu: libxml2-xpath0: New package with patch for xpath0 option
to xmllint.
* gnu/packages/patches/libxml2-xpath0-Add-option-xpath0.patch: New file...
* gnu/local.mk: register it.
* gnu/packages/xml.scm (libxml2-xpath0) [source]: ...apply it.
---
gnu/local.mk | 1 +
.../libxml2-xpath0-Add-option-xpath0.patch | 139 ++++++++++++++++++
gnu/packages/xml.scm | 14 ++
3 files changed, 154 insertions(+)
create mode 100644 gnu/packages/patches/libxml2-xpath0-Add-option-xpath0.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index c3b0274945..d3e8baf17e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1366,6 +1366,7 @@ dist_patch_DATA = \
%D%/packages/patches/libutils-remove-damaging-includes.patch \
%D%/packages/patches/libvdpau-va-gl-unbundle.patch \
%D%/packages/patches/libvpx-CVE-2016-2818.patch \
+ %D%/packages/patches/libxml2-xpath0-Add-option-xpath0.patch \
%D%/packages/patches/libxslt-generated-ids.patch \
%D%/packages/patches/libxt-guix-search-paths.patch \
%D%/packages/patches/lierolibre-check-unaligned-access.patch \
diff --git a/gnu/packages/patches/libxml2-xpath0-Add-option-xpath0.patch b/gnu/packages/patches/libxml2-xpath0-Add-option-xpath0.patch
new file mode 100644
index 0000000000..3337374a8c
--- /dev/null
+++ b/gnu/packages/patches/libxml2-xpath0-Add-option-xpath0.patch
@@ -0,0 +1,139 @@
+From e1df743329bdfd94fbfdea18303c5c6c6fe13403 Mon Sep 17 00:00:00 2001
+From: methuselah-0 <david.larsson@selfhosted.xyz>
+Date: Thu, 1 Apr 2021 08:33:56 +0200
+Subject: [PATCH] Add option --xpath0
+
+---
+ doc/xmllint.xml | 16 ++++++++++++++++
+ xmllint.c | 32 +++++++++++++++++++++++---------
+ 2 files changed, 39 insertions(+), 9 deletions(-)
+
+diff --git a/doc/xmllint.xml b/doc/xmllint.xml
+index 1008179b..fcdc237e 100644
+--- a/doc/xmllint.xml
++++ b/doc/xmllint.xml
+@@ -70,6 +70,7 @@
+ <arg choice="plain"><option>--debug</option></arg>
+ <arg choice="plain"><option>--shell</option></arg>
+ <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
++ <arg choice="plain"><option>--xpath0 "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
+ <arg choice="plain"><option>--debugent</option></arg>
+ <arg choice="plain"><option>--copy</option></arg>
+ <arg choice="plain"><option>--recover</option></arg>
+@@ -537,6 +538,21 @@
+ node set is serialized in full in the output. In case
+ of an empty node set the "XPath set is empty" result
+ will be shown and an error exit code will be returned.
++ Results are separated by the newline character.
++ </para>
++ </listitem>
++ </varlistentry>
++
++ <varlistentry>
++ <term><option>--xpath0 "<replaceable class="option">XPath_expression</replaceable>"</option></term>
++ <listitem>
++ <para>
++ Run an XPath expression given as argument and print the
++ result. In case of a nodeset result, each node in the
++ node set is serialized in full in the output. In case
++ of an empty node set the "XPath set is empty" result
++ will be shown and an error exit code will be returned.
++ Results are separated by the null character.
+ </para>
+ </listitem>
+ </varlistentry>
+diff --git a/xmllint.c b/xmllint.c
+index 6ca1bf54..a60e1f4f 100644
+--- a/xmllint.c
++++ b/xmllint.c
+@@ -194,6 +194,7 @@ static int sax1 = 0;
+ #endif /* LIBXML_SAX1_ENABLED */
+ #ifdef LIBXML_XPATH_ENABLED
+ static const char *xpathquery = NULL;
++static const char *xpathsep = "\n";
+ #endif
+ static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES;
+ static int sax = 0;
+@@ -2095,7 +2096,7 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
+ for (i = 0;i < cur->nodesetval->nodeNr;i++) {
+ node = cur->nodesetval->nodeTab[i];
+ xmlNodeDumpOutput(buf, NULL, node, 0, 0, NULL);
+- xmlOutputBufferWrite(buf, 1, "\n");
++ xmlOutputBufferWrite(buf, 1, xpathsep);
+ }
+ xmlOutputBufferClose(buf);
+ #else
+@@ -2104,27 +2105,27 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
+ break;
+ }
+ case XPATH_BOOLEAN:
+- if (cur->boolval) printf("true\n");
+- else printf("false\n");
++ if (cur->boolval) printf("true%s", xpathsep);
++ else printf("false%s", xpathsep);
+ break;
+ case XPATH_NUMBER:
+ switch (xmlXPathIsInf(cur->floatval)) {
+ case 1:
+- printf("Infinity\n");
++ printf("Infinity%s", xpathsep);
+ break;
+ case -1:
+- printf("-Infinity\n");
++ printf("-Infinity%s", xpathsep);
+ break;
+ default:
+ if (xmlXPathIsNaN(cur->floatval)) {
+- printf("NaN\n");
++ printf("NaN%s", xpathsep);
+ } else {
+- printf("%0g\n", cur->floatval);
++ printf("%0g%s", cur->floatval, xpathsep);
+ }
+ }
+ break;
+ case XPATH_STRING:
+- printf("%s\n", (const char *) cur->stringval);
++ printf("%s%s", (const char *) cur->stringval, xpathsep);
+ break;
+ case XPATH_UNDEFINED:
+ fprintf(stderr, "XPath Object is uninitialized\n");
+@@ -3098,7 +3099,8 @@ static void usage(FILE *f, const char *name) {
+ fprintf(f, "\t--sax: do not build a tree but work just at the SAX level\n");
+ fprintf(f, "\t--oldxml10: use XML-1.0 parsing rules before the 5th edition\n");
+ #ifdef LIBXML_XPATH_ENABLED
+- fprintf(f, "\t--xpath expr: evaluate the XPath expression, imply --noout\n");
++ fprintf(f, "\t--xpath expr: evaluate the XPath expression, results are separated by \\n, imply --noout\n");
++ fprintf(f, "\t--xpath0 expr: evaluate the XPath expression, results are separated by \\0, imply --noout\n");
+ #endif
+
+ fprintf(f, "\nLibxml project home page: http://xmlsoft.org/\n");
+@@ -3480,6 +3482,13 @@ main(int argc, char **argv) {
+ i++;
+ noout++;
+ xpathquery = argv[i];
++ xpathsep = "\n";
++ } else if ((!strcmp(argv[i], "-xpath0")) ||
++ (!strcmp(argv[i], "--xpath0"))) {
++ i++;
++ noout++;
++ xpathquery = argv[i];
++ xpathsep = "\0";
+ #endif
+ } else if ((!strcmp(argv[i], "-oldxml10")) ||
+ (!strcmp(argv[i], "--oldxml10"))) {
+@@ -3712,6 +3721,11 @@ main(int argc, char **argv) {
+ i++;
+ continue;
+ }
++ if ((!strcmp(argv[i], "-xpath0")) ||
++ (!strcmp(argv[i], "--xpath0"))) {
++ i++;
++ continue;
++ }
+ #endif
+ if ((timing) && (repeat))
+ startTimer();
+--
+2.30.2
+
diff --git a/gnu/packages/xml.scm b/gnu/packages/xml.scm
index 931698a575..28601f0d09 100644
--- a/gnu/packages/xml.scm
+++ b/gnu/packages/xml.scm
@@ -31,6 +31,7 @@
;;; Copyright © 2021 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2021 Felix Gruber <felgru@posteo.net>
;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
+;;; Copyright © 2021 David Larsson <david.larsson@selfhosted.xyz>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -218,6 +219,19 @@ hierarchical form with variable field lengths.")
project (but it is usable outside of the Gnome platform).")
(license license:x11)))
+(define-public libxml2-xpath0
+ (package/inherit libxml2
+ (name "libxml2-xpath0")
+ (source (origin
+ (inherit (package-source libxml2))
+ (patches (append (search-patches
+ "libxml2-xpath0-Add-option-xpath0.patch")
+ (origin-patches (package-source libxml2))))))
+ (description
+ "Libxml2-xpath0 is like libxml2 but with a patch applied that
+provides an --xpath0 option to xmllint that enables it to output xpath
+results with a null delimiter")))
+
(define-public libxlsxwriter
(package
(name "libxlsxwriter")
--
2.31.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* bug#47898: [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2
2021-05-15 19:21 ` david larsson
@ 2021-05-18 20:25 ` Marius Bakke
0 siblings, 0 replies; 9+ messages in thread
From: Marius Bakke @ 2021-05-18 20:25 UTC (permalink / raw)
To: david larsson; +Cc: 47898-done
[-- Attachment #1: Type: text/plain, Size: 1595 bytes --]
david larsson <david.larsson@selfhosted.xyz> skriver:
> Hi, new patch attached. There's a lint warning though:
> "libxml2-xpath0@2.9.10: no updater for libxml2-xpath0". I don't know
> what it means, maybe it should be fixed before committing?
That warning is harmless and affects a lot of packages. I've applied
the patch with a couple minor tweaks:
> +From e1df743329bdfd94fbfdea18303c5c6c6fe13403 Mon Sep 17 00:00:00 2001
> +From: methuselah-0 <david.larsson@selfhosted.xyz>
> +Date: Thu, 1 Apr 2021 08:33:56 +0200
> +Subject: [PATCH] Add option --xpath0
> +
> +---
> + doc/xmllint.xml | 16 ++++++++++++++++
> + xmllint.c | 32 +++++++++++++++++++++++---------
> + 2 files changed, 39 insertions(+), 9 deletions(-)
I replaced this git-style patch header with a short description and an
URL to the upstream issue, like we usually do.
> +(define-public libxml2-xpath0
> + (package/inherit libxml2
> + (name "libxml2-xpath0")
> + (source (origin
> + (inherit (package-source libxml2))
> + (patches (append (search-patches
> + "libxml2-xpath0-Add-option-xpath0.patch")
> + (origin-patches (package-source libxml2))))))
> + (description
> + "Libxml2-xpath0 is like libxml2 but with a patch applied that
> +provides an --xpath0 option to xmllint that enables it to output xpath
> +results with a null delimiter")))
...and sprinkled some markup and punctuation into the description.
Pushed as b58efbc6611550ad9234163e198ff71ace5306ea, thank you!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-05-18 20:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-19 18:48 [bug#47898] [PATCH] [core-updates] Add option --xpath0 to xmllint from libxml2 david larsson
2021-05-13 12:41 ` Marius Bakke
2021-05-13 13:21 ` david larsson
2021-05-13 13:29 ` Marius Bakke
[not found] ` <80bc8f6c73d5aa423cf906d59bbcd43e@selfhosted.xyz>
2021-05-15 12:53 ` david larsson
2021-05-15 16:12 ` Marius Bakke
2021-05-15 17:12 ` david larsson
2021-05-15 19:21 ` david larsson
2021-05-18 20:25 ` bug#47898: " Marius Bakke
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.