-
Notifications
You must be signed in to change notification settings - Fork 4
fix(postgresql): place deb-extracted binaries at lib/postgresql/<major>/bin so PG can relocate sharedir #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |||||||||||||||||||||
| "os" | ||||||||||||||||||||||
| "os/exec" | ||||||||||||||||||||||
| "path/filepath" | ||||||||||||||||||||||
| "runtime" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| "github.com/ProxySQL/dbdeployer/providers" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
@@ -20,6 +21,10 @@ func (p *PostgreSQLProvider) CreateSandbox(config providers.SandboxConfig) (*pro | |||||||||||||||||||||
| logDir := filepath.Join(dataDir, "log") | ||||||||||||||||||||||
| logFile := filepath.Join(config.Dir, "postgresql.log") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if err := checkLinuxLayout(basedir, binDir); err != nil { | ||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+24
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new Linux layout moves shared libraries to a nested directory (
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| replication := config.Options["replication"] == "true" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Run initdb (data dir must not exist or must be empty) | ||||||||||||||||||||||
|
|
@@ -94,3 +99,35 @@ func (p *PostgreSQLProvider) resolveBasedir(config providers.SandboxConfig) (str | |||||||||||||||||||||
| } | ||||||||||||||||||||||
| return basedirFromVersion(config.Version) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // checkLinuxLayout detects PostgreSQL extractions produced by older | ||||||||||||||||||||||
| // versions of dbdeployer (before issue #112 was fixed). In the old layout, | ||||||||||||||||||||||
| // <basedir>/bin/<binary> were regular files; PG's make_relative_path() then | ||||||||||||||||||||||
| // failed to relocate the compiled-in SHAREDIR (`/usr/share/postgresql/<major>`), | ||||||||||||||||||||||
| // so initdb died with "could not open directory /usr/share/postgresql/<major>/timezonesets". | ||||||||||||||||||||||
| // | ||||||||||||||||||||||
| // New extractions place the real binaries under | ||||||||||||||||||||||
| // <basedir>/lib/postgresql/<major>/bin/ and expose them via symlinks at | ||||||||||||||||||||||
| // <basedir>/bin/. If we find a regular file there on Linux, the user | ||||||||||||||||||||||
| // needs to re-run unpack. | ||||||||||||||||||||||
| func checkLinuxLayout(basedir, binDir string) error { | ||||||||||||||||||||||
| if runtime.GOOS != "linux" { | ||||||||||||||||||||||
| return nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| fi, err := os.Lstat(filepath.Join(binDir, "postgres")) | ||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||
| // Missing binary will be reported by the initdb step below with a | ||||||||||||||||||||||
| // clearer error than we could produce here. | ||||||||||||||||||||||
| return nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if fi.Mode()&os.ModeSymlink != 0 { | ||||||||||||||||||||||
| return nil | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| return fmt.Errorf( | ||||||||||||||||||||||
| "PostgreSQL binaries at %s were unpacked by an older dbdeployer using\n"+ | ||||||||||||||||||||||
| "a layout incompatible with deb-packaged PostgreSQL — initdb would fail\n"+ | ||||||||||||||||||||||
| "to find share files (see issue #112). Re-run unpack to fix:\n"+ | ||||||||||||||||||||||
| " dbdeployer unpack --provider=postgresql <server.deb> <client.deb>", | ||||||||||||||||||||||
| basedir, | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
stringspackage is required to extract the major version fromconfig.Versionfor the updated library path logic.