Blob Blame History Raw
From 69dbfdc99ce993d541984f7305bb1206858f4bcf Mon Sep 17 00:00:00 2001
From: Dennis Gilmore <dennis@ausil.us>
Date: Fri, 10 Oct 2014 01:38:27 -0500
Subject: [PATCH 09/10] add support for devicetree directories for use on arm

---
 grubby.c                     |  3 +++
 new-kernel-pkg               | 31 ++++++++++++++++++++++++++-----
 test.sh                      |  5 +++++
 test/extlinux.6              | 21 +++++++++++++++++++++
 test/results/add/extlinux6.1 | 21 +++++++++++++++++++++
 5 files changed, 76 insertions(+), 5 deletions(-)
 create mode 100644 test/extlinux.6
 create mode 100644 test/results/add/extlinux6.1

diff --git a/grubby.c b/grubby.c
index cbb1cca..a4a9811 100644
--- a/grubby.c
+++ b/grubby.c
@@ -582,6 +582,7 @@ struct keywordTypes extlinuxKeywords[] = {
     { "append",	    LT_KERNELARGS,  ' ' },
     { "prompt",     LT_UNKNOWN,     ' ' },
     { "fdt",        LT_DEVTREE,     ' ' },
+    { "fdtdir",     LT_DEVTREE,     ' ' },
     { NULL,	    0, 0 },
 };
 int useextlinuxmenu;
@@ -4232,6 +4233,8 @@ int main(int argc, const char ** argv) {
 	    _("display the title of the default kernel") },
 	{ "devtree", 0, POPT_ARG_STRING, &newDevTreePath, 0,
 	    _("device tree file for new stanza"), _("dtb-path") },
+	{ "devtreedir", 0, POPT_ARG_STRING, &newDevTreePath, 0,
+	    _("device tree directory for new stanza"), _("dtb-path") },
 	{ "elilo", 0, POPT_ARG_NONE, &configureELilo, 0,
 	    _("configure elilo bootloader") },
 	{ "efi", 0, POPT_ARG_NONE, &isEfi, 0,
diff --git a/new-kernel-pkg b/new-kernel-pkg
index 0f21e39..31976a7 100755
--- a/new-kernel-pkg
+++ b/new-kernel-pkg
@@ -128,7 +128,7 @@ usage() {
     echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2
     echo "       [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
     echo "       [--add-plymouth-initrd]" >&2
-    echo "       [--host-only] [--devtree=<devicetree.dtb>]" >&2
+    echo "       [--host-only] [--devtree=<devicetree.dtb>] [--devtreedir=</devicetree/path/>]" >&2
     echo "       <--install | --remove | --update | --rpmposttrans> <kernel-version>" >&2
     echo "       (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2
     exit 1
@@ -153,11 +153,17 @@ install() {
     fi
 
     DEVTREE=""
-    if [ "x$devtreefile" != "x" -a -f "$devtreefile" ]; then
+    if [ -n "$devtreefile" -a -f "$devtreefile" ]; then
 	[ -n "$verbose" ] && echo "found $devtreefile and using it with grubby"
 	DEVTREE="--devtree $devtreefile"
     fi
 
+    DEVTREEDIR=""
+    if [ -n "$devtreedir" -a -d "$devtreedir" ]; then
+	[ -n "$verbose" ] && echo "found $devtreedir and using it with grubby"
+	DEVTREEDIR="--devtreedir $devtreedir"
+    fi
+
     # FIXME: is this a good heuristic to find out if we're on iSeries?
     if [ -d /proc/iSeries ]; then
 	[ -n "$verbose" ] && echo "On an iSeries, just making img file"
@@ -264,7 +270,7 @@ install() {
 	[ -n "$verbose" ] && echo "adding $version to $extlinuxConfig"
 
 	$grubby --extlinux -c $extlinuxConfig \
-	    --add-kernel=$kernelImage \
+	    --add-kernel=$kernelImage $DEVTREEDIR \
 	    $DEVTREE $INITRD --copy-default $makedefault --title "$title" \
 	    ${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \
 	    --args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title"
@@ -412,11 +418,17 @@ update() {
     fi
 
     DEVTREE=""
-    if [ "x$devtreefile" != "x" -a -f "$devtreefile" ]; then
+    if [ -n "$devtreefile" -a -f "$devtreefile" ]; then
         [ -n "$verbose" ] && echo "found $devtreefile and using it with grubby"
         DEVTREE="--devtree $devtreefile"
     fi
 
+    DEVTREEDIR=""
+    if [ -n "$devtreedir" -a -d "$devtreedir" ]; then
+	[ -n "$verbose" ] && echo "found $devtreedir and using it with grubby"
+	DEVTREEDIR="--devtreedir $devtreedir"
+    fi
+
     if [ -n "$cfgGrub" ]; then
 	[ -n "$verbose" ] && echo "updating $version from $grubConfig"
 	$grubby --grub -c $grubConfig \
@@ -505,7 +517,7 @@ update() {
 	[ -n "$verbose" ] && echo "updating $version from $extlinuxConfig"
 	$grubby --extlinux -c $extlinuxConfig \
 	    --update-kernel=$kernelImage \
-	    $DEVTREE $INITRD \
+	    $DEVTREE $DEVTREEDIR $INITRD \
 	    ${kernargs:+--args="$kernargs"} \
 	    ${removeargs:+--remove-args="$removeargs"}
     else
@@ -566,6 +578,15 @@ while [ $# -gt 0 ]; do
 	    fi
 	    ;;
 
+	--devtreedir*)
+	    if [[ $1 == --devtreedir\=* ]]; then
+		devtreedir=${1#--devtreedir=}
+	    else
+		devtreedir=$2
+		shift
+	    fi
+	    ;;
+
 	--dracut)
 	    dracut=--dracut
 	    ;;
diff --git a/test.sh b/test.sh
index 67b932d..fe574c3 100755
--- a/test.sh
+++ b/test.sh
@@ -652,6 +652,11 @@ extlinuxTest extlinux.5 add/extlinux5.1 --add-kernel=/boot/vmlinuz-3.15.0-0.rc1.
     --initrd=/boot/initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img --boot-filesystem=/boot --copy-default \
     --title="Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)" \
     --remove-kernel="TITLE=Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)"
+extlinuxTest extlinux.6 add/extlinux6.1 --add-kernel=/boot/vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl \
+    --devtreedir='/boot/dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/' \
+    --initrd=/boot/initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img --boot-filesystem=/boot --copy-default \
+    --title="Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)" \
+    --remove-kernel="TITLE=Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)"
 
 testing="LILO long titles"
 liloTest lilo.1 longtitle/l1.1 --add-kernel=/boot/new-kernel.img \
diff --git a/test/extlinux.6 b/test/extlinux.6
new file mode 100644
index 0000000..c28a4a8
--- /dev/null
+++ b/test/extlinux.6
@@ -0,0 +1,21 @@
+ui menu.c32
+
+menu hidden
+timeout 50
+totaltimeout 9000
+
+prompt 10
+default Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)
+
+label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl
+fdtdir /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img
+
+label Fedora (3.12.0-0.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.12.0-0.fc21.armv7hl
+fdtdir /dtb-3.12.0-0.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.12.0-0.fc21.armv7hl.img
+
diff --git a/test/results/add/extlinux6.1 b/test/results/add/extlinux6.1
new file mode 100644
index 0000000..ec2a2ea
--- /dev/null
+++ b/test/results/add/extlinux6.1
@@ -0,0 +1,21 @@
+ui menu.c32
+
+menu hidden
+timeout 50
+totaltimeout 9000
+
+prompt 10
+default Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)
+
+label Fedora (3.15.0-0.rc1.git4.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git4.1.fc21.armv7hl
+fdtdir /dtb-3.15.0-0.rc1.git4.1.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git4.1.fc21.armv7hl.img
+
+label Fedora (3.15.0-0.rc1.git0.1.fc21.armv7hl) 21 (Rawhide)
+kernel /vmlinuz-3.15.0-0.rc1.git0.1.fc21.armv7hl
+fdtdir /dtb-3.15.0-0.rc1.git0.1.fc21.armv7hl/
+append console=ttymxc0,115200 root=UUID=7ee85ed8-de4a-4779-8658-2daed0d35e97 ro rhgb quiet LANG=en_US.UTF-8
+initrd /initramfs-3.15.0-0.rc1.git0.1.fc21.armv7hl.img
+
-- 
1.9.3