Skip to content

PostgreSQL: Add initial v17.4 package#4267

Merged
mreid-tt merged 22 commits intoSynoCommunity:masterfrom
hgy59:postgresql
Apr 10, 2026
Merged

PostgreSQL: Add initial v17.4 package#4267
mreid-tt merged 22 commits intoSynoCommunity:masterfrom
hgy59:postgresql

Conversation

@hgy59
Copy link
Copy Markdown
Contributor

@hgy59 hgy59 commented Nov 16, 2020

Description

This PR adds the PostgreSQL package with significant improvements to security, architecture support, and adds the PostGIS spatial extension.

Motivation: This is a followup of the PR #3826 (fork was deleted)

PostGIS Spatial Extension

  • Added PostGIS 3.5.2 with GEOS 3.12.3 and PROJ support
  • Enables geographic/geometric data types and spatial queries
  • Cross-compilation support for multiple architectures
  • PostGIS is only included when GCC >= 5.0 is available (DSM 7+)

Security Improvements

  • Changed default authentication from md5 to scram-sha-256
  • Added password complexity validation in install wizard
  • Improved backup/restore handling during upgrades

Architecture Support

  • Supported with PostGIS: x64, aarch64, evansport, armv7 (generic) on DSM 7.0+ (GCC 5+)
  • Supported without PostGIS: comcerto2k (DSM 7.0/7.1), DSM 6.2.4 (GCC 4.9)
  • Excluded: ARMv5 (88f6281) - libicu-74.2 doesn't support it

Dependencies Added

  • cross/postgis - PostGIS 3.5.2
  • cross/libgeos - GEOS 3.12.3
  • cross/libproj - PROJ cartographic library
  • native/sqlite - Required for PROJ build

Checklist

  • Build rule all-supported completed successfully
  • New installation of package completed successfully
  • Package upgrade completed successfully (Manually install the package again)
  • Package functionality was tested
  • Any needed documentation is updated/created

Type of change

  • New Package
  • This change requires a documentation update (e.g. Wiki)

@hgy59 hgy59 changed the title Postgresql PostgreSQL 11.x including wizard install/uninstall Nov 16, 2020
@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Mar 18, 2022

@DigitalBox98 @ymartin59 are you still interested in PostgreSQL package?
It is now working on DSM 7 and DSM 6.

@DigitalBox98
Copy link
Copy Markdown
Contributor

Yes :)

@RMHogervorst
Copy link
Copy Markdown

I can't get this build for alpine. Am I missing someting?

I tried:

  • make spk-postgres-alpine-7.0 from the rootfolder
  • moving into the postgres folder and running make alpine-7.0
  • idem with make syno-alpine-7.0
    result: make: *** No rule to make target 'syno-alpine-7.0'. Stop.

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Jan 9, 2023

@RMHogervorst did you try (in the spk/postgres folder)?

make arch-alpine-7.0

an alternative would be:

make ARCH=alpine TCVERSION=7.0

@RMHogervorst
Copy link
Copy Markdown

wow, that was the piece of missing information! I think I missed this because the developer docs talk about make arch-88f6281 and I read that as make [architecturestring], but the arch part is separate!

It now fails on zlib

Downloading files for zlib
===>    wget https://zlib.net/zlib-1.2.11.tar.gz
https://zlib.net/zlib-1.2.11.tar.gz:
2023-01-09 06:26:32 ERROR 404: Not Found.

@RMHogervorst
Copy link
Copy Markdown

RMHogervorst commented Jan 9, 2023

it seems the current version of zlib is 1.2.13 (released October 13, 2022 ) because of a cve all previous versions are unavailable I think.

Here are the changes, not in an PR, not just because I am lazy, but also because I think you should verify the hash digests yourself since I am a random person on the internet.

cross/zlib/makefile

PKG_NAME = zlib
PKG_VERS = 1.2.13
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME)-$(PKG_VERS).$(PKG_EXT)
PKG_DIST_SITE = https://zlib.net
PKG_DIR = $(PKG_NAME)-$(PKG_VERS)

DEPENDS =

HOMEPAGE = https://zlib.net/
COMMENT  = A Massively Spiffy Yet Delicately Unobtrusive Compression Library.
LICENSE  = zlib-license

ADDITIONAL_CFLAGS = -Os

include ../../mk/spksrc.cross-cc.mk

and the digests in cross/zlib/digests

zlib-1.2.13.tar.gz SHA1 55eaa84906f31ac20d725aa26cd20839196b6ba6
zlib-1.2.13.tar.gz SHA256 b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30
zlib-1.2.13.tar.gz MD5 9b8aa094c4e5765dabf4da391f00d15c

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Jan 9, 2023

@RMHogervorst we already have the current zlib on the master branch. So I have rebased this PR.

BTW: for alpine you can use the armv7 package created by the github build action (when it is successfully completed, and within 90 days).

@RMHogervorst
Copy link
Copy Markdown

I feel really stupid, where can I find the installation docs? I get invalid file format. contact developers
I tried manual install within DSM with the zipfile for arm v7 and arm v7-6.1 but also the file inside.

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Jan 9, 2023

you must install *.spk files (not zip)

@RMHogervorst
Copy link
Copy Markdown

RMHogervorst commented Jan 9, 2023

alright this is what I tried
version 1

  • change extension of zip file to spk
  • install the spk file (did not work)

version 2

  • unpack the downloaded zip file
  • tar the file and turn it into a spk file tar -cvzf postgresql.spk postgresql_armv7-7.0_11.16-3
  • install the spk file (did not work)

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Jan 9, 2023

  1. download the artifacts (*.zip)
  2. unpack the artifacts -> you will get the spk
  3. In DSM Package center of your Diskstation chose "Manual Install" and select the spk file to upload and install

@RMHogervorst
Copy link
Copy Markdown

Alright this is what lives in the unpacked zipfile. Did something go wrong? because there is no spk file here.

postgresql_armv7-7.0_11.16-3 tree
.
├── INFO
├── PACKAGE_ICON.PNG
├── PACKAGE_ICON_256.PNG
├── WIZARD_UIFILES
│   ├── install_uifile
│   ├── uninstall_uifile
│   └── upgrade_uifile.sh
├── conf
│   ├── privilege
│   └── resource
├── package.tgz
└── scripts
    ├── functions
    ├── installer
    ├── postinst
    ├── postuninst
    ├── postupgrade
    ├── preinst
    ├── preuninst
    ├── preupgrade
    ├── service-setup
    └── start-stop-status

3 directories, 19 files

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Jan 9, 2023

I have not a clue what's going wrong.

  1. navigate to "checks - build -artifacts"
  2. click (e.g.) "Packages for aarch64-6.1"
  3. it will download Packages for aarch64-6.1.zip
  4. unpack the downloaded zip will extract postgresql_aarch64-6.1_11.16-3.spk

This should work for all archs (I have also validated the armv7-6.1 and armv7-7.0 artifacts)

The tree you showed above looks like the content of package.tgz within the spk file.

@RMHogervorst
Copy link
Copy Markdown

Wow this is really weird, it must be a mac specific (or my computer specific) issue. When I use the standard macos build in tool to open the zip, it opens to the folder as I described, but when I use a different tool it unzips to the spk file!

Thanks for the help!

@RMHogervorst
Copy link
Copy Markdown

ah shoot! it doesn't install because the package requires root privileges:

Screenshot 2023-01-10 at 07 20 25

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Jan 10, 2023

@RMHogervorst can you please try with the new version?
(didn't test it, but the installer should work)

@RMHogervorst
Copy link
Copy Markdown

Awesome! it installs cleanly! I don't have the time (for the next 10 hours ) to check if everything works, but I see no errors during installation and it seems to 'just' work.

@RMHogervorst
Copy link
Copy Markdown

There might be an issue in the long run with no superuser to do maintainence?

 tail postgresql.log
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [6-1] 2023-01-10 00:14:18.543 GMT [16794] WARNING:  skipping "pg_subscription" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [7-1] 2023-01-10 00:14:18.825 GMT [16794] WARNING:  skipping "pg_database" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [8-1] 2023-01-10 00:14:18.825 GMT [16794] WARNING:  skipping "pg_db_role_setting" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [9-1] 2023-01-10 00:14:18.825 GMT [16794] WARNING:  skipping "pg_tablespace" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [10-1] 2023-01-10 00:14:18.841 GMT [16794] WARNING:  skipping "pg_pltemplate" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [11-1] 2023-01-10 00:14:18.841 GMT [16794] WARNING:  skipping "pg_auth_members" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [12-1] 2023-01-10 00:14:18.842 GMT [16794] WARNING:  skipping "pg_shdepend" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [13-1] 2023-01-10 00:14:18.842 GMT [16794] WARNING:  skipping "pg_shdescription" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [14-1] 2023-01-10 00:14:18.848 GMT [16794] WARNING:  skipping "pg_replication_origin" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [15-1] 2023-01-10 00:14:18.850 GMT [16794] WARNING:  skipping "pg_shseclabel" --- only superuser can vacuum it
ash-4.4# tail postgresql.log
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [6-1] 2023-01-10 00:14:18.543 GMT [16794] WARNING:  skipping "pg_subscription" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [7-1] 2023-01-10 00:14:18.825 GMT [16794] WARNING:  skipping "pg_database" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [8-1] 2023-01-10 00:14:18.825 GMT [16794] WARNING:  skipping "pg_db_role_setting" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [9-1] 2023-01-10 00:14:18.825 GMT [16794] WARNING:  skipping "pg_tablespace" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [10-1] 2023-01-10 00:14:18.841 GMT [16794] WARNING:  skipping "pg_pltemplate" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [11-1] 2023-01-10 00:14:18.841 GMT [16794] WARNING:  skipping "pg_auth_members" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [12-1] 2023-01-10 00:14:18.842 GMT [16794] WARNING:  skipping "pg_shdepend" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [13-1] 2023-01-10 00:14:18.842 GMT [16794] WARNING:  skipping "pg_shdescription" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [14-1] 2023-01-10 00:14:18.848 GMT [16794] WARNING:  skipping "pg_replication_origin" --- only superuser can vacuum it
2023-01-10T01:14:18+01:00 netwerkhdd postgres[16794]: [15-1] 2023-01-10 00:14:18.850 GMT [16794] WARNING:  skipping "pg_shseclabel" --- only superuser can vacuum it

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Jan 21, 2023

@RMHogervorst do you know what cleanup script/task is run by postgresql?
we should disable the pgsql internal cleanup and run a scheduled task in DSM (yes, those task can run scripts with root privileges in DSM 7).

@RMHogervorst
Copy link
Copy Markdown

RMHogervorst commented Jan 22, 2023 via email

@RMHogervorst
Copy link
Copy Markdown

As far as I can see these are automatic cleanup tasks from the 'Autovacuum Daemon'.

  • autovacuum VACUUM
  • updating the statistics on tables ANALYZE

The errors only happen on the system (pg_catalog) tables. so pg_tablespace, db_role_settings, pg_database etc.
I don't think this will cause many problems (but I'm no dba)

The settings for this deamon should be in the postgresql.conf file.
But autovacuum = off in my /etc/postgresql/postgresql.conf file.

So, I don't have a clue what is going on here.

@hgy59 hgy59 added the new-package PR/WIP for a new package label Apr 7, 2023
@osmeest
Copy link
Copy Markdown

osmeest commented Nov 8, 2023

Hi,
Is there any reason why this PR is not getting merged into master ?
Looking at the scripts in the branch, I don't see timescaledb extension being included as was originally requested in #3815. Correct ?

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Nov 9, 2023

Hi, Is there any reason why this PR is not getting merged into master ?

There are still issues with cleanup that need to be solved.

Looking at the scripts in the branch, I don't see timescaledb extension being included as was originally requested in #3815. Correct ?

timescaledb is not related to this PR (it is a different product/project, not a pgsql extension).

@DigitalBox98
Copy link
Copy Markdown
Contributor

It seems the solution consists to deactivate auto vacuum and to create a DSM task to replace it.

If I have some time I will look at it (some useful information are in https://hevodata.com/learn/postgresql-vacuum-command/)

- Remove keep/delete data option from wizard (DSM 6 doesn't support it,
  DSM 7 framework handles it automatically)
- Add validation to check backup directory exists and is writable
- Fix chown group to use dynamic lookup instead of hardcoded value
…plexity

- Use scram-sha-256 authentication instead of trust (requires password)
- Move Unix socket from /tmp to package var directory for persistence
- Add password complexity validation (10+ chars, mixed case, number, special)
- Set default admin username to 'pgadmin'
- Add PostgreSQL's 63-character username limit
- Use peer auth during initial setup to allow passwordless role creation
- After setup, switch to hybrid auth: system user keeps peer (for backups),
  all other users require scram-sha-256
- Host connections always require scram-sha-256
- Update backup commands to use peer auth (no -h flag)
@mreid-tt mreid-tt changed the title PostgreSQL 11.x including wizard install/uninstall PostgreSQL: Add initial v17.4 package Feb 27, 2026
Comment thread spk/postgresql/Makefile
- Add native/postgresql for pg_config during cross-compilation
- Add cross/libgeos (GEOS 3.12.3)
- Add cross/libproj (PROJ 8.2.1 - compatible with GCC 8)
- Add cross/postgis (PostGIS 3.5.2)
- Auto-create PostGIS extension in template1 and postgres databases
- Restore GEOS 3.12.3 (was downgraded to 3.9.6 causing ARMv7 ODR violations)
- Add pg_config wrapper for cross-compilation paths
- Fix PostGIS configure libpq detection with sed patch
- Exclude comcerto2k (GCC 4.9.3 lacks C++14 for GEOS 3.12.3)
- Require DSM 7.0+ (GCC 4.9 strict linker fails libpq detection)
@mreid-tt

This comment was marked as outdated.

@mreid-tt mreid-tt self-assigned this Mar 2, 2026
@mreid-tt
Copy link
Copy Markdown
Contributor

mreid-tt commented Mar 2, 2026

hey @hgy59, @DigitalBox98 — I’ve done some work to bring this up to date and ready for merging. It now includes the PostGIS Spatial Extension, which appears to load correctly within the database. I’ve also updated the PR description to reflect the current set of commits.

I’d really appreciate any review and, if possible, some testing of the code and/or the resulting package.

@mreid-tt
Copy link
Copy Markdown
Contributor

hey @hgy59, I've been testing this with an updated build of TT-RSS and it seems to be working well. Let me know if there is anything else I should consider before merging.

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Apr 5, 2026

@mreid-tt what about to build pgsql package for DSM 6.2.4 without postgis/geos?

@mreid-tt

This comment was marked as outdated.

@hgy59

This comment was marked as outdated.

@mreid-tt

This comment was marked as outdated.

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Apr 5, 2026

I don’t plan to maintain two separate PostgreSQL packages.

We don't need two separate packages. Only one package, but DSM 6 versions without postgis etc.

mreid-tt added 3 commits April 5, 2026 20:43
- Remove explicit REQUIRED_MIN_DSM and UNSUPPORTED_ARCHS constraints
- Only include postgis dependency when TC_GCC >= 5.0
- Make PostGIS extension creation conditional in service-setup.sh
- Allows building on older DSM versions (DSM 6.2.4) without PostGIS
@mreid-tt
Copy link
Copy Markdown
Contributor

mreid-tt commented Apr 6, 2026

We don't need two separate packages. Only one package, but DSM 6 versions without postgis etc.

Very well, I've added some commits to achieve this. I've also installed on DSM 6.2.4 and ran a few tests which were successful:

$ /usr/local/bin/psql -h localhost -p 5433 -U pgadmin -d postgres
Password for user pgadmin: 
psql (17.4)
Type "help" for help.

postgres=# SELECT version();
                                                                version                                                                
---------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 17.4 on x86_64-pc-linux-gnu, compiled by x86_64-pc-linux-gnu-gcc (crosstool-NG 1.20.0) 4.9.3 20150311 (prerelease), 64-bit
(1 row)

postgres=# SHOW autovacuum;
 autovacuum 
------------
 on
(1 row)

And also, the manual maintenance tasks from your earlier comments:

$ sudo -u sc-postgresql /usr/local/bin/vacuumdb -h localhost -p 5433 -U pgadmin --all --analyze
Password: 
vacuumdb: vacuuming database "postgres"
vacuumdb: vacuuming database "template1"
$ sudo -u sc-postgresql /usr/local/bin/reindexdb -h localhost -p 5433 -U pgadmin --all
Password: 
reindexdb: reindexing database "postgres"
reindexdb: reindexing database "template1"
$ 

@mreid-tt
Copy link
Copy Markdown
Contributor

mreid-tt commented Apr 8, 2026

hey @hgy59, are there any further actions to be taken before this is approved for merging?

@hgy59
Copy link
Copy Markdown
Contributor Author

hgy59 commented Apr 8, 2026

hey @hgy59, are there any further actions to be taken before this is approved for merging?

Nothing comes to mind at the moment. Maybe @DigitalBox98 has some feedback.

I might create an OpenStreetMap database on my NAS using this package if I ever find the time...

@DigitalBox98
Copy link
Copy Markdown
Contributor

It’s fine by me. Just wondering what is the SQLite dependency ?

@mreid-tt
Copy link
Copy Markdown
Contributor

mreid-tt commented Apr 8, 2026

hey @DigitalBox98, here's the details of the SQLite dependency:

SQLite Dependency Explanation

The native/sqlite and cross/sqlite dependencies come from libproj, not directly from PostgreSQL.

Dependency chain:

postgresql → postgis → libproj → sqlite

Why libproj needs these dependencies:

Dependency Required Reason
SQLite3 Required Headers and library for target architecture, and sqlite3 executable for build architecture. PROJ uses SQLite for the proj.db database that stores coordinate reference system definitions.
libtiff Optional (recommended) Enable reading of grid formats based on GeoTIFF. Only basic TIFF support is required.
curl Optional (recommended) Support automatic downloading of remote grid files during runtime, allowing PROJ to fetch required transformation data on demand.

PostGIS requires libproj (a cartographic projections library) for coordinate system transformations. libproj uses SQLite for its projection database (proj.db), which is generated during the build using the native sqlite3 executable.

@mreid-tt mreid-tt merged commit 8d763c2 into SynoCommunity:master Apr 10, 2026
16 checks passed
@mreid-tt mreid-tt added the status/published Published and activated (may take up to 48h until visible in DSM package manager) label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-package PR/WIP for a new package status/published Published and activated (may take up to 48h until visible in DSM package manager)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants