John 9 месяцев назад
Родитель
Сommit
dfcef2d84c

+ 26 - 21
.github/workflows/postgres.yml

@@ -7,7 +7,7 @@ on:
   workflow_dispatch:
 
 env:
-  ALPINE_VER: 3.20
+  ALPINE_VER: 3.21
 
 jobs:
   job1:
@@ -15,51 +15,56 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
 
       - name: download postgres src
         run: |
           sudo apt-get update
           sudo apt-get install  git
           git clone https://github.com/docker-library/postgres.git
-          sed -i 's/coreutils/coreutils patch/g' postgres/14/alpine3.20/Dockerfile
-          sed -i 's/^ENV.*PG_VERSION.*/ENV PG_VERSION 14.1/g' postgres/14/alpine3.20/Dockerfile
-          sed -i 's/^ENV.*PG_SHA256.*/ENV PG_SHA256 4d3c101ea7ae38982f06bdc73758b53727fb6402ecd9382006fa5ecc7c2ca41f/g' postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < postgresql.git-99e4d24a9d77e7bb87e15b318e96dc36651a7da2.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/postgresql.git-99e4d24a9d77e7bb87e15b318e96dc36651a7da2.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < v1-0001-WIP-jit-LLVM-15-Minimal-changes.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/v1-0001-WIP-jit-LLVM-15-Minimal-changes.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < postgresql.git-0052fb489008a68d0f3e0445f52e1ab3166632a4.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/postgresql.git-0052fb489008a68d0f3e0445f52e1ab3166632a4.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < llvm14-support.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/llvm14-support.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < 0001-Replace-uses-of-deprecated-Python-module-distutils.s.patch; \\ '  postgres/14/alpine3.20/Dockerfile
-          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/0001-Replace-uses-of-deprecated-Python-module-distutils.s.patch; \\ '  postgres/14/alpine3.20/Dockerfile
+          sed -i 's/llvm19/llvm15/g' postgres/14/alpine3.21/Dockerfile
+          sed -i 's/clang19/clang15/g' postgres/14/alpine3.21/Dockerfile
+          sed -i 's/clang-19/clang-15/g' postgres/14/alpine3.21/Dockerfile
+          sed -i 's/coreutils/coreutils patch/g' postgres/14/alpine3.21/Dockerfile
+          sed -i 's/^ENV.*PG_VERSION.*/ENV PG_VERSION 14.1/g' postgres/14/alpine3.21/Dockerfile
+          sed -i 's/^ENV.*PG_SHA256.*/ENV PG_SHA256 4d3c101ea7ae38982f06bdc73758b53727fb6402ecd9382006fa5ecc7c2ca41f/g' postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < postgresql-14-xml-2.12.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/postgresql-14-xml-2.12.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < postgresql.git-99e4d24a9d77e7bb87e15b318e96dc36651a7da2.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/postgresql.git-99e4d24a9d77e7bb87e15b318e96dc36651a7da2.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < v1-0001-WIP-jit-LLVM-15-Minimal-changes.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/v1-0001-WIP-jit-LLVM-15-Minimal-changes.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < postgresql.git-0052fb489008a68d0f3e0445f52e1ab3166632a4.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/postgresql.git-0052fb489008a68d0f3e0445f52e1ab3166632a4.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < llvm14-support.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/llvm14-support.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ patch -p1 < 0001-Replace-uses-of-deprecated-Python-module-distutils.s.patch; \\ '  postgres/14/alpine3.21/Dockerfile
+          sed -i '/cd \/usr\/src\/postgresql; \\/a\\ \ \ \ wget https://raw.githubusercontent.com/gshang2017/docker/master/tt-rss-plugins/postgresql/patches/0001-Replace-uses-of-deprecated-Python-module-distutils.s.patch; \\ '  postgres/14/alpine3.21/Dockerfile
 
       - name: Set up QEMU
         id: qemu
-        uses: docker/setup-qemu-action@v2
+        uses: docker/setup-qemu-action@v3
         with:
           platforms: all
 
       - name: Set up Docker Buildx
         id: buildx
-        uses: docker/setup-buildx-action@v2
+        uses: docker/setup-buildx-action@v3
         with:
           version: latest
 
       - name: Login to GHCR
-        uses: docker/login-action@v2
+        uses: docker/login-action@v3
         with:
           registry: ghcr.io
           username: ${{ github.actor }}
           password: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Build and push
-        uses: docker/build-push-action@v3
+        uses: docker/build-push-action@v6
         with:
-          context: ./postgres/14/alpine3.20
-          file: ./postgres/14/alpine3.20/Dockerfile
+          context: ./postgres/14/alpine3.21
+          file: ./postgres/14/alpine3.21/Dockerfile
           platforms: linux/amd64,linux/arm64,linux/arm/v7
           push: true
           tags: |

+ 83 - 0
tt-rss-plugins/postgresql/patches/postgresql-14-xml-2.12.patch

@@ -0,0 +1,83 @@
+From 29e25a6b1eb1b77ecfdbcb5b8dc07c8a6cdcf089 Mon Sep 17 00:00:00 2001
+From: Tom Lane <[email protected]>
+Date: Mon, 29 Jan 2024 12:06:08 -0500
+Subject: [PATCH] Fix incompatibilities with libxml2 >= 2.12.0.
+
+libxml2 changed the required signature of error handler callbacks
+to make the passed xmlError struct "const".  This is causing build
+failures on buildfarm member caiman, and no doubt will start showing
+up in the field quite soon.  Add a version check to adjust the
+declaration of xml_errorHandler() according to LIBXML_VERSION.
+
+2.12.x also produces deprecation warnings for contrib/xml2/xpath.c's
+assignment to xmlLoadExtDtdDefaultValue.  I see no good reason for
+that to still be there, seeing that we disabled external DTDs (at a
+lower level) years ago for security reasons.  Let's just remove it.
+
+Back-patch to all supported branches, since they might all get built
+with newer libxml2 once it gets a bit more popular.  (The back
+branches produce another deprecation warning about xpath.c's use of
+xmlSubstituteEntitiesDefault().  We ought to consider whether to
+back-patch all or part of commit 65c5864d7 to silence that.  It's
+less urgent though, since it won't break the buildfarm.)
+
+Discussion: https://postgr.es/m/[email protected]
+---
+ contrib/xml2/xpath.c        |  1 -
+ src/backend/utils/adt/xml.c | 14 ++++++++++++--
+ 2 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c
+index 1e5b71d9a0..f44caf0020 100644
+--- a/contrib/xml2/xpath.c
++++ b/contrib/xml2/xpath.c
+@@ -75,7 +75,6 @@ pgxml_parser_init(PgXmlStrictness strictness)
+ 	xmlInitParser();
+ 
+ 	xmlSubstituteEntitiesDefault(1);
+-	xmlLoadExtDtdDefaultValue = 1;
+ 
+ 	return xmlerrcxt;
+ }
+diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
+index df7a1b6c40..d7caaaaca0 100644
+--- a/src/backend/utils/adt/xml.c
++++ b/src/backend/utils/adt/xml.c
+@@ -65,6 +65,16 @@
+ #if LIBXML_VERSION >= 20704
+ #define HAVE_XMLSTRUCTUREDERRORCONTEXT 1
+ #endif
++
++/*
++ * libxml2 2.12 decided to insert "const" into the error handler API.
++ */
++#if LIBXML_VERSION >= 21200
++#define PgXmlErrorPtr const xmlError *
++#else
++#define PgXmlErrorPtr xmlErrorPtr
++#endif
++
+ #endif							/* USE_LIBXML */
+ 
+ #include "access/htup_details.h"
+@@ -119,7 +129,7 @@ struct PgXmlErrorContext
+ 
+ static xmlParserInputPtr xmlPgEntityLoader(const char *URL, const char *ID,
+ 										   xmlParserCtxtPtr ctxt);
+-static void xml_errorHandler(void *data, xmlErrorPtr error);
++static void xml_errorHandler(void *data, PgXmlErrorPtr error);
+ static void xml_ereport_by_code(int level, int sqlcode,
+ 								const char *msg, int errcode);
+ static void chopStringInfoNewlines(StringInfo str);
+@@ -1750,7 +1760,7 @@ xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode, const char *msg)
+  * Error handler for libxml errors and warnings
+  */
+ static void
+-xml_errorHandler(void *data, xmlErrorPtr error)
++xml_errorHandler(void *data, PgXmlErrorPtr error)
+ {
+ 	PgXmlErrorContext *xmlerrcxt = (PgXmlErrorContext *) data;
+ 	xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) error->ctxt;
+-- 
+2.30.2
+