Skip to content

Commit

Permalink
cargo-rpm: Hax for stable
Browse files Browse the repository at this point in the history
We need to hack around this issue which should be on stable soon:

rust-lang/rust#44431
  • Loading branch information
tony-iqlusion committed Apr 16, 2018
1 parent 7cfa803 commit 70833e9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cargo-rpm/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ pub struct InitOpts {

/// Path to the systemd service unit config template
#[options(no_short, long = "service")]
pub service: Option<PathBuf>,
pub service: Option<String>,

/// Configure this RPM as a systemd service unit
#[options(short = "s", long = "systemd")]
pub systemd: bool,

/// Path to the RPM spec template
#[options(long = "template")]
pub template: Option<PathBuf>,
pub template: Option<String>,
}

impl InitOpts {
Expand Down Expand Up @@ -149,13 +149,15 @@ impl InitOpts {
/// Render this package's RPM spec
fn render_spec(
spec_path: &Path,
template: &Option<PathBuf>,
template_path_str: &Option<String>,
package_config: &PackageConfig,
service_name: &Option<String>,
) -> Result<(), Error> {
let mut spec_params = SpecParams::from(package_config);
spec_params.service = service_name.clone();
let spec_rendered = spec_params.render(template.as_ref().map(|p| p.as_ref()))?;

let template_path = template_path_str.as_ref().map(|t| PathBuf::from(t));
let spec_rendered = spec_params.render(template_path.as_ref().map(|t| t.as_ref()))?;

let mut spec_file = File::create(spec_path)?;
spec_file.write_all(spec_rendered.as_bytes())?;
Expand All @@ -173,11 +175,12 @@ fn render_spec(
/// Render this package's systemd service unit config (if enabled)
fn render_service(
service_path: &Path,
template: &Option<PathBuf>,
template_path_str: &Option<String>,
package_config: &PackageConfig,
) -> Result<(), Error> {
let service_params = ServiceParams::from(package_config);
let service_rendered = service_params.render(template.as_ref().map(|p| p.as_ref()))?;
let template_path = template_path_str.as_ref().map(|t| PathBuf::from(t));
let service_rendered = service_params.render(template_path.as_ref().map(|t| t.as_ref()))?;

let mut service_file = File::create(service_path)?;
service_file.write_all(service_rendered.as_bytes())?;
Expand Down

0 comments on commit 70833e9

Please sign in to comment.