From b1e44d8ec2103dfe72374e6bc94b9eb9ee80a984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Correa=20G=C3=B3mez?= Date: Mon, 29 May 2023 23:16:33 +0200 Subject: [PATCH] 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. --- cmd/mkinitfs/main.go | 8 ++++++-- doc/mkinitfs.1.scd | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/mkinitfs/main.go b/cmd/mkinitfs/main.go index 2480ba8..b51e9d6 100644 --- a/cmd/mkinitfs/main.go +++ b/cmd/mkinitfs/main.go @@ -50,8 +50,12 @@ func main() { log.Default().SetFlags(log.Lmicroseconds) var devinfo deviceinfo.DeviceInfo - if err := devinfo.ReadDeviceinfo("/etc/deviceinfo"); err != nil { - log.Println("Error reading deviceinfo:", err) + deverr_usr := devinfo.ReadDeviceinfo("/usr/share/deviceinfo/deviceinfo") + 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 return } diff --git a/doc/mkinitfs.1.scd b/doc/mkinitfs.1.scd index 7d1fd48..4aebc85 100644 --- a/doc/mkinitfs.1.scd +++ b/doc/mkinitfs.1.scd @@ -38,7 +38,8 @@ Design goals of this project are: The canonical deviceinfo "specification" is at 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: - deviceinfo_initfs_compression @@ -63,7 +64,7 @@ it are for constructing the initramfs archive. Configuration under */usr/share/mkinitfs* is intended to be managed by distributions, while configuration under */etc/mkinitfs* is for users to -create/manage. mkinitfs reads configuration from */usr/share/mkinitfs* first, and then from */etc/mkinitfs*. +create/manage. mkinitfs reads configuration from */usr/share/mkinitfs* first, and then from */etc/mkinitfs*. ## /usr/share/mkinitfs/files, /etc/mkinitfs/files ## /usr/share/mkinitfs/files-extra, /etc/mkinitfs/files-extra @@ -136,7 +137,7 @@ search for the app. The following commandline options are passed to it: Currently this is hardcoded to be "initramfs" *-k* - + *-d* Path to the directory containing the build artifacts from mkinitfs.