Added Thomas Perl's patches to Fremantle scripts
authorAlan Bruce <qole@qole.org>
Thu, 12 Nov 2009 18:51:28 +0000 (10:51 -0800)
committerAlan Bruce <qole@qole.org>
Thu, 12 Nov 2009 18:51:28 +0000 (10:51 -0800)
fremantle/easy-chroot/src/sbin/qchroot
fremantle/easy-chroot/src/sbin/qmount
fremantle/easy-chroot/src/sbin/qumount
fremantle/easy-chroot/src/usr/share/applications/hildon/cpu-ondemand.desktop [deleted file]
fremantle/easy-chroot/src/usr/share/applications/hildon/cpu-perform.desktop [deleted file]
fremantle/easy-deb-chroot/src/sbin/debian
fremantle/easy-deb-chroot/src/usr/bin/debbie

index 7c6f647..8ae0c5e 100755 (executable)
@@ -2,7 +2,7 @@
 # Sets up (if necessary) and chroots into a different environment.
 # Expects root privileges, does not drop them. 
 
-# By Alan M Bruce (qole) with help from Benson Mitchell
+# By Alan M Bruce (qole) with help from Benson Mitchell and Thomas Perl
 #
 # GPL licensed; keep code free!
 
@@ -33,12 +33,12 @@ fi
 
 if [ "$MOUNTSUCCESS" = "0" ] ; then
   #Make the tablet's devices available to the chroot
-  echo .
+  echo . >/dev/stderr
   mount -o bind /dev "$CHROOT/dev"
   mount -o bind /proc "$CHROOT/proc"
 
   #Gentoo wiki says this will make X work
-  echo ..
+  echo .. >/dev/stderr
   mount -t devpts none "$CHROOT/dev/pts"
   mount -o bind /tmp "$CHROOT/tmp"
 
@@ -46,7 +46,7 @@ if [ "$MOUNTSUCCESS" = "0" ] ; then
   mount -o bind /var/tmp "$CHROOT/var/tmp"
 
   #Any external devices
-  echo ...
+  echo ... >/dev/stderr
   MNTD=`cat /proc/mounts | grep ' /media/' | awk '{print $2}'`
 
   for MDRV in $MNTD ; do
@@ -57,7 +57,7 @@ if [ "$MOUNTSUCCESS" = "0" ] ; then
   done
 
   #Mount the user's home dir
-  echo ....
+  echo .... >/dev/stderr
   #mount -o bind /home/user "$CHROOT/home/user"
 
   # Do it the Fremantle way.
@@ -123,11 +123,11 @@ CHRLABEL=`blkid -s LABEL $IMGFILE | cut -d' ' -f2 | cut -d'=' -f2 | sed 's/"//g'
 if [ "x$CHRLABEL" = "x" ] ; then
   CHRLABEL=chroot
 fi
-echo -ne "\033]0;$CHRLABEL\007"
+echo -ne "\033]0;$CHRLABEL\007" >/dev/stderr
 export PS1="[\u@$CHRLABEL: \w]"
 
 #Actually chroot
-echo "Everything set up, running chroot..."
+echo "Everything set up, running chroot..." >/dev/stderr
 chroot $CHROOT "$@"
 
 #All done, reset.
index ffeffaf..d9e0238 100755 (executable)
@@ -2,7 +2,7 @@
 # Sets up (if necessary) and chroots into a different environment.
 # Expects root privileges, does not drop them. 
 
-# By Alan M Bruce (qole) with help from Benson Mitchell
+# By Alan M Bruce (qole) with help from Benson Mitchell and Thomas Perl
 #
 # GPL licensed; keep code free!
 
@@ -20,14 +20,14 @@ fi
 IMGFILE=$1
 MNTPT=$2
 
-echo qmount $IMGFILE $MNTPT
+# echo qmount $IMGFILE $MNTPT
 
 #Ensure that we have an image or partition to mount
 
 if [ ! -f "$IMGFILE" ] && [ ! -b "$IMGFILE" ] ; then
   MSG1=`printf "ERROR!\n\nThe image specified ($IMGFILE) does not exist or is neither\na regular nor a block special file.\n\nFirst parameter must be an image file or partition"`
   if [ ! -f "/usr/bin/gxmessage" ] ; then
-    echo $MSG1
+    echo $MSG1 >/dev/stderr
   else
     gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
   fi
@@ -39,7 +39,7 @@ fi
 if [ "x$MNTPT" = "x" ] || [ "x`echo $MNTPT | grep '/'`" = "x"  ] ; then
   MSG1=`printf "ERROR!\n\nNo chroot directory specified!\n\nSecond parameter must be chroot dir (eg. /debian)"`
   if [ ! -f "/usr/bin/gxmessage" ] ; then
-    echo $MSG1
+    echo $MSG1 >/dev/stderr
   else
     gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
   fi
@@ -48,13 +48,13 @@ fi
 
 #Check to see if already mounted
 if [ -f "$MNTPT/var/lock/qmount-complete" ] ; then
-  echo "$MNTPT has a qmount already!"
+  echo "$MNTPT has a qmount already!" >/dev/stderr
   MTDIMGFILE=`cat $MNTPT/var/lock/qmount-complete`
   if [ "$IMGFILE" != "$MTDIMGFILE" ] ; then
-    echo $MTDIMGFILE already mounted here! 
+    echo $MTDIMGFILE already mounted here! >/dev/stderr
     MSG1=`printf "Mount problem!\n\n$MTDIMGFILE already mounted on $MNTPT"`
        if [ ! -f "/usr/bin/gxmessage" ] ; then
-         echo $MSG1
+         echo $MSG1 >/dev/stderr
        else
          gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
        fi
@@ -63,7 +63,7 @@ if [ -f "$MNTPT/var/lock/qmount-complete" ] ; then
     # echo Unmounting...
     # closechroot $MNTPT
   else
-    echo $MTDIMGFILE already mounted on $MNTPT...
+    echo $MTDIMGFILE already mounted on $MNTPT... >/dev/stderr
     exit 1
   fi
 fi 
@@ -74,14 +74,14 @@ if [ ! -f "$MNTPT/var/lock/qmount-complete" ] ; then
 
    if [ -f "$IMGFILE" ] ; then
      LOOP=loop,
-     echo "using image file: $IMGFILE"
+     echo "using image file: $IMGFILE" >/dev/stderr
      if [ "x$IMGFS" = x ] ; then
        IMGFS=`echo $IMGFILE | awk -F '.' '{print $NF}'`
-       echo "fs type is $IMGFS"
+       echo "fs type is $IMGFS" >/dev/stderr
      fi
    else
      LOOP=
-     echo "using device: $IMGFILE"
+     echo "using device: $IMGFILE" >/dev/stderr
      PARTINFO="`blkid -s TYPE $IMGFILE`"
      if [ "x$IMGFS" = x ] ; then
        IMGFS=`echo $PARTINFO | awk '{print $NF}' | awk -F '=' '{print $NF}' | sed s/\"//g`
@@ -98,7 +98,7 @@ if [ ! -f "$MNTPT/var/lock/qmount-complete" ] ; then
    modprobe mbcache
 
    if [ "$IMGFS" != "ext3" ] && [ "$IMGFS" != "ext2" ] ; then
-     echo "Don't know $IMGFS: Using ext2 file system"
+     echo "Don't know $IMGFS: Using ext2 file system" >/dev/stderr
      IMGFS=ext2
    fi
 
@@ -113,7 +113,7 @@ if [ ! -f "$MNTPT/var/lock/qmount-complete" ] ; then
 
    if [ "$LOOP" = "loop," ] ; then
     #echo "mounting $IMGFILE on the turbo-loop ;)"
-    echo "mounting $IMGFILE on the slow Fremantle-loop ;)"
+    echo "mounting $IMGFILE on the slow Fremantle-loop ;)" >/dev/stderr
      #insmod /lib/modules/2.6.21-omap1/dm-mod.ko 2>/dev/null
      #insmod /lib/modules/2.6.21-omap1/dm-loop.ko 2>/dev/null
      #NEXTLOOP=`ls -l /dev/dm-* 2>/dev/null | tail -1 | awk '{print $NF}' | awk -F '-' '{print $NF+1}'`
@@ -128,19 +128,19 @@ if [ ! -f "$MNTPT/var/lock/qmount-complete" ] ; then
      if [ "$?" != 0 ] ; then
        MSG1=`printf "Mount failure!\n\n$IMGFILE failed to mount on loop$NEXTLOOP\n\n$DMLOMSG\n$MNTMSG"`
        if [ ! -f "/usr/bin/gxmessage" ] ; then
-         echo $MSG1
+         echo $MSG1 >/dev/stderr
        else
          gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
        fi
        exit 2
      fi
-     echo ...$IMGFILE mounted on loop$NEXTLOOP
+     echo ...$IMGFILE mounted on loop$NEXTLOOP >/dev/stderr
    else
-     echo "mounting device: $IMGFILE"
+     echo "mounting device: $IMGFILE" >/dev/stderr
      if ! mount -t "$IMGFS" "$IMGFILE" "$MNTPT" -o ${LOOP}noatime ; then
        MSG1=`printf "Mount failure!\n\n$IMGFILE failed to mount on $MNTPT"`
        if [ ! -f "/usr/bin/gxmessage" ] ; then
-         echo $MSG1
+         echo $MSG1 >/dev/stderr
        else
          gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "EZ-CHROOT ERROR" "$MSG1"
        fi
@@ -150,7 +150,7 @@ if [ ! -f "$MNTPT/var/lock/qmount-complete" ] ; then
    fi
 
   else
-    echo "Not mounting any filesystem, chroot is $MNTPT"
+    echo "Not mounting any filesystem, chroot is $MNTPT" >/dev/stderr
   fi 
 
 #All set up. Set flag for next time...
index d57ae19..03701a0 100755 (executable)
@@ -19,7 +19,7 @@ if [ "x$MNTPT" = x ] ; then
   MNTPT=$CHROOT
   #Still not set? FAIL
   if [ "x$MNTPT" != x ] ; then
-    echo "No mountpoint to unmount!"
+    echo "No mountpoint to unmount!" >/dev/stderr
     exit 8
   fi
 fi
@@ -28,31 +28,31 @@ fi
 TEST1=`mount | grep " $MNTPT "`
 
 if [ "x$TEST1" != "x" ] ; then
-  echo "..Unmounting $MNTPT..."
+  echo "..Unmounting $MNTPT..." >/dev/stderr
   umount -ld "$MNTPT"
 
   TEST2=`mount | grep " $MNTPT "`
 
   if [ "x$TEST2" != "x" ] ; then
-    echo "...$MNTPT didn't unmount!"
+    echo "...$MNTPT didn't unmount!" >/dev/stderr
     exit 8
   fi
 else
-  echo "$MNTPT is not mounted; Check for trailing slashes."
+  echo "$MNTPT is not mounted; Check for trailing slashes." >/dev/stderr
 fi
 
 if [ ! "x`grep device-mapper /proc/misc`" = "x" ] ; then
   LOOPDEV=`echo $TEST1 | cut -f1 -d' '`
   while [ "x`echo $LOOPDEV | grep dm-`" != "x" ] ; do
     LOOPNO=`echo $LOOPDEV | awk -F '-' '{print $NF}'`
-    echo "..Unmounting turbo loop ($LOOPNO)..."
+    echo "..Unmounting turbo loop ($LOOPNO)..." >/dev/stderr
     dmlosetup -d /dev/loop$LOOPNO
     if [ "$?" != 0 ] || [ "x`dmsetup status | grep loop$LOOPNO`" != "x" ] ; then
-      echo "Waiting for apps to terminate, will try again."
+      echo "Waiting for apps to terminate, will try again." >/dev/stderr
       sleep 5
       dmlosetup -d /dev/loop$LOOPNO 
       if [ "$?" != 0 ] ; then
-        echo "Can't unmount turbo-loop! Try dmlosetup -d /dev/loop$LOOPNO manually."
+        echo "Can't unmount turbo-loop! Try dmlosetup -d /dev/loop$LOOPNO manually." >/dev/stderr
         exit 9
       fi
     fi
@@ -60,5 +60,5 @@ if [ ! "x`grep device-mapper /proc/misc`" = "x" ] ; then
   done
 fi
 
-echo "successful unmount..."
-exit 0
\ No newline at end of file
+echo "successful unmount..." >/dev/stderr
+exit 0
diff --git a/fremantle/easy-chroot/src/usr/share/applications/hildon/cpu-ondemand.desktop b/fremantle/easy-chroot/src/usr/share/applications/hildon/cpu-ondemand.desktop
deleted file mode 100644 (file)
index cb81ace..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Name=Set CPU to On-Demand mode
-GenericName=CPU On-Demand mode
-Exec=sudo /sbin/cpu-ondemand
-Icon=qgn_list_cp_memory
-X-Osso-Type=application/x-executable
-X-HildonDesk-ShowInToolbar=true
-Terminal=false
-Type=Application
-StartupNotify=true
\ No newline at end of file
diff --git a/fremantle/easy-chroot/src/usr/share/applications/hildon/cpu-perform.desktop b/fremantle/easy-chroot/src/usr/share/applications/hildon/cpu-perform.desktop
deleted file mode 100644 (file)
index b84129f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Name=Set CPU to Performance mode
-GenericName=CPU Performance mode
-Exec=sudo /sbin/cpu-perform
-Icon=qgn_list_cp_memory
-X-Osso-Type=application/x-executable
-X-HildonDesk-ShowInToolbar=true
-Terminal=false
-Type=Application
-StartupNotify=true
\ No newline at end of file
index c3a8eb2..01659da 100755 (executable)
@@ -3,7 +3,7 @@
 # Expects root privileges, does not drop them. 
 # Look to /usr/bin/debbie for a friendly wrapper.
 
-# By Alan M Bruce (qole) with help from Benson Mitchell
+# By Alan M Bruce (qole) with help from Benson Mitchell and Thomas Perl
 #
 # GPL licensed; keep code free!
 
@@ -18,34 +18,34 @@ if [ -f "/home/user/.chroot" ] ; then
 . /home/user/.chroot
 
 else
-  echo "No ~/.chroot file."
+  echo "No ~/.chroot file." >/dev/stderr
 fi
 
 #This comes from the config file... If not, fall back on '/debian'
 if [ "x$CHROOT" = "x" ] ; then
   CHROOT=/debian
-  echo "No chroot dir specified; using $CHROOT"
+  echo "No chroot dir specified; using $CHROOT" >/dev/stderr
 else
-  echo "Chroot dir specified: $CHROOT"
+  echo "Chroot dir specified: $CHROOT" >/dev/stderr
 fi
 
 #This comes from the config. If not, search for debian*.img.ext2
 if [ "x$IMGFILE" = "x" ] ; then
-  echo "No image file or partition specified."
+  echo "No image file or partition specified." >/dev/stderr
   IMGMMC="`ls -1 /home/user/MyDocs/debian*.img* /media/mmc1/debian*.img* | head -1`"
   if [ "x$IMGMMC" != x ] ; then
     IMGFILE="$IMGMMC"
   else
     MSG1=`printf "ERROR!\n\nYou have no debian.img.ext2 file on your memory cards.\n\nPlease use the Debian Image Installer in Extras."`
     if [ ! -f "/usr/bin/gxmessage" ] ; then
-      echo $MSG1
+      echo $MSG1 >/dev/stderr
     else
       gxmessage -center -alignbuttons center -buttons GTK_STOCK_OK:0 -geometry 680x250 -title "MISSING DISK IMAGE" "$MSG1"
     fi
     exit 9
   fi
 else
-  echo "$IMGFILE specified in ~/.chroot"
+  echo "$IMGFILE specified in ~/.chroot" >/dev/stderr
 fi
 
 #
index 8d13632..9726148 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Chroots to Debian and runs a shell, or any command-line as non-root.
 
-# By Alan M Bruce (qole) and Benson Mitchell
+# By Alan M Bruce (qole), Benson Mitchell and Thomas Perl
 #
 # GPL licensed; keep code free!
 
@@ -14,7 +14,8 @@ fi
 [ -f /home/user/.chroot ] && . /home/user/.chroot
 
 #This comes from the config file... If not, fall back on 'user'
-[ "x$DEBUSER" != x ] || DEBUSER=user
+#[ "x$DEBUSER" != x ] || DEBUSER=user
+DEBUSER=$USER
 
 CHROOTUSER=$DEBUSER
 
@@ -32,9 +33,13 @@ CHROOTUSER=$DEBUSER
 #With args, just run them as $DEBUSER.
 
 if [ $# = 0 ] ; then
-  echo Starting Debian shell...
+  echo Starting Debian shell... >/dev/stderr
   sudo /sbin/debian su $DEBUSER
 else
-  echo Starting Debian $1
+  # Workaround to allow "debbie" to be used as login shell
+  if [ "$1" == "-c" ]; then
+    shift
+  fi
+  echo Starting Debian $* >/dev/stderr
   sudo /sbin/debian su $DEBUSER -c "$*"
 fi