[PATCH 3/3] Add capability to read /etc/flash-kernel/db to override db entries.
---
README | 4 ++++
debian/changelog | 2 ++
debian/flash-kernel.install | 1 +
etc/db | 7 +++++++
functions | 3 +++
test_functions | 26 ++++++++++++++++++++++++++
6 files changed, 43 insertions(+)
create mode 100644 etc/db
diff --git a/README b/README
index 920acb3..3280871 100644
--- a/README
+++ b/README
@@ -77,6 +77,10 @@ RFC 2822 data or Debian control data, i.e. header: value pairs,
with definitions separated by an empty line. Comments starting with a
pound are ignored.
+/etc/flash-kernel/db is parsed first and allows for local override of any
+field. Note that you must include the "Machine" field here as well as the
+field(s) to be overridden
+
The supported fields are:
* Machine: (required) value of the "Hardware:" line in /proc/cpuinfo and
diff --git a/debian/changelog b/debian/changelog
index a2732ce..dfc4b1c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ flash-kernel (3.9) UNRELEASED; urgency=low
* Honour FK_MACHINE in get_machine, to allow initramfs hooks etc to
work inside a chroot. Also support reading the machine from
/etc/flash-kernel/machine.
+ * Add capability to read /etc/flash-kernel/db to override db entries.
+ Closes: #680900
-- Ian Campbell <ijc@hellion.org.uk> Thu, 15 Aug 2013 09:00:17 +0100
diff --git a/debian/flash-kernel.install b/debian/flash-kernel.install
index 7191f6d..5d3aebd 100644
--- a/debian/flash-kernel.install
+++ b/debian/flash-kernel.install
@@ -1,6 +1,7 @@
initramfs-hook/flash-kernel etc/initramfs/post-update.d
kernel-hook/zz-flash-kernel etc/kernel/postinst.d
kernel-hook/zz-flash-kernel etc/kernel/postrm.d
+etc/db etc/flash-kernel
flash-kernel usr/sbin
initramfs-tools usr/share
bootscript usr/share/flash-kernel
diff --git a/etc/db b/etc/db
new file mode 100644
index 0000000..62422a9
--- /dev/null
+++ b/etc/db
@@ -0,0 +1,7 @@
+# To override fields include the Machine field and the fields you wish to
+# override.
+#
+# e.g. to override Boot-Device on the Dreamplug to sdb rather than sda
+#
+#Machine: Globalscale Technologies Dreamplug
+#Boot-Device: /dev/sdb1
diff --git a/functions b/functions
index 280f342..17a4650 100644
--- a/functions
+++ b/functions
@@ -24,6 +24,9 @@ PROC_DTMODEL="${FK_PROC_DRMODEL:-/proc/device-tree/model}"
PROC_MTD="/proc/mtd"
read_machine_db() {
+ if [ -f "${FK_ETC_DB:-/etc/flash-kernel/db}" ] ; then
+ cat "${FK_ETC_DB:-/etc/flash-kernel/db}"
+ fi
cat "${FK_CHECKOUT:-$FK_DIR}/db/"*.db
}
MACHINE_DB="$(read_machine_db)"
diff --git a/test_functions b/test_functions
index 6f3fbe8..be29f29 100755
--- a/test_functions
+++ b/test_functions
@@ -239,6 +239,32 @@ test_get_machine_field() {
}
add_test test_get_machine_field
+test_etc_db() {
+ get_tempfile
+ mock_etc_db="$last_tempfile"
+ cat >"$mock_etc_db" <<EOF
+Machine: Marvell SheevaPlug Reference Board
+Kernel-Flavors: Dummy
+EOF
+
+ (
+ FK_ETC_DB="$mock_etc_db"
+ . "$functions"
+ machine="Marvell SheevaPlug Reference Board"
+ kflavors=$(get_machine_field "$machine" "Kernel-Flavors")
+ if [ "$kflavors" != "Dummy" ] ; then
+ echo "Expected Kernel-Flavors field to be overridden to Dummy but got $kflavors" >&2
+ exit 1
+ fi
+ kaddress=$(get_machine_field "$machine" "U-Boot-Kernel-Address")
+ if [ "$kaddress" != "0x00008000" ] ; then
+ echo "Expected U-Boot-Kernel-Address to be 0x00008000 but got $kaddress" >&2
+ exit 1
+ fi
+ )
+}
+add_test test_etc_db
+
test_machine_uses_flash() {
(
. "$functions"
--
1.7.10.4
Reply to: