Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] initramfs fixes
@ 2012-09-27 14:20 Ross Burton
  2012-09-27 14:20 ` [PATCH 1/2] initrd: Spawn an emergency shell when something goes wrong Ross Burton
  2012-09-27 14:20 ` [PATCH 2/2] initramfs: Make mkdir not fail Ross Burton
  0 siblings, 2 replies; 3+ messages in thread
From: Ross Burton @ 2012-09-27 14:20 UTC (permalink / raw)
  To: openembedded-core

A colleague was working on an initramfs-based yocto system and encounting some
issues because the initial script is quite fragile.

Attached are two patches to make it less fragile, and drop you to a shell if it
does break.

The following changes since commit 55b3e7bf48a67c0ce42308b8332262fbe4eccd24:

  dbus: disable all X11 when native (2012-09-26 21:23:37 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib ross/initramfs

for you to fetch changes up to 265e1e50186d5982b40d87f37f0662a0e09a7daa:

  initramfs: Make mkdir not fail (2012-09-27 15:17:35 +0100)

----------------------------------------------------------------
Damien Lespiau (2):
      initrd: Spawn an emergency shell when something goes wrong
      initramfs: Make mkdir not fail

 meta/recipes-core/initrdscripts/files/init-live.sh |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Damien Lespiau (2):
  initrd: Spawn an emergency shell when something goes wrong
  initramfs: Make mkdir not fail

 meta/recipes-core/initrdscripts/files/init-live.sh |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

-- 
1.7.10




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] initrd: Spawn an emergency shell when something goes wrong
  2012-09-27 14:20 [PATCH 0/2] initramfs fixes Ross Burton
@ 2012-09-27 14:20 ` Ross Burton
  2012-09-27 14:20 ` [PATCH 2/2] initramfs: Make mkdir not fail Ross Burton
  1 sibling, 0 replies; 3+ messages in thread
From: Ross Burton @ 2012-09-27 14:20 UTC (permalink / raw)
  To: openembedded-core

From: Damien Lespiau <damien.lespiau@intel.com>

set -e allows to exit if a command fails. We install a trap and execute
emergency_shell() when either the init script exits or when ctrl-c is
typed (say if we are stuck somewhere and we want to debug it).

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/recipes-core/initrdscripts/files/init-live.sh |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index 3fba7dc..fb7af31 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -2,6 +2,17 @@
 
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
+emergency_shell()
+{
+    echo "Bug in initramfs /init detected. Dropping to a shell. Good luck!"
+    echo
+    sh
+}
+trap "emergency_shell" 0 2
+
+# exit immediately if a command fails
+set -e
+
 ROOT_MOUNT="/rootfs/"
 ROOT_IMAGE="rootfs.img"
 MOUNT="/bin/mount"
-- 
1.7.10




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] initramfs: Make mkdir not fail
  2012-09-27 14:20 [PATCH 0/2] initramfs fixes Ross Burton
  2012-09-27 14:20 ` [PATCH 1/2] initrd: Spawn an emergency shell when something goes wrong Ross Burton
@ 2012-09-27 14:20 ` Ross Burton
  1 sibling, 0 replies; 3+ messages in thread
From: Ross Burton @ 2012-09-27 14:20 UTC (permalink / raw)
  To: openembedded-core

From: Damien Lespiau <damien.lespiau@intel.com>

This patch make "mkdir foo" not fail if foo already exists.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/recipes-core/initrdscripts/files/init-live.sh |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index fb7af31..2639308 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -21,15 +21,15 @@ ISOLINUX=""
 UNIONFS="no"
 
 early_setup() {
-    mkdir /proc
-    mkdir /sys
+    mkdir -p /proc
+    mkdir -p /sys
     mount -t proc proc /proc
     mount -t sysfs sysfs /sys
 
     # support modular kernel
     modprobe isofs 2> /dev/null
 
-    mkdir /run
+    mkdir -p /run
     udevd --daemon
     udevadm trigger --action=add
 }
-- 
1.7.10




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-27 14:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27 14:20 [PATCH 0/2] initramfs fixes Ross Burton
2012-09-27 14:20 ` [PATCH 1/2] initrd: Spawn an emergency shell when something goes wrong Ross Burton
2012-09-27 14:20 ` [PATCH 2/2] initramfs: Make mkdir not fail Ross Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox