diff --git a/src/command_line.rs b/src/command_line.rs index d3d93d34..19545ffc 100644 --- a/src/command_line.rs +++ b/src/command_line.rs @@ -366,6 +366,12 @@ impl Config { } Arg::Long("nosign") => self.sign = Sign::No, Arg::Long("nosigndb") => self.sign_db = Sign::No, + Arg::Long("post-build-command") => match value { + Ok(v) => { + self.post_build_command = Some(v.to_string()); + } + Err(_) => bail!(tr!("argument --post-build-command requires a value")), + }, Arg::Long(a) if !arg.is_pacman_arg() && !arg.is_pacman_global() => { bail!(tr!("unknown option --{}", a)) } @@ -448,6 +454,7 @@ fn takes_value(arg: Arg) -> TakesValue { Arg::Long("sign") => TakesValue::Optional, Arg::Long("signdb") => TakesValue::Optional, Arg::Long("mode") => TakesValue::Required, + Arg::Long("post-build-command") => TakesValue::Required, _ => TakesValue::No, } } diff --git a/src/config.rs b/src/config.rs index 0ffd8ed5..4b622c59 100644 --- a/src/config.rs +++ b/src/config.rs @@ -471,6 +471,7 @@ pub struct Config { pub sign_db: Sign, pub pre_build_command: Option, + pub post_build_command: Option, #[default = "makepkg"] pub makepkg_bin: String, @@ -1023,6 +1024,7 @@ then initialise it with: "FileManagerFlags" => self.fm_flags.extend(split), "ChrootFlags" => self.chroot_flags.extend(split), "PreBuildCommand" => self.pre_build_command = Some(value), + "PostBuildCommand" => self.post_build_command = Some(value), _ => eprintln!( "{}", tr!("error: unknown option '{}' in section [bin]", key) diff --git a/src/install.rs b/src/install.rs index 867beb6a..3449c260 100644 --- a/src/install.rs +++ b/src/install.rs @@ -607,6 +607,9 @@ impl Installer { self.add_pkg(config, base, repo, &pkgdests, &debug_paths)?; self.queue_install(base, &pkgdests, &debug_paths); + + post_build_command(config, dir, base.package_base(), &version)?; + Ok((pkgdests, version)) } @@ -1260,7 +1263,6 @@ fn print_warnings(config: &Config, cache: &Cache, actions: Option<&Actions>) { if !config.mode.aur() && !config.mode.pkgbuild() { return; } - if config.args.has_arg("u", "sysupgrade") && config.mode.aur() { let (_, mut pkgs) = repo_aur_pkgs(config); pkgs.retain(|pkg| config.pkgbuild_repos.pkg(config, pkg.name()).is_none()); @@ -1558,6 +1560,19 @@ fn pre_build_command(config: &Config, dir: &Path, base: &str, version: &str) -> Ok(()) } +fn post_build_command(config: &Config, dir: &Path, base: &str, version: &str) -> Result<()> { + if let Some(ref pb_cmd) = config.post_build_command { + let mut cmd = Command::new("sh"); + cmd.env("PKGBASE", base) + .env("VERSION", version) + .current_dir(dir) + .arg("-c") + .arg(pb_cmd); + exec::command(&mut cmd)?; + } + Ok(()) +} + fn file_manager( config: &Config, fetch: &aur_fetch::Fetch,