summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2008-01-30 15:37:49 +0000
committerRichard Purdie <richard@openedhand.com>2008-01-30 15:37:49 +0000
commit2713386f233907d652935cca7158475c26a0cac7 (patch)
treee67b6d5cc1d5f386ac32025c9f6bdbf0fcb42279 /scripts
parentf55e6e493e881453975fb038d88fcf13474ef42f (diff)
downloadopenembedded-core-2713386f233907d652935cca7158475c26a0cac7.tar.gz
openembedded-core-2713386f233907d652935cca7158475c26a0cac7.tar.bz2
openembedded-core-2713386f233907d652935cca7158475c26a0cac7.zip
scripts: Add poky-chroot scripts (credit should mainly go to Ross)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@3627 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/poky-chroot-run73
-rwxr-xr-xscripts/poky-chroot-setup30
2 files changed, 103 insertions, 0 deletions
diff --git a/scripts/poky-chroot-run b/scripts/poky-chroot-run
new file mode 100755
index 0000000000..6b78e3c60b
--- /dev/null
+++ b/scripts/poky-chroot-run
@@ -0,0 +1,73 @@
+#!/bin/bash
+#
+# Runs a command within a Poky chroot
+#
+
+set -e
+
+case $# in
+ 0)
+ echo "Invalid arguments."
+ echo "$ $0 <target> [command]"
+ exit 1
+ ;;
+ 1)
+ ROOTFS=$1
+ shift
+ # Set $1 to be the boot script
+ set -- /usr/bin/poky-chroot-launch
+ ;;
+ *)
+ ROOTFS=$1
+ shift
+ # Now $1 onwards are the command and arguments to run
+ ;;
+esac
+
+test -f "$ROOTFS/.pokychroot" || { echo "$ROOTFS is not setup for use as a Poky chroot." ; exit 1 ;}
+
+# chrootuid doesn't handle relative paths, so ensure that the rootfs path is
+# absolute
+if test ${ROOTFS:0:1} != /; then
+ ROOTFS="$(pwd)/$ROOTFS"
+fi
+
+safe_mount() {
+ if ! mountpoint -q "$ROOTFS/$1"; then
+ sudo mount --bind $1 "$ROOTFS/$1"
+ fi
+}
+safe_umount() {
+ if mountpoint -q "$ROOTFS/$1"; then
+ sudo umount "$ROOTFS/$1"
+ fi
+}
+
+# Mount the directories we need
+for m in /dev /dev/pts /dev/shm /proc /sys /tmp; do
+ safe_mount $m
+done
+
+# Set up the environment
+export PATH=/bin:/usr/bin:/sbin:/usr/sbin
+export HOME=/home/$USER
+
+if [ ! -f "$ROOTFS/.pokychroot.init" ]; then
+ sudo chrootuid -i "$ROOTFS" $USER /bin/sh -c "/usr/bin/poky-chroot-init"
+ touch "$ROOTFS/.pokychroot.init"
+fi
+
+Xephyr :1 -ac -screen 640x480x16 &
+
+# Go go go!
+sudo chrootuid -i "$ROOTFS" $USER "$@" || /bin/true
+
+# Trap term signals so we don't kill ourselves
+trap true TERM
+# send term signal to the process group
+kill -- -$$
+
+# Unmount TODO: only umount if there are no other sessions active, somehow.
+for m in /tmp /sys /proc /dev/shm /dev/pts /dev; do
+ safe_umount $m
+done
diff --git a/scripts/poky-chroot-setup b/scripts/poky-chroot-setup
new file mode 100755
index 0000000000..d85c864da7
--- /dev/null
+++ b/scripts/poky-chroot-setup
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# Script to extract a poky qemux86 rootfs and prepare it for
+# use as a chroot
+#
+
+set -e
+
+case $# in
+ 2)
+ TGZ=$1
+ TARGET=$2
+ ;;
+ *)
+ echo "Invalid arguments, please run as:"
+ echo "$ $0 <qemux86-rootfs.tar.gz> <target-directory>"
+ exit 1
+esac
+
+echo "Extracting $TGZ into $TARGET"
+
+test -d "$TARGET" && { echo "$TARGET already exists, please remove and retry or specify a dirferent directory." ; exit 1 ; }
+mkdir --parents "$TARGET"
+
+tar -C "$TARGET" --exclude ./dev/\* -jxp -f "$TGZ"
+echo "HAVE_TOUCHSCREEN=0" >> "$TARGET/etc/formfactor/machconfig"
+echo "DISPLAY_WIDTH_PIXELS=640" >> "$TARGET/etc/formfactor/machconfig"
+echo "DISPLAY_HEIGHT_PIXELS=480" >> "$TARGET/etc/formfactor/machconfig"
+cp /etc/passwd "$TARGET/etc/passwd"
+touch "$TARGET/.pokychroot"