summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
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 @@
1#!/bin/bash
2#
3# Runs a command within a Poky chroot
4#
5
6set -e
7
8case $# in
9 0)
10 echo "Invalid arguments."
11 echo "$ $0 <target> [command]"
12 exit 1
13 ;;
14 1)
15 ROOTFS=$1
16 shift
17 # Set $1 to be the boot script
18 set -- /usr/bin/poky-chroot-launch
19 ;;
20 *)
21 ROOTFS=$1
22 shift
23 # Now $1 onwards are the command and arguments to run
24 ;;
25esac
26
27test -f "$ROOTFS/.pokychroot" || { echo "$ROOTFS is not setup for use as a Poky chroot." ; exit 1 ;}
28
29# chrootuid doesn't handle relative paths, so ensure that the rootfs path is
30# absolute
31if test ${ROOTFS:0:1} != /; then
32 ROOTFS="$(pwd)/$ROOTFS"
33fi
34
35safe_mount() {
36 if ! mountpoint -q "$ROOTFS/$1"; then
37 sudo mount --bind $1 "$ROOTFS/$1"
38 fi
39}
40safe_umount() {
41 if mountpoint -q "$ROOTFS/$1"; then
42 sudo umount "$ROOTFS/$1"
43 fi
44}
45
46# Mount the directories we need
47for m in /dev /dev/pts /dev/shm /proc /sys /tmp; do
48 safe_mount $m
49done
50
51# Set up the environment
52export PATH=/bin:/usr/bin:/sbin:/usr/sbin
53export HOME=/home/$USER
54
55if [ ! -f "$ROOTFS/.pokychroot.init" ]; then
56 sudo chrootuid -i "$ROOTFS" $USER /bin/sh -c "/usr/bin/poky-chroot-init"
57 touch "$ROOTFS/.pokychroot.init"
58fi
59
60Xephyr :1 -ac -screen 640x480x16 &
61
62# Go go go!
63sudo chrootuid -i "$ROOTFS" $USER "$@" || /bin/true
64
65# Trap term signals so we don't kill ourselves
66trap true TERM
67# send term signal to the process group
68kill -- -$$
69
70# Unmount TODO: only umount if there are no other sessions active, somehow.
71for m in /tmp /sys /proc /dev/shm /dev/pts /dev; do
72 safe_umount $m
73done
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 @@
1#!/bin/bash
2#
3# Script to extract a poky qemux86 rootfs and prepare it for
4# use as a chroot
5#
6
7set -e
8
9case $# in
10 2)
11 TGZ=$1
12 TARGET=$2
13 ;;
14 *)
15 echo "Invalid arguments, please run as:"
16 echo "$ $0 <qemux86-rootfs.tar.gz> <target-directory>"
17 exit 1
18esac
19
20echo "Extracting $TGZ into $TARGET"
21
22test -d "$TARGET" && { echo "$TARGET already exists, please remove and retry or specify a dirferent directory." ; exit 1 ; }
23mkdir --parents "$TARGET"
24
25tar -C "$TARGET" --exclude ./dev/\* -jxp -f "$TGZ"
26echo "HAVE_TOUCHSCREEN=0" >> "$TARGET/etc/formfactor/machconfig"
27echo "DISPLAY_WIDTH_PIXELS=640" >> "$TARGET/etc/formfactor/machconfig"
28echo "DISPLAY_HEIGHT_PIXELS=480" >> "$TARGET/etc/formfactor/machconfig"
29cp /etc/passwd "$TARGET/etc/passwd"
30touch "$TARGET/.pokychroot"