Move logic to check if deviceinfo file exists to pkgs/deviceinfo (MR 37)
This is mostly a preparatory commit to later be able to read the deviceinfo from multiple places. It has a bit better encapsulation, and makes the functions methods, so that they can update deviceinfo file in-place.
This commit is contained in:
committed by
Clayton Craft
parent
b2cdfe9da4
commit
c87b926a53
@@ -49,19 +49,9 @@ func main() {
|
||||
|
||||
log.Default().SetFlags(log.Lmicroseconds)
|
||||
|
||||
deviceinfoFile := "/etc/deviceinfo"
|
||||
if exists, err := misc.Exists(deviceinfoFile); !exists {
|
||||
log.Printf("NOTE: %q not found, this file is required by mkinitfs.\n", deviceinfoFile)
|
||||
return
|
||||
} else if err != nil {
|
||||
retCode = 1
|
||||
log.Printf("received unexpected error when getting status for %q: %s", deviceinfoFile, err)
|
||||
return
|
||||
}
|
||||
|
||||
devinfo, err := deviceinfo.ReadDeviceinfo(deviceinfoFile)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
var devinfo deviceinfo.DeviceInfo
|
||||
if err := devinfo.ReadDeviceinfo("/etc/deviceinfo"); err != nil {
|
||||
log.Println("Error reading deviceinfo:", err)
|
||||
retCode = 1
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user