diff options
| -rw-r--r-- | handbook/development.xml | 42 | ||||
| -rw-r--r-- | meta/packages/oh/qemu-config.bb | 8 | ||||
| -rwxr-xr-x | meta/packages/oh/qemu-config/poky-chroot-init | 7 | ||||
| -rwxr-xr-x | meta/packages/oh/qemu-config/poky-chroot-launch | 26 | ||||
| -rwxr-xr-x | scripts/poky-chroot-run | 86 | ||||
| -rwxr-xr-x | scripts/poky-chroot-setup | 31 |
6 files changed, 2 insertions, 198 deletions
diff --git a/handbook/development.xml b/handbook/development.xml index 4f36c7aa82..3bcf40506c 100644 --- a/handbook/development.xml +++ b/handbook/development.xml | |||
| @@ -241,48 +241,6 @@ | |||
| 241 | </para> | 241 | </para> |
| 242 | </section> | 242 | </section> |
| 243 | 243 | ||
| 244 | <section id="platdev-appdev-chroot"> | ||
| 245 | <title>Developing externally in a chroot</title> | ||
| 246 | <para> | ||
| 247 | If you have a system that matches the architecture of the Poky machine you're using, | ||
| 248 | such as qemux86, you can run binaries directly from the image on the host system | ||
| 249 | using a chroot combined with tools like <ulink url='http://projects.o-hand.com/xephyr'>Xephyr</ulink>. | ||
| 250 | </para> | ||
| 251 | <para> | ||
| 252 | Poky has some scripts to make using its qemux86 images within a chroot easier. To use | ||
| 253 | these you need to install the poky-scripts package or otherwise obtain the | ||
| 254 | <filename>poky-chroot-setup</filename> and <filename>poky-chroot-run</filename> scripts. | ||
| 255 | You also need Xephyr and chrootuid binaries available. To initialize a system use the setup script: | ||
| 256 | </para> | ||
| 257 | <para> | ||
| 258 | <literallayout class='monospaced'> | ||
| 259 | # poky-chroot-setup <qemux86-rootfs.tgz> <target-directory> | ||
| 260 | </literallayout> | ||
| 261 | </para> | ||
| 262 | <para> | ||
| 263 | which will unpack the specified qemux86 rootfs tarball into the target-directory. | ||
| 264 | You can then start the system with: | ||
| 265 | </para> | ||
| 266 | <para> | ||
| 267 | <literallayout class='monospaced'> | ||
| 268 | # poky-chroot-run <target-directory> <command> | ||
| 269 | </literallayout> | ||
| 270 | </para> | ||
| 271 | <para> | ||
| 272 | where the target-directory is the place the rootfs was unpacked to and command is | ||
| 273 | an optional command to run. If no command is specified, the system will drop you | ||
| 274 | within a bash shell. A Xephyr window will be displayed containing the emulated | ||
| 275 | system and you may be asked for a password since some of the commands used for | ||
| 276 | bind mounting directories need to be run using sudo. | ||
| 277 | </para> | ||
| 278 | <para> | ||
| 279 | There are limits as to how far the the realism of the chroot environment extends. | ||
| 280 | It is useful for simple development work or quick tests but full system emulation | ||
| 281 | with QEMU offers a much more realistic environment for more complex development | ||
| 282 | tasks. Note that chroot support within Poky is still experimental. | ||
| 283 | </para> | ||
| 284 | </section> | ||
| 285 | |||
| 286 | <section id="platdev-appdev-insitu"> | 244 | <section id="platdev-appdev-insitu"> |
| 287 | <title>Developing in Poky directly</title> | 245 | <title>Developing in Poky directly</title> |
| 288 | <para> | 246 | <para> |
diff --git a/meta/packages/oh/qemu-config.bb b/meta/packages/oh/qemu-config.bb index f1b7de74aa..fc59320282 100644 --- a/meta/packages/oh/qemu-config.bb +++ b/meta/packages/oh/qemu-config.bb | |||
| @@ -1,14 +1,12 @@ | |||
| 1 | DESCRIPTION = "Adds scripts to use distcc on the host system under qemu" | 1 | DESCRIPTION = "Adds scripts to use distcc on the host system under qemu" |
| 2 | LICENSE = "GPL" | 2 | LICENSE = "GPL" |
| 3 | RDEPENDS = "distcc task-poky-nfs-server fakeroot oprofileui-server rsync bash" | 3 | RDEPENDS = "distcc task-poky-nfs-server oprofileui-server rsync bash" |
| 4 | PR = "r16" | 4 | PR = "r17" |
| 5 | 5 | ||
| 6 | SRC_URI = "file://distcc.sh \ | 6 | SRC_URI = "file://distcc.sh \ |
| 7 | file://anjuta-remote-run \ | 7 | file://anjuta-remote-run \ |
| 8 | file://exports \ | 8 | file://exports \ |
| 9 | file://shutdown.desktop \ | 9 | file://shutdown.desktop \ |
| 10 | file://poky-chroot-init \ | ||
| 11 | file://poky-chroot-launch \ | ||
| 12 | file://qemu-autostart" | 10 | file://qemu-autostart" |
| 13 | 11 | ||
| 14 | S = "${WORKDIR}" | 12 | S = "${WORKDIR}" |
| @@ -24,8 +22,6 @@ do_install() { | |||
| 24 | 22 | ||
| 25 | install -d ${D}${bindir} | 23 | install -d ${D}${bindir} |
| 26 | install -m 0755 anjuta-remote-run ${D}${bindir}/ | 24 | install -m 0755 anjuta-remote-run ${D}${bindir}/ |
| 27 | install -m 0775 poky-chroot-init ${D}${bindir}/ | ||
| 28 | install -m 0775 poky-chroot-launch ${D}${bindir}/ | ||
| 29 | 25 | ||
| 30 | install -d ${D}${datadir}/applications | 26 | install -d ${D}${datadir}/applications |
| 31 | install -m 0644 shutdown.desktop ${D}${datadir}/applications/ | 27 | install -m 0644 shutdown.desktop ${D}${datadir}/applications/ |
diff --git a/meta/packages/oh/qemu-config/poky-chroot-init b/meta/packages/oh/qemu-config/poky-chroot-init deleted file mode 100755 index 0afa505100..0000000000 --- a/meta/packages/oh/qemu-config/poky-chroot-init +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | export USER=root | ||
| 4 | export HOME=/home/root | ||
| 5 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
| 6 | |||
| 7 | fakeroot ipkg configure | ||
diff --git a/meta/packages/oh/qemu-config/poky-chroot-launch b/meta/packages/oh/qemu-config/poky-chroot-launch deleted file mode 100755 index dbc432b66c..0000000000 --- a/meta/packages/oh/qemu-config/poky-chroot-launch +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | export USER=root | ||
| 4 | export HOME=/home/root | ||
| 5 | export PATH=/sbin:/bin:/usr/sbin:/usr/bin | ||
| 6 | |||
| 7 | export DISPLAY=:1 | ||
| 8 | |||
| 9 | unset DBUS_SESSION_BUS_ADDRESS | ||
| 10 | |||
| 11 | SERVICES=dbus-1 | ||
| 12 | |||
| 13 | for S in $SERVICES; do | ||
| 14 | fakeroot /etc/init.d/$S start | ||
| 15 | done | ||
| 16 | |||
| 17 | /etc/X11/Xsession & | ||
| 18 | |||
| 19 | bash -l | ||
| 20 | |||
| 21 | # The --user option in the dbus stop script breaks under chroot | ||
| 22 | /sbin/start-stop-daemon --stop --pidfile /var/run/dbus/pid | ||
| 23 | |||
| 24 | for S in $SERVICES; do | ||
| 25 | fakeroot /etc/init.d/$S stop | ||
| 26 | done | ||
diff --git a/scripts/poky-chroot-run b/scripts/poky-chroot-run deleted file mode 100755 index f1f4dec6a4..0000000000 --- a/scripts/poky-chroot-run +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Runs a command within a Poky chroot | ||
| 4 | # | ||
| 5 | |||
| 6 | XEPHYR=`which Xephyr` | ||
| 7 | if [ ! -n "$XEPHYR" -o ! -x "$XEPHYR" ]; then | ||
| 8 | echo "You need to install Xephyr to use $0" | ||
| 9 | exit 1 | ||
| 10 | fi | ||
| 11 | |||
| 12 | CHROOTUID=`which chrootuid` | ||
| 13 | if [ ! -n "$CHROOTUID" -o ! -x "$CHROOTUID" ]; then | ||
| 14 | echo "You need to install Xephyr to use $0" | ||
| 15 | exit 1 | ||
| 16 | fi | ||
| 17 | |||
| 18 | |||
| 19 | case $# in | ||
| 20 | 0) | ||
| 21 | echo "Invalid arguments." | ||
| 22 | echo "$ $0 <target> [command]" | ||
| 23 | exit 1 | ||
| 24 | ;; | ||
| 25 | 1) | ||
| 26 | ROOTFS=$1 | ||
| 27 | shift | ||
| 28 | # Set $1 to be the boot script | ||
| 29 | set -- /usr/bin/poky-chroot-launch | ||
| 30 | ;; | ||
| 31 | *) | ||
| 32 | ROOTFS=$1 | ||
| 33 | shift | ||
| 34 | # Now $1 onwards are the command and arguments to run | ||
| 35 | ;; | ||
| 36 | esac | ||
| 37 | |||
| 38 | test -f "$ROOTFS/.pokychroot" || { echo "$ROOTFS is not setup for use as a Poky chroot." ; exit 1 ;} | ||
| 39 | |||
| 40 | set -e | ||
| 41 | |||
| 42 | # chrootuid doesn't handle relative paths, so ensure that the rootfs path is | ||
| 43 | # absolute | ||
| 44 | if test ${ROOTFS:0:1} != /; then | ||
| 45 | ROOTFS="$(pwd)/$ROOTFS" | ||
| 46 | fi | ||
| 47 | |||
| 48 | safe_mount() { | ||
| 49 | if ! mountpoint -q "$ROOTFS/$1"; then | ||
| 50 | sudo mount --bind $1 "$ROOTFS/$1" | ||
| 51 | fi | ||
| 52 | } | ||
| 53 | safe_umount() { | ||
| 54 | if mountpoint -q "$ROOTFS/$1"; then | ||
| 55 | sudo umount "$ROOTFS/$1" | ||
| 56 | fi | ||
| 57 | } | ||
| 58 | |||
| 59 | # Mount the directories we need | ||
| 60 | for m in /dev /dev/pts /dev/shm /proc /sys /tmp; do | ||
| 61 | safe_mount $m | ||
| 62 | done | ||
| 63 | |||
| 64 | # Set up the environment | ||
| 65 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin | ||
| 66 | export HOME=/home/$USER | ||
| 67 | |||
| 68 | if [ ! -f "$ROOTFS/.pokychroot.init" ]; then | ||
| 69 | sudo $CHROOTUID -i "$ROOTFS" $USER /bin/sh -c "/usr/bin/poky-chroot-init" | ||
| 70 | touch "$ROOTFS/.pokychroot.init" | ||
| 71 | fi | ||
| 72 | |||
| 73 | $XEPHYR :1 -ac -screen 640x480x16 & | ||
| 74 | |||
| 75 | # Go go go! | ||
| 76 | sudo $CHROOTUID -i "$ROOTFS" $USER "$@" || /bin/true | ||
| 77 | |||
| 78 | # Trap term signals so we don't kill ourselves | ||
| 79 | trap true TERM | ||
| 80 | # send term signal to the process group | ||
| 81 | kill -- -$$ | ||
| 82 | |||
| 83 | # Unmount TODO: only umount if there are no other sessions active, somehow. | ||
| 84 | for m in /tmp /sys /proc /dev/shm /dev/pts /dev; do | ||
| 85 | safe_umount $m | ||
| 86 | done | ||
diff --git a/scripts/poky-chroot-setup b/scripts/poky-chroot-setup deleted file mode 100755 index 209efd6df4..0000000000 --- a/scripts/poky-chroot-setup +++ /dev/null | |||
| @@ -1,31 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Script to extract a poky qemux86 rootfs and prepare it for | ||
| 4 | # use as a chroot | ||
| 5 | # | ||
| 6 | |||
| 7 | set -e | ||
| 8 | |||
| 9 | case $# 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 | ||
| 18 | esac | ||
| 19 | |||
| 20 | echo "Extracting $TGZ into $TARGET" | ||
| 21 | |||
| 22 | test -d "$TARGET" && { echo "$TARGET already exists, please remove and retry or specify a dirferent directory." ; exit 1 ; } | ||
| 23 | mkdir --parents "$TARGET" | ||
| 24 | |||
| 25 | tar -C "$TARGET" --exclude ./dev/\* -jxp -f "$TGZ" | ||
| 26 | echo "HAVE_TOUCHSCREEN=0" >> "$TARGET/etc/formfactor/machconfig" | ||
| 27 | echo "DISPLAY_WIDTH_PIXELS=640" >> "$TARGET/etc/formfactor/machconfig" | ||
| 28 | echo "DISPLAY_HEIGHT_PIXELS=480" >> "$TARGET/etc/formfactor/machconfig" | ||
| 29 | cp /etc/passwd "$TARGET/etc/passwd" | ||
| 30 | cp /etc/resolv.conf "$TARGET/etc/resolv.conf" | ||
| 31 | touch "$TARGET/.pokychroot" | ||
