Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar-chroot
diff options
context:
space:
mode:
Diffstat (limited to 'sugar-chroot')
-rwxr-xr-xsugar-chroot72
1 files changed, 72 insertions, 0 deletions
diff --git a/sugar-chroot b/sugar-chroot
new file mode 100755
index 0000000..817d8d4
--- /dev/null
+++ b/sugar-chroot
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Daniel Francis <francis@sugarlabs.org>
+#
+# Based in qchroot
+# by Alan M Bruce (qole) with help from Benson Mitchell and Thomas Perl
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+CHROOT=$1
+
+# Devices
+mount --bind /dev "$CHROOT/dev"
+# Processes
+mount --bind /proc "$CHROOT/proc"
+
+#Gentoo wiki says this will make X work
+mount --bind /dev/pts "$CHROOT/dev/pts"
+mount --bind /tmp "$CHROOT/tmp"
+
+#Open e-mail attachments, etc
+mount --bind /var/tmp "$CHROOT/var/tmp"
+
+#ArchLinux suggestions
+mount --bind /dev/shm "$CHROOT/dev/shm"
+mount --bind /sys "$CHROOT/sys"
+
+#Make DBus work
+mount --bind /var/run/dbus "$CHROOT/var/run/dbus"
+mount --bind /var/lib/dbus "$CHROOT/var/lib/dbus"
+
+#Make pulseaudio work
+mount -o bind /var/run/pulse "$CHROOT/var/run/pulse"
+
+xhost + > /dev/null
+
+# Now chroot
+chroot $@
+
+# Unmount all partitions
+umount "$CHROOT/dev"
+
+umount "$CHROOT/proc"
+
+umount "$CHROOT/dev/pts"
+umount "$CHROOT/tmp"
+
+umount "$CHROOT/var/tmp"
+
+umount "$CHROOT/dev/shm"
+umount "$CHROOT/sys"
+
+umount "$CHROOT/var/run/dbus"
+umount "$CHROOT/var/lib/dbus"
+
+umount "$CHROOT/var/run/pulse"
+
+#All done, reset.
+exit 0