@@ -18,7 +18,6 @@ package config
1818
1919import (
2020 "fmt"
21- "os/exec"
2221 "path/filepath"
2322 "runtime"
2423 "strings"
@@ -589,34 +588,34 @@ func NewBuildConfig(opts ...GenericOptions) *types.BuildConfig {
589588
590589// ReconcileUpgradeSpec will check current mounts which may differ from elemental disovery from /sys/block tree
591590// as this skips multipathed devices which may be in use.
592- func ReconcileUpgradeSpec (spec * v1 .UpgradeSpec ) error {
591+ func ReconcileUpgradeSpec (r * types. RunConfig , spec * types .UpgradeSpec ) error {
593592 if spec .Partitions .State != nil {
594- if err := reconcilePartition (spec .Partitions .State ); err != nil {
593+ if err := reconcilePartition (r , spec .Partitions .State ); err != nil {
595594 return err
596595 }
597596 }
598597 if spec .Partitions .Recovery != nil {
599- if err := reconcilePartition (spec .Partitions .Recovery ); err != nil {
598+ if err := reconcilePartition (r , spec .Partitions .Recovery ); err != nil {
600599 return err
601600 }
602601 }
603602
604603 if spec .Partitions .Persistent != nil {
605- if err := reconcilePartition (spec .Partitions .Persistent ); err != nil {
604+ if err := reconcilePartition (r , spec .Partitions .Persistent ); err != nil {
606605 return err
607606 }
608607 }
609608
610609 if spec .Partitions .OEM != nil {
611- if err := reconcilePartition (spec .Partitions .OEM ); err != nil {
610+ if err := reconcilePartition (r , spec .Partitions .OEM ); err != nil {
612611 return err
613612 }
614613 }
615614 return nil
616615}
617616
618- func reconcilePartition (part * v1 .Partition ) error {
619- discoveredMountDiskBytes , err := execBlkid (part .FilesystemLabel )
617+ func reconcilePartition (r * types. RunConfig , part * types .Partition ) error {
618+ discoveredMountDiskBytes , err := execBlkid (r , part .FilesystemLabel )
620619 if err != nil {
621620 return fmt .Errorf ("error discovering current partition using label %s: %w" , part .FilesystemLabel , err )
622621 }
@@ -628,12 +627,10 @@ func reconcilePartition(part *v1.Partition) error {
628627 }
629628 return nil
630629}
631- func execBlkid (name string ) ([]byte , error ) {
632- path , err := exec .LookPath ("blkid" )
633- if err != nil {
634- return nil , err
630+ func execBlkid (r * types.RunConfig , name string ) ([]byte , error ) {
631+ if ok := r .Config .Runner .CommandExists ("blkid" ); ok {
632+ return r .Config .Runner .Run ("blkid" , "-L" , name )
635633 }
636634
637- blkidCmd := exec .Command (path , "-L" , name )
638- return blkidCmd .Output ()
635+ return []byte {}, fmt .Errorf ("blkid not found" )
639636}
0 commit comments