@@ -23,7 +23,6 @@ import (
23
23
"github.com/coreos/ignition/v2/config/shared/errors"
24
24
cutil "github.com/coreos/ignition/v2/config/util"
25
25
"github.com/coreos/ignition/v2/config/v3_4_experimental/types"
26
- "github.com/coreos/ignition/v2/internal/distro"
27
26
"github.com/coreos/ignition/v2/internal/exec/util"
28
27
"github.com/coreos/ignition/v2/internal/systemd"
29
28
)
@@ -55,7 +54,7 @@ func (s *stage) warnOnOldSystemdVersion() error {
55
54
func (s * stage ) createUnits (config types.Config ) error {
56
55
presets := make (map [string ]* Preset )
57
56
for _ , unit := range config .Systemd .Units {
58
- if err := s .writeSystemdUnit (unit , false ); err != nil {
57
+ if err := s .writeSystemdUnit (unit ); err != nil {
59
58
return err
60
59
}
61
60
if unit .Enabled != nil {
@@ -213,35 +212,25 @@ func (s *stage) createSystemdPresetFiles(presets map[string]*Preset) error {
213
212
// writeSystemdUnit creates the specified unit and any dropins for that unit.
214
213
// If the contents of the unit or are empty, the unit is not created. The same
215
214
// applies to the unit's dropins.
216
- func (s * stage ) writeSystemdUnit (unit types.Unit , runtime bool ) error {
217
- // use a different DestDir if it's runtime so it affects our /run (but not
218
- // if we're running locally through blackbox tests)
219
- u := s .Util
220
- if runtime && ! distro .BlackboxTesting () {
221
- u .DestDir = "/"
222
- }
223
-
215
+ func (s * stage ) writeSystemdUnit (unit types.Unit ) error {
224
216
return s .Logger .LogOp (func () error {
225
217
relabeledDropinDir := false
226
218
for _ , dropin := range unit .Dropins {
227
219
if dropin .Contents == nil {
228
220
continue
229
221
}
230
- f , err := u .FileFromSystemdUnitDropin (unit , dropin , runtime )
222
+ f , err := s .FileFromSystemdUnitDropin (unit , dropin )
231
223
if err != nil {
232
224
s .Logger .Crit ("error converting systemd dropin: %v" , err )
233
225
return err
234
226
}
235
- relabelPath := f .Node .Path
236
- if ! runtime {
237
- // trim off prefix since this needs to be relative to the sysroot
238
- if ! strings .HasPrefix (f .Node .Path , s .DestDir ) {
239
- panic (fmt .Sprintf ("Dropin path %s isn't under prefix %s" , f .Node .Path , s .DestDir ))
240
- }
241
- relabelPath = f .Node .Path [len (s .DestDir ):]
227
+ // trim off prefix since this needs to be relative to the sysroot
228
+ if ! strings .HasPrefix (f .Node .Path , s .DestDir ) {
229
+ panic (fmt .Sprintf ("Dropin path %s isn't under prefix %s" , f .Node .Path , s .DestDir ))
242
230
}
231
+ relabelPath := f .Node .Path [len (s .DestDir ):]
243
232
if err := s .Logger .LogOp (
244
- func () error { return u .PerformFetch (f ) },
233
+ func () error { return s .PerformFetch (f ) },
245
234
"writing systemd drop-in %q at %q" , dropin .Name , f .Node .Path ,
246
235
); err != nil {
247
236
return err
@@ -256,21 +245,18 @@ func (s *stage) writeSystemdUnit(unit types.Unit, runtime bool) error {
256
245
return nil
257
246
}
258
247
259
- f , err := u .FileFromSystemdUnit (unit , runtime )
248
+ f , err := s .FileFromSystemdUnit (unit )
260
249
if err != nil {
261
250
s .Logger .Crit ("error converting unit: %v" , err )
262
251
return err
263
252
}
264
- relabelPath := f .Node .Path
265
- if ! runtime {
266
- // trim off prefix since this needs to be relative to the sysroot
267
- if ! strings .HasPrefix (f .Node .Path , s .DestDir ) {
268
- panic (fmt .Sprintf ("Unit path %s isn't under prefix %s" , f .Node .Path , s .DestDir ))
269
- }
270
- relabelPath = f .Node .Path [len (s .DestDir ):]
253
+ // trim off prefix since this needs to be relative to the sysroot
254
+ if ! strings .HasPrefix (f .Node .Path , s .DestDir ) {
255
+ panic (fmt .Sprintf ("Unit path %s isn't under prefix %s" , f .Node .Path , s .DestDir ))
271
256
}
257
+ relabelPath := f .Node .Path [len (s .DestDir ):]
272
258
if err := s .Logger .LogOp (
273
- func () error { return u .PerformFetch (f ) },
259
+ func () error { return s .PerformFetch (f ) },
274
260
"writing unit %q at %q" , unit .Name , f .Node .Path ,
275
261
); err != nil {
276
262
return err
0 commit comments