main: read /usr/share/deviceinfo/deviceinfo in addition to /etc/deviceinfo (MR 37)

Relates https://gitlab.com/postmarketOS/pmaports/-/issues/1836

The error checking for the detection of both files is not ideal, but there
are no obvious better solutions. For now, we want to avoid requiring one
by default, since it allows this change to be forward compatible so not
all MRs related to /usr/share have to go in at once. I followed the same
pattern as in boot-deploy!29 although there we check for "deviceinfo_arch"
to make sure that at least one of those files is complete.

The other alternative would be to add an Arch field to DeviceInfo struct,
and use it to check that at least one of the files was complete, and
ignore any errors if it exists. Since this is not ideal either, keep the
double test, and let's take care of fixes once one of them is compulsory.
This commit is contained in:
Pablo Correa Gómez
2023-05-29 23:16:33 +02:00
committed by Clayton Craft
parent c87b926a53
commit b1e44d8ec2
2 changed files with 10 additions and 5 deletions

View File

@@ -50,8 +50,12 @@ func main() {
log.Default().SetFlags(log.Lmicroseconds) log.Default().SetFlags(log.Lmicroseconds)
var devinfo deviceinfo.DeviceInfo var devinfo deviceinfo.DeviceInfo
if err := devinfo.ReadDeviceinfo("/etc/deviceinfo"); err != nil { deverr_usr := devinfo.ReadDeviceinfo("/usr/share/deviceinfo/deviceinfo")
log.Println("Error reading deviceinfo:", err) deverr_etc := devinfo.ReadDeviceinfo("/etc/deviceinfo")
if deverr_etc != nil && deverr_usr != nil {
log.Println("Error reading deviceinfo")
log.Println("\t/usr/share/deviceinfo/deviceinfo:", deverr_usr)
log.Println("\t/etc/deviceinfo:", deverr_etc)
retCode = 1 retCode = 1
return return
} }

View File

@@ -38,7 +38,8 @@ Design goals of this project are:
The canonical deviceinfo "specification" is at The canonical deviceinfo "specification" is at
https://wiki.postmarketos.org/wiki/Deviceinfo_reference https://wiki.postmarketos.org/wiki/Deviceinfo_reference
mkinitfs reads deviceinfo values from */etc/deviceinfo*. The following variables mkinitfs reads deviceinfo values from */usr/share/deviceinfo/deviceinfo* and
*/etc/deviceinfo*, in that order. The following variables
are *required* by mkinitfs: are *required* by mkinitfs:
- deviceinfo_initfs_compression - deviceinfo_initfs_compression