Skip to content

Commit

Permalink
Merge pull request wdv4758h#2 from ZettaScript/master
Browse files Browse the repository at this point in the history
Fixes & --manifest-path argument
  • Loading branch information
wdv4758h authored Sep 13, 2019
2 parents 13f03fe + 703168a commit 756b909
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/arguments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ subcommands:
- mksrcinfo:
help: Run mksrcinfo
long: mksrcinfo
- manifest-path:
help: Cargo.toml directory path
long: manifest-path
short: p
takes_value: true
15 changes: 12 additions & 3 deletions src/config/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,18 @@ pub struct ArchConfig {
}

impl ArchConfig {
pub fn new() -> ArchConfig {
pub fn new(manifest_path: Option<&str>) -> ArchConfig {
let mut content = String::new();
let path = format!("{}/Cargo.toml", env!("CARGO_MANIFEST_DIR"));
let path = format!(
"{}/Cargo.toml",
match manifest_path {
Some(val) => val.to_string(),
None => match std::env::var("CARGO_MANIFEST_DIR") {
Ok(val) => val,
Err(_) => ".".to_string(),
}
}
);
let mut path = File::open(path.as_str()).unwrap();
path.read_to_string(&mut content)
.expect("cargo-arch: invalid or missing Cargo.toml options");
Expand Down Expand Up @@ -193,7 +202,7 @@ impl ArchConfig {
buffer.push_str("\n");

add_data!("pkgname={}\n", self.pkgname);
add_data!("pkgver={}\n", self.pkgver);
add_data!("pkgver={}\n", self.pkgver.replace("-","_"));
add_data!("pkgrel={}\n", self.pkgrel);
add_data!("epoch={}\n", self.epoch);
add_data!("pkgdesc=\"{}\"\n", self.pkgdesc);
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ fn build_arch_package(mksrcinfo: bool,
build: bool,
install: bool,
syncdeps: bool,
force: bool) {
force: bool,
manifest_path: Option<&str>) {
use std::process::Command;
use std::fs::File;
use std::io::Write;
use crate::config::core::GeneratePackageConfig;

config::ArchConfig::new().generate_package_config();
config::ArchConfig::new(manifest_path).generate_package_config();

if mksrcinfo {
let output = Command::new("makepkg")
Expand Down Expand Up @@ -73,11 +74,12 @@ fn main() {
let syncdeps = arguments.is_present("syncdeps");
let force = arguments.is_present("force");
let mksrcinfo = arguments.is_present("mksrcinfo");
let manifest_path = arguments.value_of("manifest-path");

////////////////////
// Build Arch Package
////////////////////

build_arch_package(mksrcinfo, build, install, syncdeps, force);
build_arch_package(mksrcinfo, build, install, syncdeps, force, manifest_path);

}

0 comments on commit 756b909

Please sign in to comment.