set the DYLIB path for pg_dump and pg_restore bins

This commit is contained in:
Puskar Basu
2025-03-19 17:22:45 +05:30
parent 7493960075
commit a9e66247c7
3 changed files with 19 additions and 3 deletions

View File

@@ -27,12 +27,12 @@ const (
// constants for installing db and fdw images
const (
DatabaseVersion = "14.17.0-dev.4"
DatabaseVersion = "14.17.0-dev.5"
FdwVersion = "1.12.4"
// PostgresImageRef is the OCI Image ref for the database binaries
PostgresImageRef = "ghcr.io/turbot/steampipe/db:14.17.0-dev.4"
PostgresImageDigest = "sha256:899d2ec4e75226bd04c62d9a185416252a6ce5b966a5fc47d2d7b082684f51b8"
PostgresImageRef = "ghcr.io/turbot/steampipe/db:14.17.0-dev.5"
PostgresImageDigest = "sha256:bf7dcd73414ba12ca867b281ecc3b55ab9cfc828fab73b435ea02d3582e1e532"
FdwImageRef = "ghcr.io/turbot/steampipe/fdw:" + FdwVersion
FdwBinaryFileName = "steampipe_postgres_fdw.so"

View File

@@ -449,6 +449,12 @@ func pgDumpCmd(ctx context.Context, args ...string) *exec.Cmd {
)
cmd.Env = append(os.Environ(), "PGSSLMODE=disable")
// set the library path for the pg_dump command
// this is required for the pg_dump to work correctly since we build the pg_dump binary
// from source(zonkyio does not package it), they are incorrectly linked, so the correct
// library path must be set before running it
cmd.Env = append(cmd.Env, fmt.Sprintf("DYLD_LIBRARY_PATH=%s", filepaths.GetDatabaseLibPath()))
log.Println("[TRACE] pg_dump command:", cmd.String())
return cmd
}
@@ -461,6 +467,12 @@ func pgRestoreCmd(ctx context.Context, args ...string) *exec.Cmd {
)
cmd.Env = append(os.Environ(), "PGSSLMODE=disable")
// set the library path for the pg_restore command
// this is required for the pg_restore to work correctly since we build the pg_restore binary
// from source(zonkyio does not package it), they are incorrectly linked, so the correct
// library path must be set before running it
cmd.Env = append(cmd.Env, fmt.Sprintf("DYLD_LIBRARY_PATH=%s", filepaths.GetDatabaseLibPath()))
log.Println("[TRACE] pg_restore command:", cmd.String())
return cmd
}

View File

@@ -46,6 +46,10 @@ func DatabaseBackupFilePath() string {
return filepath.Join(EnsureDatabaseDir(), "backup.bk")
}
func GetDatabaseLibPath() string {
return filepath.Join(GetDatabaseLocation(), "lib")
}
func GetRootCertLocation() string {
return filepath.Join(GetDataLocation(), constants.RootCert)
}