Easy Chroot 0.3.1
[easy-deb-chroot] / fremantle / easy-chroot / .py2deb_build_folder / easy-chroot / src / sbin / qchroot
index 8ae0c5e..8955351 100755 (executable)
@@ -23,6 +23,13 @@ shift 1
 
 # echo ezchroot $IMGFILE $CHROOT $*
 
+# Strip off a trailing slash
+LASTCHAR=`echo $CHROOT | cut -c ${#CHROOT}`
+if [ "$LASTCHAR" = "/" ] ; then
+   echo "..stripping trailing slash..." >/dev/stderr
+   CHROOT=`echo $CHROOT | cut -c 0-$((${#CHROOT}-1))`
+fi
+
 qmount $IMGFILE $CHROOT
 MOUNTSUCCESS=$?
 
@@ -45,6 +52,10 @@ if [ "$MOUNTSUCCESS" = "0" ] ; then
   #Open e-mail attachments, etc
   mount -o bind /var/tmp "$CHROOT/var/tmp"
 
+  #ArchLinux suggestions
+  mount -o bind /dev/shm "$CHROOT/dev/shm"
+  mount -o bind /sys "$CHROOT/sys"
+
   #Any external devices
   echo ... >/dev/stderr
   MNTD=`cat /proc/mounts | grep ' /media/' | awk '{print $2}'`
@@ -66,10 +77,14 @@ if [ "$MOUNTSUCCESS" = "0" ] ; then
   
   #Make DBus work
   mount -o bind /var/run/dbus "$CHROOT/var/run/dbus"
+  mount -o bind /var/lib/dbus "$CHROOT/var/lib/dbus"
+
+  #Make pulseaudio work
+  mount -o bind /var/run/pulse "$CHROOT/var/run/pulse"
 
   #Speed hacks: lower the priority of processes
   #renice 0 `pidof mmcqd`
-  #renice 20 `pidof metalayer-crawler`
+  #renice 20 `pidof trackerd`
 
   # Sync the chroot if requested...
   if [ -f /home/user/.synchroot ] ; then 
@@ -120,9 +135,22 @@ echo $IMGFILE $@ > "$CHROOT/var/lock/chroot-complete"
 
 #Custom prompt and xterm title. Reduces confusion.
 CHRLABEL=`blkid -s LABEL $IMGFILE | cut -d' ' -f2 | cut -d'=' -f2 | sed 's/"//g'`
+
+#If the file is mounted on loop, use that label.
+if [ "x$CHRLABEL" = "x" ] ; then
+
+  # first find the loop
+  LOOPNO=`mount | grep loop | grep $CHROOT | awk '{print $1}'`
+
+  if [ "x$LOOPNO" != "x" ] ; then
+     CHRLABEL=`blkid -s LABEL $LOOPNO | cut -d' ' -f2 | cut -d'=' -f2 | sed 's/"//g'`
+  fi
+fi
+
 if [ "x$CHRLABEL" = "x" ] ; then
   CHRLABEL=chroot
 fi
+
 echo -ne "\033]0;$CHRLABEL\007" >/dev/stderr
 export PS1="[\u@$CHRLABEL: \w]"