Skip to content

Commit 9f6a12c

Browse files
committed
Add --sharedir and --pkglibdir (#951)
To enable installing in locations other than those provided by `pg_config`. While at it fix a couple of linter warnings and remove the "experimental" note from the `--pg-version` option docs.
1 parent 1c0d8cd commit 9f6a12c

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pg-trunk"
3-
version = "0.16.0"
3+
version = "0.16.1"
44
edition = "2021"
55
authors = ["Ian Stanton", "Vinícius Miguel", "David E. Wheeler"]
66
description = "A package manager for PostgreSQL extensions"

cli/src/commands/containers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ pub async fn package_installed_extension_files(
609609

610610
let manifest = serde_json::to_string_pretty(&manifest).unwrap_or_default();
611611
let mut header = Header::new_gnu();
612-
header.set_size(manifest.as_bytes().len() as u64);
612+
header.set_size(manifest.len() as u64);
613613
header.set_cksum();
614614
header.set_mode(0o644);
615615
new_archive.append_data(&mut header, "manifest.json", Cursor::new(manifest))?;

cli/src/commands/install.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct InstallCommand {
6464
default_value = "https://registry.pgtrunk.io"
6565
)]
6666
registry: String,
67-
/// The PostgreSQL version for which this extension should be installed. Experimental for versions other than Postgres 15.
67+
/// The PostgreSQL version for which this extension should be installed.
6868
#[clap(long, action)]
6969
pg_version: Option<u8>,
7070
/// Skip dependency resolution.
@@ -73,6 +73,12 @@ pub struct InstallCommand {
7373
/// Installs required system dependencies for the extension
7474
#[clap(long = "deps", action)]
7575
install_system_dependencies: bool,
76+
/// Installation location for architecture-independent support files.
77+
#[clap(long = "sharedir", action)]
78+
sharedir: Option<PathBuf>,
79+
/// Installation location for dynamically loadable modules.
80+
#[clap(long = "pkglibdir", action)]
81+
pkglibdir: Option<PathBuf>,
7682
}
7783

7884
impl InstallCommand {
@@ -155,9 +161,14 @@ impl SubCommand for InstallCommand {
155161
async fn execute(&self, _task: Task) -> Result<()> {
156162
let pg_config = self.pgconfig()?;
157163

158-
let package_lib_dir = pg_config.pkglibdir()?;
159-
160-
let sharedir = pg_config.sharedir()?;
164+
let package_lib_dir = match &self.pkglibdir {
165+
Some(p) => p.clone(),
166+
None => pg_config.pkglibdir()?,
167+
};
168+
let sharedir = match &self.sharedir {
169+
Some(p) => p.clone(),
170+
None => pg_config.sharedir()?,
171+
};
161172

162173
if !package_lib_dir.exists() && !package_lib_dir.is_dir() {
163174
println!(
@@ -348,8 +359,8 @@ async fn fetch_archive_legacy(registry: &str, name: &str, version: &str) -> Resu
348359
}
349360
}
350361

351-
async fn fetch_archive_from_registry<'a>(
352-
name: Name<'a>,
362+
async fn fetch_archive_from_registry(
363+
name: Name<'_>,
353364
version: &str,
354365
registry: &str,
355366
postgres_version: u8,
@@ -675,7 +686,7 @@ async fn install_trunk_archive(
675686
for package_manager in operating_system.package_managers() {
676687
if let Some(packages_to_install) = system_deps.get(package_manager.as_str()) {
677688
for package in packages_to_install {
678-
let installation_command = package_manager.install(&package);
689+
let installation_command = package_manager.install(package);
679690

680691
let status = mockcmd::Command::new("sh")
681692
.arg("-c")

0 commit comments

Comments
 (0)