转换LFS仓库为普通仓库

This commit is contained in:
Jiayi Yin 2025-05-18 16:59:02 +00:00
commit 7d9151e025
7 changed files with 495 additions and 0 deletions

View File

@ -0,0 +1,50 @@
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 6b368a5..86e0e84 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -696,6 +696,45 @@ do \
#endif /* __mips__ && !__sgi */
+#if defined(__loongarch__) /* loongarch */
+#define HAS_TEST_AND_SET
+
+typedef unsigned int slock_t;
+
+#define TAS(lock) tas(lock)
+
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+ register volatile slock_t *_l = lock;
+ register int _res;
+ register int _tmp;
+
+ __asm__ __volatile__(
+ " ll.w %0, %2 \n"
+ " ori %1, %0, 1 \n"
+ " sc.w %1, %2 \n"
+ " xori %1, %1, 1 \n"
+ " or %0, %0, %1 \n"
+ " dbar 0 \n"
+: "=&r" (_res), "=&r" (_tmp), "+R" (*_l)
+: /* no inputs */
+: "memory");
+ return _res;
+}
+
+#define S_UNLOCK(lock) \
+do \
+{ \
+ __asm__ __volatile__( \
+ " dbar 0 \n" \
+: /* no outputs */ \
+: /* no inputs */ \
+: "memory"); \
+ *((volatile slock_t *) (lock)) = 0; \
+} while (0)
+#endif /* __loongarch__ */
+
#if defined(__m32r__) && defined(HAVE_SYS_TAS_H) /* Renesas' M32R */
#define HAS_TEST_AND_SET

80
add-sw_64-support.patch Normal file
View File

@ -0,0 +1,80 @@
From ed05d50b808df2bb0d11456515896a40e620389b Mon Sep 17 00:00:00 2001
From: mahailiang <mahailiang@uniontech.com>
Date: Sat, 15 Mar 2025 11:46:26 +0800
Subject: [PATCH] add sw_64 support
---
contrib/pgcrypto/crypt-blowfish.c | 2 +-
src/include/storage/s_lock.h | 43 +++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c
index a663852..e6d72b2 100644
--- a/contrib/pgcrypto/crypt-blowfish.c
+++ b/contrib/pgcrypto/crypt-blowfish.c
@@ -41,7 +41,7 @@
#ifdef __i386__
#define BF_ASM 0 /* 1 */
#define BF_SCALE 1
-#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__)
+#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__) || defined(__sw_64__)
#define BF_ASM 0
#define BF_SCALE 1
#else
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 1ada0a8..3afd20e 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -771,6 +771,49 @@ tas(volatile slock_t *lock)
#endif /* __sh__ */
+#if defined(__sw_64) || defined(__sw_64__) /* sw_64 */
+#define HAS_TEST_AND_SET
+
+typedef unsigned long slock_t;
+
+#define TAS(lock) tas(lock)
+
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+ register slock_t _res;
+ unsigned long tmp;
+ __asm__ __volatile__(
+ " ldl $0, %1 \n"
+ " bne $0, 2f \n"
+ " ldi %2, %1\n"
+ " lldl %0, 0(%2) \n"
+ " mov 1, $0 \n"
+ " wr_f $0 \n"
+ " memb \n"
+ " lstl $0, 0(%2) \n"
+ " rd_f $0 \n"
+ " bne %0, 2f \n"
+ " beq $0, 2f \n"
+ " memb \n"
+ " br 3f \n"
+ "2: mov 1, %0 \n"
+ "3: \n"
+: "=&r"(_res), "+m"(*lock),"=r" (tmp)
+:
+: "memory", "0");
+ return (int) _res;
+}
+
+#define S_UNLOCK(lock) \
+do \
+{\
+ __asm__ __volatile__ (" memb \n"); \
+ *((volatile slock_t *) (lock)) = 0; \
+} while (0)
+
+#endif /* __sw_64 || __sw_64__ */
+
/* These live in s_lock.c, but only for gcc */
--
2.43.5

View File

@ -0,0 +1,72 @@
For the RPMs, we want the custom installation directories to end in
/pgsql not /postgresql. This is historical but not worth changing.
Notice that this patch also makes the appending of /pgsql unconditional.
This is to avoid unexpected behavior if the RPM is built in a working
directory whose path happens to include "postgres" or "pgsql" already.
However, datadir and sysconfdir are already set up in the specfile's
configure call, so we do not have to append anything to them.
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 9a6265b3a0..c9371a07c4 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -82,8 +82,7 @@ vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $
# Installation directories
#
# These are set by the equivalent --xxxdir configure options. We
-# append "postgresql" to some of them, if the string does not already
-# contain "pgsql" or "postgres", in order to avoid directory clutter.
+# append "pgsql" to some of them, in order to avoid directory clutter.
#
# In a PGXS build, we cannot use the values inserted into Makefile.global
# by configure, since the installation tree may have been relocated.
@@ -101,45 +100,23 @@ datarootdir := @datarootdir@
bindir := @bindir@
datadir := @datadir@
-ifeq "$(findstring pgsql, $(datadir))" ""
-ifeq "$(findstring postgres, $(datadir))" ""
-override datadir := $(datadir)/postgresql
-endif
-endif
sysconfdir := @sysconfdir@
-ifeq "$(findstring pgsql, $(sysconfdir))" ""
-ifeq "$(findstring postgres, $(sysconfdir))" ""
-override sysconfdir := $(sysconfdir)/postgresql
-endif
-endif
libdir := @libdir@
pkglibdir = $(libdir)
-ifeq "$(findstring pgsql, $(pkglibdir))" ""
-ifeq "$(findstring postgres, $(pkglibdir))" ""
-override pkglibdir := $(pkglibdir)/postgresql
-endif
-endif
+override pkglibdir := $(pkglibdir)/pgsql
includedir := @includedir@
pkgincludedir = $(includedir)
-ifeq "$(findstring pgsql, $(pkgincludedir))" ""
-ifeq "$(findstring postgres, $(pkgincludedir))" ""
-override pkgincludedir := $(pkgincludedir)/postgresql
-endif
-endif
+override pkgincludedir := $(pkgincludedir)/pgsql
mandir := @mandir@
docdir := @docdir@
-ifeq "$(findstring pgsql, $(docdir))" ""
-ifeq "$(findstring postgres, $(docdir))" ""
-override docdir := $(docdir)/postgresql
-endif
-endif
+override docdir := $(docdir)/pgsql
htmldir := @htmldir@

View File

@ -0,0 +1,53 @@
Change the built-in default socket directory to be /var/run/postgresql.
For backwards compatibility with (probably non-libpq-based) clients that
might still expect to find the socket in /tmp, also create a socket in
/tmp. This is to resolve communication problems with clients operating
under systemd's PrivateTmp environment, which won't be using the same
global /tmp directory as the server; see bug #825448.
Note that we apply the socket directory change at the level of the
hard-wired defaults in the C code, not by just twiddling the setting in
postgresql.conf.sample; this is so that the change will take effect on
server package update, without requiring any existing postgresql.conf
to be updated. (Of course, a user who dislikes this behavior can still
override it via postgresql.conf.)
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 4dde819652..8c2f601333 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -4159,7 +4159,7 @@ static struct config_string ConfigureNamesString[] =
},
&Unix_socket_directories,
#ifdef HAVE_UNIX_SOCKETS
- DEFAULT_PGSOCKET_DIR,
+ DEFAULT_PGSOCKET_DIR ", /tmp",
#else
"",
#endif
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 4ff0c6c700..6ccd96b1f2 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1091,7 +1091,7 @@ setup_config(void)
#ifdef HAVE_UNIX_SOCKETS
snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
- DEFAULT_PGSOCKET_DIR);
+ DEFAULT_PGSOCKET_DIR ", /tmp");
#else
snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
#endif
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
index 8f3ec6bde1..066daf3f08 100644
--- a/src/include/pg_config_manual.h
+++ b/src/include/pg_config_manual.h
@@ -201,7 +201,7 @@
* support them yet.
*/
#ifndef WIN32
-#define DEFAULT_PGSOCKET_DIR "/tmp"
+#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql"
#else
#define DEFAULT_PGSOCKET_DIR ""
#endif

View File

@ -0,0 +1,103 @@
commit 75040c3388d9a7dd5ad2bee53cbcc8bf3d35cd17
Author: Honza Horak <hhorak@redhat.com>
Date: Fri Oct 30 20:16:50 2020 +0100
The libpq package is supposed to be used for all the PostgreSQL modules
available in RHEL 8, and ABI versioning will guarantee us that modular RPMs will
depend on appropriate libpq ABI version (picked at build-time).
diff --git a/config/Makefile b/config/Makefile
index 67e7998..86612a4 100644
--- a/config/Makefile
+++ b/config/Makefile
@@ -8,6 +8,7 @@ include $(top_builddir)/src/Makefile.global
install: all installdirs
$(INSTALL_SCRIPT) $(srcdir)/install-sh '$(DESTDIR)$(pgxsdir)/config/install-sh'
$(INSTALL_SCRIPT) $(srcdir)/missing '$(DESTDIR)$(pgxsdir)/config/missing'
+ $(INSTALL_SCRIPT) $(srcdir)/build-exports-gnu-ld '$(DESTDIR)$(pgxsdir)/config/build-exports-gnu-ld'
installdirs:
$(MKDIR_P) '$(DESTDIR)$(pgxsdir)/config'
diff --git a/config/build-exports-gnu-ld b/config/build-exports-gnu-ld
new file mode 100755
index 0000000000..84c48e3ade
--- /dev/null
+++ b/config/build-exports-gnu-ld
@@ -0,0 +1,41 @@
+#! /bin/sh
+
+# by default use PG_ prefix
+: "${SYMBOL_VERSION_PREFIX=PG_}"
+
+# we started symbol versioning since v10
+: "${SYMBOL_VERSION_START=9.6}"
+
+version=$SYMBOL_VERSION_START
+version_prev=
+first=:
+
+open_block ()
+{
+ $first || echo
+ first=false
+ echo "${SYMBOL_VERSION_PREFIX}$version {"
+ echo "global:"
+}
+
+close_block ()
+{
+ echo "}${version_prev:+ $SYMBOL_VERSION_PREFIX$version_prev};"
+ version_prev=$version
+ version=$1
+}
+
+open_block
+while read -r symbol _ new_version
+do
+ case $symbol in '#'*) continue ;; esac
+ if test -n "$new_version" && test "$new_version" != "$version"; then
+ close_block "$new_version"
+ open_block
+ fi
+ echo " $symbol;"
+done
+
+echo "local:"
+echo " *;"
+close_block
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 373d73caef..d5bd5468cd 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -231,7 +231,7 @@ ifeq ($(PORTNAME), linux)
ifdef soname
LINK.shared += -Wl,-soname,$(soname)
endif
- BUILD.exports = ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
+ BUILD.exports = $(SHELL) $(top_srcdir)/config/build-exports-gnu-ld < $< > $@
exports_file = $(SHLIB_EXPORTS:%.txt=%.list)
ifneq (,$(exports_file))
LINK.shared += -Wl,--version-script=$(exports_file)
diff -ur postgresql-14.1/src/interfaces/libpq/exports.txt patched/src/interfaces/libpq/exports.txt
--- postgresql-14.1/src/interfaces/libpq/exports.txt 2021-11-08 22:58:24.000000000 +0100
+++ patched/src/interfaces/libpq/exports.txt 2022-01-12 12:00:28.000000000 +0100
@@ -171,15 +171,15 @@
PQsslAttribute 169
PQsetErrorContextVisibility 170
PQresultVerboseErrorMessage 171
-PQencryptPasswordConn 172
-PQresultMemorySize 173
+PQencryptPasswordConn 172 10
+PQresultMemorySize 173 12
PQhostaddr 174
PQgssEncInUse 175
PQgetgssctx 176
-PQsetSSLKeyPassHook_OpenSSL 177
+PQsetSSLKeyPassHook_OpenSSL 177 13
PQgetSSLKeyPassHook_OpenSSL 178
PQdefaultSSLKeyPassHook_OpenSSL 179
-PQenterPipelineMode 180
+PQenterPipelineMode 180 14
PQexitPipelineMode 181
PQpipelineSync 182
PQpipelineStatus 183

137
libpq.spec Normal file
View File

@ -0,0 +1,137 @@
Name: libpq
Version: 15.13
Release: 1
Summary: PostgreSQL client library
License: PostgreSQL
Url: http://www.postgresql.org/
Source0: https://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}.tar.bz2
Patch0001: libpq-10.3-rpm-pgsql.patch
Patch0002: libpq-10.3-var-run-socket.patch
Patch0003: libpq-12.1-symbol-versioning.patch
Patch0004: add-loongarch-support.patch
Patch0005: add-sw_64-support.patch
BuildRequires: gcc glibc-devel bison flex gawk zlib-devel openssl-devel
BuildRequires: krb5-devel openldap-devel gettext multilib-rpm-config
Obsoletes: postgresql-libs < 15
Provides: postgresql-libs = %{version}-%{release}
%description
PostgreSQL is a powerful, open source object-relational database system
that uses and extends the SQL language combined with many features that
safely store and scale the most complicated data workloads. This package
provides the essential shared library for any PostgreSQL client program
or interface.
%package devel
Summary: Development files for building PostgreSQL client tools
Requires: libpq%{?_isa} = %{version}-%{release}
Provides: postgresql-devel = %{version}-%{release}
Obsoletes: postgresql-devel < 15
%description devel
The development package of libpq
%prep
%autosetup -n postgresql-%{version} -p1
%build
export SYMBOL_VERSION_PREFIX=RHPG_
%configure --disable-rpath --with-ldap --with-openssl --with-gssapi \
--enable-nls --without-readline --datadir=%_datadir/pgsql
%global build_subdirs \\\
src/port \\\
src/interfaces/libpq \\\
src/bin/pg_config \\\
src/include
for subdir in %build_subdirs; do
%make_build -C "$subdir"
done
%install
for subdir in %build_subdirs; do
%make_install -C "$subdir"
done
find $RPM_BUILD_ROOT -name '*.a' -delete
rm -r $RPM_BUILD_ROOT%_includedir/pgsql/server
%multilib_fix_c_header --file "%_includedir/pg_config.h"
%multilib_fix_c_header --file "%_includedir/pg_config_ext.h"
cp /dev/null libpq.lst
%find_lang libpq5-15
cat libpq5-15.lang >>libpq.lst
cp /dev/null libpq-devel.lst
%find_lang pg_config-15
cat pg_config-15.lang >>libpq-devel.lst
%files -f libpq.lst
%license COPYRIGHT
%_libdir/libpq.so.5*
%dir %_datadir/pgsql
%doc %_datadir/pgsql/pg_service.conf.sample
%files devel -f libpq-devel.lst
%_bindir/pg_config
%_includedir/*
%_libdir/libpq.so
%_libdir/pkgconfig/libpq.pc
%changelog
* Fri May 09 2025 Funda Wang <fundawang@yeah.net> - 15.13-1
- update to version 15.13
* Sat Mar 15 2025 mahailiang <mahailiang@uniontech.com> - 15.12-2
- add sw_64 support
* Thu Feb 20 2025 Funda Wang <fundawang@yeah.net> - 15.12-1
- update to 15.12 to fix CVE-2025-1094
* Fri Nov 15 2024 Funda Wang <fundawang@yeah.net> - 15.9-1
- update to 15.9
* Fri Aug 09 2024 Funda Wang <fundawang@yeah.net> - 15.8-1
- update to 15.8
* Fri May 10 2024 qz_cx wangqingzheng@kylinos.cn - 15.6-2
- Type:CVE
- ID:NA
- SUG:NA
- DESC: fix CVE-2024-4317
* Wed Apr 3 2024 xiejing <xiejing@kylinos.cn> - 15.6-1
- upgrade libpq to 15.6
* Mon Nov 20 2023 dillon chen<dillon.chen@gmail.com> - 15.5-1
- upgrade libpq to 15.5
- CVE-2023-5868/5869/5870
* Wed Aug 16 2023 dillon chen<dillon.chen@gmail.com> - 15.4-1
- upgrade libpq to 15.4
* Tue Aug 8 2023 dillon chen<dillon.chen@gmail.com> - 15.3-1
- upgrade libpq to 15.3
* Tue Jun 27 2023 dillon chen<dillon.chen@gmail.com> - 15.0-1
- upgrade libpq to 15.0
* Thu Dec 1 2022 huajingyun <huajingyun@loongson.cn> - 13.7-2
- add loongarch support
* Mon Jun 13 2022 duyiwei <duyiwei@kylinos.cn> - 13.7-1
- upgrade libpq to 13.7,fix CVE-2021-32027,CVE-2022-1552
* Thu May 19 2022 yangweidong <yangweidong9@huawei.com> - 11.16-1
- Upgrade libpq to 11.16, fix CVES: CVE-2021-32028 CVE-2021-3677 CVE-2021-23222
* Wed Sep 2 2020 chengzihan <chengzihan2@huawei.com> - 11.2-5
- Change actually numbers of version and release to macros
* Wed Aug 26 2020 chengzihan <chengzihan2@huawei.com> - 11.2-4
- Fix installing problem of libpq-devel
* Tue Nov 26 2019 openEuler Buildteam <buildteam@openeuler.org> - 11.2-3
- Package init

BIN
postgresql-15.13.tar.bz2 Normal file

Binary file not shown.