@@ -30,15 +30,15 @@ pub struct InitOpts {
30
30
31
31
/// Path to the systemd service unit config template
32
32
#[ options( no_short, long = "service" ) ]
33
- pub service : Option < PathBuf > ,
33
+ pub service : Option < String > ,
34
34
35
35
/// Configure this RPM as a systemd service unit
36
36
#[ options( short = "s" , long = "systemd" ) ]
37
37
pub systemd : bool ,
38
38
39
39
/// Path to the RPM spec template
40
40
#[ options( long = "template" ) ]
41
- pub template : Option < PathBuf > ,
41
+ pub template : Option < String > ,
42
42
}
43
43
44
44
impl InitOpts {
@@ -149,13 +149,15 @@ impl InitOpts {
149
149
/// Render this package's RPM spec
150
150
fn render_spec (
151
151
spec_path : & Path ,
152
- template : & Option < PathBuf > ,
152
+ template_path_str : & Option < String > ,
153
153
package_config : & PackageConfig ,
154
154
service_name : & Option < String > ,
155
155
) -> Result < ( ) , Error > {
156
156
let mut spec_params = SpecParams :: from ( package_config) ;
157
157
spec_params. service = service_name. clone ( ) ;
158
- let spec_rendered = spec_params. render ( template. as_ref ( ) . map ( |p| p. as_ref ( ) ) ) ?;
158
+
159
+ let template_path = template_path_str. as_ref ( ) . map ( |t| PathBuf :: from ( t) ) ;
160
+ let spec_rendered = spec_params. render ( template_path. as_ref ( ) . map ( |t| t. as_ref ( ) ) ) ?;
159
161
160
162
let mut spec_file = File :: create ( spec_path) ?;
161
163
spec_file. write_all ( spec_rendered. as_bytes ( ) ) ?;
@@ -173,11 +175,12 @@ fn render_spec(
173
175
/// Render this package's systemd service unit config (if enabled)
174
176
fn render_service (
175
177
service_path : & Path ,
176
- template : & Option < PathBuf > ,
178
+ template_path_str : & Option < String > ,
177
179
package_config : & PackageConfig ,
178
180
) -> Result < ( ) , Error > {
179
181
let service_params = ServiceParams :: from ( package_config) ;
180
- let service_rendered = service_params. render ( template. as_ref ( ) . map ( |p| p. as_ref ( ) ) ) ?;
182
+ let template_path = template_path_str. as_ref ( ) . map ( |t| PathBuf :: from ( t) ) ;
183
+ let service_rendered = service_params. render ( template_path. as_ref ( ) . map ( |t| t. as_ref ( ) ) ) ?;
181
184
182
185
let mut service_file = File :: create ( service_path) ?;
183
186
service_file. write_all ( service_rendered. as_bytes ( ) ) ?;
0 commit comments