Skip to content

Commit 15b0909

Browse files
committed
add el10 confgen logic
1 parent 8bf2262 commit 15b0909

File tree

4 files changed

+99
-99
lines changed

4 files changed

+99
-99
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ gen-mdx:
9494
@echo "Extension MDX files generated in content/docs/ext/"
9595

9696
arm:
97-
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -ldflags "$(LD_FLAGS) -extldflags '-static'" -o pgext
97+
CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -a -ldflags "$(LD_FLAGS) -extldflags '-static'" -o pgext
9898
upx pgext
9999
amd:
100-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags "$(LD_FLAGS) -extldflags '-static'" -o pgext
100+
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -ldflags "$(LD_FLAGS) -extldflags '-static'" -o pgext
101101
upx pgext
102102

103103
# inventory

cli/confgen.go

Lines changed: 79 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ func (g *PigstyConfigGenerator) generateCategoryPackages(extensions map[string]*
368368
// Generate package name based on distribution type
369369
pkgName := g.getPackageNameForCategory(ext, pgVer)
370370

371-
// Determine if should be hidden
372-
isHidden := ext.Hidden || g.shouldHideInCategory(ext.Name, pgVer)
371+
// Use the hide flag from database configuration
372+
isHidden := ext.Hidden
373373

374374
// Don't add asterisk for wildcard matching - the package name already includes it if needed
375375

@@ -423,13 +423,64 @@ func (g *PigstyConfigGenerator) generateExtensionMappings(extensions map[string]
423423
// Sort extensions by category ID and extension ID
424424
sortedExts := sortExtensionsByID(extensions)
425425

426+
// Collect all hunspell extensions for aggregation
427+
hunspellExts := []string{}
428+
hunspellVersions := make(map[int]bool)
429+
for _, ext := range sortedExts {
430+
if strings.HasPrefix(ext.Name, "hunspell_") && ext.Name != "hunspell_pt_pt" { // Exclude broken hunspell_pt_pt
431+
hunspellExts = append(hunspellExts, ext.Alias)
432+
for pg := range ext.Available {
433+
if ext.Available[pg] {
434+
hunspellVersions[pg] = true
435+
}
436+
}
437+
}
438+
}
439+
426440
// Generate mappings
427441
for _, ext := range sortedExts {
428442
// Skip contrib extensions
429443
if ext.Category == "CONTRIB" {
430444
continue
431445
}
432446

447+
// Special handling: insert hunspell aggregation alias before hunspell_cs_cz
448+
if ext.Name == "hunspell_cs_cz" && len(hunspellExts) > 0 {
449+
// Create hunspell aggregate package pattern
450+
var hunspellPkgPattern string
451+
if g.isRPM() {
452+
// For RPM: hunspell_cs_cz_$v hunspell_de_de_$v hunspell_en_us_$v ...
453+
var pkgs []string
454+
for _, hext := range hunspellExts {
455+
pkgs = append(pkgs, hext+"_$v")
456+
}
457+
hunspellPkgPattern = strings.Join(pkgs, " ")
458+
} else {
459+
// For DEB: postgresql-$v-hunspell-cs-cz,postgresql-$v-hunspell-de-de,...
460+
var pkgs []string
461+
for _, hext := range hunspellExts {
462+
pkgs = append(pkgs, "postgresql-$v-"+strings.ReplaceAll(hext, "_", "-"))
463+
}
464+
hunspellPkgPattern = strings.Join(pkgs, ",")
465+
}
466+
467+
// Convert map to slice for versions
468+
var hunspellVerList []int
469+
for v := range hunspellVersions {
470+
hunspellVerList = append(hunspellVerList, v)
471+
}
472+
sort.Sort(sort.Reverse(sort.IntSlice(hunspellVerList)))
473+
474+
// Add hunspell aggregate alias
475+
mappings = append(mappings, ExtensionMapping{
476+
Name: "hunspell",
477+
Package: hunspellPkgPattern,
478+
PGVers: hunspellVerList,
479+
Comment: "aggregate all hunspell extensions",
480+
Category: ext.Category,
481+
})
482+
}
483+
433484
// Determine package pattern
434485
var pkgPattern string
435486
if g.isRPM() {
@@ -463,13 +514,6 @@ func (g *PigstyConfigGenerator) generateExtensionMappings(extensions map[string]
463514
func (g *PigstyConfigGenerator) getPackageNameForCategory(ext *ExtensionData, pgVer int) string {
464515
// Special case handling
465516
switch ext.Name {
466-
case "pgaudit":
467-
// Fix: use proper pgaudit naming for Debian/Ubuntu systems
468-
if !g.isRPM() {
469-
// For Debian/Ubuntu, use postgresql-$v-pgaudit pattern
470-
return fmt.Sprintf("postgresql-%d-pgaudit", pgVer)
471-
}
472-
return g.getPGAuditPackageName(pgVer)
473517
case "babelfishpg_common":
474518
// Merge babelfish into wiltondb
475519
if g.osCode == "el7" || g.osCode == "el8" || g.osCode == "el9" ||
@@ -513,90 +557,22 @@ func (g *PigstyConfigGenerator) getPackageNameForCategory(ext *ExtensionData, pg
513557

514558
// getRPMPackagePattern returns the RPM package pattern for an extension
515559
func (g *PigstyConfigGenerator) getRPMPackagePattern(ext *ExtensionData) string {
516-
// Special handling for specific extensions
517-
switch ext.Alias {
518-
case "pgaudit":
519-
return "pgaudit_$v*"
520-
case "hunspell_cs_cz":
521-
return "hunspell_cs_cz_$v hunspell_de_de_$v hunspell_en_us_$v hunspell_fr_$v hunspell_ne_np_$v hunspell_nl_nl_$v hunspell_nn_no_$v hunspell_ru_ru_$v hunspell_ru_ru_aot_$v"
522-
default:
523-
// Use RPMPkg if available, keeping $v placeholder
524-
if ext.RPMPkg != "" {
525-
return ext.RPMPkg
526-
}
527-
return ext.Alias + "_$v"
560+
// Use RPMPkg if available, keeping $v placeholder
561+
if ext.RPMPkg != "" {
562+
return ext.RPMPkg
528563
}
564+
return ext.Alias + "_$v"
529565
}
530566

531567
// getDEBPackagePattern returns the DEB package pattern for an extension
532568
func (g *PigstyConfigGenerator) getDEBPackagePattern(ext *ExtensionData) string {
533-
// Special handling for specific extensions
534-
switch ext.Alias {
535-
case "hunspell_cs_cz":
536-
return "postgresql-$v-hunspell-cs-cz,postgresql-$v-hunspell-de-de,postgresql-$v-hunspell-en-us,postgresql-$v-hunspell-fr,postgresql-$v-hunspell-ne-np,postgresql-$v-hunspell-nl-nl,postgresql-$v-hunspell-nn-no,postgresql-$v-hunspell-ru-ru,postgresql-$v-hunspell-ru-ru-aot"
537-
case "pgaudit":
538-
return "postgresql-$v-pgaudit"
539-
default:
540-
// Use DEBPkg if available, keeping $v placeholder
541-
if ext.DEBPkg != "" {
542-
return ext.DEBPkg
543-
}
544-
return "postgresql-$v-" + strings.ReplaceAll(ext.Alias, "_", "-")
569+
// Use DEBPkg if available, keeping $v placeholder
570+
if ext.DEBPkg != "" {
571+
return ext.DEBPkg
545572
}
573+
return "postgresql-$v-" + strings.ReplaceAll(ext.Alias, "_", "-")
546574
}
547575

548-
// shouldHideInCategory determines if an extension should be hidden in category packages
549-
func (g *PigstyConfigGenerator) shouldHideInCategory(extName string, pgVer int) bool {
550-
// Extensions that should be hidden from the 16 category extension alias lists
551-
// Special case: hydra extension is marked as HIDE status and excluded from category listings
552-
hideList := []string{
553-
"hydra", "duckdb_fdw", "pg_timeseries", "pgpool", "plr",
554-
"pgagent", "dbt2", "pgtap", "faker", "repmgr", "slony",
555-
"oracle_fdw", "pg_strom", "db2_fdw", "orioledb",
556-
}
557-
558-
for _, h := range hideList {
559-
if extName == h {
560-
return true
561-
}
562-
}
563-
564-
// OS/arch specific hiding
565-
if extName == "rdkit" && g.osCode != "u24" {
566-
return true
567-
}
568-
569-
if extName == "jdbc_fdw" && (g.osCode == "el8" || g.osCode == "el9") && g.arch == "aarch64" {
570-
return true
571-
}
572-
573-
if extName == "pllua" && (g.osCode == "el8" || g.osCode == "el9") && g.arch == "aarch64" && pgVer < 16 {
574-
return true
575-
}
576-
577-
// Hide timescaledb and timescaledb_toolkit for PG13
578-
if (extName == "timescaledb" || extName == "timescaledb_toolkit") && pgVer == 13 {
579-
return true
580-
}
581-
582-
return false
583-
}
584-
585-
// getPGAuditPackageName returns the correct pgaudit package name
586-
func (g *PigstyConfigGenerator) getPGAuditPackageName(pgVer int) string {
587-
switch pgVer {
588-
case 18, 17, 16:
589-
return fmt.Sprintf("pgaudit_%d", pgVer)
590-
case 15:
591-
return "pgaudit17_15"
592-
case 14:
593-
return "pgaudit16_14"
594-
case 13:
595-
return "pgaudit15_13"
596-
default:
597-
return fmt.Sprintf("pgaudit_%d", pgVer)
598-
}
599-
}
600576

601577
// getExtensionComment returns the comment for an extension
602578
func (g *PigstyConfigGenerator) getExtensionComment(ext *ExtensionData) string {
@@ -676,6 +652,21 @@ func (g *PigstyConfigGenerator) getFuncMap() template.FuncMap {
676652
}
677653
return g.constants.DistroAdhocPkg["deb"]
678654
},
655+
"getJavaRuntime": func() string {
656+
// el10 uses Java 21, others use Java 17
657+
if g.osCode == "el10" {
658+
return "java-21-openjdk-src java-21-openjdk-headless"
659+
}
660+
return "java-17-openjdk-src java-17-openjdk-headless"
661+
},
662+
"getNodePackage1": func() string {
663+
// el10 doesn't have flamegraph package
664+
basePkgs := "lz4 unzip bzip2 zlib yum pv jq git ncdu make patch bash lsof wget uuid tuned nvme-cli numactl grubby sysstat iotop htop rsync tcpdump perf"
665+
if g.osCode == "el10" {
666+
return basePkgs + " chkconfig"
667+
}
668+
return basePkgs + " flamegraph chkconfig"
669+
},
679670
}
680671
}
681672

@@ -807,7 +798,7 @@ func GetConfigConstants() *ConfigConstants {
807798
"el7": "ansible python3 python3-pip python36-virtualenv python36-requests python36-idna yum-utils createrepo_c sshpass",
808799
"el8": "ansible python3 python3-pip python3-virtualenv python3-requests python3.12-jmespath python3-cryptography dnf-utils modulemd-tools createrepo_c sshpass",
809800
"el9": "ansible python3 python3-pip python3-virtualenv python3-requests python3-jmespath python3-cryptography dnf-utils modulemd-tools createrepo_c sshpass",
810-
"el10": "ansible-core python3 python3-pip python3-virtualenv python3-requests python3-jmespath python3-cryptography dnf-utils modulemd-tools createrepo_c sshpass",
801+
"el10": "ansible-core python3 python3-pip python3-virtualenv python3-requests python3-jmespath python3-cryptography dnf-utils createrepo_c sshpass",
811802
"d11": "ansible python3 python3-pip python3-venv python3-jmespath dpkg-dev sshpass tnftp linux-perf",
812803
"d12": "ansible python3 python3-pip python3-venv python3-jmespath dpkg-dev sshpass tnftp linux-perf",
813804
"d13": "ansible python3 python3-pip python3-venv python3-jmespath dpkg-dev sshpass tnftp linux-perf",
@@ -916,7 +907,7 @@ package_map:
916907
infra-package: "{{ index .Constants.RPMCommonPkg 0 }}"
917908
infra-addons: "{{ index .Constants.RPMCommonPkg 1 }}"
918909
extra-modules: "{{ index .Constants.RPMCommonPkg 2 }}"
919-
node-package1: "{{ index .Constants.RPMCommonPkg 3 }}"
910+
node-package1: "{{ getNodePackage1 }}"
920911
node-package2: "{{ index .Constants.RPMCommonPkg 4 }}"
921912
pgsql-utility: "{{ index .Constants.RPMCommonPkg 5 }}"
922913
@@ -930,7 +921,7 @@ package_map:
930921
# MISC: pro modules
931922
#--------------------------------#{{ range .Constants.PGSQLExoticMap }}{{ if and (or (eq .Key "greenplum") (eq .Key "gpsql")) (eq $.Arch "aarch64") }}{{ else if .RPM }}
932923
{{ printf "%-24s" (printf "%s:" .Key) }} "{{ .RPM }}"{{ end }}{{ end }}
933-
java-runtime: "java-17-openjdk-src java-17-openjdk-headless"
924+
java-runtime: "{{ getJavaRuntime }}"
934925
kafka: "kafka kafka_exporter"
935926
kube-runtime: "containerd.io"
936927
sealos: "sealos"

db/reload.sql

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,27 @@ UPDATE pgext.pkg SET name = (regexp_split_to_array(name, ' '))[1] WHERE pkg = 'p
2121
UPDATE pgext.pkg SET count = (SELECT COUNT(*) FROM pgext.bin b WHERE b.pg = pkg.pg AND b.os = pkg.os AND b.name = pkg.name);
2222

2323
-- 'step 4/5: update pgext.pkg org and version ...';
24-
UPDATE pgext.pkg SET org = sub.org, version = sub.version
25-
FROM (SELECT DISTINCT ON (pg,os,name) pg,os,name,org,version FROM pgext.bin b,LATERAL (SELECT org FROM pgext.repository r WHERE r.id = b.repo) ORDER BY pg,os,name,ver::pgext.version USING OPERATOR (pgext.>)) sub
24+
UPDATE pgext.pkg SET org = sub.org, version = sub.version, hide = sub.hide
25+
FROM (SELECT DISTINCT ON (pg,os,name) pg,os,name,org,version,hide FROM pgext.bin b,LATERAL (SELECT org, position('pgnf' in id) > 0 AS hide FROM pgext.repository r WHERE r.id = b.repo) ORDER BY pg,os,name,ver::pgext.version USING OPERATOR (pgext.>)) sub
2626
WHERE pkg.pg = sub.pg AND pkg.os = sub.os AND pkg.name = sub.name;
2727

2828
-- 'step 5/5: update pgext.pkg state ...';
2929
UPDATE pgext.pkg SET state = 'AVAIL' WHERE count > 0;
30-
-- Special case: hydra extension should be hidden from the 16 category extension alias lists
31-
-- UPDATE pgext.pkg SET hide = true, state = 'HIDE' WHERE pkg IN ('hydra','duckdb_fdw','pg_timeseries','pgpool','plr','pgagent','dbt2','pgtap','faker','repmgr','oracle_fdw','pg_strom','db2_fdw','orioledb');
32-
UPDATE pgext.pkg SET hide = true, state = 'HIDE' WHERE pkg IN ('hydra','duckdb_fdw');
33-
UPDATE pgext.pkg SET hide = true, state = 'THROW' WHERE pkg IN ('orioledb', 'pg_tde', 'hunspell_pt_pt');
34-
UPDATE pgext.pkg SET state = 'BREAK' WHERE pkg = 'pg_dbms_job' AND os ~ '^el8';
35-
-- UPDATE pgext.pkg SET state = 'BREAK' WHERE pkg in ('pg_snakeoil') AND os ~ '^el8' AND state = 'AVAIL'; -- el8 duckdb/mooncake/snake oil break
30+
31+
-- conflict with other extension, hide in list
32+
UPDATE pgext.pkg SET hide = true WHERE pkg IN ('hydra' ,'duckdb_fdw', 'pg_timeseries');
33+
34+
-- too big, non-free, heavy extensions
35+
UPDATE pgext.pkg SET hide = true WHERE pkg IN ('plr' ,'oracle_fdw', 'db2_fdw', 'pg_strom', 'repmgr', 'pgpool', 'pgagent', 'dbt2');
36+
37+
-- only works on postgres forks
38+
UPDATE pgext.pkg SET hide = true, state = 'FORK' WHERE pkg IN ('orioledb', 'pg_tde' ,'babelfishpg_common', 'babelfishpg_tsql', 'babelfishpg_tds', 'babelfishpg_money');
39+
40+
-- broken extensions
41+
UPDATE pgext.pkg SET hide = true, state = 'THROW' WHERE pkg IN ('hunspell_pt_pt'); -- a broken extension conflict with pg dict file
42+
43+
-- mark a brokwn extension
44+
UPDATE pgext.pkg SET hide = true, state = 'BREAK' WHERE pkg = 'pg_dbms_job' AND os ~ '^el8';
3645

3746
-- 'pgext.refresh_pkg complete';
3847
UPDATE pgext.status SET recap_time = now();

db/schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ COMMENT ON COLUMN pgext.bin.size_full IS 'Installed size';
467467
-- Extension Package Availability
468468
-----------------------------------
469469
-- DROP TYPE IF EXISTS pgext.pkg_state CASCADE;
470-
CREATE TYPE pgext.pkg_state AS ENUM ('AVAIL', 'MISS', 'HIDE', 'BREAK','THROW');
470+
CREATE TYPE pgext.pkg_state AS ENUM ('AVAIL', 'MISS', 'HIDE', 'BREAK','THROW', 'FORK');
471471

472472
-- Cross-reference table showing extension package availability across PG versions and OS platforms
473473
-- DROP TABLE IF EXISTS pgext.pkg CASCADE;

0 commit comments

Comments
 (0)